Dmitry vor 9 Jahren
Ursprung
Commit
74c1a51d59
7 geänderte Dateien mit 69 neuen und 23 gelöschten Zeilen
  1. 24 4
      inc/usb_std.h
  2. 0 4
      inc/usbd_core.h
  3. 13 5
      readme.md
  4. 8 4
      src/usb_32l0A.S
  5. 3 1
      src/usb_32v0.c
  6. 1 0
      src/usbd_core.c
  7. 20 5
      usb.h

+ 24 - 4
inc/usb_std.h

@@ -128,6 +128,23 @@ extern "C" {
 #define USB_STD_SYNCH_FRAME         0x0C /**< This request is used to set and then report an endpoint's synchronization frame */
 /** @} */
 
+/**\name USB Feature selector
+ * @{ */
+#define USB_FEAT_ENDPOINT_HALT      0x00
+#define USB_FEAT_REMOTE_WKUP        0x01
+#define USB_FEAT_TEST_MODE          0x02
+#define USB_FEAT_DEBUG_MODE         0x06
+/** @} */
+
+/**\name USB Test mode Selectors
+ * @{ */
+#define USB_TEST_J                  0x01
+#define USB_TEST_K                  0x02
+#define USB_TEST_SE0_NAK            0x03
+#define USB_TEST_PACKET             0x04
+#define USB_TEST_FOECR_ENABLE       0x05
+/** @} */
+
 /** \addtogroup USB_STD_LANGID USB standard LANGID codes
  * @{ */
 #define USB_LANGID_AFR          0x0436   /**< Afrikaans */
@@ -371,7 +388,6 @@ struct usb_endpoint_descriptor {
     uint16_t wMaxPacketSize;        /**< Size of the endpoint bank, in bytes. This indicates the maximum packet size that the endpoint can receive at a time. */
     uint8_t  bInterval;             /**< Polling interval in milliseconds for the endpoint if it is an INTERRUPT or ISOCHRONOUS type. */
 } __attribute__((packed));
-
 /** \brief USB string descriptor
  *  \details String descriptors are referenced by their one-based index number. A string descriptor contains one or more not NULL-terminated Unicode strings.
  *  \note String descriptors are optional. if a device does not support string descriptors, all references to string descriptors within device, configuration,
@@ -382,10 +398,14 @@ struct usb_string_descriptor {
     uint8_t  bDescriptorType;       /**< Type of the descriptor, must be \ref USB_DTYPE_STRING */
     uint16_t wString[];             /**< String data, as unicode characters (for zero-indexed descriptor, array of \ref USB_STD_LANGID ). */
 } __attribute__((packed));
-
+/** \brief USB debug descriptor
+ *  \details This descriptor is used to describe certain characteristics of the device that the host debug port driver needs to know
+ *           to communicate with the device. Specifically, the debug descriptor lists the addresses of the endpoints that comprise the
+ *           Debug Pipe. The endpoints are identified by endpoint number.
+ */
 struct usb_debug_descriptor {
-    uint8_t  bLength;
-    uint8_t  bDescriptorType;
+    uint8_t  bLength;               /**< Size of the descriptor, in bytes. */
+    uint8_t  bDescriptorType;       /**< Type ot the descriptor, must be \ref USB_DTYPE_DEBUG */
     uint8_t  bDebugInEndpoint;      /**< Endpoint number of the Debug Data IN endpoint. This is a Bulk-type endpoint with a maximum packet size of 8 bytes.  */
     uint8_t  bDebugOutEndpoint;     /**< Endpoint number of the Debug Data OUTendpoint. This is a Bulk-type endpoint with a maximum packet size of 8 bytes.  */
 } __attribute__((packed));

+ 0 - 4
inc/usbd_core.h

