freeRtos seems to work well with nrf52840

This commit is contained in:
hathach 2018-08-23 14:45:22 +07:00
parent d18a9e8759
commit d478064a80
3 changed files with 28 additions and 23 deletions

View File

@ -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 };

View File

@ -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

View File

@ -20,7 +20,7 @@
#define configUSE_PREEMPTION 1
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
#define configTICK_RATE_HZ ( 1000 )
#define configMAX_PRIORITIES (8 )
#define configMAX_PRIORITIES (5)
#define configMINIMAL_STACK_SIZE (128 )
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 16*1024 ) )
#define configMAX_TASK_NAME_LEN 32