项目作者: Majid-Derhambakhsh

项目描述 :
Co-Op (Co-Operative) Multitasking Algorithm library for c/c++ application's
高级语言: C
项目地址: git://github.com/Majid-Derhambakhsh/CoOp-Core.git
创建时间: 2021-02-14T03:24:46Z
项目社区:https://github.com/Majid-Derhambakhsh/CoOp-Core

开源协议:GNU General Public License v3.0

下载


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 :

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

  • Properties :

  • Changes :

  • Required Library/Driver :

Initialization and de-initialization functions:

CoOp Core operation functions:

  1. uint8_t Task_RegisterNew(cTask_TypeDef *uTask, cTaskFunc_TypeDef uFunc);
  2. uint8_t Task_GetStepParam(uint8_t *paramIn);
  3. void Task_SetNextStepParam(uint8_t nexStep);
  4. void Task_IncTick(void);
  5. void Task_Delay(uint16_t tim, uint8_t step);
  6. void Task_Resume(cTask_TypeDef *uTask);
  7. void Task_ResumeAll(void);
  8. void Task_Suspend(cTask_TypeDef *uTask);
  9. void Task_SuspendAll(void);
  10. void Task_Delete(cTask_TypeDef *uTask);
  11. void Task_DeleteAll(void);
  12. void Task_RunCoOpSystem(void);

Macros:

  1. #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:

  1. /* -------- Configuration -------- */
  2. #define _COOP_NMB_OF_TASK 3
  1. Add Task_IncTick() in the 1ms timer ISR:
  1. Timer_ISR()
  2. {
  3. Task_IncTick();
  4. }
  1. Create the Tasks and her functions:
  1. cTask_TypeDef Task1;
  2. cTask_TypeDef Task2;
  3. cTask_TypeDef Task3;
  4. void Task1Func(uint8_t *argument)
  5. {
  6. LED1_Toggle();
  7. Task_Delay(500, 0);
  8. }
  9. void Task2Func(uint8_t *argument)
  10. {
  11. LED2_Toggle();
  12. Task_Delay(500, 0);
  13. }
  14. void Task3Func(uint8_t *argument)
  15. {
  16. switch(*argument)
  17. {
  18. case 0: // Step 0 is default
  19. {
  20. LED3_On();
  21. Task_Delay(250, 1); // Wait 250ms and goto step 1 (case 1)
  22. }
  23. break;
  24. case 1: // Step 1
  25. {
  26. LED3_Off();
  27. Task_Delay(250, 0); // Wait 250ms and goto step 0 (case 0)
  28. }
  29. break;
  30. default:
  31. break;
  32. }
  33. }
  1. Register Tasks and run CoOp System, for example:
  1. /* Register User Tasks */
  2. Task_RegisterNew(&Task1, Task1Func);
  3. Task_RegisterNew(&Task2, Task2Func);
  4. Task_RegisterNew(&Task3, Task3Func);
  5. /* Run CoOp System */
  6. Task_RunCoOpSystem();
Example 1 (AVR): Download
Example 2, 7Segment Counter (AVR): Download.rar)
Example 3, Read Key (AVR): Download.rar)
Example 4 (STM32): Download

Tests performed:

  • [X] Run on AVR
  • Run on STM32 Fx cores

Developer: Majid Derhambakhsh