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

📄 app.c

📁 编译环境是 iar EWARM ,STM32 下的UCOSII
💻 C
📖 第 1 页 / 共 3 页
字号:
*
* Caller(s)   : App_TaskStart().
*
* Note(s)     : none.
*********************************************************************************************************
*/

#if ((APP_PROBE_COM_EN == DEF_ENABLED) || \
     (APP_OS_PROBE_EN  == DEF_ENABLED))
static  void  App_InitProbe (void)
{
#if (APP_OS_PROBE_EN        == DEF_ENABLED)
    (void)App_ProbeCounts;
    (void)App_ProbeB1;
    (void)App_ProbeJoystickCenter;
    (void)App_ProbeJoystickDown;
    (void)App_ProbeJoystickLeft;
    (void)App_ProbeJoystickRight;
    (void)App_ProbeJoystickUp;

#if ((APP_PROBE_COM_EN      == DEF_ENABLED) && \
     (PROBE_COM_STAT_EN     == DEF_ENABLED))
    (void)App_ProbeComRxPktSpd;
    (void)App_ProbeComTxPktSpd;
    (void)App_ProbeComTxSymSpd;
    (void)App_ProbeComTxSymByteSpd;
#endif

    OSProbe_Init();
    OSProbe_SetCallback(App_ProbeCallback);
    OSProbe_SetDelay(250);
#endif

#if (APP_PROBE_COM_EN       == DEF_ENABLED)
    ProbeCom_Init();                                            /* Initialize the uC/Probe communications module.       */
#if (PROBE_COM_METHOD_RS232 == DEF_ENABLED)
    ProbeRS232_Init(115200);
    ProbeRS232_RxIntEn();
#endif
#endif
}
#endif


/*
*********************************************************************************************************
*                                         AppProbeCallback()
*
* Description : uC/Probe OS plugin callback.
*
* Argument(s) : none.
*
* Return(s)   : none.
*
* Caller(s)   : uC/Probe OS plugin task.
*
* Note(s)     : none.
*********************************************************************************************************
*/

#if (APP_OS_PROBE_EN == DEF_ENABLED)
static  void  App_ProbeCallback (void)
{

#if ((APP_PROBE_COM_EN  == DEF_ENABLED) && \
     (PROBE_COM_STAT_EN == DEF_ENABLED))
    CPU_INT32U  ctr_curr;
    CPU_INT32U  rxpkt_curr;
    CPU_INT32U  txpkt_curr;
    CPU_INT32U  sym_curr;
    CPU_INT32U  symbyte_curr;
#endif
    CPU_INT32U  joystick;


    App_ProbeCounts++;

    App_ProbeB1             = BSP_PB_GetStatus(1);

    joystick                = BSP_Joystick_GetStatus();
    App_ProbeJoystickCenter = DEF_BIT_IS_SET(joystick, BSP_JOYSTICK_CENTER);
    App_ProbeJoystickDown   = DEF_BIT_IS_SET(joystick, BSP_JOYSTICK_DOWN);
    App_ProbeJoystickLeft   = DEF_BIT_IS_SET(joystick, BSP_JOYSTICK_LEFT);
    App_ProbeJoystickRight  = DEF_BIT_IS_SET(joystick, BSP_JOYSTICK_RIGHT);
    App_ProbeJoystickUp     = DEF_BIT_IS_SET(joystick, BSP_JOYSTICK_UP);


#if ((APP_PROBE_COM_EN  == DEF_ENABLED) && \
     (PROBE_COM_STAT_EN == DEF_ENABLED))
    ctr_curr     = OSTime;
    rxpkt_curr   = ProbeCom_RxPktCtr;
    txpkt_curr   = ProbeCom_TxPktCtr;
    sym_curr     = ProbeCom_TxSymCtr;
    symbyte_curr = ProbeCom_TxSymByteCtr;

    if ((ctr_curr - App_ProbeComCtrLast) >= OS_TICKS_PER_SEC) {
        App_ProbeComRxPktSpd      = ((CPU_FP32)(rxpkt_curr   - App_ProbeComRxPktLast)     / (ctr_curr - App_ProbeComCtrLast)) * OS_TICKS_PER_SEC;
        App_ProbeComTxPktSpd      = ((CPU_FP32)(txpkt_curr   - App_ProbeComTxPktLast)     / (ctr_curr - App_ProbeComCtrLast)) * OS_TICKS_PER_SEC;
        App_ProbeComTxSymSpd      = ((CPU_FP32)(sym_curr     - App_ProbeComTxSymLast)     / (ctr_curr - App_ProbeComCtrLast)) * OS_TICKS_PER_SEC;
        App_ProbeComTxSymByteSpd  = ((CPU_FP32)(symbyte_curr - App_ProbeComTxSymByteLast) / (ctr_curr - App_ProbeComCtrLast)) * OS_TICKS_PER_SEC;

        App_ProbeComCtrLast       = ctr_curr;
        App_ProbeComRxPktLast     = rxpkt_curr;
        App_ProbeComTxPktLast     = txpkt_curr;
        App_ProbeComTxSymLast     = sym_curr;
        App_ProbeComTxSymByteLast = symbyte_curr;
    }
#endif
}
#endif


