📄 app.c
字号:
for (i = 1; i <= 4; i++) {
if ((leds & (1 << i)) == (1 << i)) {
LED_Toggle(i);
}
}
delay1 = (ADC_GetStatus(2) >> 2) + 32;
OSTimeDlyHMSM(0, 0, (CPU_INT08U)(delay1 / 1000), (CPU_INT16U)(delay1 % 1000));
}
}
OSTimeDlyHMSM(0,0,0,10);
if (OSCPUUsage > OSCPUUsageMax) {
OSCPUUsageMax = OSCPUUsage;
}
}
}
/*
*********************************************************************************************************
* CREATE APPLICATION TASKS
*
* Description: This function creates the application tasks.
*
* Arguments : none
*
* Returns : none
*********************************************************************************************************
*/
static void AppTaskCreate (void)
{
CPU_INT08U os_err;
os_err = OSTaskCreateExt((void (*)(void *)) AppTaskKbd,
(void * ) 0,
(OS_STK * )&AppTaskKbdStk[APP_TASK_KBD_STK_SIZE - 1],
(INT8U ) APP_TASK_KBD_PRIO,
(INT16U ) APP_TASK_KBD_PRIO,
(OS_STK * )&AppTaskKbdStk[0],
(INT32U ) APP_TASK_KBD_STK_SIZE,
(void * ) 0,
(INT16U )(OS_TASK_OPT_STK_CLR | OS_TASK_OPT_STK_CHK));
#if (OS_TASK_NAME_SIZE >= 9)
OSTaskNameSet(APP_TASK_KBD_PRIO, (CPU_INT08U *)"Keyboard", &os_err);
#endif
os_err = OSTaskCreateExt((void (*)(void *)) AppIRD1s,
(void * ) 0,
(OS_STK * )&AppTaskIRD1sStk[APP_TASK_IRD1s_STK_SIZE - 1],
(INT8U ) APP_TASK_IRD1s_PRIO,
(INT16U ) APP_TASK_IRD1s_PRIO,
(OS_STK * )&AppTaskIRD1sStk[0],
(INT32U ) APP_TASK_IRD1s_STK_SIZE,
(void * ) 0,
(INT16U )(OS_TASK_OPT_STK_CLR | OS_TASK_OPT_STK_CHK));
#if (OS_TASK_NAME_SIZE >= 9)
OSTaskNameSet(APP_TASK_IRD1s_PRIO, (CPU_INT08U *)"IRD1s", &os_err);
#endif
#if (DALI_APP_MODULE > 0)
os_err = OSTaskCreateExt(AppTaskDali,
(void *)0,
(OS_STK *)&AppTaskDaliStk[APP_TASK_DALI_STK_SIZE - 1],
APP_TASK_DALI_PRIO,
APP_TASK_DALI_PRIO,
(OS_STK *)&AppTaskDaliStk[0],
APP_TASK_DALI_STK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
#if (OS_TASK_NAME_SIZE >= 9)
OSTaskNameSet(APP_TASK_DALI_PRIO, (CPU_CHAR *)"Dali", &os_err);
#endif
#endif
/*Insert the OSTaskCreateExt call here */
}
/*
*********************************************************************************************************
* AppInit_TCPIP()
*
* Description : Initialize uC/TCP-IP.
*
* Argument(s) : none.
*
* Return(s) : none.
*********************************************************************************************************
*/
#if (uC_TCPIP_MODULE > 0)
static void AppInitTCPIP (void)
{
NET_ERR err;
#if (EMAC_CFG_MAC_ADDR_SEL == EMAC_CFG_MAC_ADDR_SEL_CFG)
NetIF_MAC_Addr[0] = 0x00;
NetIF_MAC_Addr[1] = 0x50;
NetIF_MAC_Addr[2] = 0xC2;
NetIF_MAC_Addr[3] = 0x25;
NetIF_MAC_Addr[4] = 0x61;
NetIF_MAC_Addr[5] = 0x99;
#endif
err = Net_Init(); /* Initialize uC/TCP-IP */
AppNetIP = NetASCII_Str_to_IP("192.168.2.80", &err);
AppNetMsk = NetASCII_Str_to_IP("255.255.255.0", &err);
AppNetGateway = NetASCII_Str_to_IP("192.168.2.1", &err);
err = NetIP_CfgAddrThisHost(AppNetIP, AppNetMsk);
err = NetIP_CfgAddrDfltGateway(AppNetGateway);
}
#endif
/*
*********************************************************************************************************
*********************************************************************************************************
** uC/OS-II APP HOOKS
*********************************************************************************************************
*********************************************************************************************************
*/
#if (OS_APP_HOOKS_EN > 0)
/*
*********************************************************************************************************
* TASK CREATION HOOK (APPLICATION)
*
* Description : This function is called when a task is created.
*
* Argument(s) : ptcb is a pointer to the task control block of the task being created.
*
* Note(s) : (1) Interrupts are disabled during this call.
*********************************************************************************************************
*/
void App_TaskCreateHook (OS_TCB *ptcb)
{
#if (uC_PROBE_OS_PLUGIN > 0) && (OS_PROBE_HOOKS_EN > 0)
OSProbe_TaskCreateHook(ptcb);
#endif
}
/*
*********************************************************************************************************
* TASK DELETION HOOK (APPLICATION)
*
* Description : This function is called when a task is deleted.
*
* Argument(s) : ptcb is a pointer to the task control block of the task being deleted.
*
* Note(s) : (1) Interrupts are disabled during this call.
*********************************************************************************************************
*/
void App_TaskDelHook (OS_TCB *ptcb)
{
(void)ptcb;
}
/*
*********************************************************************************************************
* IDLE TASK HOOK (APPLICATION)
*
* Description : This function is called by OSTaskIdleHook(), which is called by the idle task. This hook
* has been added to allow you to do such things as STOP the CPU to conserve power.
*
* Argument(s) : none.
*
* Note(s) : (1) Interrupts are enabled during this call.
*********************************************************************************************************
*/
#if OS_VERSION >= 251
void App_TaskIdleHook (void)
{
}
#endif
/*
*********************************************************************************************************
* STATISTIC TASK HOOK (APPLICATION)
*
* Description : This function is called by OSTaskStatHook(), which is called every second by uC/OS-II's
* statistics task. This allows your application to add functionality to the statistics task.
*
* Argument(s) : none.
*********************************************************************************************************
*/
void App_TaskStatHook (void)
{
}
/*
*********************************************************************************************************
* TASK SWITCH HOOK (APPLICATION)
*
* Description : This function is called when a task switch is performed. This allows you to perform other
* operations during a context switch.
*
* Argument(s) : none.
*
* Note(s) : (1) Interrupts are disabled during this call.
*
* (2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
* will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the
* task being switched out (i.e. the preempted task).
*********************************************************************************************************
*/
#if OS_TASK_SW_HOOK_EN > 0
void App_TaskSwHook (void)
{
#if (uC_PROBE_OS_PLUGIN > 0) && (OS_PROBE_HOOKS_EN > 0)
OSProbe_TaskSwHook();
#endif
}
#endif
/*
*********************************************************************************************************
* OS_TCBInit() HOOK (APPLICATION)
*
* Description : This function is called by OSTCBInitHook(), which is called by OS_TCBInit() after setting
* up most of the TCB.
*
* Argument(s) : ptcb is a pointer to the TCB of the task being created.
*
* Note(s) : (1) Interrupts may or may not be ENABLED during this call.
*********************************************************************************************************
*/
#if OS_VERSION >= 204
void App_TCBInitHook (OS_TCB *ptcb)
{
(void)ptcb;
}
#endif
/*
*********************************************************************************************************
* TICK HOOK (APPLICATION)
*
* Description : This function is called every tick.
*
* Argument(s) : none.
*
* Note(s) : (1) Interrupts may or may not be ENABLED during this call.
*********************************************************************************************************
*/
#if OS_TIME_TICK_HOOK_EN > 0
void App_TimeTickHook (void)
{
#if (uC_PROBE_OS_PLUGIN > 0) && (OS_PROBE_HOOKS_EN > 0)
OSProbe_TickHook();
#endif
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -