Prep for v1.2.0
[hackover2013-badge-firmware.git] / drivers / displays / tft / hw / ILI9325.h
1 /**************************************************************************/
2 /*!
3 @file ILI9325.h
4 @author K. Townsend (microBuilder.eu)
5
6 @section LICENSE
7
8 Software License Agreement (BSD License)
9
10 Copyright (c) 2010, microBuilder SARL
11 All rights reserved.
12
13 Redistribution and use in source and binary forms, with or without
14 modification, are permitted provided that the following conditions are met:
15 1. Redistributions of source code must retain the above copyright
16 notice, this list of conditions and the following disclaimer.
17 2. Redistributions in binary form must reproduce the above copyright
18 notice, this list of conditions and the following disclaimer in the
19 documentation and/or other materials provided with the distribution.
20 3. Neither the name of the copyright holders nor the
21 names of its contributors may be used to endorse or promote products
22 derived from this software without specific prior written permission.
23
24 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
25 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
26 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
28 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
29 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
31 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
33 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 */
35 /**************************************************************************/
36 #ifndef __ILI9325_H__
37 #define __ILI9325_H__
38
39 #include "projectconfig.h"
40
41 #include "drivers/displays/tft/lcd.h"
42 #include "core/gpio/gpio.h"
43
44 // Control pins
45 #define ILI9325_CS_PORT 1 // CS (LCD Pin 7)
46 #define ILI9325_CS_PIN 8
47 #define ILI9325_CD_PORT 1 // CS/RS (LCD Pin 8)
48 #define ILI9325_CD_PIN 9
49 #define ILI9325_WR_PORT 1 // WR (LCD Pin 9)
50 #define ILI9325_WR_PIN 10
51 #define ILI9325_RD_PORT 1 // RD (LCD Pin 10)
52 #define ILI9325_RD_PIN 11
53
54 // These combined pin definitions are for optimisation purposes.
55 // If the pin values above are modified the bit equivalents
56 // below will also need to be updated
57 #define ILI9325_CS_CD_PINS 0x300 // 8 + 9
58 #define ILI9325_RD_WR_PINS 0xC00 // 11 + 10
59 #define ILI9325_WR_CS_PINS 0x500 // 10 + 8
60 #define ILI9325_CD_RD_WR_PINS 0xE00 // 9 + 11 + 10
61 #define ILI9325_CS_CD_RD_WR_PINS 0xF00 // 8 + 9 + 11 + 10
62
63 // Backlight and Reset pins
64 #define ILI9325_RES_PORT 3 // LCD Reset (LCD Pin 31)
65 #define ILI9325_RES_PIN 3
66 #define ILI9325_BL_PORT 2 // Backlight Enable (LCD Pin 16)
67 #define ILI9325_BL_PIN 9
68
69 // Data pins
70 // Note: data pins must be consecutive and on the same port
71 #define ILI9325_DATA_PORT 2 // 8-Pin Data Port
72 #define ILI9325_DATA_PIN1 1
73 #define ILI9325_DATA_PIN2 2
74 #define ILI9325_DATA_PIN3 3
75 #define ILI9325_DATA_PIN4 4
76 #define ILI9325_DATA_PIN5 5
77 #define ILI9325_DATA_PIN6 6
78 #define ILI9325_DATA_PIN7 7
79 #define ILI9325_DATA_PIN8 8
80 #define ILI9325_DATA_MASK 0x000001FE
81 #define ILI9325_DATA_OFFSET 1 // Offset = PIN1
82
83 // Placed here to try to keep all pin specific values in header file
84 #define ILI9325_DISABLEPULLUPS() do { gpioSetPullup(&IOCON_PIO2_1, gpioPullupMode_Inactive); \
85 gpioSetPullup(&IOCON_PIO2_2, gpioPullupMode_Inactive); \
86 gpioSetPullup(&IOCON_PIO2_3, gpioPullupMode_Inactive); \
87 gpioSetPullup(&IOCON_PIO2_4, gpioPullupMode_Inactive); \
88 gpioSetPullup(&IOCON_PIO2_5, gpioPullupMode_Inactive); \
89 gpioSetPullup(&IOCON_PIO2_6, gpioPullupMode_Inactive); \
90 gpioSetPullup(&IOCON_PIO2_7, gpioPullupMode_Inactive); \
91 gpioSetPullup(&IOCON_PIO2_8, gpioPullupMode_Inactive); } while (0)
92
93 // These registers allow fast single operation clear+set of bits (see section 8.5.1 of LPC1343 UM)
94 #define ILI9325_GPIO2DATA_DATA (*(pREG32 (GPIO_GPIO2_BASE + (ILI9325_DATA_MASK << 2))))
95 #define ILI9325_GPIO1DATA_WR (*(pREG32 (GPIO_GPIO1_BASE + ((1 << ILI9325_WR_PIN) << 2))))
96 #define ILI9325_GPIO1DATA_CD (*(pREG32 (GPIO_GPIO1_BASE + ((1 << ILI9325_CD_PIN) << 2))))
97 #define ILI9325_GPIO1DATA_CS (*(pREG32 (GPIO_GPIO1_BASE + ((1 << ILI9325_CS_PIN) << 2))))
98 #define ILI9325_GPIO1DATA_RD (*(pREG32 (GPIO_GPIO1_BASE + ((1 << ILI9325_RD_PIN) << 2))))
99 #define ILI9325_GPIO3DATA_RES (*(pREG32 (GPIO_GPIO3_BASE + ((1 << ILI9325_RES_PIN) << 2))))
100 #define ILI9325_GPIO1DATA_CS_CD (*(pREG32 (GPIO_GPIO1_BASE + ((ILI9325_CS_CD_PINS) << 2))))
101 #define ILI9325_GPIO1DATA_RD_WR (*(pREG32 (GPIO_GPIO1_BASE + ((ILI9325_RD_WR_PINS) << 2))))
102 #define ILI9325_GPIO1DATA_WR_CS (*(pREG32 (GPIO_GPIO1_BASE + ((ILI9325_WR_CS_PINS) << 2))))
103 #define ILI9325_GPIO1DATA_CD_RD_WR (*(pREG32 (GPIO_GPIO1_BASE + ((ILI9325_CD_RD_WR_PINS) << 2))))
104 #define ILI9325_GPIO1DATA_CS_CD_RD_WR (*(pREG32 (GPIO_GPIO1_BASE + ((ILI9325_CS_CD_RD_WR_PINS) << 2))))
105
106 // Macros to set data bus direction to input/output
107 #define ILI9325_GPIO2DATA_SETINPUT GPIO_GPIO2DIR &= ~ILI9325_DATA_MASK
108 #define ILI9325_GPIO2DATA_SETOUTPUT GPIO_GPIO2DIR |= ILI9325_DATA_MASK
109
110 // Macros for control line state
111 #define CLR_CD ILI9325_GPIO1DATA_CD = (0)
112 #define SET_CD ILI9325_GPIO1DATA_CD = (1 << ILI9325_CD_PIN)
113 #define CLR_CS ILI9325_GPIO1DATA_CS = (0)
114 #define SET_CS ILI9325_GPIO1DATA_CS = (1 << ILI9325_CS_PIN)
115 #define CLR_WR ILI9325_GPIO1DATA_WR = (0)
116 #define SET_WR ILI9325_GPIO1DATA_WR = (1 << ILI9325_WR_PIN)
117 #define CLR_RD ILI9325_GPIO1DATA_RD = (0)
118 #define SET_RD ILI9325_GPIO1DATA_RD = (1 << ILI9325_RD_PIN)
119 #define CLR_RESET ILI9325_GPIO3DATA_RES = (0)
120 #define SET_RESET ILI9325_GPIO3DATA_RES = (1 << ILI9325_RES_PIN)
121
122 // These 'combined' macros are defined to improve code performance by
123 // reducing the number of instructions in heavily used functions
124 #define CLR_CS_CD ILI9325_GPIO1DATA_CS_CD = (0);
125 #define SET_RD_WR ILI9325_GPIO1DATA_RD_WR = (ILI9325_RD_WR_PINS);
126 #define SET_WR_CS ILI9325_GPIO1DATA_WR_CS = (ILI9325_WR_CS_PINS);
127 #define SET_CD_RD_WR ILI9325_GPIO1DATA_CD_RD_WR = (ILI9325_CD_RD_WR_PINS);
128 #define CLR_CS_CD_SET_RD_WR ILI9325_GPIO1DATA_CS_CD_RD_WR = (ILI9325_RD_WR_PINS);
129 #define CLR_CS_SET_CD_RD_WR ILI9325_GPIO1DATA_CS_CD_RD_WR = (ILI9325_CD_RD_WR_PINS);
130
131 enum
132 {
133 ILI9325_COMMANDS_DRIVERCODEREAD = 0x0000,
134 ILI9325_COMMANDS_DRIVEROUTPUTCONTROL1 = 0x0001,
135 ILI9325_COMMANDS_LCDDRIVINGCONTROL = 0x0002,
136 ILI9325_COMMANDS_ENTRYMODE = 0x0003,
137 ILI9325_COMMANDS_RESIZECONTROL = 0x0004,
138 ILI9325_COMMANDS_DISPLAYCONTROL1 = 0x0007,
139 ILI9325_COMMANDS_DISPLAYCONTROL2 = 0x0008,
140 ILI9325_COMMANDS_DISPLAYCONTROL3 = 0x0009,
141 ILI9325_COMMANDS_DISPLAYCONTROL4 = 0x000A,
142 ILI9325_COMMANDS_RGBDISPLAYINTERFACECONTROL1 = 0x000C,
143 ILI9325_COMMANDS_FRAMEMAKERPOSITION = 0x000D,
144 ILI9325_COMMANDS_RGBDISPLAYINTERFACECONTROL2 = 0x000F,
145 ILI9325_COMMANDS_POWERCONTROL1 = 0x0010,
146 ILI9325_COMMANDS_POWERCONTROL2 = 0x0011,
147 ILI9325_COMMANDS_POWERCONTROL3 = 0x0012,
148 ILI9325_COMMANDS_POWERCONTROL4 = 0x0013,
149 ILI9325_COMMANDS_HORIZONTALGRAMADDRESSSET = 0x0020,
150 ILI9325_COMMANDS_VERTICALGRAMADDRESSSET = 0x0021,
151 ILI9325_COMMANDS_WRITEDATATOGRAM = 0x0022,
152 ILI9325_COMMANDS_POWERCONTROL7 = 0x0029,
153 ILI9325_COMMANDS_FRAMERATEANDCOLORCONTROL = 0x002B,
154 ILI9325_COMMANDS_GAMMACONTROL1 = 0x0030,
155 ILI9325_COMMANDS_GAMMACONTROL2 = 0x0031,
156 ILI9325_COMMANDS_GAMMACONTROL3 = 0x0032,
157 ILI9325_COMMANDS_GAMMACONTROL4 = 0x0035,
158 ILI9325_COMMANDS_GAMMACONTROL5 = 0x0036,
159 ILI9325_COMMANDS_GAMMACONTROL6 = 0x0037,
160 ILI9325_COMMANDS_GAMMACONTROL7 = 0x0038,
161 ILI9325_COMMANDS_GAMMACONTROL8 = 0x0039,
162 ILI9325_COMMANDS_GAMMACONTROL9 = 0x003C,
163 ILI9325_COMMANDS_GAMMACONTROL10 = 0x003D,
164 ILI9325_COMMANDS_HORIZONTALADDRESSSTARTPOSITION = 0x0050,
165 ILI9325_COMMANDS_HORIZONTALADDRESSENDPOSITION = 0x0051,
166 ILI9325_COMMANDS_VERTICALADDRESSSTARTPOSITION = 0x0052,
167 ILI9325_COMMANDS_VERTICALADDRESSENDPOSITION = 0x0053,
168 ILI9325_COMMANDS_DRIVEROUTPUTCONTROL2 = 0x0060,
169 ILI9325_COMMANDS_BASEIMAGEDISPLAYCONTROL = 0x0061,
170 ILI9325_COMMANDS_VERTICALSCROLLCONTROL = 0x006A,
171 ILI9325_COMMANDS_PARTIALIMAGE1DISPLAYPOSITION = 0x0080,
172 ILI9325_COMMANDS_PARTIALIMAGE1AREASTARTLINE = 0x0081,
173 ILI9325_COMMANDS_PARTIALIMAGE1AREAENDLINE = 0x0082,
174 ILI9325_COMMANDS_PARTIALIMAGE2DISPLAYPOSITION = 0x0083,
175 ILI9325_COMMANDS_PARTIALIMAGE2AREASTARTLINE = 0x0084,
176 ILI9325_COMMANDS_PARTIALIMAGE2AREAENDLINE = 0x0085,
177 ILI9325_COMMANDS_PANELINTERFACECONTROL1 = 0x0090,
178 ILI9325_COMMANDS_PANELINTERFACECONTROL2 = 0x0092,
179 ILI9325_COMMANDS_PANELINTERFACECONTROL4 = 0x0095,
180 ILI9325_COMMANDS_OTPVCMPROGRAMMINGCONTROL = 0x00A1,
181 ILI9325_COMMANDS_OTPVCMSTATUSANDENABLE = 0x00A2,
182 ILI9325_COMMANDS_OTPPROGRAMMINGIDKEY = 0x00A5
183 };
184
185 #endif
This page took 0.059786 seconds and 5 git commands to generate.