📄 main.c
字号:
#include "../includes.h" /* uC/OS interface */
//#include "Sems.h"
//task stack size
#ifdef SEMIHOSTED
#define TASK_STACK_SIZE (64+SEMIHOSTED_STACK_NEEDS)
#else
#define TASK_STACK_SIZE 10*1024
#endif
//Task definition
/* allocate memory for tasks' stacks */
#define STACKSIZE 64
/* Global Variable */
unsigned int Stack1[STACKSIZE];
unsigned int Stack2[STACKSIZE];
unsigned int Stack3[STACKSIZE];
unsigned int StackMain[STACKSIZE];
void Task1(void *Id)
{
// OSSemPend(UART_sem, 0, &err);
uHALr_printf(" Task%c Called.\n", *(char *)Id);
// OSSemPost(UART_sem);
while(1)
{
//leds_on();
OSTimeDly(1000);
//leds_off();
uHALr_printf(" saaas\r");
OSTimeDly(1030);
}
}
void Task2(void *Id)
{
int i;
// OSSemPend(UART_sem, 0, &err);
uHALr_printf(" Task%c Called.\n", *(char *)Id);
// OSSemPost(UART_sem);
while(1)
{
for(i=0; i<16; i++)
{
// Digit_Led_Symbol(i);
uHALr_printf(" ssss\r");
OSTimeDly(1050);
}
}
}
void Task3(void *Id)
{
// char *Msg;
int i=0;
//OSSemPend(UART_sem, 0, &err);
uHALr_printf("task%c called \n",*(char *)Id);
//OSSemPost(UART_sem);
while(1)
{
i++;
uHALr_printf(" **** %d ****\r",i);
OSTimeDly(1900);
}
}
void TaskStart (void *i)
{
char Id1 = '1';
char Id2 = '2';
char Id3 = '3';
// UART_sem=OSSemCreate(1);
uHALr_InitTimers(); // enable timer counter interrupt
/*
* create the tasks in uC/OS and assign decreasing
* priority to them
*/
OSTaskCreate(Task1, (void *)0, &Stack1[STACKSIZE - 1], 2);
OSTaskCreate(Task2, (void *)0, &Stack2[STACKSIZE - 1], 3);
OSTaskCreate(Task3, (void *)0, &Stack3[STACKSIZE - 1], 4);
// Delete current task
// OSTaskDel(OS_PRIO_SELF);
}
int Main(void)//int argc, char **argv
{
char Id1 = '1';
char Id2 = '2';
char Id3 = '3';
//char Id4 = '4';
ARMTargetInit();
/* needed by uC/OS */
OSInit();
uHALr_ResetMMU();
//OSTimeSet(0);
uHALr_InitTimers(); // enable timer counter interrupt
/* create the start task */
OSTaskCreate(Task1, (void *)0, &Stack1[STACKSIZE - 1], 2);
OSTaskCreate(Task2, (void *)0, &Stack2[STACKSIZE - 1], 3);
OSTaskCreate(Task3, (void *)0, &Stack3[STACKSIZE - 1], 4);
ARMTargetStart();
/* start the operating system */
OSStart();
return(0);
//* End
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -