Forráskód Böngészése

Merge pull request #3 from dmitrystu/rename

Rename
Maxthon Chan 8 éve
szülő
commit
c6565faecc

+ 46 - 32
inc/usb.h

@@ -19,6 +19,11 @@
     extern "C" {
 #endif
 
+#include "usbd_core.h"
+#if !defined(__ASSEMBLER__)
+#include "usb_std.h"
+#endif
+
 #if defined(STM32L052xx) || defined(STM32L053xx) || \
     defined(STM32L062xx) || defined(STM32L063xx) || \
     defined(STM32L072xx) || defined(STM32L073xx) || \
@@ -30,13 +35,40 @@
     defined(STM32F070x6) || defined(STM32F070xB) || \
     defined(STM32F072xB) || defined(STM32F078xx)
 
-    #define USE_STMV0_DRIVER
+    #define USBD_STM32L052
+
+    #if !defined(__ASSEMBLER__)
+    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
+    #endif
 
 #elif defined(STM32L1)
-    #define USE_STMV1_DRIVER
+
+    #define USBD_STM32L100
+
+    #if !defined(__ASSEMBLER__)
+    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
+    #endif
 
 #elif defined(STM32L476xx)
-    #define USE_STMV2_DRIVER
+
+    #define USBD_STM32L476
+
+    #if !defined(__ASSEMBLER__)
+    extern const struct usbd_driver usbd_otgfs;
+    #define usbd_hw usbd_otgfs
+    #endif
 
 #elif defined(STM32F102x6) || defined(STM32F102xB) || \
       defined(STM32F103x6) || defined(STM32F103xB) || \
@@ -45,40 +77,22 @@
       defined(STM32F303xC) || defined(STM32F303xE) || \
       defined(STM32F373xC)
 
-    #define USE_STMV3_DRIVER
+    #define USBD_STM32F103
+
+    #if !defined(__ASSEMBLER__)
+    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
+    #endif
 
 #else
     #error Unsupported STM32 family
 #endif
 
-#include <stdbool.h>
-#include "usbd_core.h"
-#if !defined(__ASSEMBLER__)
-    #include "usb_std.h"
-    #if defined(USE_STMV0_DRIVER) && defined(USBD_ASM_DRIVER)
-        extern const struct usbd_driver usb_stmv0a;
-        #define usbd_hw usb_stmv0a
-    #elif defined(USE_STMV0_DRIVER)
-        extern const struct usbd_driver usb_stmv0;
-        #define usbd_hw usb_stmv0
-    #elif defined(USE_STMV1_DRIVER) && defined(USBD_ASM_DRIVER)
-        extern const struct usbd_driver usb_stmv1a;
-        #define usbd_hw usb_stmv1a
-    #elif defined(USE_STMV1_DRIVER)
-        extern const struct usbd_driver usb_stmv1;
-        #define usbd_hw usb_stmv1
-    #elif defined(USE_STMV2_DRIVER)
-        extern const struct usbd_driver usb_stmv2;
-        #define usbd_hw usb_stmv2
-    #elif defined(USE_STMV3_DRIVER) && defined(USBD_ASM_DRIVER)
-        extern const struct usbd_driver usb_stmv3a;
-        #define usbd_hw usb_stmv3a
-    #elif defined(USE_STMV3_DRIVER)
-        extern const struct usbd_driver usb_stmv3;
-        #define usbd_hw usb_stmv3
-    #endif
-#endif
-
 #if defined (__cplusplus)
     }
 #endif

+ 2 - 2
inc/usbd_core.h

