?? app.c
字號:
while (DEF_TRUE) {
msg = (CPU_INT08U *)(OSMboxPend(AppUserIFMbox, OS_TICKS_PER_SEC / 3, &err));
if (err == OS_NO_ERR) {
nstate = (CPU_INT32U)msg;
}
if (nstate != pstate) {
DispClrScr();
pstate = nstate;
}
switch (nstate) {
case 2:
AppDispScr_VersionTickRate();
break;
case 3:
AppDispScr_CPU();
break;
case 4:
AppDispScr_CtxSw();
break;
case 1:
default:
AppDispScr_SignOn();
break;
}
}
}
#endif
/*
*********************************************************************************************************
* KEYBOARD RESPONSE TASK
*
* Description : This task monitors the state of the push buttons and passes messages to AppTaskUserIF()
*
* Arguments : p_arg is the argument passed to 'AppStartKbd()' by 'OSTaskCreate()'.
*
* Returns : none
*********************************************************************************************************
*/
static void AppTaskKbd (void *p_arg)
{
CPU_BOOLEAN b1_prev;
CPU_BOOLEAN b1;
CPU_BOOLEAN b2_prev;
CPU_BOOLEAN b2;
CPU_INT08U key;
(void)p_arg;
b1_prev = DEF_FALSE;
b2_prev = DEF_FALSE;
key = 1;
while (DEF_TRUE) {
b1 = PB_GetStatus(1);
b2 = PB_GetStatus(2);
if (b1 == DEF_TRUE && b1_prev == DEF_FALSE) {
if (key == 4) {
key = 1;
} else {
key++;
}
OSMboxPost(AppUserIFMbox, (void *)key);
}
if (b2 == DEF_TRUE && b2_prev == DEF_FALSE) {
LCD_LightToggle();
}
b1_prev = b1;
b2_prev = b2;
OSTimeDlyHMSM(0, 0, 0, 20);
}
}
/*
*********************************************************************************************************
* DISPLAY SCREENS
*
* Descrition: These functions each display one of the screens used in the demonstration.
*
* Arguments : none
*
* Returns : none
*********************************************************************************************************
*/
#if (uC_LCD_MODULE > 0)
static void AppDispScr_SignOn (void)
{
OS_StrCopy(AppLCDLine1, "Micrium uC/OS-II");
OS_StrCopy(AppLCDLine2, "STMicro STM32");
DispStr(0, 0, AppLCDLine1);
DispStr(1, 0, AppLCDLine2);
}
static void AppDispScr_VersionTickRate (void)
{
CPU_INT32U value;
OS_StrCopy(AppLCDLine1, "uC/OS-II: Vx.yy");
value = (CPU_INT32U)OSVersion();
AppLCDLine1[12] = value / 100 + '0';
AppLCDLine1[14] = (value % 100) / 10 + '0';
AppLCDLine1[15] = (value % 10) + '0';
OS_StrCopy(AppLCDLine2, "TickRate: xxxx");
value = (CPU_INT32U)OS_TICKS_PER_SEC;
AppFormatDec(&AppLCDLine2[12], value, 4);
DispStr(0, 0, AppLCDLine1);
DispStr(1, 0, AppLCDLine2);
}
static void AppDispScr_CPU (void)
{
CPU_INT32U value;
OS_StrCopy(AppLCDLine1, "CPU Usage:xx % ");
value = (CPU_INT32U)OSCPUUsage;
AppLCDLine1[10] = (value / 10) + '0';
AppLCDLine1[11] = (value % 10) + '0';
OS_StrCopy(AppLCDLine2, "CPU Speed:xx MHz");
value = (CPU_INT32U)BSP_CPU_ClkFreq() / 1000000L;
AppLCDLine2[10] = (value / 10) + '0';
AppLCDLine2[11] = (value % 10) + '0';
DispStr(0, 0, AppLCDLine1);
DispStr(1, 0, AppLCDLine2);
}
static void AppDispScr_CtxSw (void)
{
CPU_INT32U value;
OS_StrCopy(AppLCDLine1, "#Ticks: xxxxxxxx");
value = (CPU_INT32U)OSTime;
AppFormatDec(AppLCDLine1 + 8, value, 8);
OS_StrCopy(AppLCDLine2, "#CtxSw: xxxxxxxx");
value = (CPU_INT32U)OSCtxSwCtr;
AppFormatDec(AppLCDLine2 + 8, value, 8);
DispStr(0, 0, AppLCDLine1);
DispStr(1, 0, AppLCDLine2);
}
#endif
/*
*********************************************************************************************************
* STRING OUTPUT TASK
*
* Description : This task constantly output a string via the uC/Probe general communication module.
*
* Arguments : p_arg is the argument passed to 'AppTaskProbeStr()' by 'OSTaskCreate()'.
*
* Returns : none
*********************************************************************************************************
*/
#if (uC_PROBE_COM_MODULE > 0) && \
(PROBE_COM_SUPPORT_STR > 0)
static void AppTaskProbeStr (void *p_arg)
{
CPU_INT32U i;
static CPU_CHAR buffer[64];
i = 0;
while (DEF_TRUE) {
Str_Copy(buffer, "String Tx #xxxxx\n");
AppFormatDec(&buffer[11], i, 5);
i++;
ProbeCom_TxStr(buffer, 100);
OSTimeDlyHMSM(0, 0, 1, 0);
}
}
#endif
/*
*********************************************************************************************************
* uC/Probe Callback
*
* Description : This task is called by the uC/Probe uC/OS-II plug-in after updating task information.
*
* Arguments : none.
*
* Returns : none
*********************************************************************************************************
*/
#if (uC_PROBE_OS_PLUGIN > 0)
static void AppProbeCallback (void)
{
#if (uC_PROBE_COM_MODULE > 0) && \
(PROBE_COM_STAT_EN > 0)
CPU_INT32U ctr_curr;
CPU_INT32U rx_curr;
CPU_INT32U tx_curr;
CPU_INT32U rxpkt_curr;
CPU_INT32U txpkt_curr;
CPU_INT32U sym_curr;
CPU_INT32U symbyte_curr;
#endif
Probe_Counts++;
Probe_B1 = PB_GetStatus(1);
Probe_B2 = PB_GetStatus(2);
Probe_B3 = PB_GetStatus(3);
Probe_B_WakeUp = PB_GetStatus(4);
Probe_ADC = (ADC_GetStatus(1) * 100) / 0x1000;
#if (uC_PROBE_COM_MODULE > 0) && \
(PROBE_COM_STAT_EN > 0)
ctr_curr = OSTime;
rxpkt_curr = ProbeRS232_RxPktCtr;
txpkt_curr = ProbeRS232_TxPktCtr;
rx_curr = ProbeRS232_RxCtr;
tx_curr = ProbeRS232_TxCtr;
sym_curr = ProbeCom_TxSymCtr;
symbyte_curr = ProbeCom_TxSymByteCtr;
if ((ctr_curr - Probe_ComCtrLast) >= OS_TICKS_PER_SEC) {
Probe_RS232RxSpd = ((CPU_FP32)(rx_curr - Probe_RS232RxLast) / (ctr_curr - Probe_ComCtrLast)) * OS_TICKS_PER_SEC;
Probe_RS232TxSpd = ((CPU_FP32)(tx_curr - Probe_RS232TxLast) / (ctr_curr - Probe_ComCtrLast)) * OS_TICKS_PER_SEC;
Probe_ComRxPktSpd = ((CPU_FP32)(rxpkt_curr - Probe_ComRxPktLast) / (ctr_curr - Probe_ComCtrLast)) * OS_TICKS_PER_SEC;
Probe_ComTxPktSpd = ((CPU_FP32)(txpkt_curr - Probe_ComTxPktLast) / (ctr_curr - Probe_ComCtrLast)) * OS_TICKS_PER_SEC;
Probe_ComTxSymSpd = ((CPU_FP32)(sym_curr - Probe_ComTxSymLast) / (ctr_curr - Probe_ComCtrLast)) * OS_TICKS_PER_SEC;
Probe_ComTxSymByteSpd = ((CPU_FP32)(symbyte_curr - Probe_ComTxSymByteLast) / (ctr_curr - Probe_ComCtrLast)) * OS_TICKS_PER_SEC;
Probe_ComCtrLast = ctr_curr;
Probe_RS232RxLast = rx_curr;
Probe_RS232TxLast = tx_curr;
Probe_ComRxPktLast = rxpkt_curr;
Probe_ComTxPktLast = txpkt_curr;
Probe_ComTxSymLast = sym_curr;
Probe_ComTxSymByteLast = symbyte_curr;
}
#endif
}
#endif
/*
*********************************************************************************************************
* FORMAT A DECIMAL VALUE
*
* Description: This function converts a decimal value to ASCII (with leading zeros)
*
* Arguments : s is a pointer to the destination ASCII string
* value is the value to convert (assumes an unsigned value)
* digits is the desired number of digits
*
* Returns : none
*********************************************************************************************************
*/
static void AppFormatDec (CPU_INT08U *s, CPU_INT32U value, CPU_INT08U digits)
{
CPU_INT08U i;
CPU_INT32U mult;
mult = 1;
for (i = 0; i < (digits - 1); i++) {
mult *= 10;
}
while (mult > 0) {
*s++ = value / mult + '0';
value %= mult;
mult /= 10;
}
}
/*
*********************************************************************************************************
* APPLICATION-DEFINED HOOKS
*
* Description: These functions are called by the hooks in os_cpu_c.c.
*
* Returns : none
*********************************************************************************************************
*/
#if (OS_APP_HOOKS_EN > 0)
void App_TaskCreateHook (OS_TCB *ptcb)
{
#if (uC_PROBE_OS_PLUGIN > 0) && (OS_PROBE_HOOKS_EN > 0)
OSProbe_TaskCreateHook(ptcb);
#endif
}
void App_TaskDelHook (OS_TCB *ptcb)
{
(void)ptcb;
}
#if OS_VERSION >= 251
void App_TaskIdleHook (void)
{
}
#endif
void App_TaskStatHook (void)
{
}
#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
#if OS_VERSION >= 204
void App_TCBInitHook (OS_TCB *ptcb)
{
(void)ptcb;
}
#endif
#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 + -