Co-Op (Co-Operative) Multitasking Algorithm library for c/c++ application's
-
+ Any c/c++ software's
uint8_t Task_RegisterNew(cTask_TypeDef *uTask, cTaskFunc_TypeDef uFunc);
uint8_t Task_GetStepParam(uint8_t *paramIn);
void Task_SetNextStepParam(uint8_t nexStep);
void Task_IncTick(void);
void Task_Delay(uint16_t tim, uint8_t step);
void Task_Resume(cTask_TypeDef *uTask);
void Task_ResumeAll(void);
void Task_Suspend(cTask_TypeDef *uTask);
void Task_SuspendAll(void);
void Task_Delete(cTask_TypeDef *uTask);
void Task_DeleteAll(void);
void Task_RunCoOpSystem(void);
#define _COOP_NMB_OF_TASK
-
Add coop_core.h header
-
Set the max number of tasks in coop_core_conf.h header, for example:
/* -------- Configuration -------- */
#define _COOP_NMB_OF_TASK 3
- Add Task_IncTick() in the 1ms timer ISR:
Timer_ISR()
{
Task_IncTick();
}
- Create the Tasks and her functions:
cTask_TypeDef Task1;
cTask_TypeDef Task2;
cTask_TypeDef Task3;
void Task1Func(uint8_t *argument)
{
LED1_Toggle();
Task_Delay(500, 0);
}
void Task2Func(uint8_t *argument)
{
LED2_Toggle();
Task_Delay(500, 0);
}
void Task3Func(uint8_t *argument)
{
switch(*argument)
{
case 0: // Step 0 is default
{
LED3_On();
Task_Delay(250, 1); // Wait 250ms and goto step 1 (case 1)
}
break;
case 1: // Step 1
{
LED3_Off();
Task_Delay(250, 0); // Wait 250ms and goto step 0 (case 0)
}
break;
default:
break;
}
}
- Register Tasks and run CoOp System, for example:
/* Register User Tasks */
Task_RegisterNew(&Task1, Task1Func);
Task_RegisterNew(&Task2, Task2Func);
Task_RegisterNew(&Task3, Task3Func);
/* Run CoOp System */
Task_RunCoOpSystem();
Example 1 (AVR): Download
Example 2, 7Segment Counter (AVR): Download
Example 3, Read Key (AVR): Download
Example 4 (STM32): Download
- Run on AVR
- Run on STM32 Fx cores