Browse Source

add STM32L4x3 and STM32L4x2 support for L052 assembly driver

Dmitry 7 years ago
parent
commit
9ee39e862e
3 changed files with 28 additions and 11 deletions
  1. 6 6
      inc/usb.h
  2. 19 3
      src/memmap.inc
  3. 3 2
      src/usbd_stm32l052_devfs_asm.S

+ 6 - 6
inc/usb.h

@@ -52,12 +52,12 @@
 
 
     #if !defined(__ASSEMBLER__)
     #if !defined(__ASSEMBLER__)
     extern const struct usbd_driver usbd_devfs;
     extern const struct usbd_driver usbd_devfs;
-    //extern const struct usbd_driver usbd_devfs_asm;
-    //#if defined(USBD_ASM_DRIVER)
-    //#define usbd_hw usbd_devfs_asm
-    //#else
-    //#define usbd_hw usbd_devfs
-    //#endif
+    extern const struct usbd_driver usbd_devfs_asm;
+    #if defined(USBD_ASM_DRIVER)
+    #define usbd_hw usbd_devfs_asm
+    #else
+    #define usbd_hw usbd_devfs
+    #endif
     #endif
     #endif
 
 
 #elif defined(STM32L1)
 #elif defined(STM32L1)

+ 19 - 3
src/memmap.inc

@@ -17,9 +17,6 @@
     defined(STM32L062xx) || defined(STM32L063xx) || \
     defined(STM32L062xx) || defined(STM32L063xx) || \
     defined(STM32L072xx) || defined(STM32L073xx) || \
     defined(STM32L072xx) || defined(STM32L073xx) || \
     defined(STM32L082xx) || defined(STM32L083xx) || \
     defined(STM32L082xx) || defined(STM32L083xx) || \
-    defined(STM32L432xx) || defined(STM32L433xx) || \
-    defined(STM32L442xx) || defined(STM32L443xx) || \
-    defined(STM32L452xx) || defined(STM32L462xx) || \
     defined(STM32F042x6) || defined(STM32F048xx) || \
     defined(STM32F042x6) || defined(STM32F048xx) || \
     defined(STM32F070x6) || defined(STM32F070xB) || \
     defined(STM32F070x6) || defined(STM32F070xB) || \
     defined(STM32F072xB) || defined(STM32F078xx) \
     defined(STM32F072xB) || defined(STM32F078xx) \
@@ -34,6 +31,7 @@
     #define USB_BCDR        0x18
     #define USB_BCDR        0x18
     #define USB_PMABASE     0x40006000
     #define USB_PMABASE     0x40006000
     #define RCC_BASE        0x40021000
     #define RCC_BASE        0x40021000
+    #define RCC_USBEN       23
     #if defined(STM32F042x6) || defined(STM32F048xx) || \
     #if defined(STM32F042x6) || defined(STM32F048xx) || \
         defined(STM32F070x6) || defined(STM32F070xB) || \
         defined(STM32F070x6) || defined(STM32F070xB) || \
         defined(STM32F072xB) || defined(STM32F078xx)
         defined(STM32F072xB) || defined(STM32F078xx)
@@ -46,6 +44,24 @@
         #define UID_BASE        0x1FF80050
         #define UID_BASE        0x1FF80050
     #endif
     #endif
 
 
+#elif defined(STM32L432xx) || defined(STM32L433xx) || \
+      defined(STM32L442xx) || defined(STM32L443xx) || \
+      defined(STM32L452xx) || defined(STM32L462xx)
+    #define USB_EPBASE      0x40006800
+    #define USB_REGBASE     0x40006840
+    #define USB_CNTR        0x00
+    #define USB_ISTR        0x04
+    #define USB_FNR         0x08
+    #define USB_DADDR       0x0C
+    #define USB_BTABLE      0x10
+    #define USB_BCDR        0x18
+    #define USB_PMABASE     0x40006C00
+    #define RCC_BASE        0x40021000
+    #define RCC_APB1RSTR    0x38
+    #define RCC_APB1ENR     0x58
+    #define UID_BASE        0x1FFF7590
+    #define RCC_USBEN       26
+
 #elif defined(STM32L1)
 #elif defined(STM32L1)
 /* common definitions for STM31L100xx STM32L151xx STM32L152xx STM32L162xx */
 /* common definitions for STM31L100xx STM32L151xx STM32L152xx STM32L162xx */
     #define USB_EPBASE      0x40005C00
     #define USB_EPBASE      0x40005C00

+ 3 - 2
src/usbd_stm32l052_devfs_asm.S

@@ -18,7 +18,7 @@
 #endif
 #endif
 
 
 #include "usb.h"
 #include "usb.h"
-#if defined(USBD_STM32L052)
+#if defined(USBD_STM32L052) || defined(USBD_STM32L433)
 #include "memmap.inc"
 #include "memmap.inc"
 
 
 #define EP_SETUP    0x0800
 #define EP_SETUP    0x0800
@@ -219,7 +219,8 @@ _enable:
     ldr     r1, =#USB_REGBASE     //USB->CNTR
     ldr     r1, =#USB_REGBASE     //USB->CNTR
     ldr     r2, =#RCC_BASE        //RCC
     ldr     r2, =#RCC_BASE        //RCC
     movs    r3, #0x01
     movs    r3, #0x01
-    lsls    r3, #23             //USBEN or USBRST
+//    lsls    r3, #23             //USBEN or USBRST
+    lsls    r3, #RCC_USBEN        //USBEN or USBRST
     tst     r0, r0
     tst     r0, r0
     beq     .L_disable
     beq     .L_disable
 .L_enable:
 .L_enable: