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

📄 bsp.c

📁 Micrium提供的专门针对ucos操作系统的TCP/IP协议栈 ucip
💻 C
📖 第 1 页 / 共 2 页
字号:
    }
}




/*
*********************************************************************************************************
*********************************************************************************************************
*                             uC/Probe PLUG-IN FOR uC/OS-II FUNCTIONS
*********************************************************************************************************
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                       OSProbe_TmrInit()
*
* Description : Select & initialize a timer for use with the uC/Probe Plug-In for uC/OS-II.
*
* Argument(s) : none.
*
* Return(s)   : none.
*********************************************************************************************************
*/

#if ((uC_PROBE_OS_PLUGIN == DEF_ENABLED) && \
     (OS_PROBE_HOOKS_EN  == DEF_ENABLED))
void  OSProbe_TmrInit (void)
{
#if 0 /* Copied from AT91SAM7X256 -- TBD : refactor to work on CSB637 AT91RM9200 */
    AT91C_BASE_PMC->PMC_PCER        =  1 << AT91C_ID_TC2;       /* Enable the peripheral clk                                */
    AT91C_BASE_TCB->TCB_TC2.TC_CCR  =  DEF_BIT_01;              /* TC2 timer disabled                                       */
    AT91C_BASE_TCB->TCB_TC2.TC_CMR &= ~(7 <<  0);               /* TIMER_CLOCK1 is input clk                                */
    AT91C_BASE_TCB->TCB_TC2.TC_CCR  =  DEF_BIT_00;              /* TC2 timer enabled                                        */
    AT91C_BASE_TCB->TCB_TC2.TC_CCR  =  DEF_BIT_02;              /* SWTRG to reset and start                                 */
#endif
}
#endif


/*
*********************************************************************************************************
*                                        OSProbe_TmrRd()
*
* Description : Read the current counts of a 32-bit free running timer.
*
* Argument(s) : none.
*
* Return(s)   : The 32bit counts of the timer.
*********************************************************************************************************
*/

#if ((uC_PROBE_OS_PLUGIN == DEF_ENABLED) && \
     (OS_PROBE_HOOKS_EN  == DEF_ENABLED))
CPU_INT32U  OSProbe_TmrRd (void)
{
    CPU_INT32U  cnts;


#if 0 /* Copied from AT91SAM7X256 -- TBD : refactor to work on CSB637 AT91RM9200 */
    cnts = (CPU_INT32U)(AT91C_BASE_TCB->TCB_TC2.TC_CV & 0x0000FFFF);    /* Read timer 2                                     */
#else
    cnts = 0;
#endif

    return (cnts);
}
#endif


/*
*********************************************************************************************************
*                                          LED INITIALIZATION
*
* Description : This function should be called by your application code before you make use of any of the
*               functions found in this module.
*
* Arguments   : None.
*********************************************************************************************************
*/

void  LED_Init (void)
{
    LED_On(0);                                                  /* Turn ON all the LEDs.                                */
}


/*
*********************************************************************************************************
*                                                LED OFF
*
* Description : This function is used to control any or all the LEDs on the board.
*
* Arguments   : led    is the number of the LED to turn OFF
*                      0    indicates that you want ALL the LEDs to be OFF
*                      1    turns OFF User LED0 on the board
*                      .
*                      .
*                      3    turns OFF User LED2 on the board
*********************************************************************************************************
*/

void  LED_Off (CPU_INT08U  led)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
    CPU_SR  cpu_sr;
#endif


    CPU_CRITICAL_ENTER();

    switch (led) {
        case 0:
             BSP_CSB_ARM_LED_RegImage &= ~DEF_BIT_02;
             break;

        case 1:
             BSP_CSB_ARM_LED_RegImage &= ~DEF_BIT_02;
             break;
    }

   *AT91C_PIOB_SODR =  BSP_CSB_ARM_LED_RegImage & DEF_BIT_02;
   *AT91C_PIOB_CODR = ~BSP_CSB_ARM_LED_RegImage & DEF_BIT_02;

    CPU_CRITICAL_EXIT();
}


