git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@4565 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2012-08-14 06:58:24 +00:00
parent 55f4744930
commit 56dafb8295
2 changed files with 16 additions and 7 deletions

View File

@ -138,6 +138,7 @@ static void otg_disable_ep(void) {
OTG->oe[i].DOEPTSIZ = 0; OTG->oe[i].DOEPTSIZ = 0;
OTG->oe[i].DOEPINT = 0xFFFFFFFF; OTG->oe[i].DOEPINT = 0xFFFFFFFF;
} }
OTG->DAINTMSK = DAINTMSK_OEPM(0) | DAINTMSK_IEPM(0);
} }
static void otg_rxfifo_flush(void) { static void otg_rxfifo_flush(void) {
@ -699,7 +700,10 @@ void usb_lld_start(USBDriver *usbp) {
void usb_lld_stop(USBDriver *usbp) { void usb_lld_stop(USBDriver *usbp) {
/* If in ready state then disables the USB clock.*/ /* If in ready state then disables the USB clock.*/
if (usbp->state == USB_STOP) { if (usbp->state != USB_STOP) {
OTG->DAINTMSK = 0;
OTG->GCCFG = 0;
#if STM32_USB_USE_USB1 #if STM32_USB_USE_USB1
if (&USBD1 == usbp) { if (&USBD1 == usbp) {
nvicDisableVector(STM32_OTG1_NUMBER); nvicDisableVector(STM32_OTG1_NUMBER);
@ -707,7 +711,6 @@ void usb_lld_stop(USBDriver *usbp) {
} }
#endif #endif
} }
OTG->GCCFG = 0;
} }
/** /**
@ -809,10 +812,14 @@ void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep) {
/* OUT endpoint activation or deactivation.*/ /* OUT endpoint activation or deactivation.*/
OTG->oe[ep].DOEPTSIZ = 0; OTG->oe[ep].DOEPTSIZ = 0;
if (usbp->epc[ep]->out_cb != NULL) if (usbp->epc[ep]->out_cb != NULL) {
OTG->oe[ep].DOEPCTL = ctl | DOEPCTL_MPSIZ(usbp->epc[ep]->out_maxsize); OTG->oe[ep].DOEPCTL = ctl | DOEPCTL_MPSIZ(usbp->epc[ep]->out_maxsize);
else OTG->DAINTMSK |= DAINTMSK_OEPM(ep);
}
else {
OTG->oe[ep].DOEPCTL &= ~DOEPCTL_USBAEP; OTG->oe[ep].DOEPCTL &= ~DOEPCTL_USBAEP;
OTG->DAINTMSK &= ~DAINTMSK_OEPM(ep);
}
/* IN endpoint activation or deactivation.*/ /* IN endpoint activation or deactivation.*/
OTG->ie[ep].DIEPTSIZ = 0; OTG->ie[ep].DIEPTSIZ = 0;
@ -828,11 +835,13 @@ void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep) {
OTG->ie[ep].DIEPCTL = ctl | OTG->ie[ep].DIEPCTL = ctl |
DIEPCTL_TXFNUM(ep) | DIEPCTL_TXFNUM(ep) |
DIEPCTL_MPSIZ(usbp->epc[ep]->in_maxsize); DIEPCTL_MPSIZ(usbp->epc[ep]->in_maxsize);
OTG->DAINTMSK |= DAINTMSK_IEPM(ep);
} }
else { else {
OTG->DIEPTXF[ep - 1] = 0x02000400; /* Reset value.*/ OTG->DIEPTXF[ep - 1] = 0x02000400; /* Reset value.*/
otg_txfifo_flush(ep); otg_txfifo_flush(ep);
OTG->ie[ep].DIEPCTL &= ~DIEPCTL_USBAEP; OTG->ie[ep].DIEPCTL &= ~DIEPCTL_USBAEP;
OTG->DAINTMSK &= ~DAINTMSK_IEPM(ep);
} }
} }

View File

@ -394,7 +394,7 @@ static void cmd_test(BaseSequentialStream *chp, int argc, char *argv[]) {
chThdWait(tp); chThdWait(tp);
} }
static void cmd_usbblast(BaseSequentialStream *chp, int argc, char *argv[]) { static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) {
static uint8_t buf[] = static uint8_t buf[] =
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
@ -431,7 +431,7 @@ static void cmd_usbblast(BaseSequentialStream *chp, int argc, char *argv[]) {
(void)argv; (void)argv;
if (argc > 0) { if (argc > 0) {
chprintf(chp, "Usage: usbblast\r\n"); chprintf(chp, "Usage: write\r\n");
return; return;
} }
@ -445,7 +445,7 @@ static const ShellCommand commands[] = {
{"mem", cmd_mem}, {"mem", cmd_mem},
{"threads", cmd_threads}, {"threads", cmd_threads},
{"test", cmd_test}, {"test", cmd_test},
{"usbblast", cmd_usbblast}, {"write", cmd_write},
{NULL, NULL} {NULL, NULL}
}; };