/*
*********************************************************************************************************
*                                      App_FormatDec()
*
* Description : Convert a decimal value to ASCII (without leading zeros).
*
* Argument(s) : pstr            Pointer to the destination ASCII string.
*
*               value           Value to convert (assumes an unsigned value).
*
*               digits          The desired number of digits.
*
* Return(s)   : none.
*
* Caller(s)   : various.
*
* Note(s)     : none.
*********************************************************************************************************
*/

static  void  App_FormatDec (CPU_INT08U *pstr, CPU_INT32U value, CPU_INT08U digits)
{
    CPU_INT08U   i;
    CPU_INT32U   mult;
    CPU_BOOLEAN  found;
    CPU_INT32U   nbr;


    found = DEF_NO;
    mult  = 1;
    for (i = 0; i < (digits - 1); i++) {
        mult *= 10;
    }
    while (mult > 0) {
        nbr = value / mult;
        if (found == DEF_NO) {
            if (nbr != 0) {
                found = DEF_YES;
                *pstr = nbr + '0';
            } else{
                if (mult == 1) {
                    *pstr = '0';
                } else {
                    *pstr = ' ';
                }
            }
        } else {
            *pstr = nbr + '0';
        }
        pstr++;
        value %= mult;
        mult  /= 10;
    }
}


/*
*********************************************************************************************************
*********************************************************************************************************
*                                          uC/OS-II APP HOOKS
*********************************************************************************************************
*********************************************************************************************************
*/

#if (OS_APP_HOOKS_EN > 0)
/*
*********************************************************************************************************
*                                      TASK CREATION HOOK (APPLICATION)
*
* Description : This function is called when a task is created.
*
* Argument(s) : ptcb   is a pointer to the task control block of the task being created.
*
* Note(s)     : (1) Interrupts are disabled during this call.
*********************************************************************************************************
*/

void  App_TaskCreateHook (OS_TCB *ptcb)
{
#if ((APP_OS_PROBE_EN   == DEF_ENABLED) && \
     (OS_PROBE_HOOKS_EN == DEF_ENABLED))
    OSProbe_TaskCreateHook(ptcb);
#endif
}

/*
*********************************************************************************************************
*                                    TASK DELETION HOOK (APPLICATION)
*
* Description : This function is called when a task is deleted.
*
* Argument(s) : ptcb   is a pointer to the task control block of the task being deleted.
*
* Note(s)     : (1) Interrupts are disabled during this call.
*********************************************************************************************************
*/

void  App_TaskDelHook (OS_TCB *ptcb)
{
    (void)ptcb;
}

/*
*********************************************************************************************************
*                                      IDLE TASK HOOK (APPLICATION)
*
* Description : This function is called by OSTaskIdleHook(), which is called by the idle task.  This hook
*               has been added to allow you to do such things as STOP the CPU to conserve power.
*
* Argument(s) : none.
*
* Note(s)     : (1) Interrupts are enabled during this call.
*********************************************************************************************************
*/

#if OS_VERSION >= 251
void  App_TaskIdleHook (void)
{
}
#endif

/*
*********************************************************************************************************
*                                        STATISTIC TASK HOOK (APPLICATION)
*
* Description : This function is called by OSTaskStatHook(), which is called every second by uC/OS-II's
*               statistics task.  This allows your application to add functionality to the statistics task.
*
* Argument(s) : none.
*********************************************************************************************************
*/

void  App_TaskStatHook (void)
{
}

/*
*********************************************************************************************************
*                                        TASK SWITCH HOOK (APPLICATION)
*
* Description : This function is called when a task switch is performed.  This allows you to perform other
*               operations during a context switch.
*
* Argument(s) : none.
*
* Note(s)     : (1) Interrupts are disabled during this call.
*
*               (2) It is assumed that the global pointer 'OSTCBHighRdy' points to the TCB of the task that
*                   will be 'switched in' (i.e. the highest priority task) and, 'OSTCBCur' points to the
*                  task being switched out (i.e. the preempted task).
*********************************************************************************************************
*/

#if OS_TASK_SW_HOOK_EN > 0
void  App_TaskSwHook (void)
{
#if ((APP_OS_PROBE_EN   == DEF_ENABLED) && \
     (OS_PROBE_HOOKS_EN == DEF_ENABLED))
    OSProbe_TaskSwHook();
#endif
}
#endif

/*
*********************************************************************************************************
*                                     OS_TCBInit() HOOK (APPLICATION)
*
* Description : This function is called by OSTCBInitHook(), which is called by OS_TCBInit() after setting
*               up most of the TCB.
*
* Argument(s) : ptcb    is a pointer to the TCB of the task being created.
*
* Note(s)     : (1) Interrupts may or may not be ENABLED during this call.
*********************************************************************************************************
*/

#if OS_VERSION >= 204
void  App_TCBInitHook (OS_TCB *ptcb)
{
    (void)ptcb;
}
#endif

/*
*********************************************************************************************************
*                                        TICK HOOK (APPLICATION)
*
* Description : This function is called every tick.
*
* Argument(s) : none.
*
* Note(s)     : (1) Interrupts may or may not be ENABLED during this call.
*********************************************************************************************************
*/

#if OS_TIME_TICK_HOOK_EN > 0
void  App_TimeTickHook (void)
{
#if ((APP_OS_PROBE_EN   == DEF_ENABLED) && \
     (OS_PROBE_HOOKS_EN == DEF_ENABLED))
    OSProbe_TickHook();
#endif
}
#endif
#endif

⌨️ 快捷键说明

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