uilcd.c

来自「基于EP7312的MP3播放器源代码,包括MCU和PC端代码.」· C语言 代码 · 共 533 行 · 第 1/2 页

C
533
字号
    //    // Assert nWR.    //    ulLCDValue &= ~HwLCD_nWR;    *pulPtr = ulLCDValue;    //    // Wait for 450ns.    //    for(ulLoop = 0; ulLoop < 8; ulLoop++)    {    }    //    // De-assert nWR.    //    ulLCDValue |= HwLCD_nWR;    *pulPtr = ulLCDValue;    //    // De-assert nCS.    //    ulLCDValue |= HwLCD_nCS;    *pulPtr = ulLCDValue;}//****************************************************************************//// LCDWriteData writes the given value to the data register of the HD66410.////****************************************************************************static voidLCDWriteData(unsigned long ulValue){    volatile unsigned long *pulPtr = (unsigned long *)HwLCDAddress;    unsigned long ulLoop;    //    // Assert nCS, set RS high, and write the value.    //    ulLCDValue &= ~(HwLCD_nCS | HwLCD_Data);    ulLCDValue |= HwLCD_RS | ulValue;    *pulPtr = ulLCDValue;    //    // Assert nWR.    //    ulLCDValue &= ~HwLCD_nWR;    *pulPtr = ulLCDValue;    //    // Wait for 450ns.    //    for(ulLoop = 0; ulLoop < 8; ulLoop++)    {    }    //    // De-assert nWR.    //    ulLCDValue |= HwLCD_nWR;    *pulPtr = ulLCDValue;    //    // De-assert nCS.    //    ulLCDValue |= HwLCD_nCS;    *pulPtr = ulLCDValue;}//****************************************************************************//// LCDOn turns on the LCD display.////****************************************************************************static voidLCDOn(void){    //    // Turn on the display bit in the first control regiser.    //    LCDWriteIndex(LCD_REG_CONTROL1);    LCDWriteData(LCD_CONTROL1_DISP | LCD_CONTROL1_PWR | LCD_CONTROL1_CNF);}//****************************************************************************//// LCDOff turns off the LCD display.////****************************************************************************static voidLCDOff(void){    //    // Turn off the display bit in the first control regiser.    //    LCDWriteIndex(LCD_REG_CONTROL1);    LCDWriteData(LCD_CONTROL1_PWR | LCD_CONTROL1_CNF);}//****************************************************************************//// LCDDisplayImage draws an image on the LCD.  The image is organized in// column major order.////****************************************************************************static voidLCDDisplayImage(const unsigned char *pucData, unsigned long ulX,                unsigned long ulY, unsigned long ulWidth,                unsigned long ulHeight){    unsigned long ulDX, ulDY;    //    // Loop through the columns in the image.    //    for(ulDX = 0; ulDX < ulWidth; ulDX++)    {        //        // Set the column address.        //        LCDWriteIndex(LCD_REG_X);        LCDWriteData(ulX + ulDX);        //        // Set the row address.        //        LCDWriteIndex(LCD_REG_Y);        LCDWriteData(ulY);        //        // Select the data register.        //        LCDWriteIndex(LCD_REG_DATA);        //        // Loop through the rows in the image.        //        for(ulDY = 0; ulDY < ulHeight; ulDY++)        {            //            // Write the next value to the LCD.            //            LCDWriteData(*pucData++);        }    }}//****************************************************************************//// UIEnable initializes the user interface.////****************************************************************************voidUIEnable(void){    volatile unsigned long *pulPtr = (unsigned long *)HwLCDAddress;    long lCount;    //    // Reset the HD66410.    //    ulLCDValue = HwLCD_nCS | HwLCD_nWR | HwLCD_nRD;    *pulPtr = ulLCDValue;    //    // Delay for 1ms.    //    for(lCount = 0; lCount < 49152; lCount++)    {    }    //    // Bring the HD66410 out of reset.    //    ulLCDValue |= HwLCD_nRES;    *pulPtr = ulLCDValue;    //    // Set the index register to control register one.    //    LCDWriteIndex(LCD_REG_CONTROL1);    //    // Power on the HD66410.    //    LCDWriteData(LCD_CONTROL1_PWR);    //    // Configure the HD66410.    //    LCDWriteData(LCD_CONTROL1_PWR | LCD_CONTROL1_CNF);}//****************************************************************************//// UIDisable shuts down the user interface.////****************************************************************************voidUIDisable(void){    //    // Turn off the display bit in the first control register.    //    LCDWriteIndex(LCD_REG_CONTROL1);    LCDWriteData(LCD_CONTROL1_PWR | LCD_CONTROL1_CNF);    //    // Turn off the power bit in the first control register.    //    LCDWriteData(LCD_CONTROL1_CNF);}//****************************************************************************//// UIRequestUpdate displays a message on the LCD telling the user to update// the player software.////****************************************************************************voidUIRequestUpdate(void){    //    // Turn off the LCD.    //    LCDOff();    //    // Display the update request image on the LCD.    //    LCDDisplayImage(pucNeedUpdate, 0, 0, 16, 33);    //    // Turn on the LCD.    //    LCDOn();}//****************************************************************************//// UIUpdate displays a message on the LCD telling the user that an update is// in progress.////****************************************************************************voidUIUpdate(void){    //    // Turn off the LCD.    //    LCDOff();    //    // Display the update in progress image on the LCD.    //    LCDDisplayImage(pucUpdating, 0, 0, 16, 33);    //    // Turn on the LCD.    //    LCDOn();}#endif

⌨️ 快捷键说明

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