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

📄 copy of bsp.c

📁 ucos+ucgui+proteus仿真lpc2138.非常强大的例子。用keil for arm 编译。值得下载。强烈推荐。
💻 C
📖 第 1 页 / 共 3 页
字号:
    IO0CLR = value;

    DispDly_uS(100);
    DispE_Low();
}

#if DISP_BUS_WIDTH == 4
void DispDataWrOneNibble(CPU_INT08U data)
{
    CPU_INT32U  value;


    DispRW_Low();                                               /* Set R/W write LOW to write to the LCD module             */

    DispE_High();                                               /* Write the UPPER nibble to the LCD module                 */
    value  =  ((data >> 4) & 0x0F) << 10;

    IO0SET = value;
    value  = (~(data >> 4) & 0x0F) << 10;
    IO0CLR = value;

    DispDly_uS(100);
    DispE_Low();
}
#endif

#endif


/*
*********************************************************************************************************
*                                               DispDly_uS()
*
* Description : Delay for the specified number of microseconds.
*
* Argument(s) : us      Number of microseconds
*
* Return(s)   : none.
*********************************************************************************************************
*/

#ifdef DISP_MODULE_PRESENT
void  DispDly_uS (CPU_INT32U us)
{
    CPU_INT32U  us_per_tick;
    CPU_INT32U  ticks;


    us_per_tick = 1000000L / OS_TICKS_PER_SEC;
    ticks       = us / us_per_tick + 1;
    OSTimeDly(ticks);
}
#endif


/*
*********************************************************************************************************
*                                            DispSel()
*
* Description : Change the Register Select control line to the LCD controller to select either
*               command or data register.
*
* Argument(s) : sel         Indicates whether command or data register should be selected:
*                           DISP_SEL_CMD_REG    select command register
*                           DISP_SEL_DATA_REG   select data    register
*
* Return(s)   : none.
*********************************************************************************************************
*/

#ifdef DISP_MODULE_PRESENT
void  DispSel (CPU_INT08U sel)
{
    if (sel == DISP_SEL_CMD_REG) {
        IO0CLR = GPIO0_LCD_RS;                                  /* Select the command register (RS low)                     */
    } else {
        IO0SET = GPIO0_LCD_RS;                                  /* Select the data    register (RS high)                    */
    }
}
#endif


/*
*********************************************************************************************************
*                                      DISPLAY CONTROL LINE FUNCTIONS
*********************************************************************************************************
*/

#ifdef DISP_MODULE_PRESENT
static  void  DispE_High (void)
{
    IO0SET = GPIO0_LCD_E;
}


static  void  DispE_Low (void)
{
    IO0CLR = GPIO0_LCD_E;
}


static  void  DispRW_High (void)
{
    IO0SET = GPIO0_LCD_RW;
}


static  void  DispRW_Low (void)
{
    IO0CLR = GPIO0_LCD_RW;
}
#endif


/*
*********************************************************************************************************
*********************************************************************************************************
**                                       PB, LED, AND ADC FUNCTIONS
*********************************************************************************************************
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                             LED_Init()
*
* Description : Setup the I/O for the LEDs.
*
* Argument(s) : none.
*
* Return(s)   : none.
*********************************************************************************************************
*/

void  LED_Init (void)
{
    LED_Off(0);                                                 /* Turn OFF all the LEDs                                    */
}


/*
*********************************************************************************************************
*                                             LED_On()
*
* Description : Turn ON any or all the LEDs on the board.
*
* Argument(s) : led     The ID of the LED to control:
*
*                       0    turn ON all LEDs on the board
*                       1    turn ON LCD backlight
*
* Return(s)   : none.
*********************************************************************************************************
*/

void  LED_On (CPU_INT08U led)
{
    switch (led) {
        case 0:
        case 1:
             IO0SET = GPIO0_PWM5;
             break;
        default:
             break;
    }
}


/*
*********************************************************************************************************
*                                             LED_Off()
*
* Description : Turn OFF any or all the LEDs on the board.
*
* Argument(s) : led     The ID of the LED to control:
*
*                       0    turn OFF all LEDs on the board
*                       1    turn OFF LCD backlight
*
* Return(s)   : none.
*********************************************************************************************************
*/

void  LED_Off (CPU_INT08U led)
{
    switch (led) {
        case 0:
        case 1:
             IO0CLR = GPIO0_PWM5;
             break;
        default:
             break;
    }
}


