From 995e1e32d9854dd3e445c245b7463c3db52ad674 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 30 Oct 2009 23:06:30 +0000 Subject: [PATCH] Misc integration fixes git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2197 42af7a65-404d-4744-a932-0658087f49c3 --- arch/arm/src/lpc214x/lpc214x_usbdev.c | 2 +- arch/arm/src/stm32/stm32_usbdev.c | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/arch/arm/src/lpc214x/lpc214x_usbdev.c b/arch/arm/src/lpc214x/lpc214x_usbdev.c index f4bd1bd1334..ddd03fc90ee 100644 --- a/arch/arm/src/lpc214x/lpc214x_usbdev.c +++ b/arch/arm/src/lpc214x/lpc214x_usbdev.c @@ -528,7 +528,7 @@ static uint32 lpc214x_getreg(uint32 addr) * we polling the register? If so, suppress some of the output. */ - if (addr == prevaddr || val == preval) + if (addr == prevaddr && val == preval) { if (count == 0xffffffff || ++count > 3) { diff --git a/arch/arm/src/stm32/stm32_usbdev.c b/arch/arm/src/stm32/stm32_usbdev.c index 3995e6071b1..536bb97d896 100644 --- a/arch/arm/src/stm32/stm32_usbdev.c +++ b/arch/arm/src/stm32/stm32_usbdev.c @@ -514,7 +514,7 @@ static uint16 stm32_getreg(uint32 addr) * Are we polling the register? If so, suppress some of the output. */ - if (addr == prevaddr || val == preval) + if (addr == prevaddr && val == preval) { if (count == 0xffffffff || ++count > 3) { @@ -673,7 +673,7 @@ static inline void stm32_setepaddress(ubyte epno, ubyte addr) regval = stm32_getreg(epaddr); regval &= EPR_NOTOG_MASK; regval &= ~USB_EPR_EA_MASK; - regval |= USB_EPR_EA_SHIFT; + regval |= (addr << USB_EPR_EA_SHIFT); stm32_putreg(regval, epaddr); } @@ -703,7 +703,7 @@ static inline void stm32_setstatusout(ubyte epno) uint16 regval; /* For a BULK endpoint the EP_KIND bit is used to enabled double buffering; - * for a CONTROL endpoint, it is set to indicatate that a status OUT + * for a CONTROL endpoint, it is set to indicate that a status OUT * transaction is expected. The bit is not used with out endpoint types. */ @@ -723,7 +723,7 @@ static inline void stm32_clrstatusout(ubyte epno) uint16 regval; /* For a BULK endpoint the EP_KIND bit is used to enabled double buffering; - * for a CONTROL endpoint, it is set to indicatate that a status OUT + * for a CONTROL endpoint, it is set to indicate that a status OUT * transaction is expected. The bit is not used with out endpoint types. */ @@ -858,14 +858,14 @@ static void stm32_seteprxstatus(ubyte epno, uint16 state) /* Toggle first bit */ - if ((USB_EPR_STATTX_DTOG1 & state) != 0) + if ((USB_EPR_STATRX_DTOG1 & state) != 0) { regval ^= USB_EPR_STATRX_DTOG1; } /* Toggle second bit */ - if ((USB_EPR_STATTX_DTOG2 & state) != 0) + if ((USB_EPR_STATRX_DTOG2 & state) != 0) { regval ^= USB_EPR_STATRX_DTOG2; } @@ -3127,7 +3127,7 @@ static void stm32_hwreset(struct stm32_usbdev_s *priv) /* Clear pending interrupts */ - stm32_putreg((uint16)~USB_ISTR_ALLINTS, STM32_USB_ISTR); + stm32_putreg(0, STM32_USB_ISTR); /* Set the STM32 BTABLE address */ @@ -3184,7 +3184,9 @@ void up_usbinitialize(void) stm32_putreg(USB_CNTR_FRES|USB_CNTR_PDWN, STM32_USB_CNTR); - /* Disconnect the device / disable the pull-up */ + /* Disconnect the device / disable the pull-up. We don't want the + * host to enumerate us until the class driver is registered. + */ stm32_usbpullup(&priv->usbdev, FALSE); @@ -3299,7 +3301,7 @@ void up_usbuninitialize(void) /* Clear pending interrupts */ - stm32_putreg(~USB_ISTR_ALLINTS, STM32_USB_ISTR); + stm32_putreg(0, STM32_USB_ISTR); /* Disconnect the device / disable the pull-up */ @@ -3371,7 +3373,9 @@ int usbdev_register(struct usbdevclass_driver_s *driver) up_prioritize_irq(STM32_IRQ_USBHPCANTX, CONFIG_USB_PRI); up_prioritize_irq(STM32_IRQ_USBLPCANRX0, CONFIG_USB_PRI); - /* Enable pull-up to connect the device */ + /* Enable pull-up to connect the device. The host should enumerate us + * some time after this + */ stm32_usbpullup(&priv->usbdev, TRUE); }