Bladeren bron

Renamed request completed callback function, revised doxygen docs

Dmitry 9 jaren geleden
bovenliggende
commit
68dfeea293
6 gewijzigde bestanden met toevoegingen van 47 en 53 verwijderingen
  1. 1 1
      Doxyfile
  2. 2 0
      inc/usb_std.h
  3. 39 45
      inc/usbd_core.h
  4. 1 1
      src/usb_32v0A.S
  5. 1 1
      src/usb_32v1A.S
  6. 3 5
      usb.h

+ 1 - 1
Doxyfile

@@ -434,7 +434,7 @@ EXTRACT_PACKAGE        = NO
 # included in the documentation.
 # The default value is: NO.
 
-EXTRACT_STATIC         = NO
+EXTRACT_STATIC         = YES
 
 # If the EXTRACT_LOCAL_CLASSES tag is set to YES, classes (and structs) defined
 # locally in source files will be included in the documentation. If set to NO,

+ 2 - 0
inc/usb_std.h

@@ -50,6 +50,8 @@ extern "C" {
 /** \anchor USB_ENDPOINT_DEF
  *  \name USB endpoint attributes definitions
  * @{ */
+#define USB_EPDIR_IN                0x00        /**< indicates host-to-device endpoint direction  */
+#define USB_EPDIR_OUT               0x80        /**< indicates device-to-host endpoint direction */
 #define USB_EPTYPE_CONTROL          0x00
 #define USB_EPTYPE_ISOCHRONUS       0x01
 #define USB_EPTYPE_BULK             0x02

+ 39 - 45
inc/usbd_core.h

@@ -31,9 +31,6 @@
  * \brief Contains core and hardware driver framework definitions
  * @{ */
 #define USB_EPTYPE_DBLBUF       0x04        /**< indicates a doublebuffered endpoint (bulk endpoint only) */
-#define USB_EPDIR_IN            0x00        /**< indicates host-to-device endpoint direction  */
-#define USB_EPDIR_OUT           0x80        /**< indicates device-to-host endpoint direction */
-
 
 /** \name bmRequestType bitmapped field
  * @{ */
@@ -55,20 +52,20 @@
 /** \name USB device events
  * @{ */
 #define usbd_evt_reset      0   /**< Reset */
-#define usbd_evt_sof        1   /**< Start Of Frame */
+#define usbd_evt_sof        1   /**< Start of frame */
 #define usbd_evt_susp       2   /**< Suspend */
 #define usbd_evt_wkup       3   /**< Wakeup */
-#define usbd_evt_eptx       4   /**< Transmit completed */
+#define usbd_evt_eptx       4   /**< Data packet transmitted*/
 #define usbd_evt_eprx       5   /**< Data packet received */
 #define usbd_evt_epsetup    6   /**< Setup packet received */
 #define usbd_evt_error      7   /**< Data error */
 #define usbd_evt_esof       8   /**< Missed SOF */
-#define usbd_evt_count      9   /* this is trick to count qty */
+#define usbd_evt_count      9
 /** @} */
 
 #if !defined(__ASSEMBLER__)
 
-/** USB device machine state */
+/** USB device machine states */
 enum usbd_machine_state {
     usbd_state_disabled,
     usbd_state_disconnected,
@@ -97,7 +94,7 @@ enum usbd_commands {
     usbd_cmd_reset,             /**< Resets device */
 };
 
-/* Reporting status results */
+/** Reporting status results */
 typedef enum _usbd_respond {
     usbd_fail,                  /**< Function has an error, STALLPID will be issued */
     usbd_ack,                   /**< Function completes request accepted ZLP or data will be send */
@@ -118,14 +115,14 @@ typedef struct _usbd_status usbd_status;
   */
 typedef void (*usbd_evt_callback)(usbd_device *dev, uint8_t event, uint8_t ep);
 
-/** USB control transfer completed callback function typedef.
+/** USB control transfer completed callback function.
  * \param[in] dev pointer to USB device
  * \param[in] req pointer to usb request structure
  * \note When this callback will be completed usbd_device#complete_callback will be reseted to NULL
  */
-typedef void (*usbd_ctl_complete)(usbd_device *dev, usbd_ctlreq *req);
+typedef void (*usbd_rqc_callback)(usbd_device *dev, usbd_ctlreq *req);
 
-/** USB control callback function typedef.
+/** USB control callback function.
  * \details Uses for the control request processing.
  *          Some requests will be handled by core if callback don't process it (returns FALSE). If request was not processed STALL PID will be issued.
  *          - GET_CONFIGURATION
@@ -136,12 +133,12 @@ typedef void (*usbd_ctl_complete)(usbd_device *dev, usbd_ctlreq *req);
  *          - SET_ADDRESS
  * \param[in] dev points to USB device
  * \param[in] req points to usb control request
- * \param[out] *callback \ref usbd_ctl_complete "pointer to USB control transfer completed callback", default is NULL (no callback)
+ * \param[out] *callback \ref usbd_rqc_callback "pointer to USB control transfer completed callback", default is NULL (no callback)
  * \return usbd_respond status.
  */
-typedef usbd_respond (*usbd_ctl_callback)(usbd_device *dev, usbd_ctlreq *req, usbd_ctl_complete *callback);
+typedef usbd_respond (*usbd_ctl_callback)(usbd_device *dev, usbd_ctlreq *req, usbd_rqc_callback *callback);
 
-/** USB get descriptor callback function typedef
+/** USB get descriptor callback function
  * \details Called when GET_DESCRIPTOR request issued
  * \param[in] req pointer to usb control request structure
  * \param[in,out] address pointer to the descriptor in memory. Points to req->data by default. You can use this buffer.
@@ -150,7 +147,7 @@ typedef usbd_respond (*usbd_ctl_callback)(usbd_device *dev, usbd_ctlreq *req, us
  */
 typedef bool (*usbd_dsc_callback)(usbd_ctlreq *req, void **address, uint16_t *dsize);
 
-/** USB set configuration callback function typedef
+/** USB set configuration callback function
  * \details called when SET_CONFIGURATION request issued
  * \param[in] dev pointer to USB device
  * \param[in] cfg configuration number.
@@ -251,52 +248,49 @@ struct _usbd_ctlreq {
     uint16_t    wValue;         /**< It is used to pass a parameter to the device, specific to the request. */
     uint16_t    wIndex;         /**< It is used to pass a parameter to the device, specific to the request. */
     uint16_t    wLength;        /**< This field specifies the length of the data transferred during the second phase of the control transfer */
-    uint8_t     data[];         /**< Request data payload */
+    uint8_t     data[];         /**< Data payload */
 };
 
-
-/** USB device status data for control endpoint */
+/** USB device status data */
 struct _usbd_status {
-    void        *data_buf;
-    void        *data_ptr;      /**< Pointer to control endpoint current data buffer */
-    uint16_t    data_count;     /**< Control endpoint data counter */
-    uint16_t    data_maxsize;   /**< Size of the data buffer for control endpoint */
+    void        *data_buf;      /**< Pointer to data buffer used for control requests */
+    void        *data_ptr;      /**< Pointer to current data for control request */
+    uint16_t    data_count;     /**< Count remained data for control request */
+    uint16_t    data_maxsize;   /**< Size of the data buffer for control requests */
     uint8_t     ep0size;        /**< Size of the control endpoint */
-    uint8_t     device_cfg;     /**< Current device configuration ID */
+    uint8_t     device_cfg;     /**< Current device configuration number */
     uint8_t     device_state;   /**< Current \ref usbd_machine_state */
     uint8_t     control_state;  /**< Current \ref usbd_ctl_state */
 };
 
-/** Structure represents a hardware USB driver call table */
+/** Represents a hardware USB driver call table */
 struct usbd_driver {
-    usbd_hw_enable          enable;
-    usbd_hw_reset           reset;
-    usbd_hw_connect         connect;
-    usbd_hw_setaddr         setaddr;
-    usbd_hw_ep_config       ep_config;
-    usbd_hw_ep_deconfig     ep_deconfig;
-    usbd_hw_ep_read         ep_read;
-    usbd_hw_ep_write        ep_write;
-    usbd_hw_ep_setstall     ep_setstall;
-    usbd_hw_ep_isstalled    ep_isstalled;
-    usbd_hw_poll            poll;
-    usbd_hw_get_frameno     frame_no;
-    usbd_hw_get_serialno    get_serialno_desc;
+    usbd_hw_enable          enable;             /**< \copydoc usbd_hw_enable */
+    usbd_hw_reset           reset;              /**< \copydoc usbd_hw_reset */
+    usbd_hw_connect         connect;            /**< \copydoc usbd_hw_connect */
+    usbd_hw_setaddr         setaddr;            /**< \copydoc usbd_hw_setaddr */
+    usbd_hw_ep_config       ep_config;          /**< \copydoc usbd_hw_ep_config */
+    usbd_hw_ep_deconfig     ep_deconfig;        /**< \copydoc usbd_hw_ep_deconfig */
+    usbd_hw_ep_read         ep_read;            /**< \copydoc usbd_hw_ep_read */
+    usbd_hw_ep_write        ep_write;           /**< \copydoc usbd_hw_ep_write */
+    usbd_hw_ep_setstall     ep_setstall;        /**< \copydoc usbd_hw_ep_setstall */
+    usbd_hw_ep_isstalled    ep_isstalled;       /**< \copydoc usbd_hw_ep_isstalled */
+    usbd_hw_poll            poll;               /**< \copydoc usbd_hw_poll */
+    usbd_hw_get_frameno     frame_no;           /**< \copydoc usbd_hw_get_frameno */
+    usbd_hw_get_serialno    get_serialno_desc;  /**< \copydoc usbd_hw_get_serialno */
 };
 
-/** Structure represents a USB device data. No other data used by USB core and driver
- *  \note use helper \ref usbd_device typedef
- *  \note structure must be aligned
+/** Represents a USB device data.
  */
 struct _usbd_device {
     const struct usbd_driver    *driver;
-    usbd_ctl_callback           control_callback;
-    usbd_ctl_complete           complete_callback;
-    usbd_cfg_callback           config_callback;
-    usbd_dsc_callback           descriptor_callback;
+    usbd_ctl_callback           control_callback;           /**< \copydoc usbd_ctl_callback */
+    usbd_rqc_callback           complete_callback;          /**< \copydoc usbd_rqc_callback */
+    usbd_cfg_callback           config_callback;            /**< \copydoc usbd_cfg_callback */
+    usbd_dsc_callback           descriptor_callback;        /**< \copydoc usbd_dsc_callback */
     usbd_evt_callback           events[usbd_evt_count];     /**< events callbacks array */
     usbd_evt_callback           endpoint[8];                /**< endpoint callbacks array for tx, rx and setup events */
-    usbd_status                 status;
+    usbd_status                 status;                     /**< \copydoc _usbd_status */
 };
 
 /** \addtogroup USB_CORE_API

+ 1 - 1
src/usb_32v0A.S

@@ -19,7 +19,7 @@
 
 #include "../usb.h"
 #include "memmap.inc"
-#if defined(USE_STMV0A_DRIVER)
+#if defined(USE_STMV0_DRIVER)
 
 #define EP_SETUP    0x0800
 #define EP_TYPE     0x0600

+ 1 - 1
src/usb_32v1A.S

@@ -19,7 +19,7 @@
 
 #include "../usb.h"
 #include "memmap.inc"
-#if defined(USE_STMV1A_DRIVER)
+#if defined(USE_STMV1_DRIVER)
 
 
 #define EP_SETUP    0x0800

+ 3 - 5
usb.h

@@ -34,14 +34,12 @@
     #define USE_STMV0_DRIVER
 
     #if (defined(FORCE_ASM_DRIVER) || defined(STM32L052xx)) && !defined(FORCE_C_DRIVER)
-        #undef USE_STMV0_DRIVER
         #define USE_STMV0A_DRIVER
     #endif
 
 #elif defined(STM32L1)
     #define USE_STMV1_DRIVER
     #if (defined(FORCE_ASM_DRIVER) || defined(STM32L100xC)) && !defined(FORCE_C_DRIVER)
-        #undef USE_STMV1_DRIVER
         #define USE_STMV1A_DRIVER
     #endif
 #else
@@ -58,12 +56,12 @@
     #elif defined(USE_STMV0_DRIVER)
         extern const struct usbd_driver usb_stmv0;
         #define usbd_hw usb_stmv0
-    #elif defined(USE_STMV1_DRIVER)
-        extern const struct usbd_driver usb_stmv1;
-        #define usbd_hw usb_stmv1
     #elif defined(USE_STMV1A_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
     #endif
 #endif