123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346 |
- /**
- ******************************************************************************
- * @file ili9341.c
- * @author MCD Application Team
- * @version V1.0.2
- * @date 02-December-2014
- * @brief This file includes the LCD driver for ILI9341 LCD.
- ******************************************************************************
- * @attention
- *
- * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
- *
- * Redistribution and use in source and binary forms, with or without modification,
- * are permitted provided that the following conditions are met:
- * 1. Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- * 3. Neither the name of STMicroelectronics nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
- * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
- * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- ******************************************************************************
- */
- /* Includes ------------------------------------------------------------------*/
- #include "ili9341.h"
- /** @addtogroup BSP
- * @{
- */
- /** @addtogroup Components
- * @{
- */
-
- /** @addtogroup ILI9341
- * @brief This file provides a set of functions needed to drive the
- * ILI9341 LCD.
- * @{
- */
- /** @defgroup ILI9341_Private_TypesDefinitions
- * @{
- */
- /**
- * @}
- */
- /** @defgroup ILI9341_Private_Defines
- * @{
- */
- /**
- * @}
- */
-
- /** @defgroup ILI9341_Private_Macros
- * @{
- */
- /**
- * @}
- */
- /** @defgroup ILI9341_Private_Variables
- * @{
- */
- LCD_DrvTypeDef ili9341_drv =
- {
- ili9341_Init,
- ili9341_ReadID,
- ili9341_DisplayOn,
- ili9341_DisplayOff,
- 0,
- 0,
- 0,
- 0,
- 0,
- 0,
- ili9341_GetLcdPixelWidth,
- ili9341_GetLcdPixelHeight,
- 0,
- 0,
- };
- /**
- * @}
- */
-
- /** @defgroup ILI9341_Private_FunctionPrototypes
- * @{
- */
- /**
- * @}
- */
-
- /** @defgroup ILI9341_Private_Functions
- * @{
- */
- /**
- * @brief Power on the LCD.
- * @param None
- * @retval None
- */
- void ili9341_Init(void)
- {
- /* Initialize ILI9341 low level bus layer ----------------------------------*/
- LCD_IO_Init();
-
- /* Configure LCD */
- ili9341_WriteReg(0xCA);
- ili9341_WriteData(0xC3);
- ili9341_WriteData(0x08);
- ili9341_WriteData(0x50);
- ili9341_WriteReg(LCD_POWERB);
- ili9341_WriteData(0x00);
- ili9341_WriteData(0xC1);
- ili9341_WriteData(0x30);
- ili9341_WriteReg(LCD_POWER_SEQ);
- ili9341_WriteData(0x64);
- ili9341_WriteData(0x03);
- ili9341_WriteData(0x12);
- ili9341_WriteData(0x81);
- ili9341_WriteReg(LCD_DTCA);
- ili9341_WriteData(0x85);
- ili9341_WriteData(0x00);
- ili9341_WriteData(0x78);
- ili9341_WriteReg(LCD_POWERA);
- ili9341_WriteData(0x39);
- ili9341_WriteData(0x2C);
- ili9341_WriteData(0x00);
- ili9341_WriteData(0x34);
- ili9341_WriteData(0x02);
- ili9341_WriteReg(LCD_PRC);
- ili9341_WriteData(0x20);
- ili9341_WriteReg(LCD_DTCB);
- ili9341_WriteData(0x00);
- ili9341_WriteData(0x00);
- ili9341_WriteReg(LCD_FRMCTR1);
- ili9341_WriteData(0x00);
- ili9341_WriteData(0x1B);
- ili9341_WriteReg(LCD_DFC);
- ili9341_WriteData(0x0A);
- ili9341_WriteData(0xA2);
- ili9341_WriteReg(LCD_POWER1);
- ili9341_WriteData(0x10);
- ili9341_WriteReg(LCD_POWER2);
- ili9341_WriteData(0x10);
- ili9341_WriteReg(LCD_VCOM1);
- ili9341_WriteData(0x45);
- ili9341_WriteData(0x15);
- ili9341_WriteReg(LCD_VCOM2);
- ili9341_WriteData(0x90);
- ili9341_WriteReg(LCD_MAC);
- ili9341_WriteData(0xC8);
- ili9341_WriteReg(LCD_3GAMMA_EN);
- ili9341_WriteData(0x00);
- ili9341_WriteReg(LCD_RGB_INTERFACE);
- ili9341_WriteData(0xC2);
- ili9341_WriteReg(LCD_DFC);
- ili9341_WriteData(0x0A);
- ili9341_WriteData(0xA7);
- ili9341_WriteData(0x27);
- ili9341_WriteData(0x04);
-
- /* Colomn address set */
- ili9341_WriteReg(LCD_COLUMN_ADDR);
- ili9341_WriteData(0x00);
- ili9341_WriteData(0x00);
- ili9341_WriteData(0x00);
- ili9341_WriteData(0xEF);
- /* Page address set */
- ili9341_WriteReg(LCD_PAGE_ADDR);
- ili9341_WriteData(0x00);
- ili9341_WriteData(0x00);
- ili9341_WriteData(0x01);
- ili9341_WriteData(0x3F);
- ili9341_WriteReg(LCD_INTERFACE);
- ili9341_WriteData(0x01);
- ili9341_WriteData(0x00);
- ili9341_WriteData(0x06);
-
- ili9341_WriteReg(LCD_GRAM);
- LCD_Delay(200);
-
- ili9341_WriteReg(LCD_GAMMA);
- ili9341_WriteData(0x01);
-
- ili9341_WriteReg(LCD_PGAMMA);
- ili9341_WriteData(0x0F);
- ili9341_WriteData(0x29);
- ili9341_WriteData(0x24);
- ili9341_WriteData(0x0C);
- ili9341_WriteData(0x0E);
- ili9341_WriteData(0x09);
- ili9341_WriteData(0x4E);
- ili9341_WriteData(0x78);
- ili9341_WriteData(0x3C);
- ili9341_WriteData(0x09);
- ili9341_WriteData(0x13);
- ili9341_WriteData(0x05);
- ili9341_WriteData(0x17);
- ili9341_WriteData(0x11);
- ili9341_WriteData(0x00);
- ili9341_WriteReg(LCD_NGAMMA);
- ili9341_WriteData(0x00);
- ili9341_WriteData(0x16);
- ili9341_WriteData(0x1B);
- ili9341_WriteData(0x04);
- ili9341_WriteData(0x11);
- ili9341_WriteData(0x07);
- ili9341_WriteData(0x31);
- ili9341_WriteData(0x33);
- ili9341_WriteData(0x42);
- ili9341_WriteData(0x05);
- ili9341_WriteData(0x0C);
- ili9341_WriteData(0x0A);
- ili9341_WriteData(0x28);
- ili9341_WriteData(0x2F);
- ili9341_WriteData(0x0F);
-
- ili9341_WriteReg(LCD_SLEEP_OUT);
- LCD_Delay(200);
- ili9341_WriteReg(LCD_DISPLAY_ON);
- /* GRAM start writing */
- ili9341_WriteReg(LCD_GRAM);
- }
- /**
- * @brief Disables the Display.
- * @param None
- * @retval LCD Register Value.
- */
- uint16_t ili9341_ReadID(void)
- {
- LCD_IO_Init();
- return ((uint16_t)ili9341_ReadData(LCD_READ_ID4, LCD_READ_ID4_SIZE));
- }
- /**
- * @brief Enables the Display.
- * @param None
- * @retval None
- */
- void ili9341_DisplayOn(void)
- {
- /* Display On */
- ili9341_WriteReg(LCD_DISPLAY_ON);
- }
- /**
- * @brief Disables the Display.
- * @param None
- * @retval None
- */
- void ili9341_DisplayOff(void)
- {
- /* Display Off */
- ili9341_WriteReg(LCD_DISPLAY_OFF);
- }
- /**
- * @brief Writes to the selected LCD register.
- * @param LCD_Reg: address of the selected register.
- * @retval None
- */
- void ili9341_WriteReg(uint8_t LCD_Reg)
- {
- LCD_IO_WriteReg(LCD_Reg);
- }
- /**
- * @brief Writes data to the selected LCD register.
- * @param LCD_Reg: address of the selected register.
- * @retval None
- */
- void ili9341_WriteData(uint16_t RegValue)
- {
- LCD_IO_WriteData(RegValue);
- }
- /**
- * @brief Reads the selected LCD Register.
- * @param RegValue: Address of the register to read
- * @param ReadSize: Number of bytes to read
- * @retval LCD Register Value.
- */
- uint32_t ili9341_ReadData(uint16_t RegValue, uint8_t ReadSize)
- {
- /* Read a max of 4 bytes */
- return (LCD_IO_ReadData(RegValue, ReadSize));
- }
- /**
- * @brief Get LCD PIXEL WIDTH.
- * @param None
- * @retval LCD PIXEL WIDTH.
- */
- uint16_t ili9341_GetLcdPixelWidth(void)
- {
- /* Return LCD PIXEL WIDTH */
- return ILI9341_LCD_PIXEL_WIDTH;
- }
- /**
- * @brief Get LCD PIXEL HEIGHT.
- * @param None
- * @retval LCD PIXEL HEIGHT.
- */
- uint16_t ili9341_GetLcdPixelHeight(void)
- {
- /* Return LCD PIXEL HEIGHT */
- return ILI9341_LCD_PIXEL_HEIGHT;
- }
- /**
- * @}
- */
- /**
- * @}
- */
-
- /**
- * @}
- */
- /**
- * @}
- */
-
- /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|