Configure the scheduler with a tick of 50ms, create a simple task to toggle a led every 500ms
#include "bsp.h"
#include "scheduler.h"
/**
* @brief Task1_Init
*
* This function initializes the GPIO pin to toggle the LED
*/
void Task1_Init( void )
{
GPIO_InitTypeDef GPIO_InitStruct;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
GPIO_InitStruct.Pin = GPIO_PIN_5;
HAL_GPIO_Init( GPIOA, &GPIO_InitStruct );
}
/**
* @brief Task1_Run
*
* This function toggles the LED
*/
void Task1_Run( void )
{
HAL_GPIO_TogglePin( GPIOA, GPIO_PIN_5 );
}
/**
* @brief **Application entry point**
*
* Ptovide the proper description for function main according to your own
* implementation
*
* @retval None
*/
int main( void )
{
SchedulerType Scheduler;
TaskType TaskBuffer[ 1 ];
TimerType TimerBuffer[ 1 ];
HAL_Init( );
__HAL_RCC_GPIOA_CLK_ENABLE( );
/*set up scheduler to run up to 1 task with a 50ms tick */
Scheduler_Init( &Scheduler, 50, 1, TaskBuffer, 1, TimerBuffer );
/*Register the three task iin our application */
Scheduler_RegisterTask( &Scheduler, Task1_Init, Task1_Run, 200u );
/*start the scheduler */
Scheduler_MainFunction( &Scheduler );
return 0u;
}