2023-03-23 12:38:09 +02:00

91 lines
2.0 KiB
C++

/*
===============================================================================
Name : main.c
Author : $(author)
Version :
Copyright : $(copyright)
Description : main definition
===============================================================================
*/
#include "chip.h"
#include "board.h"
#include "FreeRTOS.h"
#include "task.h"
#include <cr_section_macros.h>
/* Sets up system hardware */
static void prvSetupHardware(void)
{
SystemCoreClockUpdate();
Board_Init();
}
/* LED0 toggle thread */
static void vLEDTask0(void *pvParameters) {
bool LedState = false;
while (1) {
Board_LED_Set(0, LedState);
LedState = (bool) !LedState;
vTaskDelay(configTICK_RATE_HZ / 2);
}
}
/* LED1 toggle thread */
static void vLEDTask1(void *pvParameters) {
bool LedState = false;
while (1) {
Board_LED_Set(1, LedState);
LedState = (bool) !LedState;
vTaskDelay(configTICK_RATE_HZ * 2);
}
}
/* LED2 toggle thread */
static void vLEDTask2(void *pvParameters) {
bool LedState = false;
while (1) {
Board_LED_Set(2, LedState);
LedState = (bool) !LedState;
vTaskDelay(configTICK_RATE_HZ);
}
}
/*****************************************************************************
* Public functions
****************************************************************************/
/**
* @brief main routine for FreeRTOS blinky example
* @return Nothing, function should not exit
*/
int main(void)
{
prvSetupHardware();
/* LED1 toggle thread */
xTaskCreate(vLEDTask1, "vTaskLed1",
configMINIMAL_STACK_SIZE, NULL, (tskIDLE_PRIORITY + 1UL),
(xTaskHandle *) NULL);
/* LED2 toggle thread */
xTaskCreate(vLEDTask2, "vTaskLed2",
configMINIMAL_STACK_SIZE, NULL, (tskIDLE_PRIORITY + 1UL),
(xTaskHandle *) NULL);
/* LED0 toggle thread */
xTaskCreate(vLEDTask0, "vTaskLed0",
configMINIMAL_STACK_SIZE, NULL, (tskIDLE_PRIORITY + 1UL),
(xTaskHandle *) NULL);
/* Start the scheduler */
vTaskStartScheduler();
/* Should never arrive here */
return 1;
}