krnl 1
Loading...
Searching...
No Matches
kernelkick.ino
Go to the documentation of this file.
1#include <krnl.h>
2
3// a simple KeRNeL arduino program
4// one task waits on sync on a semaphore
5// another task do periodic loop by a semaphore and timer facilility
6// and sync the first task
7
8
10
11char stak1[100], stak2[100];
12
13void task1Body(void)
14{
15 while (1) {
16 k_wait(syncSem,0);
17 Serial.println("kick");
18 }
19}
20
21void task2Body(void) {
23 while (1) {
24
25 k_wait(loopSem,0);
27 }
28}
29
30void setup()
31{
32 Serial.begin(9600);
33 k_init(5,5,5);
34 loopSem = k_crt_sem(0,10); // you should chk if return value = NULL == error
35 syncSem = k_crt_sem(0,10);
37 ptask2 = k_crt_task(task2Body,29,stak2,100); // 20 is lower prority than 10
38 Serial.println("just bef start");
39 k_start(10); // 10 msec tick
40 Serial.println("error - you should not com here");
41}
42void loop()
43{
44 // you will never come here
45}
char stak1[STKSZ]
char stak2[STKSZ]
struct k_t * syncSem
Definition k08isrsem.ino:19
int k_signal(struct k_t *sem)
Signal a semaphore w eventually task shift.
Definition krnl.c:636
int k_wait(struct k_t *sem, int timeout)
stand wait on semaphore call with timeout facility
Definition krnl.c:683
struct k_t * k_crt_task(void(*pTask)(void), char prio, char *pStk, int stkSize)
create a task - only to be called before k_start creates a task and put it in the active Q
Definition krnl.c:328
int k_set_sem_timer(struct k_t *sem, int val)
attach a periodic timer to a semaphore, to be used for realtime
Definition krnl.c:586
struct k_t * k_crt_sem(int init_val, int maxvalue)
change task priority and reinserts it in task Q and do a task shift
Definition krnl.c:544
int k_init(int nrTask, int nrSem, int nrMsg)
Definition krnl.c:1108
int k_start()
Definition krnl.c:1149
struct k_t * ptask2
Definition kernelkick.ino:9
void setup()
void task2Body(void)
void task1Body(void)
struct k_t * loopSem
Definition kernelkick.ino:9
struct k_t * ptask1
Definition kernelkick.ino:9
void loop()
Definition krnl.h:323