freeRtos seems to work well with nrf52840
This commit is contained in:
parent
d18a9e8759
commit
d478064a80
|
@ -61,8 +61,8 @@
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void print_greeting(void);
|
void print_greeting(void);
|
||||||
void led_blinky_cb(TimerHandle_t xTimer);
|
void led_blinky_cb(TimerHandle_t xTimer);
|
||||||
void virtual_com_task(void);
|
void cdc_task(void* params);
|
||||||
void usb_hid_task(void);
|
void usb_hid_task(void* params);
|
||||||
|
|
||||||
|
|
||||||
/*------------- MAIN -------------*/
|
/*------------- MAIN -------------*/
|
||||||
|
@ -71,49 +71,54 @@ int main(void)
|
||||||
board_init();
|
board_init();
|
||||||
print_greeting();
|
print_greeting();
|
||||||
|
|
||||||
//tusb_init();
|
|
||||||
|
|
||||||
// soft timer for blinky
|
// soft timer for blinky
|
||||||
TimerHandle_t tm_hdl = xTimerCreate(NULL, pdMS_TO_TICKS(1000), true, NULL, led_blinky_cb);
|
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();
|
vTaskStartScheduler();
|
||||||
|
|
||||||
NVIC_SystemReset();
|
NVIC_SystemReset();
|
||||||
|
|
||||||
// while (1)
|
|
||||||
// {
|
|
||||||
// virtual_com_task();
|
|
||||||
//
|
|
||||||
// usb_hid_task();
|
|
||||||
// }
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// USB CDC
|
// USB CDC
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void virtual_com_task(void)
|
void cdc_task(void* params)
|
||||||
{
|
{
|
||||||
// connected and there are data available
|
(void) params;
|
||||||
if ( tud_mounted() && tud_cdc_available() )
|
|
||||||
|
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
|
// read and echo back
|
||||||
uint32_t count = tud_cdc_read(buf, sizeof(buf));
|
uint32_t count = tud_cdc_read(buf, sizeof(buf));
|
||||||
|
|
||||||
tud_cdc_write(buf, count);
|
tud_cdc_write(buf, count);
|
||||||
tud_cdc_write_flush();
|
tud_cdc_write_flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
taskYIELD();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
// USB HID
|
// USB HID
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
void usb_hid_task(void)
|
void usb_hid_task(void* params)
|
||||||
{
|
{
|
||||||
|
(void) params;
|
||||||
|
|
||||||
// Poll every 10ms
|
// Poll every 10ms
|
||||||
static tu_timeout_t tm = { .start = 0, .interval = 10 };
|
static tu_timeout_t tm = { .start = 0, .interval = 10 };
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,7 @@
|
||||||
|
|
||||||
/*------------- RTOS -------------*/
|
/*------------- RTOS -------------*/
|
||||||
#define CFG_TUSB_OS OPT_OS_FREERTOS
|
#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_QUEUE_SZ 16
|
||||||
//#define CFG_TUD_TASK_STACK_SZ 150
|
//#define CFG_TUD_TASK_STACK_SZ 150
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#define configUSE_PREEMPTION 1
|
#define configUSE_PREEMPTION 1
|
||||||
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0
|
||||||
#define configTICK_RATE_HZ ( 1000 )
|
#define configTICK_RATE_HZ ( 1000 )
|
||||||
#define configMAX_PRIORITIES (8 )
|
#define configMAX_PRIORITIES (5)
|
||||||
#define configMINIMAL_STACK_SIZE (128 )
|
#define configMINIMAL_STACK_SIZE (128 )
|
||||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 16*1024 ) )
|
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 16*1024 ) )
|
||||||
#define configMAX_TASK_NAME_LEN 32
|
#define configMAX_TASK_NAME_LEN 32
|
||||||
|
|
Loading…
Reference in New Issue