diff options
| author | hathach <[email protected]> | 2018-08-23 14:45:22 +0700 |
|---|---|---|
| committer | hathach <[email protected]> | 2018-08-23 14:45:22 +0700 |
| commit | d478064a80d81fbbeb7a2a3cf67152d6f61fbd9d (patch) | |
| tree | 49aca442aee3acd1ada4c1182178a55250940c11 /examples | |
| parent | d18a9e8759fb168a55a2ded6f1f5b9d7db6ea078 (diff) | |
freeRtos seems to work well with nrf52840
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/device/nrf52840_freertos/src/main.c | 47 | ||||
| -rw-r--r-- | examples/device/nrf52840_freertos/src/tusb_config.h | 2 |
2 files changed, 27 insertions, 22 deletions
diff --git a/examples/device/nrf52840_freertos/src/main.c b/examples/device/nrf52840_freertos/src/main.c index 644829a66..a0c418920 100644 --- a/examples/device/nrf52840_freertos/src/main.c +++ b/examples/device/nrf52840_freertos/src/main.c @@ -61,8 +61,8 @@ //--------------------------------------------------------------------+ void print_greeting(void); void led_blinky_cb(TimerHandle_t xTimer); -void virtual_com_task(void); -void usb_hid_task(void); +void cdc_task(void* params); +void usb_hid_task(void* params); /*------------- MAIN -------------*/ @@ -71,49 +71,54 @@ int main(void) board_init(); print_greeting(); - //tusb_init(); - // soft timer for blinky TimerHandle_t tm_hdl = xTimerCreate(NULL, pdMS_TO_TICKS(1000), true, NULL, led_blinky_cb); - xTimerStart(tm_hdl, 0); + xTimerStart(tm_hdl, 0); + + tusb_init(); + + // Create task + xTaskCreate( cdc_task, "cdc", 256, NULL, 2, NULL); vTaskStartScheduler(); NVIC_SystemReset(); -// while (1) -// { -// virtual_com_task(); -// -// usb_hid_task(); -// } - return 0; } //--------------------------------------------------------------------+ // USB CDC //--------------------------------------------------------------------+ -void virtual_com_task(void) +void cdc_task(void* params) { - // connected and there are data available - if ( tud_mounted() && tud_cdc_available() ) + (void) params; + + while ( 1 ) { - uint8_t buf[64]; + // connected and there are data available + if ( tud_mounted() && tud_cdc_available() ) + { + uint8_t buf[64]; + + // read and echo back + uint32_t count = tud_cdc_read(buf, sizeof(buf)); - // read and echo back - uint32_t count = tud_cdc_read(buf, sizeof(buf)); + tud_cdc_write(buf, count); + tud_cdc_write_flush(); + } - tud_cdc_write(buf, count); - tud_cdc_write_flush(); + taskYIELD(); } } //--------------------------------------------------------------------+ // USB HID //--------------------------------------------------------------------+ -void usb_hid_task(void) +void usb_hid_task(void* params) { + (void) params; + // Poll every 10ms static tu_timeout_t tm = { .start = 0, .interval = 10 }; diff --git a/examples/device/nrf52840_freertos/src/tusb_config.h b/examples/device/nrf52840_freertos/src/tusb_config.h index 6b8b0af96..bd27f58b5 100644 --- a/examples/device/nrf52840_freertos/src/tusb_config.h +++ b/examples/device/nrf52840_freertos/src/tusb_config.h @@ -53,7 +53,7 @@ /*------------- RTOS -------------*/ #define CFG_TUSB_OS OPT_OS_FREERTOS -#define CFG_TUD_TASK_PRIO (configMAX_PRIORITIES-2) +#define CFG_TUD_TASK_PRIO (configMAX_PRIORITIES-3) //#define CFG_TUD_TASK_QUEUE_SZ 16 //#define CFG_TUD_TASK_STACK_SZ 150 |
