Skip to content

Co-Op (Co-Operative) Multitasking Algorithm library for c/c++ application's

License

Notifications You must be signed in to change notification settings

Majid-Derhambakhsh/CoOp-Core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Banner

Co-Op Core Library

Co-Op (Co-Operative) Multitasking Algorithm library for c/c++ application's

Version : 1.0.0

  • Type : Software/Embedded Software

  • Support :

    + Any c/c++ software's   
  • Program Language : C/C++

  • Properties :

  • Changes :

  • Required Library/Driver :

Initialization and de-initialization functions:

CoOp Core operation functions:

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);

Macros:

#define _COOP_NMB_OF_TASK

How to use this library

The CoOp Core library can be used as follows:

  1. Add coop_core.h header

  2. Set the max number of tasks in coop_core_conf.h header, for example:

/* -------- Configuration -------- */
#define _COOP_NMB_OF_TASK 3
  1. Add Task_IncTick() in the 1ms timer ISR:
Timer_ISR()
{
	Task_IncTick();
}
  1. 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;
  }

}
  1. 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

Tests performed:

  • Run on AVR
  • Run on STM32 Fx cores

Developer: Majid Derhambakhsh

About

Co-Op (Co-Operative) Multitasking Algorithm library for c/c++ application's

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages