Merge pull request #471 from hathach/call-usbinit-after-kernel-started

call tud_init() after freeRTOS kernel is started
This commit is contained in:
Ha Thach 2020-07-24 01:28:49 +07:00 committed by GitHub
commit 6035572036
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 2 deletions

View File

@ -83,7 +83,6 @@ void cdc_task(void* params);
int main(void) int main(void)
{ {
board_init(); board_init();
tusb_init();
// soft timer for blinky // soft timer for blinky
blinky_tm = xTimerCreateStatic(NULL, pdMS_TO_TICKS(BLINK_NOT_MOUNTED), true, NULL, led_blinky_cb, &blinky_tmdef); blinky_tm = xTimerCreateStatic(NULL, pdMS_TO_TICKS(BLINK_NOT_MOUNTED), true, NULL, led_blinky_cb, &blinky_tmdef);
@ -116,6 +115,10 @@ void usb_device_task(void* param)
{ {
(void) param; (void) param;
// This should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
tusb_init();
// RTOS forever loop // RTOS forever loop
while (1) while (1)
{ {

View File

@ -79,7 +79,6 @@ void hid_task(void* params);
int main(void) int main(void)
{ {
board_init(); board_init();
tusb_init();
// soft timer for blinky // soft timer for blinky
blinky_tm = xTimerCreateStatic(NULL, pdMS_TO_TICKS(BLINK_NOT_MOUNTED), true, NULL, led_blinky_cb, &blinky_tmdef); blinky_tm = xTimerCreateStatic(NULL, pdMS_TO_TICKS(BLINK_NOT_MOUNTED), true, NULL, led_blinky_cb, &blinky_tmdef);
@ -112,6 +111,10 @@ void usb_device_task(void* param)
{ {
(void) param; (void) param;
// This should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
tusb_init();
// RTOS forever loop // RTOS forever loop
while (1) while (1)
{ {

View File

@ -42,6 +42,8 @@
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Init device stack // Init device stack
// Note: when using with RTOS, this should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
bool tud_init (void); bool tud_init (void);
// Task function should be called in main/rtos loop // Task function should be called in main/rtos loop

View File

@ -91,6 +91,9 @@ TU_ATTR_WEAK void tuh_umount_cb(uint8_t dev_addr);
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// CLASS-USBH & INTERNAL API // CLASS-USBH & INTERNAL API
//--------------------------------------------------------------------+ //--------------------------------------------------------------------+
// Note: when using with RTOS, this should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
bool usbh_init(void); bool usbh_init(void);
bool usbh_control_xfer (uint8_t dev_addr, tusb_control_request_t* request, uint8_t* data); bool usbh_control_xfer (uint8_t dev_addr, tusb_control_request_t* request, uint8_t* data);

View File

@ -109,6 +109,8 @@
* @{ */ * @{ */
// Initialize device/host stack // Initialize device/host stack
// Note: when using with RTOS, this should be called after scheduler/kernel is started.
// Otherwise it could cause kernel issue since USB IRQ handler does use RTOS queue API.
bool tusb_init(void); bool tusb_init(void);
// Check if stack is initialized // Check if stack is initialized