📄 eg1.c
字号:
/*
* File: example1.c
*
* uC/OS Real-time multitasking kernel for the ARM processor.
*
* Simple example of using multiple tasks and mailboxes.
*
* Created by Marco Graziano (marcog@crl.com).
*
*/
#include "../includes.h" /* uC/OS interface */
#include "../arm44box/Keyboard16.h"
#include "../arm44box/8led.h"
#include "../uhal/uhal.h"
#include "Sems.h"
#include "LWIP_Main.h"
/* allocate memory for tasks' stacks */
#ifdef SEMIHOSTED
#define STACKSIZE (64+SEMIHOSTED_STACK_NEEDS)
#else
#define STACKSIZE 256
#endif
OS_STK Stack1[STACKSIZE*5]= {0, };
OS_STK Stack2[STACKSIZE]= {0, };
OS_STK Stack3[STACKSIZE]= {0, };
OS_STK Stack4[STACKSIZE]= {0, };
//OS_STK Stack5[STACKSIZE]= {0, };
/* mailbox event control blocks */
OS_EVENT *Mbox1;
OS_EVENT *Mbox2;
OS_EVENT *Mbox3;
OS_EVENT *Mbox4;
OS_EVENT *UART_RW_SEM;
OS_EVENT *ConsoleSem;
/*
OSSemPend(UART_RW_SEM,0,&err);
OSSemPost(UART_RW_SEM);
UART_RW_SEM=OSSemCreate(1);
*/
char PassMsg[] = "5678";
INT8U sdbuf[8]={0XFF,0X00,0X32,0X32,0X31,0X40,0X40,0X40};
INT8U d_key;
INT8U KKK;
void Task2(void *Id)
{
INT8U j;
uHALr_printf("Task1() called\r\n");
for (;;)
{
// uHALr_printf("%c", *(char *)Id);
// for(j=0;j<7;j++)
// {Uart_SendByte(sdbuf[j]);}
OSTimeDly(3000);
}
}
void Task3(void *Id)
{
INT32U j;
uHALr_printf("Task2() called\r\n");
while(1)
{
j++;
//uHALr_printf("%c", *(char *)Id);
uHALr_printf("%d ****\r",j);
//uHALr_printf("%d", j);
//d_key=get_ch();
//if(d_key!=0){
// onkey(d_key);
// }
OSTimeDly(300);
}
}
void Task4(void *Id)
{
uHALr_printf(" Task%c Called.\n", *(char *)Id);
OSTaskCreate(LWIP_main, (void *)0, (OS_STK *)&Stack1[STACKSIZE*5-1], 1);
uHALr_printf("LWIP Main Created!\r\n");
while(1)
{
// uHALr_printf(" Task%c Called.\n", *(char *)Id);
OSTimeDly(5000);
}
}
/*
* Main function.
*/
int Main(int argc, char **argv)
{
char Id2 = '2';
char Id3 = '3';
char Id4 = '4';
/* do target (uHAL based ARM system) initialisation */
ARMTargetInit();
/* needed by uC/OS */
OSInit();
uHALr_ResetMMU();
/*
* create the first mailbox in the pipeline with a message
* in it to get the first task started.
*/
// Mbox1 = OSMboxCreate(PassMsg);
/* create the remaining mailboxes empty */
// Mbox2 = OSMboxCreate((void *)0);
/*
* create the tasks in uC/OS and assign increasing
* priorities to them so that Task3 at the end of
* the pipeline has the highest priority.
*/
ConsoleSem = OSSemCreate(1);
OSTaskCreate(Task2, (void *)&Id2, (OS_STK *)&Stack2[STACKSIZE - 1], 2);
OSTaskCreate(Task3, (void *)&Id3, (OS_STK *)&Stack3[STACKSIZE - 1], 3);
OSTaskCreate(Task4, (void *)&Id4, (OS_STK *)&Stack4[STACKSIZE - 1], 4);
/* Start the (uHAL based ARM system) system running */
ARMTargetStart();
/* start the game */
OSStart();
/* never reached */
return 0;
} /* main */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -