|
建立一个可以下载的工程,然后添加如下代码,就是自带的例子,关于例子程序有几点疑问,
有高手帮忙讲解下,谢谢了
1.程序入口在哪里?从progStart开始执行,在其中的return(OK)返回了,接下来执行什么?其他几个任务的代码怎么执行?
还是在 tidCom=taskSpawn ("com", 200, 0, STACK_SIZE,(FUNCPTR) com,0,0,0,0,0,0,0,0,0,0);后直接跳到com函数执行?
2.程序是什么结构,顺序,选择,循环??觉得更想循环,可是在progStart中并没有WHILE循环?
STATUS progStart (void)
{
syncSemId = semBCreate (SEM_Q_FIFO, SEM_EMPTY);
dataSemId = semBCreate (SEM_Q_FIFO, SEM_EMPTY);
nodeListGuardSemId = semMCreate ( SEM_Q_PRIORITY
| SEM_INVERSION_SAFE
| SEM_DELETE_SAFE);
/* the I/O mode is output and I/O init set bard */
*(unsigned int *)0x03ff5000 = 0xffffffff;
InitUART(0,0x500);
/*creat tasks*/
tidCom=taskSpawn ("com", 200, 0, STACK_SIZE,
(FUNCPTR) com,0,0,0,0,0,0,0,0,0,0);
tidSong = taskSpawn ("song", 210, 0, STACK_SIZE,
(FUNCPTR) song,0,0,0,0,0,0,0,0,0,0);
tidPlay = taskSpawn ("music", 220, 0, STACK_SIZE,
(FUNCPTR) play,0,0,0,0,0,0,0,0,0,0);
tidLight = taskSpawn ("light", 230, 0, STACK_SIZE,
(FUNCPTR) light,0,0,0,0,0,0,0,0,0,0);
return (OK);
}
/*************************************************************************
*
* progStop - stops the program
*
* Call this routine to end it all.
*/
void progStop (void)
{
taskDelete (tidCom);
taskDelete (tidPlay);
taskDelete (tidSong);
taskDelete (tidLight);
semDelete (dataSemId);
semDelete (syncSemId);
semDelete (nodeListGuardSemId);
/* My, aren't we tidy! */
printf ("BYE!TSCHUESS!ADIEU!\n");
return;
}
/*the led is lighted one after anther*/
void light(void)
{ while (1)
{
LED_2_ON;
delay(65536);
LED_2_OFF;
LED_3_ON;
delay(65536);
LED_3_OFF;
LED_4_ON;
delay(65536);
LED_4_OFF;
LED_1_ON;
delay(65536);
LED_1_OFF;
LED_4_ON;
delay(65536);
LED_4_OFF;
LED_3_ON;
delay(65536);
LED_3_OFF;
}
}
。。。。。。。。。。。。。省略
|
|