📄 app.c
字号:
while (DEF_YES) {
;
}
}
App_IP_Addr = NetASCII_Str_to_IP(APP_CFG_IP_ADDR_STR_THIS_HOST, &err);
App_IP_Mask = NetASCII_Str_to_IP(APP_CFG_IP_ADDR_STR_NET_MASK, &err);
App_IP_DfltGateway = NetASCII_Str_to_IP(APP_CFG_IP_ADDR_STR_DFLT_GATEWAY, &err);
App_IP_DNS_Srvr = NetASCII_Str_to_IP(APP_CFG_IP_ADDR_STR_DNS_SRVR, &err);
App_IP_NTP_Srvr = NetASCII_Str_to_IP(APP_CFG_IP_ADDR_STR_NTP_SRVR, &err);
App_Clk_UTC_Offset = APP_CFG_CLK_UTC_OFFSET;
NetIP_CfgAddrThisHost(App_IP_Addr, App_IP_Mask);
NetIP_CfgAddrDfltGateway(App_IP_DfltGateway);
APP_TRACE_DEBUG((" MAC address = %s\n", pmac));
APP_TRACE_DEBUG((" IP address = %s\n", APP_CFG_IP_ADDR_STR_THIS_HOST));
APP_TRACE_DEBUG((" IP mask = %s\n", APP_CFG_IP_ADDR_STR_NET_MASK));
APP_TRACE_DEBUG((" IP gateway = %s\n", APP_CFG_IP_ADDR_STR_DFLT_GATEWAY));
(void)&App_IP_DNS_Srvr;
(void)&App_IP_NTP_Srvr;
}
#endif
/*
*********************************************************************************************************
* CREATE APPLICATION TASKS
*
* Description : This function creates the application tasks.
*
* Arguments : None.
*********************************************************************************************************
*/
static void App_TaskCreate (void)
{
#if (OS_TASK_NAME_SIZE >= 9)
INT8U os_err;
#endif
os_err = OSTaskCreateExt((void (*)(void *)) App_Task_1,
(void * ) 0,
(OS_STK * )&App1_TaskStk[APP_OS_CFG_1_TASK_STK_SIZE - 1],
(INT8U ) APP_OS_CFG_1_TASK_PRIO,
(INT16U ) APP_OS_CFG_1_TASK_PRIO,
(OS_STK * )&App1_TaskStk[0],
(INT32U ) APP_OS_CFG_1_TASK_STK_SIZE,
(void * ) 0,
(INT16U )(OS_TASK_OPT_STK_CLR | OS_TASK_OPT_STK_CHK));
#if (OS_TASK_NAME_SIZE >= 9)
OSTaskNameSet(APP_OS_CFG_1_TASK_PRIO, "LED task", &os_err);
#endif
}
/*
*********************************************************************************************************
* TASK #1
*
* Description : This is an example of a task.
*
* Arguments : p_arg argument passed to 'AppTask1()' by 'OSTaskCreate()'.
*
* Notes : 1) The first line of code is used to prevent a compiler warning because 'p_arg' is not
* used. The compiler should not generate any code for this statement.
*
* 2) Interrupts are enabled once the task start because the I-bit of the CCR register was
* set to 0 by 'OSTaskCreate()'.
*
* 3) This Task uses the LEDs and the switch of the CSB937 board,
* it blinks user LED 2 on the CSB937.
*********************************************************************************************************
*/
static void App_Task_1 (void *p_arg)
{
(void)&p_arg; /* Prevent compiler warning. */
OS_CPU_UsageMax = 0;
while (DEF_ON) { /* Task body, always written as an infinite loop. */
LED_Toggle(1);
OSTimeDlyHMSM(0, 0, 0, 250);
if (OS_CPU_UsageMax < OSCPUUsage) {
OS_CPU_UsageMax = OSCPUUsage;
}
}
}
/*
*********************************************************************************************************
*********************************************************************************************************
** 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)
{
}
/*
*********************************************************************************************************
* 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.
*********************************************************************************************************
*/
void App_TaskIdleHook (void)
{
}
/*
*********************************************************************************************************
* 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)
{
}
#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.
*********************************************************************************************************
*/
void App_TCBInitHook (OS_TCB *ptcb)
{
(void)&ptcb;
}
/*
*********************************************************************************************************
* 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)
{
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -