Skip to content

WeSpeakEnglish/ANTIRTOS_C

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 

Repository files navigation

ANTIRTOS#C

No RTOS need, you will C! Exteamly light, pure C preprocessor macros-based universal C library designed for task management in IoT and embedded applications. It is coded in a single, small file, making it incredibly easy to integrate into your projects. Enjoy the real simplicity!
Also: here

Prefer C++? It is ANTIRTOS C++ library here and also fresh new ANTIRTOS_MODERN

Conveyers of function pointers without parameters

Usage

1. Initialize needed queues like global prototypes (as many as you need, here are two like example):

  fQ(Q1,8); // define first queue (type fQ) with name Q1, 8 elements length
  fQ(Q2,8);   // define second queue (type fQ) with name Q2, 8 elements length

2. Define your tasks:

#include <antirtos_c.h>
void yourTaskOne(){
//put here what ever you want to execute
}

void yourTaskTwo(){
//put here what ever you want to execute
}

3. In main loop (loop(){} instead of main(){} for Arduino) just pull from the queues

void main(){ // or loop{} for Arduino
  Q1_Pull(); // pull from the Q1 and execute
  Q2_Pull(); // pull from the Q2 and execute
}

4. Wherever you want, you can now push your tasks, they will be handled! (for example in some interrupts)

void ISR_1(){
  Q1_Push(yourTaskOne);  // just push your task into queue!
}
void ISR_2(){
  Q2_Push(yourTaskTwo);  // just push your task into queue!
}

This is it! All the interrupts are kept extreamly fast, all the task handled

Conveyers of function pointers with parameters

Imagine now you need to pass parameters to functions in queue

1. Define all your queues:

 fQP(Q1,8,int);  //Q1 is 8 elements length, type fQP, functions receive int
 fQP(Q2,8,char); //Q2 is 8 elements length, type fQP, functions receive char

2. Define all your tasks, for example:

#include <antirtos_c.h>
void blinkLED(int led){
  switch(led){
    case 0: 
      HAL_GPIO_TogglePin(LED_YELLOW_PORT, LED_YELLOW_PIN);
      break;
    case 1:
      HAL_GPIO_TogglePin(LED_GREEN_PORT, LED_GREEN_PIN);
      break;    
  }

void printSymbol(char ch){
 printf("Symbol: %c\n", ch);
}

3. In main loop (loop{} instead of main(){} for Arduino) just add:

void main(){
  Q1_Pull();  // pull from the Q1 and execute
  Q2_Pull();  // pull from the Q2 and execute
}

4. Where you want just push the tasks into queues and pass them parameters (for example in some interrupts again):

void ISR_1(void){
  Q1_Push(blinkLED, 0); // just push your task into Q1 queue and parameter!
  }
void ISR_2(void){ 
  Q2_Push(printSymbol, 'a'); // just push your task into Q2 queue and parameter!
  }

More parameters needed?

Just wrap them into your custom structure, for example:

typedef struct {
    int index;
    int logic;
} pinout;

Task functions will receive here type pinout:

void myTask(pinout p){
// put here what ever you want, your task
}

Now you may initialize your queues, like:

fQP(Q3,8,pinout);  //Q3 is 8 elements length, type fQP, functions receive type 'pinout'

Push parameters now like:

 Q3_Push(myTask, (pinout){0,1}); //push your task into Q3 and passing arguments 

In main loop (loop{} instead of main(){} for Arduino) as usual:

void main(void){
  Q3_Pull();
}

Conveyers of pointers of delayed functions without parameters

Do you need just to delay some function from execution? Do not wait any more!

1. Initialize:

del_fQ(Q4,8); //Q4 is 8 elements length delayed queue

2. Put where you want your tasks into queue, specifying delay (here example of 2 functions put into queue):

Q4_Push_delayed(your_func_1, 1000); // function your_func_1() will be delayed for 1000 'ticks' (see calling Q4_Tick below)
Q4_Push_delayed(your_func_2, 2000); // function your_func_2() will be delayed for 2000 'ticks'

3. In the main loop (in lopp(){} for Arduino) just need to:

Q4_Pull();

4. In some timer or periodic function:

Q4_Tick();

That is it!

5. If you need to revoke a function from the delayed conveyer, use revocation

For example, you need to revoke your_func_1:

Q4_Revoke(your_func_1);

All functions are handled and executed automatically. Do not waste time—keep interrupts extremely fast and never lose them! Use ANTIRTOS

About

No RTOS need, you will C!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages