打印

请大家给我指点一下

[复制链接]
2837|1
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
jackbao|  楼主 | 2008-4-15 19:21 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
/*
*********************************************************************************************************
*                                              EXAMPLE CODE
*
*                          (c) Copyright 2003-2006; Micrium, Inc.; Weston, FL
*
*               All rights reserved.  Protected by international copyright laws.
*               Knowledge of the source code may NOT be used to develop a similar product.
*               Please help us continue to provide the Embedded community with the finest
*               software available.  Your honesty is greatly appreciated.
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*
*                                            EXAMPLE CODE
*
*                                     ST Microelectronics STM32
*                                              with the
*                                   STM3210B-EVAL Evaluation Board
*
* Filename      : app.c
* Version       : V1.00
* Programmer(s) : Brian Nagel
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                             INCLUDE FILES
*********************************************************************************************************
*/

#include <includes.h>


/*
*********************************************************************************************************
*                                            LOCAL DEFINES
*********************************************************************************************************
*/

#define  APP_LINE_0                0
#define  APP_LINE_1               24
#define  APP_LINE_2               48
#define  APP_LINE_3               72
#define  APP_LINE_4               96
#define  APP_LINE_5              120
#define  APP_LINE_6              144
#define  APP_LINE_7              168
#define  APP_LINE_8              192
#define  APP_LINE_9              216

#define  COLOR_WHITE          0xFFFF
#define  COLOR_BLACK          0x0000
#define  COLOR_BLUE           0x001F
#define  COLOR_BLUE2          0x051F
#define  COLOR_RED            0xF800
#define  COLOR_MAGENTA        0xF81F
#define  COLOR_GREEN          0x07E0
#define  COLOR_CYAN           0x7FFF
#define  COLOR_YELLOW         0xFFE0

/*
*********************************************************************************************************
*                                       LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/

                                                                /* ----------------- APPLICATION GLOBALS ------------------ */
static  OS_STK          AppTaskStartStk[APP_TASK_START_STK_SIZE];
static  OS_STK          AppTaskUserIFStk[APP_TASK_USER_IF_STK_SIZE];
static  OS_STK          AppTaskKbdStk[APP_TASK_KBD_STK_SIZE];

static  OS_EVENT       *AppUserIFMbox;

static  CPU_CHAR        AppLCDLine0[21];
static  CPU_CHAR        AppLCDLine1[21];
static  CPU_CHAR        AppLCDLine2[21];
static  CPU_CHAR        AppLCDLine3[21];
static  CPU_CHAR        AppLCDLine4[21];
static  CPU_CHAR        AppLCDLine5[21];
static  CPU_CHAR        AppLCDLine6[21];
static  CPU_CHAR        AppLCDLine7[21];
static  CPU_CHAR        AppLCDLine8[21];
static  CPU_CHAR        AppLCDLine9[21];

                                                                /* -------------- uC/PROBE RELATED GLOBALS ---------------- */
#if (uC_PROBE_OS_PLUGIN > 0)
volatile  CPU_INT32U    Probe_Counts;
volatile  CPU_BOOLEAN   Probe_B1;
volatile  CPU_BOOLEAN   Probe_JoyLeft;
volatile  CPU_BOOLEAN   Probe_JoyRight;
volatile  CPU_BOOLEAN   Probe_JoyUp;
volatile  CPU_BOOLEAN   Probe_JoyDown;
volatile  CPU_BOOLEAN   Probe_JoyCenter;
volatile  CPU_INT16U    Probe_ADC;
#endif

#if (uC_PROBE_COM_MODULE   > 0) && \
    (PROBE_COM_SUPPORT_STR > 0)
static  OS_STK          AppTaskProbeStrStk[APP_TASK_PROBE_STR_STK_SIZE];
#endif

#if (uC_PROBE_OS_PLUGIN    > 0) && \
    (uC_PROBE_COM_MODULE   > 0) && \
    (PROBE_COM_STAT_EN     > 0)
static  CPU_FP32        Probe_RS232RxSpd;
static  CPU_FP32        Probe_RS232TxSpd;
static  CPU_FP32        Probe_ComRxPktSpd;
static  CPU_FP32        Probe_ComTxPktSpd;
static  CPU_FP32        Probe_ComTxSymSpd;
static  CPU_FP32        Probe_ComTxSymByteSpd;

static  CPU_INT32U      Probe_RS232RxLast;
static  CPU_INT32U      Probe_RS232TxLast;
static  CPU_INT32U      Probe_ComRxPktLast;
static  CPU_INT32U      Probe_ComTxPktLast;
static  CPU_INT32U      Probe_ComTxSymLast;
static  CPU_INT32U      Probe_ComTxSymByteLast;