/*
*********************************************************************************************************
*                                                LED ON
*
* Description : This function is used to control any or all the LEDs on the board.
*
* Arguments   : led    is the number of the LED to control
*                      0    indicates that you want ALL the LEDs to be ON
*                      1    turns ON User LED 0 on the board
*                      .
*                      .
*                      3    turns ON User LED 2 on the board
*********************************************************************************************************
*/

void  LED_On (CPU_INT08U  led)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
    CPU_SR  cpu_sr;
#endif


    CPU_CRITICAL_ENTER();

    switch (led) {
        case 0:
             BSP_CSB_ARM_LED_RegImage |= DEF_BIT_02;
             break;

        case 1:
             BSP_CSB_ARM_LED_RegImage |= DEF_BIT_02;
             break;
    }

   *AT91C_PIOB_SODR =  BSP_CSB_ARM_LED_RegImage & DEF_BIT_02;
   *AT91C_PIOB_CODR = ~BSP_CSB_ARM_LED_RegImage & DEF_BIT_02;

    CPU_CRITICAL_EXIT();
}


/*
*********************************************************************************************************
*                                              LED TOGGLE
*
* Description : This function is used to alternate the state of any LED.
*
* Arguments   : led    is the number of the LED to control
*                      0    indicates that you want ALL the LEDs to toggle
*                      1    toggle User LED 0 on the board
*                      .
*                      .
*                      3    toggle User LED 2 on the board
*********************************************************************************************************
*/

void  LED_Toggle (CPU_INT08U  led)
{
#if (CPU_CFG_CRITICAL_METHOD == CPU_CRITICAL_METHOD_STATUS_LOCAL)
    CPU_SR  cpu_sr;
#endif


    CPU_CRITICAL_ENTER();

    switch (led) {
        case 0:
             BSP_CSB_ARM_LED_RegImage ^= DEF_BIT_02;
             break;

        case 1:
             BSP_CSB_ARM_LED_RegImage ^= DEF_BIT_02;
             break;
    }

   *AT91C_PIOB_SODR =  BSP_CSB_ARM_LED_RegImage & DEF_BIT_02;
   *AT91C_PIOB_CODR = ~BSP_CSB_ARM_LED_RegImage & DEF_BIT_02;

    CPU_CRITICAL_EXIT();
}


/*
*********************************************************************************************************
*                                       GET 'PUSH BUTTON' STATUS
*
* Description : This function is used to get the status of any push button on the board.
*
* Arguments   : push_button    is the number of the push button to probe
*                              1    probe the push button 0
*                              .
*                              .
*                              3    probe the push button 2
*********************************************************************************************************
*/

CPU_BOOLEAN  PB_GetStatus (CPU_INT08U  push_button)
{
    CPU_BOOLEAN  status;


    switch (push_button) {
        case 1:
             status = ((*AT91C_PIOB_PDSR & DEF_BIT_29) == 0);
             break;

        default:
             status = DEF_OFF;
             break;
    }

    return (status);
}


/*
*********************************************************************************************************
*                                              SERIAL READ
*
* Description : Read a string from serial port until end-of-line.
*
* Arguments   : string      pre-allocated string to write to.
*               len         maximum len of string.
*********************************************************************************************************
*/

void  Ser_RdStr (CPU_CHAR    *string,
                 CPU_INT32U   len)
{
    CPU_CHAR  input;
    CPU_CHAR  input_ix;


    input_ix  = 0;
    string[0] = 0;

    while (DEF_TRUE)
    {
        input = mon_getchar();

        if ((input == '\r') ||
            (input == '\n')) {
            APP_TRACE_INFO(("\n"));
            string[input_ix] = 0;
            break;
        }

        if (input == '\b') {
            if (input_ix > 0) {
                APP_TRACE_INFO(("\b \b"));
                input_ix--;
                string[input_ix] = 0;
            }
        }

        if (Str_IsPrint(input)) {
            APP_TRACE_INFO(("%c", input));
            string[input_ix] = input;
            input_ix++;
            if (input_ix >= len) {
                input_ix  = len;
            }
        }
    }
}

⌨️ 快捷键说明

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