@@ -25,10 +25,6 @@
 #if defined(__cplusplus)
     extern "C" {
 #endif
-#include <stdbool.h>
-
-
-
 
 /** \addtogroup USBD_CORE USB device core
  * \brief Contains core and hardware driver framework definitions

+ 13 - 5
readme.md

@@ -7,11 +7,17 @@
 
 ### Supported hardware ###
 
-| MCU series | Driver Name | Written on | Endpoints (1) | Internal S/N | Doublebuffered transfer   |
-| ---------- | ----------- | ---------- | ------------- |------------- | ------------------------- |
-| STM32L0/F0 | usb_stml0a  | GCC ASM    |             8 | FNV1A 32bit  | ISO, BULK OUT, BULK IN (2)|
-| STM32L0/F0 | usb_stmv0   | C          |             8 | FNV1A 32bit  | ISO, BULK OUT, BULK IN (2)|
-
+| MCU series   | Driver Name | Written on | Endpoints (1) | Internal S/N | Doublebuffered transfer   |
+| ------------ | ----------- | ---------- | ------------- |------------- | ------------------------- |
+| STM32L052    | usb_stmv0a  | GCC ASM    |             8 | FNV1A 32bit  | ISO, BULK OUT, BULK IN (2)|
+| STM32L052    | usb_stmv0   | C          |             8 | FNV1A 32bit  | ISO, BULK OUT, BULK IN (2)|
+| STM32L053(3) | usb_stmv0   | C          |             8 | FNV1A 32bit  | ISO, BULK OUT, BULK IN (2)|
+| STM32F042(3) | usb_stmv0   | C          |             8 | FNV1A 32bit  | ISO, BULK OUT, BULK IN (2)|
+| STM32F072(3) | usb_stmv0   | C          |             8 | FNV1A 32bit  | ISO, BULK OUT, BULK IN (2)|
+| STM32L432(3) | usb_stmv0   | C          |             8 | FNV1A 32bit  | ISO, BULK OUT, BULK IN (2)|
+| STM32L433(3) | usb_stmv0   | C          |             8 | FNV1A 32bit  | ISO, BULK OUT, BULK IN (2)|
+| STM32L442(3) | usb_stmv0   | C          |             8 | FNV1A 32bit  | ISO, BULK OUT, BULK IN (2)|
+| STM32L443(3) | usb_stmv0   | C          |             8 | FNV1A 32bit  | ISO, BULK OUT, BULK IN (2)|
 
 1. Single physicsl endpoint can be used to implement
   + one bi-directional/single-buffer logical endpoint (CONTROL)
@@ -20,6 +26,8 @@
 
 2. At this moment BULK IN endpoint can use both buffers, but it is not **real** doublebuffered.
 
+3. **Not tested**
+
 ### 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)
 2. USB DFU based on [USB Device Firmware Upgrade Specification, Revision 1.1] (http://www.usb.org/developers/docs/devclass_docs/DFU_1.1.pdf)

+ 8 - 4
src/usb_32l0A.S

@@ -16,7 +16,9 @@
 #if !defined (__ASSEMBLER__)
     #define __ASSEMBLER__
 #endif
-#include "..\inc\usbd_core.h"
+
+#include "..\usb.h"
+#if defined(USE_STMV0A_DRIVER)
 
 #define USB_EPBASE  0x40005C00
 #define USB_REGBASE 0x40005C40
@@ -68,9 +70,9 @@
     .thumb
 
 
-    .globl  usb_stml0a
+    .globl  usb_stmv0a
     .align  2
-usb_stml0a:
+usb_stmv0a:
     .long   _enable
     .long   _reset
     .long   _connect
@@ -84,7 +86,7 @@ usb_stml0a:
     .long   _evt_poll
     .long   _get_frame
     .long   _get_serial_desc
-    .size   usb_stml0a, . - usb_stml0a
+    .size   usb_stmv0a, . - usb_stmv0a
 
 
     .thumb_func
@@ -807,3 +809,5 @@ _evt_poll:
     .pool
 
    .end
+
+#endif

+ 3 - 1
src/usb_32v0.c

@@ -1,7 +1,9 @@
 #include <stdint.h>
+#include <stdbool.h>
 #include "stm32.h"
 #include "usb.h"
 
+#if defined(USE_STMV0_DRIVER)
 
 #ifndef USB_PMASIZE
     #warning PMA memory size is not defined. Use 1k by default
@@ -452,4 +454,4 @@ const struct usbd_driver usb_stmv0 = {
     get_serialno_desc,
 };
 
-
+#endif //USE_STM32V0_DRIVER

+ 1 - 0
src/usbd_core.c

@@ -14,6 +14,7 @@
  */
 
 #include <stdint.h>
+#include <stdbool.h>
 #include <string.h>
 #include "usb.h"
 

+ 20 - 5
usb.h

@@ -21,18 +21,33 @@
 #endif
 
 
-#include "inc\usbd_core.h"
-#include "inc\usb_std.h"
 
 
-#if defined(STM32L0)
-    extern const struct usbd_driver usb_stml0a;
-    #define usb_hw_driver usb_stml0a
+#if defined(STM32L052xx) && !defined(USE_C_DRIVER)
+    #define USE_STMV0A_DRIVER
+#elif defined(STM32L052xx)
+    #define USE_STMV0_DRIVER
+#elif defined(STM32L053xx) || defined(STM32F042xx) || defined(STM32F072xx) ||
+      defined(STM32L432xx) || defined(STM32L442xx) || defined(STM32L433xx) ||
+      defined(STM32L443xx)
+    #define USE_STMV0_DRIVER
+    #warning "Driver has not been tested with this MPU"
 #else
     #error "No supported MCU family selected"
 #endif
 
 
+#include "inc\usbd_core.h"
+#if !defined(__ASSEMBLER__)
+    #include "inc\usb_std.h"
+    #if defined(USE_STMV0A_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
+    #endif
+#endif
 
 #if defined (__cplusplus)
     }