static  CPU_INT32U      Probe_ComCtrLast;
#endif


/*
*********************************************************************************************************
*                                      LOCAL FUNCTION PROTOTYPES
*********************************************************************************************************
*/

static  void            AppTaskCreate               (void);
static  void            AppTaskStart                (void *p_arg);

static  void            AppTaskUserIF               (void *p_arg);
static  void            AppTaskKbd                  (void *p_arg);

static  void            AppDispScr_SignOn           (void);
static  void            AppDispScr_TaskNames        (void);

#if (uC_PROBE_OS_PLUGIN > 0)
static  void            AppProbeCallback            (void);
#endif

#if (uC_PROBE_COM_MODULE   > 0) && \
    (PROBE_COM_SUPPORT_STR > 0)
static  void            AppTaskProbeStr             (void *p_arg);
#endif

static  void            AppFormatDec                (CPU_INT08U *s, CPU_INT32U value, CPU_INT08U digits);

/*
*********************************************************************************************************
*                                                main()
*
* Description : This is the standard entry point for C code.  It is assumed that your code will call
*               main() once you have performed all necessary initialization.
*
* Arguments   : none
*
* Returns     : none
*********************************************************************************************************
*/

int  main (void)
{
    CPU_INT08U  err;


    BSP_IntDisAll();                                            /* Disable all interrupts until we are ready to accept them */

    OSInit();                                                   /* Initialize "uC/OS-II, The Real-Time Kernel"              */

    OSTaskCreateExt(AppTaskStart,                               /* Create the start task                                    */
                    (void *)0,
                    (OS_STK *)&AppTaskStartStk[APP_TASK_START_STK_SIZE - 1],
                    APP_TASK_START_PRIO,
                    APP_TASK_START_PRIO,
                    (OS_STK *)&AppTaskStartStk[0],
                    APP_TASK_START_STK_SIZE,
                    (void *)0,
                    OS_TASK_OPT_STK_CHK | OS_TASK_OPT_STK_CLR);

#if (OS_TASK_NAME_SIZE > 13)
    OSTaskNameSet(APP_TASK_START_PRIO, "Start Task", &err);
#endif

    OSStart();                                                  /* Start multitasking (i.e. give control to uC/OS-II)       */
}


/*
*********************************************************************************************************
*                                          STARTUP TASK
*
* Description : This is an example of a startup task.  As mentioned in the book's text, you MUST
*               initialize the ticker only once multitasking has started.
*
* Arguments   : p_arg   is the argument passed to 'AppTaskStart()' by 'OSTaskCreate()'.
*
* Returns     : none
*
* 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.
*********************************************************************************************************
*/

static  void  AppTaskStart (void *p_arg)
{
    CPU_INT32U  i;
    CPU_INT32U  j;


    (void)p_arg;

    BSP_Init();                                                 /* Initialize BSP functions                                 */

#if (OS_TASK_STAT_EN > 0)
    OSStatInit();                                               /* Determine CPU capacity                                   */
#endif

#if (uC_PROBE_COM_MODULE > 0)
    ProbeCom_Init();                                            /* Initialize the uC/Probe communications module            */
    ProbeRS232_Init(115200);
    ProbeRS232_RxIntEn();
#endif

#if (uC_PROBE_OS_PLUGIN > 0)
#if (uC_PROBE_COM_MODULE   > 0) && \
    (PROBE_COM_STAT_EN     > 0)
    Probe_RS232RxSpd       = 0;
    Probe_RS232TxSpd       = 0;
    Probe_ComRxPktSpd      = 0;
    Probe_ComTxPktSpd      = 0;
    Probe_ComTxSymSpd      = 0;
    Probe_ComTxSymByteSpd  = 0;

    Probe_RS232RxLast      = 0;
    Probe_RS232TxLast      = 0;
    Probe_ComRxPktLast     = 0;
    Probe_ComTxPktLast     = 0;
    Probe_ComTxSymLast     = 0;
    Probe_ComTxSymByteLast = 0;

    Probe_ComCtrLast       = 0;
#endif

    OSProbe_Init();
    OSProbe_SetCallback(AppProbeCallback);
    OSProbe_SetDelay(50);
#endif

    AppUserIFMbox = OSMboxCreate((void *)0);                    /* Create MBOX for communication between Kbd and UserIF     */

    AppTaskCreate();                                            /* Create application tasks                                 */

    while (DEF_TRUE) {                                          /* Task body, always written as an infinite loop.           */
        for (j = 0; j < 4; j++) {
            for (i = 1; i <= 4; i++) {
                LED_On(i);
                OSTimeDlyHMSM(0, 0, 1, 50);
                LED_Off(i);
                OSTimeDlyHMSM(0, 0, 1, 50);
            }

            for (i = 3; i >= 2; i--) {
                LED_On(i);
                OSTimeDlyHMSM(0, 0, 1, 50);
                LED_Off(i);
                OSTimeDlyHMSM(0, 0, 2, 50);
            }
        }

        for (i = 0; i < 4; i++) {
            LED_On(0);
            OSTimeDlyHMSM(0, 0, 0, 200);
            LED_Off(0);
            OSTimeDlyHMSM(0, 0, 0, 200);
        }
    }
}


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


