|
@@ -144,15 +144,15 @@ extern "C" {
|
|
|
* \code #define USB_DEVICE_ATTACH_AUTO_DISABLE \endcode
|
|
|
* User C file contains:
|
|
|
* \code
|
|
|
- // Authorize VBUS monitoring
|
|
|
- if (!udc_include_vbus_monitoring()) {
|
|
|
- // Implement custom VBUS monitoring via GPIO or other
|
|
|
- }
|
|
|
- Event_VBUS_present() // VBUS interrupt or GPIO interrupt or other
|
|
|
- {
|
|
|
- // Attach USB Device
|
|
|
- udc_attach();
|
|
|
- }
|
|
|
+ // Authorize VBUS monitoring
|
|
|
+ if (!udc_include_vbus_monitoring()) {
|
|
|
+ // Implement custom VBUS monitoring via GPIO or other
|
|
|
+ }
|
|
|
+ Event_VBUS_present() // VBUS interrupt or GPIO interrupt or other
|
|
|
+ {
|
|
|
+ // Attach USB Device
|
|
|
+ udc_attach();
|
|
|
+ }
|
|
|
\endcode
|
|
|
*
|
|
|
* - Case of battery charging. conf_usb.h file contains define
|
|
@@ -160,21 +160,20 @@ extern "C" {
|
|
|
* \code #define USB_DEVICE_ATTACH_AUTO_DISABLE \endcode
|
|
|
* User C file contains:
|
|
|
* \code
|
|
|
- Event VBUS present() // VBUS interrupt or GPIO interrupt or ..
|
|
|
- {
|
|
|
- // Authorize battery charging, but wait key press to start USB.
|
|
|
- }
|
|
|
- Event Key press()
|
|
|
- {
|
|
|
- // Stop batteries charging
|
|
|
- // Start USB
|
|
|
- udc_attach();
|
|
|
- }
|
|
|
+ Event VBUS present() // VBUS interrupt or GPIO interrupt or ..
|
|
|
+ {
|
|
|
+ // Authorize battery charging, but wait key press to start USB.
|
|
|
+ }
|
|
|
+ Event Key press()
|
|
|
+ {
|
|
|
+ // Stop batteries charging
|
|
|
+ // Start USB
|
|
|
+ udc_attach();
|
|
|
+ }
|
|
|
\endcode
|
|
|
*/
|
|
|
-static inline bool udc_include_vbus_monitoring(void)
|
|
|
-{
|
|
|
- return udd_include_vbus_monitoring();
|
|
|
+static inline bool udc_include_vbus_monitoring(void) {
|
|
|
+ return udd_include_vbus_monitoring();
|
|
|
}
|
|
|
|
|
|
/*! \brief Start the USB Device stack
|
|
@@ -192,32 +191,26 @@ void udc_stop(void);
|
|
|
* then it will attach device when an acceptable Vbus
|
|
|
* level from the host is detected.
|
|
|
*/
|
|
|
-static inline void udc_attach(void)
|
|
|
-{
|
|
|
- udd_attach();
|
|
|
+static inline void udc_attach(void) {
|
|
|
+ udd_attach();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* \brief Detaches the device from the bus
|
|
|
*
|
|
|
* The driver must remove pull-up on USB line D- or D+.
|
|
|
*/
|
|
|
-static inline void udc_detach(void)
|
|
|
-{
|
|
|
- udd_detach();
|
|
|
+static inline void udc_detach(void) {
|
|
|
+ udd_detach();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/*! \brief The USB driver sends a resume signal called \e "Upstream Resume"
|
|
|
* This is authorized only when the remote wakeup feature is enabled by host.
|
|
|
*/
|
|
|
-static inline void udc_remotewakeup(void)
|
|
|
-{
|
|
|
- udd_send_remotewakeup();
|
|
|
+static inline void udc_remotewakeup(void) {
|
|
|
+ udd_send_remotewakeup();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* \brief Returns a pointer on the current interface descriptor
|
|
|
*
|
|
@@ -296,23 +289,23 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void);
|
|
|
*
|
|
|
* for AVR and SAM3/4 devices, add to the initialization code:
|
|
|
* \code
|
|
|
- sysclk_init();
|
|
|
- irq_initialize_vectors();
|
|
|
- cpu_irq_enable();
|
|
|
- board_init();
|
|
|
- sleepmgr_init(); // Optional
|
|
|
+ sysclk_init();
|
|
|
+ irq_initialize_vectors();
|
|
|
+ cpu_irq_enable();
|
|
|
+ board_init();
|
|
|
+ sleepmgr_init(); // Optional
|
|
|
\endcode
|
|
|
*
|
|
|
* For SAMD devices, add to the initialization code:
|
|
|
* \code
|
|
|
- system_init();
|
|
|
- irq_initialize_vectors();
|
|
|
- cpu_irq_enable();
|
|
|
- sleepmgr_init(); // Optional
|
|
|
+ system_init();
|
|
|
+ irq_initialize_vectors();
|
|
|
+ cpu_irq_enable();
|
|
|
+ sleepmgr_init(); // Optional
|
|
|
\endcode
|
|
|
* Add to the main IDLE loop:
|
|
|
* \code
|
|
|
- sleepmgr_enter_sleep(); // Optional
|
|
|
+ sleepmgr_enter_sleep(); // Optional
|
|
|
\endcode
|
|
|
*
|
|
|
*/
|
|
@@ -324,20 +317,20 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void);
|
|
|
*
|
|
|
* Content of conf_usb.h:
|
|
|
* \code
|
|
|
- #define USB_DEVICE_VENDOR_ID 0x03EB
|
|
|
- #define USB_DEVICE_PRODUCT_ID 0xXXXX
|
|
|
- #define USB_DEVICE_MAJOR_VERSION 1
|
|
|
- #define USB_DEVICE_MINOR_VERSION 0
|
|
|
- #define USB_DEVICE_POWER 100
|
|
|
- #define USB_DEVICE_ATTR USB_CONFIG_ATTR_BUS_POWERED
|
|
|
+ #define USB_DEVICE_VENDOR_ID 0x03EB
|
|
|
+ #define USB_DEVICE_PRODUCT_ID 0xXXXX
|
|
|
+ #define USB_DEVICE_MAJOR_VERSION 1
|
|
|
+ #define USB_DEVICE_MINOR_VERSION 0
|
|
|
+ #define USB_DEVICE_POWER 100
|
|
|
+ #define USB_DEVICE_ATTR USB_CONFIG_ATTR_BUS_POWERED
|
|
|
\endcode
|
|
|
*
|
|
|
* Add to application C-file:
|
|
|
* \code
|
|
|
- void usb_init(void)
|
|
|
- {
|
|
|
- udc_start();
|
|
|
- }
|
|
|
+ void usb_init(void)
|
|
|
+ {
|
|
|
+ udc_start();
|
|
|
+ }
|
|
|
\endcode
|
|
|
*/
|
|
|
|
|
@@ -349,17 +342,17 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void);
|
|
|
* -# Ensure that conf_usb.h is available and contains the following configuration
|
|
|
* which is the main USB device configuration:
|
|
|
* - \code // Vendor ID provided by USB org (ATMEL 0x03EB)
|
|
|
- #define USB_DEVICE_VENDOR_ID 0x03EB // Type Word
|
|
|
- // Product ID (Atmel PID referenced in usb_atmel.h)
|
|
|
- #define USB_DEVICE_PRODUCT_ID 0xXXXX // Type Word
|
|
|
- // Major version of the device
|
|
|
- #define USB_DEVICE_MAJOR_VERSION 1 // Type Byte
|
|
|
- // Minor version of the device
|
|
|
- #define USB_DEVICE_MINOR_VERSION 0 // Type Byte
|
|
|
- // Maximum device power (mA)
|
|
|
- #define USB_DEVICE_POWER 100 // Type 9-bits
|
|
|
- // USB attributes to enable features
|
|
|
- #define USB_DEVICE_ATTR USB_CONFIG_ATTR_BUS_POWERED // Flags \endcode
|
|
|
+ #define USB_DEVICE_VENDOR_ID 0x03EB // Type Word
|
|
|
+ // Product ID (Atmel PID referenced in usb_atmel.h)
|
|
|
+ #define USB_DEVICE_PRODUCT_ID 0xXXXX // Type Word
|
|
|
+ // Major version of the device
|
|
|
+ #define USB_DEVICE_MAJOR_VERSION 1 // Type Byte
|
|
|
+ // Minor version of the device
|
|
|
+ #define USB_DEVICE_MINOR_VERSION 0 // Type Byte
|
|
|
+ // Maximum device power (mA)
|
|
|
+ #define USB_DEVICE_POWER 100 // Type 9-bits
|
|
|
+ // USB attributes to enable features
|
|
|
+ #define USB_DEVICE_ATTR USB_CONFIG_ATTR_BUS_POWERED // Flags \endcode
|
|
|
* -# Call the USB device stack start function to enable stack and start USB:
|
|
|
* - \code udc_start(); \endcode
|
|
|
* \note In case of USB dual roles (Device and Host) managed through USB OTG connector
|
|
@@ -372,90 +365,90 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void);
|
|
|
*
|
|
|
* Content of XMEGA conf_clock.h:
|
|
|
* \code
|
|
|
- // Configuration based on internal RC:
|
|
|
- // USB clock need of 48Mhz
|
|
|
- #define CONFIG_USBCLK_SOURCE USBCLK_SRC_RCOSC
|
|
|
- #define CONFIG_OSC_RC32_CAL 48000000UL
|
|
|
- #define CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC OSC_ID_USBSOF
|
|
|
- // CPU clock need of clock > 12MHz to run with USB (Here 24MHz)
|
|
|
- #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RC32MHZ
|
|
|
- #define CONFIG_SYSCLK_PSADIV SYSCLK_PSADIV_2
|
|
|
- #define CONFIG_SYSCLK_PSBCDIV SYSCLK_PSBCDIV_1_1
|
|
|
+ // Configuration based on internal RC:
|
|
|
+ // USB clock need of 48Mhz
|
|
|
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_RCOSC
|
|
|
+ #define CONFIG_OSC_RC32_CAL 48000000UL
|
|
|
+ #define CONFIG_OSC_AUTOCAL_RC32MHZ_REF_OSC OSC_ID_USBSOF
|
|
|
+ // CPU clock need of clock > 12MHz to run with USB (Here 24MHz)
|
|
|
+ #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_RC32MHZ
|
|
|
+ #define CONFIG_SYSCLK_PSADIV SYSCLK_PSADIV_2
|
|
|
+ #define CONFIG_SYSCLK_PSBCDIV SYSCLK_PSBCDIV_1_1
|
|
|
\endcode
|
|
|
*
|
|
|
* Content of conf_clock.h for AT32UC3A0, AT32UC3A1, AT32UC3B devices (USBB):
|
|
|
* \code
|
|
|
- // Configuration based on 12MHz external OSC:
|
|
|
- #define CONFIG_PLL1_SOURCE PLL_SRC_OSC0
|
|
|
- #define CONFIG_PLL1_MUL 8
|
|
|
- #define CONFIG_PLL1_DIV 2
|
|
|
- #define CONFIG_USBCLK_SOURCE USBCLK_SRC_PLL1
|
|
|
- #define CONFIG_USBCLK_DIV 1 // Fusb = Fsys/(2 ^ USB_div)
|
|
|
+ // Configuration based on 12MHz external OSC:
|
|
|
+ #define CONFIG_PLL1_SOURCE PLL_SRC_OSC0
|
|
|
+ #define CONFIG_PLL1_MUL 8
|
|
|
+ #define CONFIG_PLL1_DIV 2
|
|
|
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_PLL1
|
|
|
+ #define CONFIG_USBCLK_DIV 1 // Fusb = Fsys/(2 ^ USB_div)
|
|
|
\endcode
|
|
|
*
|
|
|
* Content of conf_clock.h for AT32UC3A3, AT32UC3A4 devices (USBB with high speed support):
|
|
|
* \code
|
|
|
- // Configuration based on 12MHz external OSC:
|
|
|
- #define CONFIG_USBCLK_SOURCE USBCLK_SRC_OSC0
|
|
|
- #define CONFIG_USBCLK_DIV 1 // Fusb = Fsys/(2 ^ USB_div)
|
|
|
+ // Configuration based on 12MHz external OSC:
|
|
|
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_OSC0
|
|
|
+ #define CONFIG_USBCLK_DIV 1 // Fusb = Fsys/(2 ^ USB_div)
|
|
|
\endcode
|
|
|
*
|
|
|
* Content of conf_clock.h for AT32UC3C, ATUCXXD, ATUCXXL3U, ATUCXXL4U devices (USBC):
|
|
|
* \code
|
|
|
- // Configuration based on 12MHz external OSC:
|
|
|
- #define CONFIG_PLL1_SOURCE PLL_SRC_OSC0
|
|
|
- #define CONFIG_PLL1_MUL 8
|
|
|
- #define CONFIG_PLL1_DIV 2
|
|
|
- #define CONFIG_USBCLK_SOURCE USBCLK_SRC_PLL1
|
|
|
- #define CONFIG_USBCLK_DIV 1 // Fusb = Fsys/(2 ^ USB_div)
|
|
|
- // CPU clock need of clock > 25MHz to run with USBC
|
|
|
- #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLL1
|
|
|
+ // Configuration based on 12MHz external OSC:
|
|
|
+ #define CONFIG_PLL1_SOURCE PLL_SRC_OSC0
|
|
|
+ #define CONFIG_PLL1_MUL 8
|
|
|
+ #define CONFIG_PLL1_DIV 2
|
|
|
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_PLL1
|
|
|
+ #define CONFIG_USBCLK_DIV 1 // Fusb = Fsys/(2 ^ USB_div)
|
|
|
+ // CPU clock need of clock > 25MHz to run with USBC
|
|
|
+ #define CONFIG_SYSCLK_SOURCE SYSCLK_SRC_PLL1
|
|
|
\endcode
|
|
|
*
|
|
|
* Content of conf_clock.h for SAM3S, SAM3SD, SAM4S devices (UPD: USB Peripheral Device):
|
|
|
* \code
|
|
|
- // PLL1 (B) Options (Fpll = (Fclk * PLL_mul) / PLL_div)
|
|
|
- #define CONFIG_PLL1_SOURCE PLL_SRC_MAINCK_XTAL
|
|
|
- #define CONFIG_PLL1_MUL 16
|
|
|
- #define CONFIG_PLL1_DIV 2
|
|
|
- // USB Clock Source Options (Fusb = FpllX / USB_div)
|
|
|
- #define CONFIG_USBCLK_SOURCE USBCLK_SRC_PLL1
|
|
|
- #define CONFIG_USBCLK_DIV 2
|
|
|
+ // PLL1 (B) Options (Fpll = (Fclk * PLL_mul) / PLL_div)
|
|
|
+ #define CONFIG_PLL1_SOURCE PLL_SRC_MAINCK_XTAL
|
|
|
+ #define CONFIG_PLL1_MUL 16
|
|
|
+ #define CONFIG_PLL1_DIV 2
|
|
|
+ // USB Clock Source Options (Fusb = FpllX / USB_div)
|
|
|
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_PLL1
|
|
|
+ #define CONFIG_USBCLK_DIV 2
|
|
|
\endcode
|
|
|
*
|
|
|
* Content of conf_clock.h for SAM3U device (UPDHS: USB Peripheral Device High Speed):
|
|
|
* \code
|
|
|
- // USB Clock Source fixed at UPLL.
|
|
|
+ // USB Clock Source fixed at UPLL.
|
|
|
\endcode
|
|
|
*
|
|
|
* Content of conf_clock.h for SAM3X, SAM3A devices (UOTGHS: USB OTG High Speed):
|
|
|
* \code
|
|
|
- // USB Clock Source fixed at UPLL.
|
|
|
- #define CONFIG_USBCLK_SOURCE USBCLK_SRC_UPLL
|
|
|
- #define CONFIG_USBCLK_DIV 1
|
|
|
+ // USB Clock Source fixed at UPLL.
|
|
|
+ #define CONFIG_USBCLK_SOURCE USBCLK_SRC_UPLL
|
|
|
+ #define CONFIG_USBCLK_DIV 1
|
|
|
\endcode
|
|
|
*
|
|
|
* Content of conf_clocks.h for SAMD devices (USB):
|
|
|
* \code
|
|
|
- // System clock bus configuration
|
|
|
- # define CONF_CLOCK_FLASH_WAIT_STATES 2
|
|
|
-
|
|
|
- // USB Clock Source fixed at DFLL.
|
|
|
- // SYSTEM_CLOCK_SOURCE_DFLL configuration - Digital Frequency Locked Loop
|
|
|
- # define CONF_CLOCK_DFLL_ENABLE true
|
|
|
- # define CONF_CLOCK_DFLL_LOOP_MODE SYSTEM_CLOCK_DFLL_LOOP_MODE_USB_RECOVERY
|
|
|
- # define CONF_CLOCK_DFLL_ON_DEMAND true
|
|
|
-
|
|
|
- // Set this to true to configure the GCLK when running clocks_init.
|
|
|
- // If set to false, none of the GCLK generators will be configured in clocks_init().
|
|
|
- # define CONF_CLOCK_CONFIGURE_GCLK true
|
|
|
-
|
|
|
- // Configure GCLK generator 0 (Main Clock)
|
|
|
- # define CONF_CLOCK_GCLK_0_ENABLE true
|
|
|
- # define CONF_CLOCK_GCLK_0_RUN_IN_STANDBY true
|
|
|
- # define CONF_CLOCK_GCLK_0_CLOCK_SOURCE SYSTEM_CLOCK_SOURCE_DFLL
|
|
|
- # define CONF_CLOCK_GCLK_0_PRESCALER 1
|
|
|
- # define CONF_CLOCK_GCLK_0_OUTPUT_ENABLE false
|
|
|
+ // System clock bus configuration
|
|
|
+ # define CONF_CLOCK_FLASH_WAIT_STATES 2
|
|
|
+
|
|
|
+ // USB Clock Source fixed at DFLL.
|
|
|
+ // SYSTEM_CLOCK_SOURCE_DFLL configuration - Digital Frequency Locked Loop
|
|
|
+ # define CONF_CLOCK_DFLL_ENABLE true
|
|
|
+ # define CONF_CLOCK_DFLL_LOOP_MODE SYSTEM_CLOCK_DFLL_LOOP_MODE_USB_RECOVERY
|
|
|
+ # define CONF_CLOCK_DFLL_ON_DEMAND true
|
|
|
+
|
|
|
+ // Set this to true to configure the GCLK when running clocks_init.
|
|
|
+ // If set to false, none of the GCLK generators will be configured in clocks_init().
|
|
|
+ # define CONF_CLOCK_CONFIGURE_GCLK true
|
|
|
+
|
|
|
+ // Configure GCLK generator 0 (Main Clock)
|
|
|
+ # define CONF_CLOCK_GCLK_0_ENABLE true
|
|
|
+ # define CONF_CLOCK_GCLK_0_RUN_IN_STANDBY true
|
|
|
+ # define CONF_CLOCK_GCLK_0_CLOCK_SOURCE SYSTEM_CLOCK_SOURCE_DFLL
|
|
|
+ # define CONF_CLOCK_GCLK_0_PRESCALER 1
|
|
|
+ # define CONF_CLOCK_GCLK_0_OUTPUT_ENABLE false
|
|
|
\endcode
|
|
|
*/
|
|
|
|
|
@@ -474,34 +467,34 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void);
|
|
|
* \subsection udc_use_case_1_usage_code Example code
|
|
|
* Content of conf_usb.h:
|
|
|
* \code
|
|
|
- #if // Low speed
|
|
|
- #define USB_DEVICE_LOW_SPEED
|
|
|
- // #define USB_DEVICE_HS_SUPPORT
|
|
|
+ #if // Low speed
|
|
|
+ #define USB_DEVICE_LOW_SPEED
|
|
|
+ // #define USB_DEVICE_HS_SUPPORT
|
|
|
|
|
|
- #elif // Full speed
|
|
|
- // #define USB_DEVICE_LOW_SPEED
|
|
|
- // #define USB_DEVICE_HS_SUPPORT
|
|
|
+ #elif // Full speed
|
|
|
+ // #define USB_DEVICE_LOW_SPEED
|
|
|
+ // #define USB_DEVICE_HS_SUPPORT
|
|
|
|
|
|
- #elif // High speed
|
|
|
- // #define USB_DEVICE_LOW_SPEED
|
|
|
- #define USB_DEVICE_HS_SUPPORT
|
|
|
+ #elif // High speed
|
|
|
+ // #define USB_DEVICE_LOW_SPEED
|
|
|
+ #define USB_DEVICE_HS_SUPPORT
|
|
|
|
|
|
- #endif
|
|
|
+ #endif
|
|
|
\endcode
|
|
|
*
|
|
|
* \subsection udc_use_case_1_usage_flow Workflow
|
|
|
* -# Ensure that conf_usb.h is available and contains the following parameters
|
|
|
* required for a USB device low speed (1.5Mbit/s):
|
|
|
* - \code #define USB_DEVICE_LOW_SPEED
|
|
|
- //#define USB_DEVICE_HS_SUPPORT \endcode
|
|
|
+ //#define USB_DEVICE_HS_SUPPORT \endcode
|
|
|
* -# Ensure that conf_usb.h contains the following parameters
|
|
|
* required for a USB device full speed (12Mbit/s):
|
|
|
* - \code //#define USB_DEVICE_LOW_SPEED
|
|
|
- //#define USB_DEVICE_HS_SUPPORT \endcode
|
|
|
+ //#define USB_DEVICE_HS_SUPPORT \endcode
|
|
|
* -# Ensure that conf_usb.h contains the following parameters
|
|
|
* required for a USB device high speed (480Mbit/s):
|
|
|
* - \code //#define USB_DEVICE_LOW_SPEED
|
|
|
- #define USB_DEVICE_HS_SUPPORT \endcode
|
|
|
+ #define USB_DEVICE_HS_SUPPORT \endcode
|
|
|
*/
|
|
|
|
|
|
/**
|
|
@@ -518,20 +511,20 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void);
|
|
|
* \subsection udc_use_case_2_usage_code Example code
|
|
|
* Content of conf_usb.h:
|
|
|
* \code
|
|
|
- #define USB_DEVICE_MANUFACTURE_NAME "Manufacture name"
|
|
|
- #define USB_DEVICE_PRODUCT_NAME "Product name"
|
|
|
- #define USB_DEVICE_SERIAL_NAME "12...EF"
|
|
|
+ #define USB_DEVICE_MANUFACTURE_NAME "Manufacture name"
|
|
|
+ #define USB_DEVICE_PRODUCT_NAME "Product name"
|
|
|
+ #define USB_DEVICE_SERIAL_NAME "12...EF"
|
|
|
\endcode
|
|
|
*
|
|
|
* \subsection udc_use_case_2_usage_flow Workflow
|
|
|
* -# Ensure that conf_usb.h is available and contains the following parameters
|
|
|
* required to enable different USB strings:
|
|
|
* - \code // Static ASCII name for the manufacture
|
|
|
- #define USB_DEVICE_MANUFACTURE_NAME "Manufacture name" \endcode
|
|
|
+ #define USB_DEVICE_MANUFACTURE_NAME "Manufacture name" \endcode
|
|
|
* - \code // Static ASCII name for the product
|
|
|
- #define USB_DEVICE_PRODUCT_NAME "Product name" \endcode
|
|
|
+ #define USB_DEVICE_PRODUCT_NAME "Product name" \endcode
|
|
|
* - \code // Static ASCII name to enable and set a serial number
|
|
|
- #define USB_DEVICE_SERIAL_NAME "12...EF" \endcode
|
|
|
+ #define USB_DEVICE_SERIAL_NAME "12...EF" \endcode
|
|
|
*/
|
|
|
|
|
|
/**
|
|
@@ -548,42 +541,42 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void);
|
|
|
* \subsection udc_use_case_3_usage_code Example code
|
|
|
* Content of conf_usb.h:
|
|
|
* \code
|
|
|
- #define USB_DEVICE_ATTR \
|
|
|
- (USB_CONFIG_ATTR_REMOTE_WAKEUP | USB_CONFIG_ATTR_..._POWERED)
|
|
|
- #define UDC_REMOTEWAKEUP_ENABLE() my_callback_remotewakeup_enable()
|
|
|
- extern void my_callback_remotewakeup_enable(void);
|
|
|
- #define UDC_REMOTEWAKEUP_DISABLE() my_callback_remotewakeup_disable()
|
|
|
- extern void my_callback_remotewakeup_disable(void);
|
|
|
+ #define USB_DEVICE_ATTR \
|
|
|
+ (USB_CONFIG_ATTR_REMOTE_WAKEUP | USB_CONFIG_ATTR_..._POWERED)
|
|
|
+ #define UDC_REMOTEWAKEUP_ENABLE() my_callback_remotewakeup_enable()
|
|
|
+ extern void my_callback_remotewakeup_enable(void);
|
|
|
+ #define UDC_REMOTEWAKEUP_DISABLE() my_callback_remotewakeup_disable()
|
|
|
+ extern void my_callback_remotewakeup_disable(void);
|
|
|
\endcode
|
|
|
*
|
|
|
* Add to application C-file:
|
|
|
* \code
|
|
|
- void my_callback_remotewakeup_enable(void)
|
|
|
- {
|
|
|
- // Enable application wakeup events (e.g. enable GPIO interrupt)
|
|
|
- }
|
|
|
- void my_callback_remotewakeup_disable(void)
|
|
|
- {
|
|
|
- // Disable application wakeup events (e.g. disable GPIO interrupt)
|
|
|
- }
|
|
|
-
|
|
|
- void my_interrupt_event(void)
|
|
|
- {
|
|
|
- udc_remotewakeup();
|
|
|
- }
|
|
|
+ void my_callback_remotewakeup_enable(void)
|
|
|
+ {
|
|
|
+ // Enable application wakeup events (e.g. enable GPIO interrupt)
|
|
|
+ }
|
|
|
+ void my_callback_remotewakeup_disable(void)
|
|
|
+ {
|
|
|
+ // Disable application wakeup events (e.g. disable GPIO interrupt)
|
|
|
+ }
|
|
|
+
|
|
|
+ void my_interrupt_event(void)
|
|
|
+ {
|
|
|
+ udc_remotewakeup();
|
|
|
+ }
|
|
|
\endcode
|
|
|
*
|
|
|
* \subsection udc_use_case_3_usage_flow Workflow
|
|
|
* -# Ensure that conf_usb.h is available and contains the following parameters
|
|
|
* required to enable remote wakeup feature:
|
|
|
* - \code // Authorizes the remote wakeup feature
|
|
|
- #define USB_DEVICE_ATTR (USB_CONFIG_ATTR_REMOTE_WAKEUP | USB_CONFIG_ATTR_..._POWERED) \endcode
|
|
|
+ #define USB_DEVICE_ATTR (USB_CONFIG_ATTR_REMOTE_WAKEUP | USB_CONFIG_ATTR_..._POWERED) \endcode
|
|
|
* - \code // Define callback called when the host enables the remotewakeup feature
|
|
|
- #define UDC_REMOTEWAKEUP_ENABLE() my_callback_remotewakeup_enable()
|
|
|
- extern void my_callback_remotewakeup_enable(void); \endcode
|
|
|
+ #define UDC_REMOTEWAKEUP_ENABLE() my_callback_remotewakeup_enable()
|
|
|
+ extern void my_callback_remotewakeup_enable(void); \endcode
|
|
|
* - \code // Define callback called when the host disables the remotewakeup feature
|
|
|
- #define UDC_REMOTEWAKEUP_DISABLE() my_callback_remotewakeup_disable()
|
|
|
- extern void my_callback_remotewakeup_disable(void); \endcode
|
|
|
+ #define UDC_REMOTEWAKEUP_DISABLE() my_callback_remotewakeup_disable()
|
|
|
+ extern void my_callback_remotewakeup_disable(void); \endcode
|
|
|
* -# Send a remote wakeup (USB upstream):
|
|
|
* - \code udc_remotewakeup(); \endcode
|
|
|
*/
|
|
@@ -603,40 +596,40 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void);
|
|
|
* \subsection udc_use_case_5_usage_code Example code
|
|
|
* Content of conf_usb.h:
|
|
|
* \code
|
|
|
- #define USB_DEVICE_ATTR (USB_CONFIG_ATTR_BUS_POWERED)
|
|
|
- #define UDC_SUSPEND_EVENT() user_callback_suspend_action()
|
|
|
- extern void user_callback_suspend_action(void)
|
|
|
- #define UDC_RESUME_EVENT() user_callback_resume_action()
|
|
|
- extern void user_callback_resume_action(void)
|
|
|
+ #define USB_DEVICE_ATTR (USB_CONFIG_ATTR_BUS_POWERED)
|
|
|
+ #define UDC_SUSPEND_EVENT() user_callback_suspend_action()
|
|
|
+ extern void user_callback_suspend_action(void)
|
|
|
+ #define UDC_RESUME_EVENT() user_callback_resume_action()
|
|
|
+ extern void user_callback_resume_action(void)
|
|
|
\endcode
|
|
|
*
|
|
|
* Add to application C-file:
|
|
|
* \code
|
|
|
- void user_callback_suspend_action(void)
|
|
|
- {
|
|
|
- // Disable hardware component to reduce power consumption
|
|
|
- }
|
|
|
- void user_callback_resume_action(void)
|
|
|
- {
|
|
|
- // Re-enable hardware component
|
|
|
- }
|
|
|
+ void user_callback_suspend_action(void)
|
|
|
+ {
|
|
|
+ // Disable hardware component to reduce power consumption
|
|
|
+ }
|
|
|
+ void user_callback_resume_action(void)
|
|
|
+ {
|
|
|
+ // Re-enable hardware component
|
|
|
+ }
|
|
|
\endcode
|
|
|
*
|
|
|
* \subsection udc_use_case_5_usage_flow Workflow
|
|
|
* -# Ensure that conf_usb.h is available and contains the following parameters:
|
|
|
* - \code // Authorizes the BUS power feature
|
|
|
- #define USB_DEVICE_ATTR (USB_CONFIG_ATTR_BUS_POWERED) \endcode
|
|
|
+ #define USB_DEVICE_ATTR (USB_CONFIG_ATTR_BUS_POWERED) \endcode
|
|
|
* - \code // Define callback called when the host suspend the USB line
|
|
|
- #define UDC_SUSPEND_EVENT() user_callback_suspend_action()
|
|
|
- extern void user_callback_suspend_action(void); \endcode
|
|
|
+ #define UDC_SUSPEND_EVENT() user_callback_suspend_action()
|
|
|
+ extern void user_callback_suspend_action(void); \endcode
|
|
|
* - \code // Define callback called when the host or device resume the USB line
|
|
|
- #define UDC_RESUME_EVENT() user_callback_resume_action()
|
|
|
- extern void user_callback_resume_action(void); \endcode
|
|
|
+ #define UDC_RESUME_EVENT() user_callback_resume_action()
|
|
|
+ extern void user_callback_resume_action(void); \endcode
|
|
|
* -# Reduce power consumption in suspend mode (max. 2.5mA on Vbus):
|
|
|
* - \code void user_callback_suspend_action(void)
|
|
|
- {
|
|
|
- turn_off_components();
|
|
|
- } \endcode
|
|
|
+ {
|
|
|
+ turn_off_components();
|
|
|
+ } \endcode
|
|
|
*/
|
|
|
|
|
|
/**
|
|
@@ -654,42 +647,42 @@ usb_iface_desc_t UDC_DESC_STORAGE *udc_get_interface_desc(void);
|
|
|
* \subsection udc_use_case_6_usage_code Example code
|
|
|
* Content of conf_usb.h:
|
|
|
* \code
|
|
|
- #define USB_DEVICE_SERIAL_NAME
|
|
|
- #define USB_DEVICE_GET_SERIAL_NAME_POINTER serial_number
|
|
|
- #define USB_DEVICE_GET_SERIAL_NAME_LENGTH 12
|
|
|
- extern uint8_t serial_number[];
|
|
|
+ #define USB_DEVICE_SERIAL_NAME
|
|
|
+ #define USB_DEVICE_GET_SERIAL_NAME_POINTER serial_number
|
|
|
+ #define USB_DEVICE_GET_SERIAL_NAME_LENGTH 12
|
|
|
+ extern uint8_t serial_number[];
|
|
|
\endcode
|
|
|
*
|
|
|
* Add to application C-file:
|
|
|
* \code
|
|
|
- uint8_t serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH];
|
|
|
+ uint8_t serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH];
|
|
|
|
|
|
- void init_build_usb_serial_number(void)
|
|
|
- {
|
|
|
- serial_number[0] = 'A';
|
|
|
- serial_number[1] = 'B';
|
|
|
- ...
|
|
|
- serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH-1] = 'C';
|
|
|
- } \endcode
|
|
|
+ void init_build_usb_serial_number(void)
|
|
|
+ {
|
|
|
+ serial_number[0] = 'A';
|
|
|
+ serial_number[1] = 'B';
|
|
|
+ ...
|
|
|
+ serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH-1] = 'C';
|
|
|
+ } \endcode
|
|
|
*
|
|
|
* \subsection udc_use_case_6_usage_flow Workflow
|
|
|
* -# Ensure that conf_usb.h is available and contains the following parameters
|
|
|
* required to enable a USB serial number strings dynamically:
|
|
|
* - \code #define USB_DEVICE_SERIAL_NAME // Define this empty
|
|
|
- #define USB_DEVICE_GET_SERIAL_NAME_POINTER serial_number // Give serial array pointer
|
|
|
- #define USB_DEVICE_GET_SERIAL_NAME_LENGTH 12 // Give size of serial array
|
|
|
- extern uint8_t serial_number[]; // Declare external serial array \endcode
|
|
|
+ #define USB_DEVICE_GET_SERIAL_NAME_POINTER serial_number // Give serial array pointer
|
|
|
+ #define USB_DEVICE_GET_SERIAL_NAME_LENGTH 12 // Give size of serial array
|
|
|
+ extern uint8_t serial_number[]; // Declare external serial array \endcode
|
|
|
* -# Before start USB stack, initialize the serial array
|
|
|
* - \code
|
|
|
- uint8_t serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH];
|
|
|
-
|
|
|
- void init_build_usb_serial_number(void)
|
|
|
- {
|
|
|
- serial_number[0] = 'A';
|
|
|
- serial_number[1] = 'B';
|
|
|
- ...
|
|
|
- serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH-1] = 'C';
|
|
|
- } \endcode
|
|
|
+ uint8_t serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH];
|
|
|
+
|
|
|
+ void init_build_usb_serial_number(void)
|
|
|
+ {
|
|
|
+ serial_number[0] = 'A';
|
|
|
+ serial_number[1] = 'B';
|
|
|
+ ...
|
|
|
+ serial_number[USB_DEVICE_GET_SERIAL_NAME_LENGTH-1] = 'C';
|
|
|
+ } \endcode
|
|
|
*/
|
|
|
|
|
|
|