Hi team,
I got this little task schedular that I written a while back, I have been using it for a few projects now. And I thought maybe it's a good ideal to share it here, get some feedbacks as well.
For those who are interested: (tested on pic18 and pic24, XC8 and XC16)
https://github.com/jmswu/schedular
Any feedbacks, suggestions and/or criticisms are welcome.
Example:
I got this little task schedular that I written a while back, I have been using it for a few projects now. And I thought maybe it's a good ideal to share it here, get some feedbacks as well.
For those who are interested: (tested on pic18 and pic24, XC8 and XC16)
https://github.com/jmswu/schedular
Any feedbacks, suggestions and/or criticisms are welcome.
Example:
Code:
uint32_t get_ticks(void); // get system tick, usually with a hardware timer
uint8_t task_1(void); // task 1
uint8_t task_2(void); // task 2
void main(){
schedular_init(get_ticks);
schedular_add(task_1, 10); // add task_1() to schedular, run every 10 ticks
schedular_add(task_2, 20); // add task_2() to schedular, run every 20 ticks
schedular_sort(); // optional, this function is yet to be implement
while(1){
schedular_run(); // run task schedular
}
}
uint32_t get_ticks(void{
// return system ticks generated by hardware timer
}
uint8_t task_1(void){
// user coder here
return 1; // return 1 to keep the task running
// return 0 to remove this task from schedular
}
uint8_t task_2(void){
// user coder here
return 1; // return 1 to keep the task running
// return 0 to remove this task from schedular
}