⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 app.c

📁 uCOS-II V2.84 LM3S6965 TCPIP Demo
💻 C
📖 第 1 页 / 共 2 页
字号:
    Probe_B3 = DEF_FALSE;
    Probe_B4 = DEF_FALSE;
    Probe_B5 = DEF_FALSE;

    while (DEF_TRUE) {
        level    = 0;
        Probe_B1 = PB_GetStatus(1);
        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 == APP_USER_IF_MAX) {
                key = 1;
            } else {
                key++;
            }
            OSMboxPost(AppUserIFMbox, (void *)key);
        }

        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++;
        }

        if (Probe_B1 == DEF_TRUE) {
            level += 5;
        }
        if (Probe_B2 == DEF_TRUE) {
            level += 15;
        }
        if (Probe_B3 == DEF_TRUE) {
            level += 15;
        }
        if (Probe_B4 == DEF_TRUE) {
            level += 15;
        }
        if (Probe_B5 == DEF_TRUE) {
            level += 15;
        }

        if (level != 0) {
            Buzzer_SetLevel(level);
            Buzzer_On();
        } else {
            Buzzer_Off();
        }

        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

#if (uC_PROBE_COM_MODULE   > 0) && \
    (PROBE_COM_SUPPORT_STR > 0)

    OSTaskCreateExt(AppTaskProbeStr,
                    (void *)0,
                    (OS_STK *)&AppTaskProbeStrStk[APP_TASK_PROBE_STR_STK_SIZE - 1],
                    APP_TASK_PROBE_STR_PRIO,
                    APP_TASK_PROBE_STR_PRIO,
                    (OS_STK *)&AppTaskProbeStrStk[0],
                    APP_TASK_PROBE_STR_STK_SIZE,
                    (void *)0,
                    OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);

#if (OS_TASK_NAME_SIZE > 9)
    OSTaskNameSet(APP_TASK_PROBE_STR_PRIO, "Probe Str", &err);
#endif
#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[15], 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 * 15, ROW2_Y, 11);
    } else {
        OSRAM128x64x4StringDraw((char *)str, 6 * 15, ROW2_Y,  2);
    }

    if (Probe_B3 == DEF_TRUE) {
        OSRAM128x64x4StringDraw((char *)AppUserIFLine4, 0, ROW3_Y, 11);
    } else {
        OSRAM128x64x4StringDraw((char *)AppUserIFLine4, 0, ROW3_Y,  2);
    }
}

#if (uC_PROBE_COM_MODULE   > 0) && \
    (PROBE_COM_STAT_EN     > 0)
static  void  AppDispScr_Probe (void)
{
    CPU_INT32U    value;


    Str_Copy(AppUserIFLine1, "  Rx:  yyyyyyyyyy   ");
    value = (CPU_INT32U)ProbeRS232_RxCtr;
    AppFormatDec(&AppUserIFLine1[7], value, 10);

    Str_Copy(AppUserIFLine2, "  RxPkt: xxxxxxxx   ");
    value = (CPU_INT32U)ProbeCom_RxPktCtr;
    AppFormatDec(&AppUserIFLine2[9], value, 8);

    Str_Copy(AppUserIFLine3, "  Tx:  yyyyyyyyyy   ");
    value = (CPU_INT32U)ProbeRS232_TxCtr;
    AppFormatDec(&AppUserIFLine3[7], value, 10);

    Str_Copy(AppUserIFLine4, "  TxPkt: xxxxxxxx   ");
    value = (CPU_INT32U)ProbeCom_TxPktCtr;
    AppFormatDec(&AppUserIFLine4[9], 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);
}
#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;
    }
}

static  void  AppFormatHex (CPU_INT08U *s, CPU_INT32U value, CPU_INT08U digits)
{
    CPU_INT08U  i;
    CPU_INT32U  mult;
    CPU_INT32U  temp;


    mult = 1;
    for (i = 0; i < (digits - 1); i++) {
        mult *= 16;
    }
    while (mult > 0) {
        temp = value / mult;

        switch (temp) {
            case 0:
            case 1:
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
                *s++ = temp + '0';
                break;

            case 10:
                *s++ = 'A';
                break;

            case 11:
                *s++ = 'B';
                break;

            case 12:
                *s++ = 'C';
                break;

            case 13:
                *s++ = 'D';
                break;

            case 14:
                *s++ = 'E';
                break;

            case 15:
                *s++ = 'F';
                break;
        }

        value %= mult;
        mult  /= 16;
    }
}

void  __error__(char *pcFilename, unsigned long ulLine)
{
    ;
}


/*
*********************************************************************************************************
*                                   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 + -