From 7aff487faa060fe9324b89609058743fe369280d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 12 May 2014 11:24:57 -0600 Subject: [PATCH] Add ILI9325 register definition header file --- configs/arduino-due/README.txt | 2 +- include/nuttx/lcd/ili9325.h | 524 +++++++++++++++++++++++++++++++++ 2 files changed, 525 insertions(+), 1 deletion(-) create mode 100644 include/nuttx/lcd/ili9325.h diff --git a/configs/arduino-due/README.txt b/configs/arduino-due/README.txt index 1b41aed509..9a57a88fca 100644 --- a/configs/arduino-due/README.txt +++ b/configs/arduino-due/README.txt @@ -136,7 +136,7 @@ ITEAD 2.4" TFT with Touch NOTE: When used with the ITEAD shield, the power from the USB connector seems to be inefficient (for example, I lose the USB connection when I - insert an SD card). I recommends using a 7-12V power supply with the + insert an SD card). I recommend using a 7-12V power supply with the Arduino in this case. Connector: diff --git a/include/nuttx/lcd/ili9325.h b/include/nuttx/lcd/ili9325.h new file mode 100644 index 0000000000..8d787fe49b --- /dev/null +++ b/include/nuttx/lcd/ili9325.h @@ -0,0 +1,524 @@ +/************************************************************************************** + * include/nuttx/lcd/ili9325.h + * + * Copyright (C) 2014 Gregory Nutt. All rights reserved. + * Authors: Gregory Nutt + * + * 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 NuttX 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 OWNER 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. + * + **************************************************************************************/ + +#ifndef __INCLUDE_NUTTX_LCD_ILI9325_H +#define __INCLUDE_NUTTX_LCD_ILI9325_H + +/************************************************************************************** + * Included Files + **************************************************************************************/ + +#include + +/************************************************************************************** + * Pre-processor Definitions + **************************************************************************************/ +/* ILI9325 ID code */ + +#define ILI9325_DEVICE_CODE 0x9325 + +/* ILI9325 LCD Register Addresses *****************************************************/ + + +#define ILI9325_DEVICE_CODE_REG 0x00 /* Driver Code Register */ +#define ILI9325_START_OSC_CTRL 0x00 /* Start Oscillator Control */ +#define ILI9325_DRIVER_OUTPUT_CTRL1 0x01 /* Start Oscillator Control */ +#define ILI9325_LCD_DRIVING_CTRL 0x02 /* LCD Driving Control */ +#define ILI9325_ENTRY_MODE 0x03 /* Entry Mode */ +#define ILI9325_RESIZE_CTRL 0x04 /* Resize Control */ +#define ILI9325_DISP_CTRL1 0x07 /* Display Control 1 */ +#define ILI9325_DISP_CTRL2 0x08 /* Display Control 2 */ +#define ILI9325_DISP_CTRL3 0x09 /* Display Control 3 */ +#define ILI9325_DISP_CTRL4 0x0a /* Display Control 4 */ +#define ILI9325_RGB_DISP_INTERFACE_CTRL1 0x0c /* RGB Display Interface Control 1 */ +#define ILI9325_FRAME_MAKER_SHIFT 0x0d /* Frame Maker Position */ +#define ILI9325_RGB_DISP_INTERFACE_CTRL2 0x0f /* RGB Display Interface Control 2 */ +#define ILI9325_POWER_CTRL1 0x10 /* Power Control 1 */ +#define ILI9325_POWER_CTRL2 0x11 /* Power Control 2 */ +#define ILI9325_POWER_CTRL3 0x12 /* Power Control 3 */ +#define ILI9325_POWER_CTRL4 0x13 /* Power Control 4 */ +#define ILI9325_HORIZONTAL_GRAM_ADDR_SET 0x20 /* Horizontal GRAM Address Set */ +#define ILI9325_VERTICAL_GRAM_ADDR_SET 0x21 /* Vertical GRAM Address Set */ +#define ILI9325_GRAM_DATA_REG 0x22 /* GRAM Data Register */ +#define ILI9325_POWER_CTRL7 0x29 /* Power Control 7 */ +#define ILI9325_FRAME_RATE_AND_COLOR_CTRL 0x2b /* Frame Rate and Color Control */ +#define ILI9325_GAMMA_CTRL1 0x30 /* Gamma Control 1 */ +#define ILI9325_GAMMA_CTRL2 0x31 /* Gamma Control 2 */ +#define ILI9325_GAMMA_CTRL3 0x32 /* Gamma Control 3 */ +#define ILI9325_GAMMA_CTRL4 0x35 /* Gamma Control 4 */ +#define ILI9325_GAMMA_CTRL5 0x36 /* Gamma Control 5 */ +#define ILI9325_GAMMA_CTRL6 0x37 /* Gamma Control 6 */ +#define ILI9325_GAMMA_CTRL7 0x38 /* Gamma Control 7 */ +#define ILI9325_GAMMA_CTRL8 0x39 /* Gamma Control 8 */ +#define ILI9325_GAMMA_CTRL9 0x3c /* Gamma Control 9 */ +#define ILI9325_GAMMA_CTRL10 0x3d /* Gamma Control 10 */ +#define ILI9325_HORIZONTAL_ADDR_START 0x50 /* Horizontal Address Start Position */ +#define ILI9325_HORIZONTAL_ADDR_END 0x51 /* Horizontal Address End Position */ +#define ILI9325_VERTICAL_ADDR_START 0x52 /* Vertical Address Start Position */ +#define ILI9325_VERTICAL_ADDR_END 0x53 /* Vertical Address End Position */ +#define ILI9325_DRIVER_OUTPUT_CTRL2 0x60 /* Driver Output Control 2 */ +#define ILI9325_BASE_IMG_DISP_CTRL 0x61 /* Base Image Display Control */ +#define ILI9325_VERTICAL_SCROLL_CTRL 0x6a /* Vertical Scroll Control */ +#define ILI9325_PARTIAL_IMG1_DISP_SHIFT 0x80 /* Partial Image 1 Display Position */ +#define ILI9325_PARTIAL_IMG1_AREA_START_LINE 0x81 /* Partial Image 1 Area (Start Line) */ +#define ILI9325_PARTIAL_IMG1_AREA_END_LINE 0x82 /* Partial Image 1 Area (End Line) */ +#define ILI9325_PARTIAL_IMG2_DISP_SHIFT 0x83 /* Partial Image 2 Display Position */ +#define ILI9325_PARTIAL_IMG2_AREA_START_LINE 0x84 /* Partial Image 2 Area (Start Line) */ +#define ILI9325_PARTIAL_IMG2_AREA_END_LINE 0x85 /* Partial Image 2 Area (End Line) */ +#define ILI9325_PANEL_INTERFACE_CTRL1 0x90 /* Panel Interface Control 1 */ +#define ILI9325_PANEL_INTERFACE_CTRL2 0x92 /* Panel Interface Control 2 */ +#define ILI9325_PANEL_INTERFACE_CTRL4 0x95 /* Panel Interface Control 4 */ +#define ILI9325_OTP_VCM_PROG_CTRL 0xa1 /* OTP VCM Programming Control */ +#define ILI9325_OTP_VCM_STATUS_AND_ENABLE 0xa2 /* OTP VCM Status and Enable */ +#define ILI9325_OTP_PROG_ID_KEY 0xa5 /* OTP Programming ID Key */ + +/* ILI9325 LCD Register Bit Definitions ***********************************************/ +/* ILI9325_START_OSC_CTRL, Start Oscillator Control, Offset: 0x00) */ + +#define ILI9325_START_OSC_CTRL_EN (1 << 0) + +/* ILI9325_DRIVER_OUTPUT_CTRL1, Start Oscillator Control, Offset: 0x01 */ + +#define ILI9325_DRIVER_OUTPUT_CTRL1_SS (1 << 8) +#define ILI9325_DRIVER_OUTPUT_CTRL1_SM (1 << 10) + +/* ILI9325_LCD_DRIVING_CTRL, LCD Driving Control, Offset: 0x02 */ + +#define ILI9325_LCD_DRIVING_CTRL_EOR (1 << 8) +#define ILI9325_LCD_DRIVING_CTRL_BC0 (1 << 9) +#define ILI9325_LCD_DRIVING_CTRL_BIT10 (1 << 10) + +/* ILI9325_ENTRY_MODE, Entry Mode, Offset: 0x03 */ + +#define ILI9325_ENTRY_MODE_AM (1 << 3) +#define ILI9325_ENTRY_MODE_ID_SHIFT 4 +#define ILI9325_ENTRY_MODE_ID_MASK (3 << ILI9325_ENTRY_MODE_ID_SHIFT) +# define ILI9325_ENTRY_MODE_ID(n) ((uint16_t)(n) << ILI9325_ENTRY_MODE_ID_SHIFT) +#define ILI9325_ENTRY_MODE_ORG (1 << 7) +#define ILI9325_ENTRY_MODE_HWM (1 << 9) +#define ILI9325_ENTRY_MODE_BGR (1 << 12) +#define ILI9325_ENTRY_MODE_DFM (1 << 14) +#define ILI9325_ENTRY_MODE_TRI (1 << 15) + +/* ILI9325_RESIZE_CTRL, Resize Control, Offset: 0x04 */ + +#define ILI9325_RESIZE_CTRL_RSZ_SHIFT 0 +#define ILI9325_RESIZE_CTRL_RSZ_MASK (3 << ILI9325_RESIZE_CTRL_RSZ_SHIFT) +# define ILI9325_RESIZE_CTRL_RSZ(n) ((uint16_t)(n) << ILI9325_RESIZE_CTRL_RSZ_SHIFT) +#define ILI9325_RESIZE_CTRL_RCH_SHIFT 4 +#define ILI9325_RESIZE_CTRL_RCH_MASK (3 << ILI9325_RESIZE_CTRL_RCH_SHIFT) +# define ILI9325_RESIZE_CTRL_RCH(n) ((uint16_t)(n) << ILI9325_RESIZE_CTRL_RCH_SHIFT) +#define ILI9325_RESIZE_CTRL_RCV_SHIFT 8 +#define ILI9325_RESIZE_CTRL_RCV_MASK (3 << ILI9325_RESIZE_CTRL_RCV_SHIFT) +# define ILI9325_RESIZE_CTRL_RCV(n) ((uint16_t)(n) << ILI9325_RESIZE_CTRL_RCV_SHIFT) + +/* ILI9325_DISP_CTRL1, Display Control 1, Offset: 0x07 */ + +#define ILI9325_DISP_CTRL1_D_SHIFT 0 +#define ILI9325_DISP_CTRL1_D_MASK (3 << ILI9325_DISP_CTRL1_D_SHIFT) +# define ILI9325_DISP_CTRL1_D(n) ((uint16_t)(n) << ILI9325_DISP_CTRL1_D_SHIFT))) +#define ILI9325_DISP_CTRL1_CL (1 << 3) +#define ILI9325_DISP_CTRL1_DTE (1 << 4) +#define ILI9325_DISP_CTRL1_GON (1 << 5) +#define ILI9325_DISP_CTRL1_BASEE (1 << 8) +#define ILI9325_DISP_CTRL1_PTDE_SHIFT 12 +#define ILI9325_DISP_CTRL1_PTDE_MASK (3 << ILI9325_DISP_CTRL1_PTDE_SHIFT) +# define ILI9325_DISP_CTRL1_PTDE(n) ((uint16_t)(n) << ILI9325_DISP_CTRL1_PTDE_SHIFT) + +/* ILI9325_DISP_CTRL2, Display Control 2, Offset: 0x08 */ + +#define ILI9325_DISP_CTRL2_BP_SHIFT 0 +#define ILI9325_DISP_CTRL2_BP_MASK (0xf << ILI9325_DISP_CTRL2_BP_SHIFT) +# define ILI9325_DISP_CTRL2_BP(n) ((uint16_t)(n) << ILI9325_DISP_CTRL2_BP_SHIFT))) +#define ILI9325_DISP_CTRL2_FP_SHIFT 8 +#define ILI9325_DISP_CTRL2_FP_MASK (0xf << ILI9325_DISP_CTRL2_FP_SHIFT) +# define ILI9325_DISP_CTRL2_FP(n) ((uint16_t)(n) << ILI9325_DISP_CTRL2_FP_SHIFT) + +/* ILI9325_DISP_CTRL3, Display Control 3, Offset: 0x09 */ + +#define ILI9325_DISP_CTRL3_ISC_SHIFT 0 +#define ILI9325_DISP_CTRL3_ISC_MASK (0xf << ILI9325_DISP_CTRL3_ISC_SHIFT) +# define ILI9325_DISP_CTRL3_ISC(n) ((uint16_t)(n) << ILI9325_DISP_CTRL3_ISC_SHIFT) +#define ILI9325_DISP_CTRL3_PTG_SHIFT 4 +#define ILI9325_DISP_CTRL3_PTG_MASK (3 << ILI9325_DISP_CTRL3_PTG_SHIFT) +# define ILI9325_DISP_CTRL3_PTG(n) ((uint16_t)(n) << ILI9325_DISP_CTRL3_PTG_SHIFT) +#define ILI9325_DISP_CTRL3_PTS_SHIFT 8 +#define ILI9325_DISP_CTRL3_PTS_MASK (7 << ILI9325_DISP_CTRL3_PTS_SHIFT) +# define ILI9325_DISP_CTRL3_PTS(n) ((uint16_t)(n) << ILI9325_DISP_CTRL3_PTS_SHIFT) + +/* ILI9325_DISP_CTRL4, Display Control 4, Offset: 0x0a */ + +#define ILI9325_DISP_CTRL4_FMI_SHIFT 0 +#define ILI9325_DISP_CTRL4_FMI_MASK (7 << ILI9325_DISP_CTRL4_FMI_SHIFT) +# define ILI9325_DISP_CTRL4_FMI(n) ((uint16_t)(n) << ILI9325_DISP_CTRL4_FMI_SHIFT) +#define ILI9325_DISP_CTRL4_FMARKOE (1 << 3) + +/* ILI9325_RGB_DISP_INTERFACE_CTRL1, RGB Display Interface Control 1, Offset: 0x0c */ + +#define ILI9325_RGB_DISP_INTERFACE_CTRL1_RIM_SHIFT 0 +#define ILI9325_RGB_DISP_INTERFACE_CTRL1_RIM_MASK (3 << ILI9325_RGB_DISP_INTERFACE_CTRL1_RIM_SHIFT) +# define ILI9325_RGB_DISP_INTERFACE_CTRL1_RIM(n) ((uint16_t)(n) << ILI9325_RGB_DISP_INTERFACE_CTRL1_RIM_SHIFT) +#define ILI9325_RGB_DISP_INTERFACE_CTRL1_DM0 (1 << 4) +#define ILI9325_RGB_DISP_INTERFACE_CTRL1_DM1 (1 << 5) +#define ILI9325_RGB_DISP_INTERFACE_CTRL1_DM_SHIFT 4 +#define ILI9325_RGB_DISP_INTERFACE_CTRL1_DM_MASK (3 << ILI9325_RGB_DISP_INTERFACE_CTRL1_DM_SHIFT) +# define ILI9325_RGB_DISP_INTERFACE_CTRL1_DM(n) ((uint16_t)(n) << ILI9325_RGB_DISP_INTERFACE_CTRL1_DM_SHIFT) +#define ILI9325_RGB_DISP_INTERFACE_CTRL1_RM (1 << 8) +#define ILI9325_RGB_DISP_INTERFACE_CTRL1_ENC_SHIFT 12 +#define ILI9325_RGB_DISP_INTERFACE_CTRL1_ENC_MASK (7 << ILI9325_RGB_DISP_INTERFACE_CTRL1_ENC_SHIFT) +# define ILI9325_RGB_DISP_INTERFACE_CTRL1_ENC(n) ((uint16_t)(n)