Created
October 4, 2013 15:58
-
-
Save berezovskyi/6828263 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include "includes.h" | |
/* Definition of Task Stacks */ | |
#define TASK_STACKSIZE 2048 | |
OS_STK task1_stk[TASK_STACKSIZE]; | |
/* Definition of Task Priorities */ | |
#define TASK1_PRIORITY 2 | |
INT8U timer = 1; | |
INT8U error = 0; | |
INT8U arg = 0; | |
OS_TMR* os_timer; | |
void tmr(void *ptmr, void *parg) | |
{ | |
printf("Tick\n"); | |
} | |
/* Prints "Hello World" and sleeps for three seconds */ | |
void task1(void* pdata) | |
{ | |
INT32U period = 1; // use OS_TMR_CFG_TICKS_PER_SEC to get 1 call a second | |
os_timer = OSTmrCreate(0, // no delay | |
period, // timer is called OS_TMR_CFG_TICKS_PER_SEC/period times a second on hardware | |
OS_TMR_OPT_PERIODIC, // not a one-off | |
tmr, // callback routine | |
(void*)(&arg), // no argument | |
&timer, // timer no. | |
&error); // error | |
OSTmrStart(os_timer, &error); | |
while (1) | |
{ | |
printf("Hello from task1\n"); | |
OSTimeDlyHMSM(0, 0, 3, 0); | |
} | |
} | |
/* The main function creates two task and starts multi-tasking */ | |
int main(void) | |
{ | |
OSTaskCreateExt(task1, | |
NULL, | |
(void *)&task1_stk[TASK_STACKSIZE-1], | |
TASK1_PRIORITY, | |
TASK1_PRIORITY, | |
task1_stk, | |
TASK_STACKSIZE, | |
NULL, | |
0); | |
OSStart(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment