freertos blinky with software timer
This commit is contained in:
@@ -43,6 +43,12 @@
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "timers.h"
|
||||
#include "queue.h"
|
||||
#include "semphr.h"
|
||||
|
||||
#include "bsp/board.h"
|
||||
#include "tusb.h"
|
||||
|
||||
@@ -54,27 +60,33 @@
|
||||
// INTERNAL OBJECT & FUNCTION DECLARATION
|
||||
//--------------------------------------------------------------------+
|
||||
void print_greeting(void);
|
||||
void led_blinking_task(void);
|
||||
void led_blinky_cb(TimerHandle_t xTimer);
|
||||
void virtual_com_task(void);
|
||||
void usb_hid_task(void);
|
||||
|
||||
|
||||
/*------------- MAIN -------------*/
|
||||
int main(void)
|
||||
{
|
||||
board_init();
|
||||
print_greeting();
|
||||
|
||||
tusb_init();
|
||||
//tusb_init();
|
||||
|
||||
while (1)
|
||||
{
|
||||
tusb_task();
|
||||
// soft timer for blinky
|
||||
TimerHandle_t tm_hdl = xTimerCreate(NULL, pdMS_TO_TICKS(1000), true, NULL, led_blinky_cb);
|
||||
xTimerStart(tm_hdl, 0);
|
||||
|
||||
led_blinking_task();
|
||||
virtual_com_task();
|
||||
vTaskStartScheduler();
|
||||
|
||||
usb_hid_task();
|
||||
}
|
||||
NVIC_SystemReset();
|
||||
|
||||
// while (1)
|
||||
// {
|
||||
// virtual_com_task();
|
||||
//
|
||||
// usb_hid_task();
|
||||
// }
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -173,14 +185,11 @@ void tud_cdc_rx_cb(uint8_t itf)
|
||||
//--------------------------------------------------------------------+
|
||||
// BLINKING TASK
|
||||
//--------------------------------------------------------------------+
|
||||
void led_blinking_task(void)
|
||||
void led_blinky_cb(TimerHandle_t xTimer)
|
||||
{
|
||||
static tu_timeout_t tm = { .start = 0, .interval = 1000 }; // Blink every 1000 ms
|
||||
(void) xTimer;
|
||||
static bool led_state = false;
|
||||
|
||||
if ( !tu_timeout_expired(&tm) ) return; // not enough time
|
||||
tu_timeout_reset(&tm);
|
||||
|
||||
board_led_control(BOARD_LED0, led_state);
|
||||
led_state = 1 - led_state; // toggle
|
||||
}
|
||||
|
||||
@@ -52,8 +52,8 @@
|
||||
#define CFG_TUSB_DEBUG 2
|
||||
|
||||
/*------------- RTOS -------------*/
|
||||
#define CFG_TUSB_OS OPT_OS_NONE // be passed from IDE/command line for easy project switching
|
||||
//#define CFG_TUD_TASK_PRIO 0
|
||||
#define CFG_TUSB_OS OPT_OS_FREERTOS
|
||||
#define CFG_TUD_TASK_PRIO (configMAX_PRIORITIES-2)
|
||||
//#define CFG_TUD_TASK_QUEUE_SZ 16
|
||||
//#define CFG_TUD_TASK_STACK_SZ 150
|
||||
|
||||
|
||||
Reference in New Issue
Block a user