/*
*********************************************************************************************************
*                                             LED_Toggle()
*
* Description : TOGGLE any or all the LEDs on the board.
*
* Argument(s) : led     The ID of the LED to control:
*
*                       0    TOGGLE all LEDs on the board
*                       1    TOGGLE LCD backlight
*
* Return(s)   : none.
*********************************************************************************************************
*/

void  LED_Toggle (CPU_INT08U led)
{
    CPU_INT32U  are_off;
    CPU_INT32U  are_on;


    switch (led) {
        case 0:
        case 1:
             are_off =  IO0PIN ^ GPIO0_PWM5;
             are_on  = ~IO0PIN ^ GPIO0_PWM5;
             IO0CLR  =  are_on;
             IO0SET  =  are_off;
             break;
    }
}


/*
*********************************************************************************************************
*                                         PB_GetStatus()
*
* Description : Get the status of a push button on the board.
*
* Argument(s) : pb      The ID of the push button to probe
*
*                       1    probe the push button B1
*                       2    probe the push button B2
*
* Return(s)   : DEF_FALSE   if the push button is pressed
*               DEF_TRUE    if the push button is not pressed
*********************************************************************************************************
*/

CPU_BOOLEAN  PB_GetStatus (CPU_INT08U pb)
{
    CPU_BOOLEAN  status;


    status = DEF_FALSE;

    switch (pb) {
        case 1:
             if ((IO0PIN & GPIO0_B1) == 0) {
                 return (DEF_TRUE);
             }
             break;

        case 2:
             if ((IO0PIN & GPIO0_B2) == 0) {
                 return (DEF_TRUE);
             }
             break;

        default:
             break;
    }

    return (status);
}


/*
*********************************************************************************************************
*                                         ADC_Init()
*
* Description : Initializes the board's ADC.
*
* Argument(s) : none.
*
* Return(s)   : none.
*********************************************************************************************************
*/

static  void  ADC_Init (void)
{
    CPU_INT08U  div;
    CPU_INT32U  pinsel;


    div      = (BSP_CPU_PclkFreq() / 4500000) + 1;
                                                                /* Configure ADC ...                                        */
    AD0CR    = (0x01 <<  0)                                     /*  ... Sample/convert pin AD0.0 ...                        */
             | (div  <<  8)                                     /*  ... Set divider so sample freq. < 4.5 MHz ...           */
             | (   1 << 16)                                     /*  ... Use burst mode for continuous conversion ...        */
             | (0x00 << 17)                                     /*  ... Use 11 clocks per conversion for 10-bit accuracy ...*/
             | (   1 << 21);                                    /*  ... Power up the ADC.                                   */

                                                                /* Select AD0.0 function for PIN0.27                        */
    pinsel   = PINSEL1;
    pinsel  &= ~0x00C00000;
    pinsel  |=  0x00400000;
    PINSEL1  =  pinsel;

    AD0CR   |=  (0x01 << 24);                                   /* Start conversion                                         */
}


/*
*********************************************************************************************************
*                                           ADC_GetStatus()
*
* Description : This function initializes the board's ADC
*
* Argument(s) : adc     The ID of the ADC to probe:
*                       1   Probe the potentiometer.
*
* Return(s)   : The numerator of the binary fraction representing the result of the latest ADC conversion.
*               This value will be a 10-bit value between 0x0000 and 0x03FF, inclusive.
*********************************************************************************************************
*/

CPU_INT16U  ADC_GetStatus (CPU_INT08U  adc)
{
    if (adc == 1) {
        return ((AD0DR1 >> 6) & 0x03FF);
    } else {
        return (0);
    }
}


/*
*********************************************************************************************************
*********************************************************************************************************
**                                          uC/OS-View FUNCTIONS
*********************************************************************************************************
*********************************************************************************************************
*/

/*
*********************************************************************************************************
*                                              OSView_TmrInit()
*
* Description : Select & initialize a timer for use with uC/OS-View.
*
* Argument(s) : none.
*
* Return(s)   : none.
*********************************************************************************************************
*/

#if (OS_VIEW_MODULE > 0)
void  OSView_TmrInit (void)
{
    T1PR  = 0;
    T1TCR = 0x00000001;                                         /* Enable the timer                                         */

}
#endif


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

#if (OS_VIEW_MODULE > 0)
CPU_INT32U  OSView_TmrRd (void)
{
    return ((CPU_INT32U)T1TC);
}

⌨️ 快捷键说明

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