@@ -19,8 +19,6 @@
     extern "C" {
 #endif
 
-#include <stdbool.h>
-
 /**\addtogroup USBD_HW_CORE USB Device HW driver and core API
  * @{ */
 #if defined(__DOXYGEN__)
@@ -90,6 +88,8 @@
 
 
 #if !defined(__ASSEMBLER__)
+#include <stdbool.h>
+
 /**\brief USB device machine states.*/
 enum usbd_machine_state {
     usbd_state_disabled,

+ 43 - 12
readme.md

@@ -13,24 +13,55 @@
 
 ### Supported hardware ###
 
-| HW driver  | Written on | Endpoints |                     Features | MCU series |
-|------------|------------|-----------|------------------------------|------------|
-| usb_stmv0  | GCC C      | 8         | Internal S/N, Doublebuffered, BC1.2 | STM32L0x2 STM32L0x3 STM32L4x2 STM32L4x3 STM32F0x2 STM32F0x8 |
-| usb_stmv0a | GCC ASM    | 8         | Internal S/N, Doublebuffered, BC1.2 | STM32L0x2 STM32L0x3 STM32L4x2 STM32L4x3 STM32F0x2 STM32F0x8 |
-| usb_stmv1  | GCC C      | 8         | Internal S/N, Doublebuffered | STM32L1xx  |
-| usb_stmv1a | GCC ASM    | 8         | Internal S/N, Doublebuffered | STM32L1xx  |
-| usb_stmv2  | GCC C      | 6         | Internal S/N, Doublebuffered, BC1.2 | STM32L4x5 STM32L4x6 (OTG FS Device mode) |
-| usb_stmv3  | GCC C      | 8         | Internal S/N, Doublebuffered, optional DP control | STM32F102 STM32F103 STM32F3xx  |
-| usb_stmv3a | GCC ASM    | 8         | Internal S/N, Doublebuffered, optional DP control | STM32F102 STM32F103 STM32F3xx  |
+<table>
+    <tr><th>MCU Series</th><th>Features</th><th>Driver</th><th>File</th></tr>
+    <tr>
+        <td rowspan="2">STM32L0x2 STM32L0x3 STM32L4x2 STM32L4x3 STM32F0x2 STM32F0x8</td>
+        <td nowrap rowspan="2">Doublebuffered<br />8 endpoints<br /> BC1.2</td>
+        <td>usbd_devfs</td>
+        <td>usbd_stm32l052_devfs.c</td>
+    </tr>
+    <tr>
+        <td>usbd_devfs_asm</td>
+        <td>usbd_stm32l052_devfs_asm.S</td>
+    </tr>
+    <tr>
+        <td rowspan="2">STM32L1xx</td>
+        <td nowrap rowspan="2">Doublebuffered<br />8 endpoints</td>
+        <td>usbd_devfs</td>
+        <td>usbd_stm32l100_devfs.c</td>
+    </tr>
+    <tr>
+        <td>usbd_devfs_asm</td>
+        <td>usbd_stm32l100_devfs_asm.S</td>
+    </tr>
+    <tr>
+        <td rowspan="2">STM32F102 STM32F103 STM32F302 STM32F303 STM32F373</td>
+        <td nowrap rowspan="2">Doublebuffered<br />External DP pullup<br />8 endpoints</td>
+        <td>usbd_devfs</td>
+        <td>usbd_stm32f103_devfs.c</td>
+    </tr>
+    <tr>
+        <td>usbd_devfs_asm</td>
+        <td>usbd_stm32f103_devfs_asm.S</td>
+    </tr>
+    <tr>
+        <td>STM32L4x5 STM32L4x6</td>
+        <td nowrap>Doublebuffered<br />6 endpoints<br /> BC1.2<br />VBUS detection</td>
+        <td>usbd_otgfs</td>
+        <td>usbd_stm32l476_otgfs.c</td>
+    </tr>
+
+</table>
 
 1. Single physical endpoint can be used to implement
   + one bi-directional/single-buffer logical endpoint (CONTROL)
-  + one mono-directional/double-buffer logical endpoint (BULK OR ISOCHRONOUS)
-  + two mono-directional/single-buffer logical endpoints (BULK OR INTERRUPT)
+  + one uni-directional/double-buffer logical endpoint (BULK OR ISOCHRONOUS)
+  + two -directional/single-buffer logical endpoints (BULK OR INTERRUPT)
 
 2. At this moment BULK IN endpoint can use both buffers, but it is not **real** doublebuffered.
 
-3. Tested with STM32L052, STM31L100, STM32L476RG, STM32F103CB, STM32F303CC, STM32F303RE
+3. Tested with STM32L052K8, STM31L100RC, STM32L476RG, STM32F103C8, STM32F103CB, STM32F303CC, STM32F303RE
 
 ### Implemented definitions for classes ###
 1. USB HID based on [Device Class Definition for Human Interface Devices (HID) Version 1.11](http://www.usb.org/developers/hidpage/HID1_11.pdf)

+ 3 - 3
src/usb_32v3.c → src/usbd_stm32f103_devfs.c

@@ -19,7 +19,7 @@
 #include "stm32.h"
 #include "usb.h"
 
-#if defined(USE_STMV3_DRIVER)
+#if defined(USBD_STM32F103)
 
 #define USB_EP_SWBUF_TX     USB_EP_DTOG_RX
 #define USB_EP_SWBUF_RX     USB_EP_DTOG_TX
@@ -528,7 +528,7 @@ uint16_t get_serialno_desc(void *buffer) {
     return 18;
 }
 
-const struct usbd_driver usb_stmv3 = {
+const struct usbd_driver usbd_devfs = {
     0,
     enable,
     reset,
@@ -545,4 +545,4 @@ const struct usbd_driver usb_stmv3 = {
     get_serialno_desc,
 };
 
-#endif //USE_STM32V3_DRIVER
+#endif //USBD_STM32F103

+ 5 - 5
src/usb_32v3A.S → src/usbd_stm32f103_devfs_asm.S

@@ -18,7 +18,7 @@
 #endif
 
 #include "usb.h"
-#if defined(USE_STMV3_DRIVER)
+#if defined(USBD_STM32F103)
 #include "memmap.inc"
 
 #define EP_SETUP    0x0800
@@ -133,9 +133,9 @@
     .thumb
 
 
-    .globl  usb_stmv3a
+    .globl  usbd_devfs_asm
     .align  2
-usb_stmv3a:
+usbd_devfs_asm:
     .long   0
     .long   _enable
     .long   _reset
@@ -150,7 +150,7 @@ usb_stmv3a:
     .long   _evt_poll
     .long   _get_frame
     .long   _get_serial_desc
-    .size   usb_stmv3a, . - usb_stmv3a
+    .size   usbd_devfs_asm, . - usbd_devfs_asm
 
 
     .thumb_func
@@ -890,4 +890,4 @@ _evt_poll:
 
    .end
 
-#endif
+#endif //USBD_STM32F103

+ 3 - 3
src/usb_32v0.c → src/usbd_stm32l052_devfs.c

@@ -18,7 +18,7 @@
 #include "stm32.h"
 #include "usb.h"
 
-#if defined(USE_STMV0_DRIVER)
+#if defined(USBD_STM32L052)
 
 #ifndef USB_PMASIZE
     #warning PMA memory size is not defined. Use 1k by default
@@ -454,7 +454,7 @@ uint16_t get_serialno_desc(void *buffer) {
     return 18;
 }
 
-const struct usbd_driver usb_stmv0 = {
+const struct usbd_driver usbd_devfs = {
     USBD_HW_BC,
     enable,
     reset,
@@ -471,4 +471,4 @@ const struct usbd_driver usb_stmv0 = {
     get_serialno_desc,
 };
 
-#endif //USE_STM32V0_DRIVER
+#endif //USBD_STM32L052

+ 5 - 5
src/usb_32v0A.S → src/usbd_stm32l052_devfs_asm.S

@@ -18,7 +18,7 @@
 #endif
 
 #include "usb.h"
-#if defined(USE_STMV0_DRIVER)
+#if defined(USBD_STM32L052)
 #include "memmap.inc"
 
 #define EP_SETUP    0x0800
@@ -80,9 +80,9 @@
     .thumb
 
 
-    .globl  usb_stmv0a
+    .globl  usbd_devfs_asm
     .align  2
-usb_stmv0a:
+usbd_devfs_asm:
     .long   USBD_HW_BC
     .long   _enable
     .long   _reset
@@ -97,7 +97,7 @@ usb_stmv0a:
     .long   _evt_poll
     .long   _get_frame
     .long   _get_serial_desc
-    .size   usb_stmv0a, . - usb_stmv0a
+    .size   usbd_devfs_asm, . - usbd_devfs_asm
 
 
     .thumb_func
@@ -833,4 +833,4 @@ _evt_poll:
 
    .end
 
-#endif
+#endif //USBD_STM32L052

+ 3 - 3
src/usb_32v1.c → src/usbd_stm32l100_devfs.c

@@ -18,7 +18,7 @@
 #include "stm32.h"
 #include "usb.h"
 
-#if defined(USE_STMV1_DRIVER)
+#if defined(USBD_STM32L100)
 
 #ifndef USB_PMASIZE
     #warning PMA memory size is not defined. Use 512 bytes by default
@@ -443,7 +443,7 @@ uint16_t get_serialno_desc(void *buffer) {
     return 18;
 }
 
-const struct usbd_driver usb_stmv1 = {
+const struct usbd_driver usbd_devfs = {
     0,
     enable,
     reset,
@@ -460,4 +460,4 @@ const struct usbd_driver usb_stmv1 = {
     get_serialno_desc,
 };
 
-#endif //USE_STM32V1_DRIVER
+#endif //USBD_STM32L100

+ 3 - 3
src/usb_32v1A.S → src/usbd_stm32l100_devfs_asm.S

@@ -81,9 +81,9 @@
     .thumb
 
 
-    .globl  usb_stmv1a
+    .globl  usbd_devfs_asm
     .align  2
-usb_stmv1a:
+usbd_devfs_asm:
     .long   0
     .long   _enable
     .long   _reset
@@ -98,7 +98,7 @@ usb_stmv1a:
     .long   _evt_poll
     .long   _get_frame
     .long   _get_serial_desc
-    .size   usb_stmv1a, . - usb_stmv1a
+    .size   usbd_devfs_asm, . - usbd_devfs_asm
 
 
     .thumb_func

+ 3 - 3
src/usb_32v2.c → src/usbd_stm32l476_otgfs.c

@@ -18,7 +18,7 @@
 #include "stm32.h"
 #include "usb.h"
 
-#if defined(USE_STMV2_DRIVER)
+#if defined(USBD_STM32L476)
 
 #define MAX_EP          6
 #define MAX_RX_PACKET   128
@@ -478,7 +478,7 @@ uint16_t get_serialno_desc(void *buffer) {
     return 18;
 }
 
-const struct usbd_driver usb_stmv2 = {
+const struct usbd_driver usbd_otgfs = {
     USBD_HW_ADDRFST | USBD_HW_BC,
     enable,
     reset,
@@ -495,4 +495,4 @@ const struct usbd_driver usb_stmv2 = {
     get_serialno_desc,
 };
 
-#endif //USE_STM32V2_DRIVER
+#endif //USBD_STM32L476