/*
*********************************************************************************************************
*                                         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();
    OSTimeDlyHMSM(0, 0, 1, 0);
    nstate = 1;
    pstate = 1;


    while (DEF_TRUE) {
        msg = (CPU_INT08U *)(OSMboxPend(AppUserIFMbox, OS_TICKS_PER_SEC / 10, &err));
        if (err == OS_NO_ERR) {
            nstate = (CPU_INT32U)msg;
        }

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

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

            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  b1;
    CPU_INT08U   key;


    (void)p_arg;

    b1_prev = DEF_FALSE;
    key     = 1;

    while (DEF_TRUE) {
        b1 = PB_GetStatus(1);

        if (b1 == DEF_TRUE && b1_prev == DEF_FALSE) {
            if (key == 2) {
                key = 1;
            } else {
                key++;
            }

            OSMboxPost(AppUserIFMbox, (void *)key);
        }

        b1_prev = b1;

        OSTimeDlyHMSM(0, 0, 0, 20);
    }
}


/*
*********************************************************************************************************
*                                    PRINT SYSTEM INFORMATION ON LCD
*
* Description: This function displays uC/OS-II system information on the LCD.
*
* Argument(s): None
*
* Returns    : None
*********************************************************************************************************
*/

static  void  AppDispScr_SignOn (void)
{
    CPU_INT32U  value;


    Str_Copy(AppLCDLine0, "  Micrium uC/OS-II  ");
    Str_Copy(AppLCDLine1, "ST STM32 (Cortex-M3)");

    Str_Copy(AppLCDLine2, "                    ");

    Str_Copy(AppLCDLine3, "  uC/OS-II:  Vx.yy  ");
    value           = (CPU_INT32U)OSVersion();
    AppLCDLine3[14] = value / 100 + '0';
    AppLCDLine3[16] = (value % 100) / 10 + '0';
    AppLCDLine3[17] = (value %  10) + '0';

    Str_Copy(AppLCDLine4, "  TickRate:   xxxx  ");
    value = (CPU_INT32U)OS_TICKS_PER_SEC;
    AppFormatDec(&AppLCDLine4[14], value, 4);

    Str_Copy(AppLCDLine5, "  CPU Usage:xx %    ");
    value           = (CPU_INT32U)OSCPUUsage;
    AppLCDLine5[12] = (value / 10) + '0';
    AppLCDLine5[13] = (value % 10) + '0';

    Str_Copy(AppLCDLine6, "  CPU Speed:xx MHz  ");
    value           = (CPU_INT32U)BSP_CPU_ClkFreq() / 1000000L;
    AppLCDLine6[12] = (value / 10) + '0';
    AppLCDLine6[13] = (value % 10) + '0';

    Str_Copy(AppLCDLine7, "  #Ticks: xxxxxxxx  ");
    value = (CPU_INT32U)OSTime;
    AppFormatDec(&AppLCDLine7[10], value, 8);

    Str_Copy(AppLCDLine8, "  #CtxSw: xxxxxxxx  ");
    value = (CPU_INT32U)OSCtxSwCtr;
    AppFormatDec(&AppLCDLine8[10], value, 8);

    Str_Copy(AppLCDLine9, "                    ");

    LCD_SetTextColor(COLOR_BLUE);
    LCD_DisplayString(APP_LINE_0, AppLCDLine0);
    LCD_DisplayString(APP_LINE_1, AppLCDLine1);
    LCD_SetTextColor(COLOR_BLACK);
    LCD_DisplayString(APP_LINE_2, AppLCDLine2);
    LCD_DisplayString(APP_LINE_3, AppLCDLine3);
    LCD_DisplayString(APP_LINE_4, AppLCDLine4);
    LCD_DisplayString(APP_LINE_5, AppLCDLine5);
    LCD_DisplayString(APP_LINE_6, AppLCDLine6);
    LCD_DisplayString(APP_LINE_7, AppLCDLine7);
    LCD_DisplayString(APP_LINE_8, AppLCDLine8);
}


