mirror of
https://github.com/hathach/tinyusb.git
synced 2025-04-23 17:42:22 +00:00
add tud_set_descriptors
This commit is contained in:
parent
29071c10b1
commit
6f7c4346c3
@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
/// Application MUST define this variable and initialize its pointers's member to all required USB descriptors including
|
/// Application MUST define this variable and initialize its pointers's member to all required USB descriptors including
|
||||||
/// Device Descriptor, Configuration Descriptor, String Descriptors, HID Report Descriptors etc ...
|
/// Device Descriptor, Configuration Descriptor, String Descriptors, HID Report Descriptors etc ...
|
||||||
tusbd_descriptor_pointer_t tusbd_descriptor_pointers;
|
tud_desc_init_t tusbd_descriptor_pointers;
|
||||||
|
|
||||||
/** \defgroup config_device_class Class Driver
|
/** \defgroup config_device_class Class Driver
|
||||||
* \brief For each Class Driver a value of 1 means enable, value of 0 mean disable
|
* \brief For each Class Driver a value of 1 means enable, value of 0 mean disable
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
#include "bsp/board.h"
|
#include "bsp/board.h"
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
#include "tusb_descriptors.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF
|
// MACRO CONSTANT TYPEDEF
|
||||||
@ -64,6 +65,7 @@ int main(void)
|
|||||||
print_greeting();
|
print_greeting();
|
||||||
|
|
||||||
tusb_init();
|
tusb_init();
|
||||||
|
tud_set_descriptors(&usb_desc_init);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -245,12 +245,11 @@ uint16_t const * const string_descriptor_arr [] =
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// TINYUSB Descriptors Pointer (this variable is required by the stack)
|
/*------------- Variable used by tud_set_descriptors -------------*/
|
||||||
//--------------------------------------------------------------------+
|
tud_desc_init_t usb_desc_init =
|
||||||
tusbd_descriptor_pointer_t tusbd_descriptor_pointers =
|
|
||||||
{
|
{
|
||||||
.p_device = (uint8_t const * ) &desc_device,
|
.device = (uint8_t const * ) &desc_device,
|
||||||
.p_configuration = (uint8_t const * ) &desc_configuration,
|
.configuration = (uint8_t const * ) &desc_configuration,
|
||||||
.p_string_arr = (uint8_t const **) string_descriptor_arr,
|
.string_arr = (uint8_t const **) string_descriptor_arr,
|
||||||
};
|
};
|
||||||
|
@ -98,4 +98,8 @@ typedef struct ATTR_PACKED
|
|||||||
|
|
||||||
} app_descriptor_configuration_t;
|
} app_descriptor_configuration_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern tud_desc_init_t usb_desc_init;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -45,6 +45,7 @@
|
|||||||
|
|
||||||
#include "bsp/board.h"
|
#include "bsp/board.h"
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
#include "tusb_descriptors.h"
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF
|
// MACRO CONSTANT TYPEDEF
|
||||||
@ -64,6 +65,7 @@ int main(void)
|
|||||||
print_greeting();
|
print_greeting();
|
||||||
|
|
||||||
tusb_init();
|
tusb_init();
|
||||||
|
tud_set_descriptors(&usb_desc_init);
|
||||||
|
|
||||||
while (1)
|
while (1)
|
||||||
{
|
{
|
||||||
|
@ -284,12 +284,11 @@ uint16_t const * const string_descriptor_arr [] =
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// TINYUSB Descriptors Pointer (this variable is required by the stack)
|
/*------------- Variable used by tud_set_descriptors -------------*/
|
||||||
//--------------------------------------------------------------------+
|
tud_desc_init_t usb_desc_init =
|
||||||
tusbd_descriptor_pointer_t tusbd_descriptor_pointers =
|
|
||||||
{
|
{
|
||||||
.p_device = (uint8_t const * ) &desc_device,
|
.device = (uint8_t const * ) &desc_device,
|
||||||
.p_configuration = (uint8_t const * ) &desc_configuration,
|
.configuration = (uint8_t const * ) &desc_configuration,
|
||||||
.p_string_arr = (uint8_t const **) string_descriptor_arr,
|
.string_arr = (uint8_t const **) string_descriptor_arr,
|
||||||
};
|
};
|
||||||
|
@ -113,4 +113,8 @@ typedef struct ATTR_PACKED
|
|||||||
|
|
||||||
} app_descriptor_configuration_t;
|
} app_descriptor_configuration_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern tud_desc_init_t usb_desc_init;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "bsp/board.h"
|
#include "bsp/board.h"
|
||||||
#include "app_os_prio.h"
|
#include "app_os_prio.h"
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
|
#include "tusb_descriptors.h"
|
||||||
|
|
||||||
#include "msc_device_app.h"
|
#include "msc_device_app.h"
|
||||||
#include "keyboard_device_app.h"
|
#include "keyboard_device_app.h"
|
||||||
@ -87,6 +88,7 @@ int main(void)
|
|||||||
print_greeting();
|
print_greeting();
|
||||||
|
|
||||||
tusb_init();
|
tusb_init();
|
||||||
|
tud_set_descriptors(&usb_desc_init);
|
||||||
|
|
||||||
//------------- application task init -------------//
|
//------------- application task init -------------//
|
||||||
led_blinking_init();
|
led_blinking_init();
|
||||||
|
@ -456,14 +456,13 @@ uint16_t const * const string_descriptor_arr [] =
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// TINYUSB Descriptors Pointer (this variable is required by the stack)
|
/*------------- Variable used by tud_set_descriptors -------------*/
|
||||||
//--------------------------------------------------------------------+
|
tud_desc_init_t usb_desc_init =
|
||||||
tusbd_descriptor_pointer_t tusbd_descriptor_pointers =
|
|
||||||
{
|
{
|
||||||
.p_device = (uint8_t const * ) &desc_device,
|
.device = (uint8_t const * ) &desc_device,
|
||||||
.p_configuration = (uint8_t const * ) &desc_configuration,
|
.configuration = (uint8_t const * ) &desc_configuration,
|
||||||
.p_string_arr = (uint8_t const **) string_descriptor_arr,
|
.string_arr = (uint8_t const **) string_descriptor_arr,
|
||||||
|
|
||||||
#if CFG_TUD_HID_KEYBOARD
|
#if CFG_TUD_HID_KEYBOARD
|
||||||
.p_hid_keyboard_report = (uint8_t const *) desc_keyboard_report,
|
.p_hid_keyboard_report = (uint8_t const *) desc_keyboard_report,
|
||||||
|
@ -175,4 +175,8 @@ typedef struct ATTR_PACKED
|
|||||||
|
|
||||||
} app_descriptor_configuration_t;
|
} app_descriptor_configuration_t;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
extern tud_desc_init_t usb_desc_init;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -106,13 +106,10 @@
|
|||||||
// INLINE FUNCTION
|
// INLINE FUNCTION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
#define memclr_(buffer, size) memset((buffer), 0, (size))
|
#define memclr_(buffer, size) memset((buffer), 0, (size))
|
||||||
|
#define varclr_(_var) memclr_(_var, sizeof(*(_var)))
|
||||||
|
#define arrclr_(_arr) memclr_(_arr, sizeof(_arr))
|
||||||
|
|
||||||
|
#define arrcount_(_arr) ( sizeof(_arr) / sizeof(_arr[0]) )
|
||||||
#define memclr(buffer, size) memset(buffer, 0, size)
|
|
||||||
#define varclr(_var) memclr(_var, sizeof(*(_var)))
|
|
||||||
#define arrclr(_arr) memclr(_arr, sizeof(_arr))
|
|
||||||
|
|
||||||
#define arrcount(_arr) ( sizeof(_arr) / sizeof(_arr[0]) )
|
|
||||||
|
|
||||||
static inline uint8_t const * descriptor_next(uint8_t const p_desc[])
|
static inline uint8_t const * descriptor_next(uint8_t const p_desc[])
|
||||||
{
|
{
|
||||||
|
@ -71,14 +71,11 @@
|
|||||||
// Halt CPU (breakpoint) when hitting error, only apply for Cortex M3, M4, M7
|
// Halt CPU (breakpoint) when hitting error, only apply for Cortex M3, M4, M7
|
||||||
#if defined(__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__)
|
#if defined(__ARM_ARCH_7M__) || defined (__ARM_ARCH_7EM__)
|
||||||
|
|
||||||
static inline void verify_breakpoint(void)
|
#define verify_breakpoint() \
|
||||||
{
|
do {\
|
||||||
// Cortex M CoreDebug->DHCSR
|
volatile uint32_t* ARM_CM_DHCSR = ((volatile uint32_t*) 0xE000EDF0UL); /* Cortex M CoreDebug->DHCSR */ \
|
||||||
volatile uint32_t* ARM_CM_DHCSR = ((volatile uint32_t*) 0xE000EDF0UL);
|
if ( (*ARM_CM_DHCSR) & 1UL ) __asm("BKPT #0\n"); /* Only halt mcu if debugger is attached */\
|
||||||
|
} while(0)
|
||||||
// Only halt mcu if debugger is attached
|
|
||||||
if ( (*ARM_CM_DHCSR) & 1UL ) __asm("BKPT #0\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#define verify_breakpoint()
|
#define verify_breakpoint()
|
||||||
|
@ -42,14 +42,13 @@
|
|||||||
|
|
||||||
#define _TINY_USB_SOURCE_FILE_
|
#define _TINY_USB_SOURCE_FILE_
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
// INCLUDE
|
|
||||||
//--------------------------------------------------------------------+
|
|
||||||
#include "tusb.h"
|
#include "tusb.h"
|
||||||
#include "usbd.h"
|
#include "usbd.h"
|
||||||
#include "device/usbd_pvt.h"
|
#include "device/usbd_pvt.h"
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// MACRO CONSTANT TYPEDEF
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
typedef struct {
|
typedef struct {
|
||||||
void (* init) (void);
|
void (* init) (void);
|
||||||
tusb_error_t (* open)(uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t* p_length);
|
tusb_error_t (* open)(uint8_t rhport, tusb_desc_interface_t const * desc_intf, uint16_t* p_length);
|
||||||
@ -72,11 +71,15 @@ typedef struct {
|
|||||||
}usbd_device_info_t;
|
}usbd_device_info_t;
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// MACRO CONSTANT TYPEDEF
|
// INTERNAL VARIABLE
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
usbd_device_info_t usbd_devices[CONTROLLER_DEVICE_NUMBER];
|
|
||||||
CFG_TUSB_ATTR_USBRAM CFG_TUSB_MEM_ALIGN uint8_t usbd_enum_buffer[CFG_TUD_ENUM_BUFFER_SIZE];
|
CFG_TUSB_ATTR_USBRAM CFG_TUSB_MEM_ALIGN uint8_t usbd_enum_buffer[CFG_TUD_ENUM_BUFFER_SIZE];
|
||||||
|
|
||||||
|
tud_desc_init_t _usbd_descs[CONTROLLER_DEVICE_NUMBER];
|
||||||
|
usbd_device_info_t usbd_devices[CONTROLLER_DEVICE_NUMBER];
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static usbd_class_driver_t const usbd_class_drivers[] =
|
static usbd_class_driver_t const usbd_class_drivers[] =
|
||||||
{
|
{
|
||||||
#if DEVICE_CLASS_HID
|
#if DEVICE_CLASS_HID
|
||||||
@ -130,19 +133,26 @@ enum { USBD_CLASS_DRIVER_COUNT = sizeof(usbd_class_drivers) / sizeof(usbd_class_
|
|||||||
//};
|
//};
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
// INTERNAL FUNCTION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
static tusb_error_t proc_set_config_req(uint8_t rhport, uint8_t config_number);
|
static tusb_error_t proc_set_config_req(uint8_t rhport, uint8_t config_number);
|
||||||
static uint16_t get_descriptor(uint8_t rhport, tusb_control_request_t const * const p_request, uint8_t const ** pp_buffer);
|
static uint16_t get_descriptor(uint8_t rhport, tusb_control_request_t const * const p_request, uint8_t const ** pp_buffer);
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION INTERFACE
|
// APPLICATION API
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
bool tud_n_mounted(uint8_t rhport)
|
bool tud_n_mounted(uint8_t rhport)
|
||||||
{
|
{
|
||||||
return usbd_devices[rhport].state == TUSB_DEVICE_STATE_CONFIGURED;
|
return usbd_devices[rhport].state == TUSB_DEVICE_STATE_CONFIGURED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool tud_n_set_descriptors(uint8_t rhport, tud_desc_init_t const* desc_cfg)
|
||||||
|
{
|
||||||
|
_usbd_descs[rhport] = *desc_cfg;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// IMPLEMENTATION
|
// IMPLEMENTATION
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
@ -213,8 +223,8 @@ tusb_error_t usbd_init (void)
|
|||||||
|
|
||||||
osal_task_create(usbd_task, "usbd", CFG_TUD_TASK_STACKSIZE, NULL, CFG_TUD_TASK_PRIO);
|
osal_task_create(usbd_task, "usbd", CFG_TUD_TASK_STACKSIZE, NULL, CFG_TUD_TASK_PRIO);
|
||||||
|
|
||||||
//------------- Descriptor Check -------------//
|
//------------- Core init -------------//
|
||||||
TU_ASSERT(tusbd_descriptor_pointers.p_device != NULL && tusbd_descriptor_pointers.p_configuration != NULL, TUSB_ERROR_DESCRIPTOR_CORRUPTED);
|
arrclr_( _usbd_descs );
|
||||||
|
|
||||||
//------------- class init -------------//
|
//------------- class init -------------//
|
||||||
for (uint8_t class_code = TUSB_CLASS_AUDIO; class_code < USBD_CLASS_DRIVER_COUNT; class_code++)
|
for (uint8_t class_code = TUSB_CLASS_AUDIO; class_code < USBD_CLASS_DRIVER_COUNT; class_code++)
|
||||||
@ -390,12 +400,14 @@ static tusb_error_t proc_set_config_req(uint8_t rhport, uint8_t config_number)
|
|||||||
usbd_devices[rhport].config_num = config_number;
|
usbd_devices[rhport].config_num = config_number;
|
||||||
|
|
||||||
//------------- parse configuration & open drivers -------------//
|
//------------- parse configuration & open drivers -------------//
|
||||||
uint8_t const * p_desc_config = tusbd_descriptor_pointers.p_configuration;
|
uint8_t const * p_desc_config = _usbd_descs[rhport].configuration;
|
||||||
|
TU_ASSERT(p_desc_config != NULL, TUSB_ERROR_DESCRIPTOR_CORRUPTED);
|
||||||
|
|
||||||
uint8_t const * p_desc = p_desc_config + sizeof(tusb_desc_configuration_t);
|
uint8_t const * p_desc = p_desc_config + sizeof(tusb_desc_configuration_t);
|
||||||
|
|
||||||
uint16_t const config_total_length = ((tusb_desc_configuration_t*)p_desc_config)->wTotalLength;
|
uint16_t const config_len = ((tusb_desc_configuration_t*)p_desc_config)->wTotalLength;
|
||||||
|
|
||||||
while( p_desc < p_desc_config + config_total_length )
|
while( p_desc < p_desc_config + config_len )
|
||||||
{
|
{
|
||||||
if ( TUSB_DESC_INTERFACE_ASSOCIATION == p_desc[DESCRIPTOR_OFFSET_TYPE])
|
if ( TUSB_DESC_INTERFACE_ASSOCIATION == p_desc[DESCRIPTOR_OFFSET_TYPE])
|
||||||
{
|
{
|
||||||
@ -436,23 +448,26 @@ static uint16_t get_descriptor(uint8_t rhport, tusb_control_request_t const * co
|
|||||||
uint8_t const * desc_data = NULL ;
|
uint8_t const * desc_data = NULL ;
|
||||||
uint16_t len = 0;
|
uint16_t len = 0;
|
||||||
|
|
||||||
|
//------------- Descriptor Check -------------//
|
||||||
|
tud_desc_init_t const* descs = &_usbd_descs[rhport];
|
||||||
|
|
||||||
switch(desc_type)
|
switch(desc_type)
|
||||||
{
|
{
|
||||||
case TUSB_DESC_DEVICE:
|
case TUSB_DESC_DEVICE:
|
||||||
desc_data = tusbd_descriptor_pointers.p_device;
|
desc_data = descs->device;
|
||||||
len = sizeof(tusb_desc_device_t);
|
len = sizeof(tusb_desc_device_t);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TUSB_DESC_CONFIGURATION:
|
case TUSB_DESC_CONFIGURATION:
|
||||||
desc_data = tusbd_descriptor_pointers.p_configuration;
|
desc_data = descs->configuration;
|
||||||
len = ((tusb_desc_configuration_t*)tusbd_descriptor_pointers.p_configuration)->wTotalLength;
|
len = ((tusb_desc_configuration_t*)descs->configuration)->wTotalLength;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TUSB_DESC_STRING:
|
case TUSB_DESC_STRING:
|
||||||
// windows sometimes ask for string at index 238 !!!
|
// windows sometimes ask for string at index 238 !!!
|
||||||
if ( !(desc_index < 100) ) return 0;
|
if ( !(desc_index < 100) ) return 0;
|
||||||
|
|
||||||
desc_data = tusbd_descriptor_pointers.p_string_arr[desc_index];
|
desc_data = descs->string_arr[desc_index];
|
||||||
VERIFY( desc_data != NULL, 0 );
|
VERIFY( desc_data != NULL, 0 );
|
||||||
|
|
||||||
len = desc_data[0]; // first byte of descriptor is its size
|
len = desc_data[0]; // first byte of descriptor is its size
|
||||||
@ -467,10 +482,13 @@ static uint16_t get_descriptor(uint8_t rhport, tusb_control_request_t const * co
|
|||||||
default: return 0;
|
default: return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TU_ASSERT( desc_data != NULL, 0);
|
||||||
|
|
||||||
// up to Host's length
|
// up to Host's length
|
||||||
len = min16_of(p_request->wLength, len );
|
len = min16_of(p_request->wLength, len );
|
||||||
TU_ASSERT( len <= CFG_TUD_ENUM_BUFFER_SIZE, 0);
|
TU_ASSERT( len <= CFG_TUD_ENUM_BUFFER_SIZE, 0);
|
||||||
|
|
||||||
|
// FIXME copy data to enum buffer
|
||||||
memcpy(usbd_enum_buffer, desc_data, len);
|
memcpy(usbd_enum_buffer, desc_data, len);
|
||||||
(*pp_buffer) = usbd_enum_buffer;
|
(*pp_buffer) = usbd_enum_buffer;
|
||||||
|
|
||||||
|
@ -59,29 +59,38 @@
|
|||||||
|
|
||||||
/// \brief Descriptor pointer collector to all the needed.
|
/// \brief Descriptor pointer collector to all the needed.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint8_t const * p_device; ///< pointer to device descritpor \ref tusb_desc_device_t
|
uint8_t const * device; ///< pointer to device descriptor \ref tusb_desc_device_t
|
||||||
uint8_t const * p_configuration; ///< pointer to the whole configuration descriptor, starting by \ref tusb_desc_configuration_t
|
uint8_t const * configuration; ///< pointer to the whole configuration descriptor, starting by \ref tusb_desc_configuration_t
|
||||||
uint8_t const** p_string_arr; ///< a array of pointers to string descriptors
|
uint8_t const** string_arr; ///< a array of pointers to string descriptors
|
||||||
|
|
||||||
uint8_t const * p_hid_keyboard_report; ///< pointer to HID report descriptor of Keybaord interface. Only needed if CFG_TUD_HID_KEYBOARD is enabled
|
uint8_t const * p_hid_keyboard_report; ///< pointer to HID report descriptor of Keyboard interface. Only needed if CFG_TUD_HID_KEYBOARD is enabled
|
||||||
uint8_t const * p_hid_mouse_report; ///< pointer to HID report descriptor of Mouse interface. Only needed if CFG_TUD_HID_MOUSE is enabled
|
uint8_t const * p_hid_mouse_report; ///< pointer to HID report descriptor of Mouse interface. Only needed if CFG_TUD_HID_MOUSE is enabled
|
||||||
}tusbd_descriptor_pointer_t;
|
}tud_desc_init_t;
|
||||||
|
|
||||||
// define by application
|
|
||||||
extern tusbd_descriptor_pointer_t tusbd_descriptor_pointers;
|
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// APPLICATION API
|
// APPLICATION API (Multiple Root Ports)
|
||||||
|
// Should be used only with MCU that support more than 1 ports
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
bool tud_n_mounted(uint8_t rhport);
|
bool tud_n_mounted(uint8_t rhport);
|
||||||
|
bool tud_n_set_descriptors(uint8_t rhport, tud_desc_init_t const* desc_cfg);
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
|
// APPLICATION API (Single Port)
|
||||||
|
// Should be used with MCU supporting only 1 USB port for code simplicity
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
static inline bool tud_mounted(void)
|
static inline bool tud_mounted(void)
|
||||||
{
|
{
|
||||||
return tud_n_mounted(0);
|
return tud_n_mounted(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool tud_set_descriptors(tud_desc_init_t const* desc_cfg)
|
||||||
|
{
|
||||||
|
return tud_n_set_descriptors(0, desc_cfg);
|
||||||
|
}
|
||||||
|
|
||||||
/*------------- Callback -------------*/
|
//--------------------------------------------------------------------+
|
||||||
|
// APPLICATION CALLBACK
|
||||||
|
//--------------------------------------------------------------------+
|
||||||
/** \brief Callback function that will be invoked device is mounted (configured) by USB host
|
/** \brief Callback function that will be invoked device is mounted (configured) by USB host
|
||||||
* \param[in] rhport USB Controller ID of the interface
|
* \param[in] rhport USB Controller ID of the interface
|
||||||
* \note This callback should be used by Application to \b set-up application data
|
* \note This callback should be used by Application to \b set-up application data
|
||||||
|
@ -103,7 +103,7 @@ void bus_reset(void)
|
|||||||
NRF_USBD->TASKS_STARTISOIN = 0;
|
NRF_USBD->TASKS_STARTISOIN = 0;
|
||||||
NRF_USBD->TASKS_STARTISOOUT = 0;
|
NRF_USBD->TASKS_STARTISOOUT = 0;
|
||||||
|
|
||||||
varclr(&_dcd);
|
varclr_(&_dcd);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*------------------------------------------------------------------*/
|
/*------------------------------------------------------------------*/
|
||||||
|
@ -113,6 +113,8 @@ tusb_error_t tusb_init(void);
|
|||||||
your_init_code();
|
your_init_code();
|
||||||
tusb_init();
|
tusb_init();
|
||||||
|
|
||||||
|
// other config code
|
||||||
|
|
||||||
while(1) // the mainloop
|
while(1) // the mainloop
|
||||||
{
|
{
|
||||||
your_application_code();
|
your_application_code();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user