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

📄 bsp.c

📁 基于 Philips 公司的 ARM-7 使用之 uC/OS-II 作业系统,此例程是移植于 LPC-2138 上的应用,不同于一般的 Porting 其最主要是加入了支援 OS_View 观察器功能
💻 C
📖 第 1 页 / 共 3 页
字号:
    value    = ~((3 << 10) | (3 << 14) | (3 << 20) | (3 << 30));
    PINSEL1 &= value;
    value    = LCD_BIT_DATA3 | LCD_BIT_DATA2 | LCD_BIT_DATA1 | LCD_BIT_DATA0 | LCD_BIT_E | LCD_BIT_RS | LCD_BIT_RW;
#if __VER__ == 420
    IODIR0  |= value;
    IODIR0  |= 1 << 21;                                         /* LCD Backlight control                                    */
#else
    IO0DIR  |= value;
    IO0DIR  |= 1 << 21;                                         /* LCD Backlight control                                    */
#endif

#ifdef DISP_MODULE_PRESENT
    DispRW_High();
#endif
}


/*$PAGE*/
/*
*********************************************************************************************************
*                                      WRITE DATA TO DISPLAY DEVICE
*
* Description : This function sends a single BYTE to the display device.
* Arguments   : 'data'  is the BYTE to send to the display device
* Returns     : none
* Notes       : 1) The LPC2138 evaluation board uses a 4 bit interface.
*                  If an 8 bit interface is used. BSP_IO_Init() and DispDataWr() will need
*                  to be modified to reflect the new databus. In 8 bit mode, DispDataWrOneNibble()
*                  is not necessary.
*********************************************************************************************************
*/

#ifdef DISP_MODULE_PRESENT
void  DispDataWr (INT8U 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;
#if __VER__ == 420
    IOSET0 = value;
    value  = (~(data >> 4) & 0x0F) << 10;
    IOCLR0 = value;
#else
    IO0SET = value;
    value  = (~(data >> 4) & 0x0F) << 10;
    IO0CLR = value;
#endif
    DispDly_uS(100);
    DispE_Low();

    DispDly_uS(100);                                            /* Write the LOWER nibble to the LCD module                 */
    DispE_High();
    value  =  (data & 0x0F) << 10;
#if __VER__ == 420
    IOSET0 = value;
    value  = (~data & 0x0F) << 10;
    IOCLR0 = value;
#else
    IO0SET = value;
    value  = (~data & 0x0F) << 10;
    IO0CLR = value;
#endif
    DispDly_uS(100);
    DispE_Low();
}

#if DISP_BUS_WIDTH == 4
void DispDataWrOneNibble(INT8U 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;
#if __VER__ == 420
    IOSET0 = value;
    value  = (~(data >> 4) & 0x0F) << 10;
    IOCLR0 = value;
#else
    IO0SET = value;
    value  = (~(data >> 4) & 0x0F) << 10;
    IO0CLR = value;
#endif
    DispDly_uS(100);
    DispE_Low();
}
#endif

#endif

/*
*********************************************************************************************************
*                                               DELAY
*
* Description : This function is called to delay for the specified number of microseconds.
*
* Arguments   : us      Number of microseconds
*
* Returns     : none
*********************************************************************************************************
*/

#ifdef DISP_MODULE_PRESENT
void  DispDly_uS (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

/*
*********************************************************************************************************
*                                  INITIALIZE DISPLAY DRIVER I/O PORTS
*
* Description : This initializes the I/O ports used by the display driver.
*
* Arguments   : none
*
* Returns     : none
*
* Note(s)     : 1) The I/Os for the LCD module are initialized in BSP_IO_Init().
*********************************************************************************************************
*/

#ifdef DISP_MODULE_PRESENT
void  DispInitPort (void)
{
}
#endif

/*
*********************************************************************************************************
*                                   SELECT COMMAND OR DATA REGISTER
*
* Description : This changes the Register Select control line to the LCD controller.
* Arguments   : none
*********************************************************************************************************
*/

#ifdef DISP_MODULE_PRESENT
void  DispSel (INT8U sel)
{
#if __VER__ == 420
    if (sel == DISP_SEL_CMD_REG) {
        IOCLR0 = LCD_BIT_RS;                                    /* Select the command register (RS low)                     */
    } else {
        IOSET0 = LCD_BIT_RS;                                    /* Select the data    register (RS high)                    */
    }
#else
    if (sel == DISP_SEL_CMD_REG) {
        IO0CLR = LCD_BIT_RS;                                    /* Select the command register (RS low)                     */
    } else {
        IO0SET = LCD_BIT_RS;                                    /* Select the data    register (RS high)                    */
    }
#endif
}
#endif

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

#ifdef DISP_MODULE_PRESENT
static  void  DispE_High (void)
{
#if __VER__ == 420
    IOSET0 = LCD_BIT_E;
#else
    IO0SET = LCD_BIT_E;
#endif
}


static  void  DispE_Low (void)
{
#if __VER__ == 420
    IOCLR0 = LCD_BIT_E;
#else
    IO0CLR = LCD_BIT_E;
#endif
}


static  void  DispRW_High (void)
{
#if __VER__ == 420
    IOSET0 = LCD_BIT_RW;
#else
    IO0SET = LCD_BIT_RW;
#endif
}


static  void  DispRW_Low (void)
{
#if __VER__ == 420
    IOCLR0 = LCD_BIT_RW;
#else
    IO0CLR = LCD_BIT_RW;
#endif
}
#endif

/*
*********************************************************************************************************
*                                         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 B1
*                              2    probe the push button B2
*********************************************************************************************************
*/

CPU_BOOLEAN  PB_GetStatus (CPU_INT08U push_button_id)
{
    CPU_BOOLEAN  status;


    status = DEF_FALSE;
#if __VER__ == 420
    switch (push_button_id) {
        case 1:
             if ((IOPIN0 & (1 << 15)) == 0) {
                 return (DEF_TRUE);
             }
             break;

        case 2:
             if ((IOPIN0 & (1 << 16)) == 0) {
                 return (DEF_TRUE);
             }
             break;

        default:
             break;
    }
#else
    switch (push_button_id) {
        case 1:
             if ((IO0PIN & (1 << 15)) == 0) {
                 return (DEF_TRUE);
             }
             break;

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

        default:
             break;
    }
#endif
    return (status);
}

/*
*********************************************************************************************************
*                                         BSP 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_Off(0);                                                 /* Turn OFF all the LEDs                                    */
}

/*
*********************************************************************************************************
*                                             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 LED1  on the board
*                      .
*                      .
*                     16    turns ON LED16 on the board
*********************************************************************************************************
*/

void  LED_On (CPU_INT08U led)
{
#if __VER__ == 420
    switch (led) {
        case 0:
             IOSET0 = 1 << 21;
             break;

        case 1:
             IOSET0 = 1 << 21;
             break;
    }
#else
    switch (led) {
        case 0:
             IO0SET = 1 << 21;
             break;

        case 1:
             IO0SET = 1 << 21;
             break;
    }
#endif
}

⌨️ 快捷键说明

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