static  void  AppDispScr_TaskNames (void)
{
    CPU_INT08U   idx;
    OS_TCB      *ptcb;
    CPU_CHAR    *line;
    CPU_INT08U   value;


    ptcb    = &OSTCBTbl[0];
    idx     = 0;

    Str_Copy(AppLCDLine0, "  Micrium uC/OS-II  ");
    Str_Copy(AppLCDLine1, "ST STM32 (Cortex-M3)");

    Str_Copy(AppLCDLine2, "  Prio   Taskname   ");

    while (ptcb != NULL) {

        value = ptcb->OSTCBPrio;

        switch (idx) {
            case 0:
                 line = AppLCDLine3;
                 break;

            case 1:
                 line = AppLCDLine4;
                 break;

            case 2:
                 line = AppLCDLine5;
                 break;

            case 3:
                 line = AppLCDLine6;
                 break;

            case 4:
                 line = AppLCDLine7;
                 break;

            case 5:
                 line = AppLCDLine8;
                 break;

            case 6:
                 line = AppLCDLine9;
                 break;

            default:
                 line = (CPU_CHAR *)0;
                 break;
        }

        if (line == (CPU_CHAR *)0) {
            break;
        }

        line[0] = ' ';
        line[1] = ' ';
        line[2] = ' ';
        line[3] = value / 10 + '0';
        line[4] = value % 10 + '0';
        line[5] = ' ';
        Str_Copy_N(line + 6, ptcb->OSTCBTaskName, 14);

        ptcb        = ptcb->OSTCBPrev;
        idx++;
    }

    if (idx < 6) {
        Str_Copy(AppLCDLine9, "                    ");
    }

    if (idx < 5) {
        Str_Copy(AppLCDLine8, "                    ");
    }

    if (idx < 4) {
        Str_Copy(AppLCDLine7, "                    ");
    }

    if (idx < 3) {
        Str_Copy(AppLCDLine6, "                    ");
    }

    LCD_SetTextColor(COLOR_BLUE);
    LCD_DisplayString(APP_LINE_0, AppLCDLine0);
    LCD_DisplayString(APP_LINE_1, AppLCDLine1);
    LCD_SetTextColor(COLOR_RED);
    LCD_DisplayString(APP_LINE_2, AppLCDLine2);
    LCD_SetTextColor(COLOR_BLACK);
    LCD_DisplayString(APP_LINE_3, AppLCDLine3);
    LCD_DisplayString(APP_LINE_4, AppLCDLine4);
    LCD_DisplayString(APP_LINE_5, AppLCDLine5);
    LCD_DisplayString(APP_LINE_6, AppLCDLine6);
    LCD_DisplayString(APP_LINE_7, AppLCDLine7);
    LCD_DisplayString(APP_LINE_8, AppLCDLine8);
    LCD_DisplayString(APP_LINE_9, AppLCDLine9);
}


/*
*********************************************************************************************************
*                                         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
    CPU_INT32U  joystick;


    Probe_Counts++;

    Probe_B1 = PB_GetStatus(1);

    joystick = Joystick_GetStatus();

    if ((joystick & JOYSTICK_LEFT) == JOYSTICK_LEFT) {
        Probe_JoyLeft = DEF_TRUE;
    } else {
        Probe_JoyLeft = DEF_FALSE;
    }

    if ((joystick & JOYSTICK_RIGHT) == JOYSTICK_RIGHT) {
        Probe_JoyRight = DEF_TRUE;
    } else {
        Probe_JoyRight = DEF_FALSE;
    }

    if ((joystick & JOYSTICK_UP) == JOYSTICK_UP) {
        Probe_JoyUp = DEF_TRUE;
    } else {
        Probe_JoyUp = DEF_FALSE;
    }

    if ((joystick & JOYSTICK_DOWN) == JOYSTICK_DOWN) {
        Probe_JoyDown = DEF_TRUE;
    } else {
        Probe_JoyDown = DEF_FALSE;
    }

    if ((joystick & JOYSTICK_CENTER) == JOYSTICK_CENTER) {
        Probe_JoyCenter = DEF_TRUE;
    } else {
        Probe_JoyCenter = DEF_FALSE;
    }

#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)
沙发
short_long| | 2008-4-17 19:20 | 只看该作者

why

大哥,到底看什么??

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

92

主题

260

帖子

0

粉丝