summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/stm32/stm32_usbdev.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-09 15:03:49 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-02-09 15:03:49 +0000
commit9f1b0571589985f9aaed28f12a0af9c55c56a0c1 (patch)
treed96a6dcb40417d6a69639444f9c111846076e89d /nuttx/arch/arm/src/stm32/stm32_usbdev.c
parent04701a1a031e14674a6f98f235b84f60e27b139a (diff)
downloadpx4-nuttx-9f1b0571589985f9aaed28f12a0af9c55c56a0c1.tar.gz
px4-nuttx-9f1b0571589985f9aaed28f12a0af9c55c56a0c1.tar.bz2
px4-nuttx-9f1b0571589985f9aaed28f12a0af9c55c56a0c1.zip
Removed stm32_internal.h; Changes for clean compile of STM32F3Discovery configuration with SPI and USB
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5630 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/stm32/stm32_usbdev.c')
-rw-r--r--nuttx/arch/arm/src/stm32/stm32_usbdev.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32_usbdev.c b/nuttx/arch/arm/src/stm32/stm32_usbdev.c
index 0ec46cebe..dc05a7ebb 100644
--- a/nuttx/arch/arm/src/stm32/stm32_usbdev.c
+++ b/nuttx/arch/arm/src/stm32/stm32_usbdev.c
@@ -59,7 +59,8 @@
#include <arch/irq.h>
#include "up_arch.h"
-#include "stm32_internal.h"
+#include "stm32.h"
+#include "stm32_syscfg.h"
#include "stm32_usbdev.h"
#if defined(CONFIG_USBDEV) && defined(CONFIG_STM32_USB)
@@ -78,6 +79,20 @@
# define CONFIG_USB_PRI NVIC_SYSH_PRIORITY_DEFAULT
#endif
+/* USB Interrupts. Should be re-mapped if CAN is used. */
+
+#ifdef CONFIG_STM32_STM32F30XX
+# ifdef CONFIG_STM32_USB_ITRMP
+# define STM32_IRQ_USBHP STM32_IRQ_USBHP_1
+# define STM32_IRQ_USBLP STM32_IRQ_USBLP_1
+# define STM32_IRQ_USBWKUP STM32_IRQ_USBWKUP_1
+# else
+# define STM32_IRQ_USBHP STM32_IRQ_USBHP_2
+# define STM32_IRQ_USBLP STM32_IRQ_USBLP_2
+# define STM32_IRQ_USBWKUP STM32_IRQ_USBWKUP_2
+# endif
+#endif
+
/* Extremely detailed register debug that you would normally never want
* enabled.
*/
@@ -1014,7 +1029,7 @@ static void stm32_copytopma(const uint8_t *buffer, uint16_t pma, uint16_t nbytes
/* Copy loop. Source=user buffer, Dest=packet memory */
- dest = (uint16_t*)(STM32_USBCANRAM_BASE + ((uint32_t)pma << 1));
+ dest = (uint16_t*)(STM32_USBRAM_BASE + ((uint32_t)pma << 1));
for (i = nwords; i != 0; i--)
{
/* Read two bytes and pack into on 16-bit word */
@@ -1044,7 +1059,7 @@ stm32_copyfrompma(uint8_t *buffer, uint16_t pma, uint16_t nbytes)
/* Copy loop. Source=packet memory, Dest=user buffer */
- src = (uint32_t*)(STM32_USBCANRAM_BASE + ((uint32_t)pma << 1));
+ src = (uint32_t*)(STM32_USBRAM_BASE + ((uint32_t)pma << 1));
for (i = nwords; i != 0; i--)
{
/* Copy 16-bits from packet memory to user buffer. */
@@ -3470,6 +3485,20 @@ void up_usbinitialize(void)
stm32_hwsetup(priv);
+ /* Remap the USB interrupt as needed (Only supported by the STM32 F3 family) */
+
+#ifdef CONFIG_STM32_STM32F30XX
+# ifdef CONFIG_STM32_USB_ITRMP
+ /* Clear the ITRMP bit to use the legacy, shared USB/CAN interrupts */
+
+ modifyreg32(STM32_RCC_APB1ENR, SYSCFG_CFGR1_USB_ITRMP, 0);
+# else
+ /* Set the ITRMP bit to use the STM32 F3's dedicated USB interrupts */
+
+ modifyreg32(STM32_RCC_APB1ENR, 0, SYSCFG_CFGR1_USB_ITRMP);
+# endif
+#endif
+
/* Attach USB controller interrupt handlers. The hardware will not be
* initialized and interrupts will not be enabled until the class device
* driver is bound. Getting the IRQs here only makes sure that we have