📄 app.c
字号:
Probe_B2 = PB_GetStatus(2);
Probe_B3 = PB_GetStatus(3);
Probe_B4 = PB_GetStatus(4);
Probe_B5 = PB_GetStatus(5);
if (Probe_B1 == DEF_TRUE && b1_prev == DEF_FALSE) {
Probe_B1Counts++;
if (key == 4) {
key = 0;
} else {
key++;
}
AppUserIFState = key;
OSMboxPost(AppUserIFMbox, &AppUserIFState);
}
if (Probe_B2 == DEF_TRUE && b2_prev == DEF_FALSE) {
Probe_B2Counts++;
}
if (Probe_B3 == DEF_TRUE && b3_prev == DEF_FALSE) {
Probe_B3Counts++;
}
if (Probe_B4 == DEF_TRUE && b4_prev == DEF_FALSE) {
Probe_B4Counts++;
}
if (Probe_B5 == DEF_TRUE && b5_prev == DEF_FALSE) {
Probe_B5Counts++;
}
b1_prev = Probe_B1;
b2_prev = Probe_B2;
b3_prev = Probe_B3;
b4_prev = Probe_B4;
b5_prev = Probe_B5;
OSTimeDly(OS_TICKS_PER_SEC / 20);
}
}
/*
*********************************************************************************************************
* CREATE APPLICATION TASKS
*
* Description: This function creates the application tasks.
*
* Arguments : none
*
* Returns : none
*********************************************************************************************************
*/
static void AppTaskCreate (void)
{
CPU_INT08U err;
OSTaskCreateExt(AppTaskUserIF,
(void *)0,
(OS_STK *)&AppTaskUserIFStk[APP_TASK_USER_IF_STK_SIZE - 1],
APP_TASK_USER_IF_PRIO,
APP_TASK_USER_IF_PRIO,
(OS_STK *)&AppTaskUserIFStk[0],
APP_TASK_USER_IF_STK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
#if (OS_TASK_NAME_SIZE > 8)
OSTaskNameSet(APP_TASK_USER_IF_PRIO, "User I/F", &err);
#endif
OSTaskCreateExt(AppTaskKbd,
(void *)0,
(OS_STK *)&AppTaskKbdStk[APP_TASK_KBD_STK_SIZE - 1],
APP_TASK_KBD_PRIO,
APP_TASK_KBD_PRIO,
(OS_STK *)&AppTaskKbdStk[0],
APP_TASK_KBD_STK_SIZE,
(void *)0,
OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);
#if (OS_TASK_NAME_SIZE > 8)
OSTaskNameSet(APP_TASK_KBD_PRIO, "Keyboard", &err);
#endif
}
/*
*********************************************************************************************************
* DISPLAY SCREENS
*
* Descrition: These functions each display one of the screens used in the demonstration.
*
* Arguments : none
*
* Returns : none
*********************************************************************************************************
*/
static void AppDispScr_SignOn (void)
{
Str_Copy(AppUserIFLine1, " Micrium uC/OS-II ");
Str_Copy(AppUserIFLine2, "on the LuminaryMicro");
Str_Copy(AppUserIFLine3, " EK-LM3S6965 ");
Str_Copy(AppUserIFLine4, " (ARM Cortex-M3) ");
OSRAM128x64x4StringDraw((char *)AppUserIFLine1, 0, ROW0_Y, 11);
OSRAM128x64x4StringDraw((char *)AppUserIFLine2, 0, ROW1_Y, 8);
OSRAM128x64x4StringDraw((char *)AppUserIFLine3, 0, ROW2_Y, 5);
OSRAM128x64x4StringDraw((char *)AppUserIFLine4, 0, ROW3_Y, 2);
}
static void AppDispScr_VersionTickRateCPU (void)
{
CPU_INT32U value;
Str_Copy(AppUserIFLine1, " uC/OS-II: Vx.yy ");
value = (CPU_INT32U)OSVersion();
AppUserIFLine1[14] = value / 100 + '0';
AppUserIFLine1[16] = (value % 100) / 10 + '0';
AppUserIFLine1[17] = (value % 10) + '0';
Str_Copy(AppUserIFLine2, " TickRate: xxxx Hz ");
value = (CPU_INT32U)OS_TICKS_PER_SEC;
AppFormatDec(&AppUserIFLine2[12], value, 4);
Str_Copy(AppUserIFLine3, " CPU Usage: xxx % ");
value = (CPU_INT32U)OSCPUUsage;
AppUserIFLine3[13] = (value / 100) + '0';
AppUserIFLine3[14] = (value % 100) / 10 + '0';
AppUserIFLine3[15] = (value ) % 10 + '0';
Str_Copy(AppUserIFLine4, " CPU Speed: xx MHz ");
value = (CPU_INT32U)SysCtlClockGet() / 1000000L;
AppUserIFLine4[13] = (value / 10) + '0';
AppUserIFLine4[14] = (value % 10) + '0';
OSRAM128x64x4StringDraw((char *)AppUserIFLine1, 0, ROW0_Y, 11);
OSRAM128x64x4StringDraw((char *)AppUserIFLine2, 0, ROW1_Y, 8);
OSRAM128x64x4StringDraw((char *)AppUserIFLine3, 0, ROW2_Y, 5);
OSRAM128x64x4StringDraw((char *)AppUserIFLine4, 0, ROW3_Y, 2);
}
static void AppDispScr_CtxSw (void)
{
CPU_INT32U value;
Str_Copy(AppUserIFLine1, " Number of Ticks: ");
Str_Copy(AppUserIFLine2, " xxxxxxxx ");
value = (CPU_INT32U)OSTime;
AppFormatDec(&AppUserIFLine2[6], value, 8);
Str_Copy(AppUserIFLine3, "Num. of Context Sw.:");
Str_Copy(AppUserIFLine4, " xxxxxxxx ");
value = (CPU_INT32U)OSCtxSwCtr;
AppFormatDec(&AppUserIFLine4[6], value, 8);
OSRAM128x64x4StringDraw((char *)AppUserIFLine1, 0, ROW0_Y, 11);
OSRAM128x64x4StringDraw((char *)AppUserIFLine2, 0, ROW1_Y, 11);
OSRAM128x64x4StringDraw((char *)AppUserIFLine3, 0, ROW2_Y, 8);
OSRAM128x64x4StringDraw((char *)AppUserIFLine4, 0, ROW3_Y, 8);
}
static void AppDispScr_Inputs (void)
{
CPU_INT32U value;
CPU_CHAR str[4];
Str_Copy(AppUserIFLine1, " Button Status: ");
Str_Copy(AppUserIFLine2, " xxx ");
value = (CPU_INT32U)Probe_B2Counts;
AppFormatDec(&AppUserIFLine2[9], value, 3);
Str_Copy(AppUserIFLine3, " yyy xxx zzz ");
value = (CPU_INT32U)Probe_B4Counts;
AppFormatDec(&AppUserIFLine3[3], value, 3);
value = (CPU_INT32U)Probe_B1Counts;
AppFormatDec(&AppUserIFLine3[9], value, 3);
value = (CPU_INT32U)Probe_B5Counts;
AppFormatDec(&AppUserIFLine3[16], value, 3);
Str_Copy(AppUserIFLine4, " xxx ");
value = (CPU_INT32U)Probe_B3Counts;
AppFormatDec(&AppUserIFLine4[9], value, 3);
OSRAM128x64x4StringDraw((char *)AppUserIFLine1, 0, ROW0_Y, 11);
if (Probe_B2 == DEF_TRUE) {
OSRAM128x64x4StringDraw((char *)AppUserIFLine2, 0, ROW1_Y, 11);
} else {
OSRAM128x64x4StringDraw((char *)AppUserIFLine2, 0, ROW1_Y, 2);
}
Str_Copy(str, " ");
value = (CPU_INT32U)Probe_B4Counts;
AppFormatDec(&str[0], value, 3);
if (Probe_B4 == DEF_TRUE) {
OSRAM128x64x4StringDraw((char *)str, 6 * 3, ROW2_Y, 11);
} else {
OSRAM128x64x4StringDraw((char *)str, 6 * 3, ROW2_Y, 2);
}
Str_Copy(str, " ");
value = (CPU_INT32U)Probe_B1Counts;
AppFormatDec(&str[0], value, 3);
if (Probe_B1 == DEF_TRUE) {
OSRAM128x64x4StringDraw((char *)str, 6 * 9, ROW2_Y, 11);
} else {
OSRAM128x64x4StringDraw((char *)str, 6 * 9, ROW2_Y, 2);
}
Str_Copy(str, " ");
value = (CPU_INT32U)Probe_B5Counts;
AppFormatDec(&str[0], value, 3);
if (Probe_B5 == DEF_TRUE) {
OSRAM128x64x4StringDraw((char *)str, 6 * 16, ROW2_Y, 11);
} else {
OSRAM128x64x4StringDraw((char *)str, 6 * 16, ROW2_Y, 2);
}
if (Probe_B3 == DEF_TRUE) {
OSRAM128x64x4StringDraw((char *)AppUserIFLine4, 0, ROW3_Y, 11);
} else {
OSRAM128x64x4StringDraw((char *)AppUserIFLine4, 0, ROW3_Y, 2);
}
}
static void AppDispScr_Tcpip (void)
{
Str_Copy(AppUserIFLine1, " Total TX Packets ");
Str_Copy(AppUserIFLine2, " xxxxxxxx ");
AppFormatDec(&AppUserIFLine2[6], NetNIC_StatTxPktCtr, 8);
Str_Copy(AppUserIFLine3, " Total RX Packets ");
Str_Copy(AppUserIFLine4, " xxxxxxxx ");
AppFormatDec(&AppUserIFLine4[6], NetNIC_StatRxPktCtr, 8);
if (NetNIC_ConnStatus == DEF_OFF) {
OSRAM128x64x4StringDraw((char *)AppUserIFLine1, 0, ROW0_Y, 3);
OSRAM128x64x4StringDraw((char *)AppUserIFLine2, 0, ROW1_Y, 3);
OSRAM128x64x4StringDraw((char *)AppUserIFLine3, 0, ROW2_Y, 3);
OSRAM128x64x4StringDraw((char *)AppUserIFLine4, 0, ROW3_Y, 3);
} else {
OSRAM128x64x4StringDraw((char *)AppUserIFLine1, 0, ROW0_Y, 11);
OSRAM128x64x4StringDraw((char *)AppUserIFLine2, 0, ROW1_Y, 11);
OSRAM128x64x4StringDraw((char *)AppUserIFLine3, 0, ROW2_Y, 11);
OSRAM128x64x4StringDraw((char *)AppUserIFLine4, 0, ROW3_Y, 11);
}
}
/*
*********************************************************************************************************
* uC/OS-VIew Terminal Window Callback
*
* Description : This is the callback function for uC/OS-View
*
* Arguments : rx_data is the received data.
*
* Returns : none
*********************************************************************************************************
*/
#if (OS_VIEW_MODULE > 0)
static void AppTerminalRx (CPU_INT08U rx_data)
{
}
#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;
}
}
void __error__(char *pcFilename, unsigned long ulLine)
{
;
}
void __program_start(void)
{
;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -