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

📄 app.c

📁 uCOS-II V2.84 LM3S6965 TCPIP Demo
💻 C
📖 第 1 页 / 共 3 页
字号:
        AppFormatHex(&buffer[24], ProbeRS232_TxPktCtr, 5);
        AppFormatHex(&buffer[30], ProbeRS232_TxCtr,    7);
        ProbeCom_TxStr(buffer, 100);
        OSTimeDlyHMSM(0, 0, 1, 0);

#if (uC_PROBE_OS_PLUGIN    > 0)
        Str_Copy(buffer, "RXSpd wwww/yyyyy --- TXSpd xxxx/zzzzz\n");
        AppFormatDec(&buffer[6],  (CPU_INT32U)Probe_ComRxPktSpd, 4);
        AppFormatDec(&buffer[11], (CPU_INT32U)Probe_RS232RxSpd,  5);
        AppFormatDec(&buffer[27], (CPU_INT32U)Probe_ComTxPktSpd, 4);
        AppFormatDec(&buffer[32], (CPU_INT32U)Probe_RS232TxSpd,  5);
        ProbeCom_TxStr(buffer, 100);
        OSTimeDlyHMSM(0, 0, 1, 0);

        Str_Copy(buffer, "Sym wwwwwwww/yyyy --- Byte wwwwwwww/yyyy\n");
        AppFormatDec(&buffer[4],  (CPU_INT32U)ProbeCom_TxSymCtr,     8);
        AppFormatDec(&buffer[13], (CPU_INT32U)Probe_ComTxSymSpd,     4);
        AppFormatDec(&buffer[27], (CPU_INT32U)ProbeCom_TxSymByteCtr, 8);
        AppFormatDec(&buffer[36], (CPU_INT32U)Probe_ComTxSymByteSpd, 4);
        ProbeCom_TxStr(buffer, 100);
        OSTimeDlyHMSM(0, 0, 1, 0);
#endif
#endif
    }
}
#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;
    CPU_INT32U  tmr_freq;
#endif

    Probe_Counts++;

#if (uC_PROBE_COM_MODULE   > 0) && \
    (PROBE_COM_STAT_EN     > 0)
    ctr_curr     = OSProbe_TmrRd();
    rxpkt_curr   = ProbeRS232_RxPktCtr;
    txpkt_curr   = ProbeRS232_TxPktCtr;
    rx_curr      = ProbeRS232_RxCtr;
    tx_curr      = ProbeRS232_TxCtr;
    sym_curr     = ProbeCom_TxSymCtr;
    symbyte_curr = ProbeCom_TxSymByteCtr;
    tmr_freq     = SysCtlClockGet();

    if ((ctr_curr - Probe_ComCtrLast) >= tmr_freq / 10) {

        Probe_RS232RxSpd      = ((CPU_FP32)(rx_curr      - Probe_RS232RxLast)      / (ctr_curr - Probe_ComCtrLast)) * tmr_freq;
        Probe_RS232TxSpd      = ((CPU_FP32)(tx_curr      - Probe_RS232TxLast)      / (ctr_curr - Probe_ComCtrLast)) * tmr_freq;
        Probe_ComRxPktSpd     = ((CPU_FP32)(rxpkt_curr   - Probe_ComRxPktLast)     / (ctr_curr - Probe_ComCtrLast)) * tmr_freq;
        Probe_ComTxPktSpd     = ((CPU_FP32)(txpkt_curr   - Probe_ComTxPktLast)     / (ctr_curr - Probe_ComCtrLast)) * tmr_freq;
        Probe_ComTxSymSpd     = ((CPU_FP32)(sym_curr     - Probe_ComTxSymLast)     / (ctr_curr - Probe_ComCtrLast)) * tmr_freq;
        Probe_ComTxSymByteSpd = ((CPU_FP32)(symbyte_curr - Probe_ComTxSymByteLast) / (ctr_curr - Probe_ComCtrLast)) * tmr_freq;

        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


/*
*********************************************************************************************************
*                                         USER INTERFACE TASK
*
* Description : This task updates the LCD screen based on messages passed to it by AppTaskKbd().
*
* Arguments   : p_arg   is the argument passed to 'AppStartUserIF()' by 'OSTaskCreate()'.
*
* Returns     : none
*********************************************************************************************************
*/

static  void  AppTaskUserIF (void *p_arg)
{
    CPU_INT08U  *msg;
    CPU_INT08U   err;
    CPU_INT32U   nstate;
    CPU_INT32U   pstate;


    (void)p_arg;

    AppDispScr_SignOn();
    OSTimeDly(OS_TICKS_PER_SEC * 2);
    pstate = 1;
    nstate = 2;


    while (DEF_TRUE) {                                          /* Task body, always written as an infinite loop.           */
        msg = (CPU_INT08U *)(OSMboxPend(AppUserIFMbox, OS_TICKS_PER_SEC / 10, &err));
        if (err == OS_NO_ERR) {
            nstate = (CPU_INT32U)msg;
        }

        if (nstate != pstate) {
            OSRAM128x64x4Clear();
            pstate  = nstate;
        }

        switch (nstate) {
            case 2:
                 AppDispScr_VersionTickRateCPU();
                 break;

            case 3:
                 AppDispScr_CtxSw();
                 break;

            case 4:
                 AppDispScr_Inputs();
                 break;

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

            case 5:
                AppDispScr_Probe();
                break;

#if (uC_TCPIP_MODULE     > 0)
            case 6:
                 AppDispScr_Tcpip();
                 break;
#endif
#else

#if (uC_TCPIP_MODULE     > 0)
            case 5:
                 AppDispScr_Tcpip();
                 break;
#endif
#endif

            case 1:
            default:
                 AppDispScr_SignOn();
                 break;
        }
    }
}


/*
*********************************************************************************************************
*                                    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  b2_prev;
    CPU_BOOLEAN  b3_prev;
    CPU_BOOLEAN  b4_prev;
    CPU_BOOLEAN  b5_prev;
    CPU_INT08U   key;
    CPU_INT08U   level;


    (void)p_arg;

    key      = 1;
    level    = 0;

    b1_prev  = DEF_FALSE;
    b2_prev  = DEF_FALSE;
    b3_prev  = DEF_FALSE;
    b4_prev  = DEF_FALSE;
    b5_prev  = DEF_FALSE;

    Probe_B1 = DEF_FALSE;
    Probe_B2 = DEF_FALSE;
    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)
{

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -