Additional font macro

Dependents:   EspSerial

Committer:
SomeRandomBloke
Date:
Fri Feb 05 09:20:30 2016 +0000
Revision:
1:a6fd0931a9e9
Parent:
0:e1d164542663
Added additional font macro

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:e1d164542663 1 /**
bcostm 0:e1d164542663 2 ******************************************************************************
bcostm 0:e1d164542663 3 * @file ili9341.c
bcostm 0:e1d164542663 4 * @author MCD Application Team
bcostm 0:e1d164542663 5 * @version V1.0.2
bcostm 0:e1d164542663 6 * @date 02-December-2014
bcostm 0:e1d164542663 7 * @brief This file includes the LCD driver for ILI9341 LCD.
bcostm 0:e1d164542663 8 ******************************************************************************
bcostm 0:e1d164542663 9 * @attention
bcostm 0:e1d164542663 10 *
bcostm 0:e1d164542663 11 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
bcostm 0:e1d164542663 12 *
bcostm 0:e1d164542663 13 * Redistribution and use in source and binary forms, with or without modification,
bcostm 0:e1d164542663 14 * are permitted provided that the following conditions are met:
bcostm 0:e1d164542663 15 * 1. Redistributions of source code must retain the above copyright notice,
bcostm 0:e1d164542663 16 * this list of conditions and the following disclaimer.
bcostm 0:e1d164542663 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
bcostm 0:e1d164542663 18 * this list of conditions and the following disclaimer in the documentation
bcostm 0:e1d164542663 19 * and/or other materials provided with the distribution.
bcostm 0:e1d164542663 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bcostm 0:e1d164542663 21 * may be used to endorse or promote products derived from this software
bcostm 0:e1d164542663 22 * without specific prior written permission.
bcostm 0:e1d164542663 23 *
bcostm 0:e1d164542663 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bcostm 0:e1d164542663 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bcostm 0:e1d164542663 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bcostm 0:e1d164542663 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bcostm 0:e1d164542663 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bcostm 0:e1d164542663 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bcostm 0:e1d164542663 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bcostm 0:e1d164542663 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bcostm 0:e1d164542663 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bcostm 0:e1d164542663 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bcostm 0:e1d164542663 34 *
bcostm 0:e1d164542663 35 ******************************************************************************
bcostm 0:e1d164542663 36 */
bcostm 0:e1d164542663 37
bcostm 0:e1d164542663 38 /* Includes ------------------------------------------------------------------*/
bcostm 0:e1d164542663 39 #include "ili9341.h"
bcostm 0:e1d164542663 40
bcostm 0:e1d164542663 41 /** @addtogroup BSP
bcostm 0:e1d164542663 42 * @{
bcostm 0:e1d164542663 43 */
bcostm 0:e1d164542663 44
bcostm 0:e1d164542663 45 /** @addtogroup Components
bcostm 0:e1d164542663 46 * @{
bcostm 0:e1d164542663 47 */
bcostm 0:e1d164542663 48
bcostm 0:e1d164542663 49 /** @addtogroup ILI9341
bcostm 0:e1d164542663 50 * @brief This file provides a set of functions needed to drive the
bcostm 0:e1d164542663 51 * ILI9341 LCD.
bcostm 0:e1d164542663 52 * @{
bcostm 0:e1d164542663 53 */
bcostm 0:e1d164542663 54
bcostm 0:e1d164542663 55 /** @defgroup ILI9341_Private_TypesDefinitions
bcostm 0:e1d164542663 56 * @{
bcostm 0:e1d164542663 57 */
bcostm 0:e1d164542663 58 /**
bcostm 0:e1d164542663 59 * @}
bcostm 0:e1d164542663 60 */
bcostm 0:e1d164542663 61
bcostm 0:e1d164542663 62 /** @defgroup ILI9341_Private_Defines
bcostm 0:e1d164542663 63 * @{
bcostm 0:e1d164542663 64 */
bcostm 0:e1d164542663 65 /**
bcostm 0:e1d164542663 66 * @}
bcostm 0:e1d164542663 67 */
bcostm 0:e1d164542663 68
bcostm 0:e1d164542663 69 /** @defgroup ILI9341_Private_Macros
bcostm 0:e1d164542663 70 * @{
bcostm 0:e1d164542663 71 */
bcostm 0:e1d164542663 72 /**
bcostm 0:e1d164542663 73 * @}
bcostm 0:e1d164542663 74 */
bcostm 0:e1d164542663 75
bcostm 0:e1d164542663 76 /** @defgroup ILI9341_Private_Variables
bcostm 0:e1d164542663 77 * @{
bcostm 0:e1d164542663 78 */
bcostm 0:e1d164542663 79
bcostm 0:e1d164542663 80 LCD_DrvTypeDef ili9341_drv =
bcostm 0:e1d164542663 81 {
bcostm 0:e1d164542663 82 ili9341_Init,
bcostm 0:e1d164542663 83 ili9341_ReadID,
bcostm 0:e1d164542663 84 ili9341_DisplayOn,
bcostm 0:e1d164542663 85 ili9341_DisplayOff,
bcostm 0:e1d164542663 86 0,
bcostm 0:e1d164542663 87 0,
bcostm 0:e1d164542663 88 0,
bcostm 0:e1d164542663 89 0,
bcostm 0:e1d164542663 90 0,
bcostm 0:e1d164542663 91 0,
bcostm 0:e1d164542663 92 ili9341_GetLcdPixelWidth,
bcostm 0:e1d164542663 93 ili9341_GetLcdPixelHeight,
bcostm 0:e1d164542663 94 0,
bcostm 0:e1d164542663 95 0,
bcostm 0:e1d164542663 96 };
bcostm 0:e1d164542663 97
bcostm 0:e1d164542663 98 /**
bcostm 0:e1d164542663 99 * @}
bcostm 0:e1d164542663 100 */
bcostm 0:e1d164542663 101
bcostm 0:e1d164542663 102 /** @defgroup ILI9341_Private_FunctionPrototypes
bcostm 0:e1d164542663 103 * @{
bcostm 0:e1d164542663 104 */
bcostm 0:e1d164542663 105
bcostm 0:e1d164542663 106 /**
bcostm 0:e1d164542663 107 * @}
bcostm 0:e1d164542663 108 */
bcostm 0:e1d164542663 109
bcostm 0:e1d164542663 110 /** @defgroup ILI9341_Private_Functions
bcostm 0:e1d164542663 111 * @{
bcostm 0:e1d164542663 112 */
bcostm 0:e1d164542663 113
bcostm 0:e1d164542663 114 /**
bcostm 0:e1d164542663 115 * @brief Power on the LCD.
bcostm 0:e1d164542663 116 * @param None
bcostm 0:e1d164542663 117 * @retval None
bcostm 0:e1d164542663 118 */
bcostm 0:e1d164542663 119 void ili9341_Init(void)
bcostm 0:e1d164542663 120 {
bcostm 0:e1d164542663 121 /* Initialize ILI9341 low level bus layer ----------------------------------*/
bcostm 0:e1d164542663 122 LCD_IO_Init();
bcostm 0:e1d164542663 123
bcostm 0:e1d164542663 124 /* Configure LCD */
bcostm 0:e1d164542663 125 ili9341_WriteReg(0xCA);
bcostm 0:e1d164542663 126 ili9341_WriteData(0xC3);
bcostm 0:e1d164542663 127 ili9341_WriteData(0x08);
bcostm 0:e1d164542663 128 ili9341_WriteData(0x50);
bcostm 0:e1d164542663 129 ili9341_WriteReg(LCD_POWERB);
bcostm 0:e1d164542663 130 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 131 ili9341_WriteData(0xC1);
bcostm 0:e1d164542663 132 ili9341_WriteData(0x30);
bcostm 0:e1d164542663 133 ili9341_WriteReg(LCD_POWER_SEQ);
bcostm 0:e1d164542663 134 ili9341_WriteData(0x64);
bcostm 0:e1d164542663 135 ili9341_WriteData(0x03);
bcostm 0:e1d164542663 136 ili9341_WriteData(0x12);
bcostm 0:e1d164542663 137 ili9341_WriteData(0x81);
bcostm 0:e1d164542663 138 ili9341_WriteReg(LCD_DTCA);
bcostm 0:e1d164542663 139 ili9341_WriteData(0x85);
bcostm 0:e1d164542663 140 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 141 ili9341_WriteData(0x78);
bcostm 0:e1d164542663 142 ili9341_WriteReg(LCD_POWERA);
bcostm 0:e1d164542663 143 ili9341_WriteData(0x39);
bcostm 0:e1d164542663 144 ili9341_WriteData(0x2C);
bcostm 0:e1d164542663 145 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 146 ili9341_WriteData(0x34);
bcostm 0:e1d164542663 147 ili9341_WriteData(0x02);
bcostm 0:e1d164542663 148 ili9341_WriteReg(LCD_PRC);
bcostm 0:e1d164542663 149 ili9341_WriteData(0x20);
bcostm 0:e1d164542663 150 ili9341_WriteReg(LCD_DTCB);
bcostm 0:e1d164542663 151 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 152 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 153 ili9341_WriteReg(LCD_FRMCTR1);
bcostm 0:e1d164542663 154 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 155 ili9341_WriteData(0x1B);
bcostm 0:e1d164542663 156 ili9341_WriteReg(LCD_DFC);
bcostm 0:e1d164542663 157 ili9341_WriteData(0x0A);
bcostm 0:e1d164542663 158 ili9341_WriteData(0xA2);
bcostm 0:e1d164542663 159 ili9341_WriteReg(LCD_POWER1);
bcostm 0:e1d164542663 160 ili9341_WriteData(0x10);
bcostm 0:e1d164542663 161 ili9341_WriteReg(LCD_POWER2);
bcostm 0:e1d164542663 162 ili9341_WriteData(0x10);
bcostm 0:e1d164542663 163 ili9341_WriteReg(LCD_VCOM1);
bcostm 0:e1d164542663 164 ili9341_WriteData(0x45);
bcostm 0:e1d164542663 165 ili9341_WriteData(0x15);
bcostm 0:e1d164542663 166 ili9341_WriteReg(LCD_VCOM2);
bcostm 0:e1d164542663 167 ili9341_WriteData(0x90);
bcostm 0:e1d164542663 168 ili9341_WriteReg(LCD_MAC);
bcostm 0:e1d164542663 169 ili9341_WriteData(0xC8);
bcostm 0:e1d164542663 170 ili9341_WriteReg(LCD_3GAMMA_EN);
bcostm 0:e1d164542663 171 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 172 ili9341_WriteReg(LCD_RGB_INTERFACE);
bcostm 0:e1d164542663 173 ili9341_WriteData(0xC2);
bcostm 0:e1d164542663 174 ili9341_WriteReg(LCD_DFC);
bcostm 0:e1d164542663 175 ili9341_WriteData(0x0A);
bcostm 0:e1d164542663 176 ili9341_WriteData(0xA7);
bcostm 0:e1d164542663 177 ili9341_WriteData(0x27);
bcostm 0:e1d164542663 178 ili9341_WriteData(0x04);
bcostm 0:e1d164542663 179
bcostm 0:e1d164542663 180 /* Colomn address set */
bcostm 0:e1d164542663 181 ili9341_WriteReg(LCD_COLUMN_ADDR);
bcostm 0:e1d164542663 182 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 183 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 184 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 185 ili9341_WriteData(0xEF);
bcostm 0:e1d164542663 186 /* Page address set */
bcostm 0:e1d164542663 187 ili9341_WriteReg(LCD_PAGE_ADDR);
bcostm 0:e1d164542663 188 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 189 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 190 ili9341_WriteData(0x01);
bcostm 0:e1d164542663 191 ili9341_WriteData(0x3F);
bcostm 0:e1d164542663 192 ili9341_WriteReg(LCD_INTERFACE);
bcostm 0:e1d164542663 193 ili9341_WriteData(0x01);
bcostm 0:e1d164542663 194 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 195 ili9341_WriteData(0x06);
bcostm 0:e1d164542663 196
bcostm 0:e1d164542663 197 ili9341_WriteReg(LCD_GRAM);
bcostm 0:e1d164542663 198 LCD_Delay(200);
bcostm 0:e1d164542663 199
bcostm 0:e1d164542663 200 ili9341_WriteReg(LCD_GAMMA);
bcostm 0:e1d164542663 201 ili9341_WriteData(0x01);
bcostm 0:e1d164542663 202
bcostm 0:e1d164542663 203 ili9341_WriteReg(LCD_PGAMMA);
bcostm 0:e1d164542663 204 ili9341_WriteData(0x0F);
bcostm 0:e1d164542663 205 ili9341_WriteData(0x29);
bcostm 0:e1d164542663 206 ili9341_WriteData(0x24);
bcostm 0:e1d164542663 207 ili9341_WriteData(0x0C);
bcostm 0:e1d164542663 208 ili9341_WriteData(0x0E);
bcostm 0:e1d164542663 209 ili9341_WriteData(0x09);
bcostm 0:e1d164542663 210 ili9341_WriteData(0x4E);
bcostm 0:e1d164542663 211 ili9341_WriteData(0x78);
bcostm 0:e1d164542663 212 ili9341_WriteData(0x3C);
bcostm 0:e1d164542663 213 ili9341_WriteData(0x09);
bcostm 0:e1d164542663 214 ili9341_WriteData(0x13);
bcostm 0:e1d164542663 215 ili9341_WriteData(0x05);
bcostm 0:e1d164542663 216 ili9341_WriteData(0x17);
bcostm 0:e1d164542663 217 ili9341_WriteData(0x11);
bcostm 0:e1d164542663 218 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 219 ili9341_WriteReg(LCD_NGAMMA);
bcostm 0:e1d164542663 220 ili9341_WriteData(0x00);
bcostm 0:e1d164542663 221 ili9341_WriteData(0x16);
bcostm 0:e1d164542663 222 ili9341_WriteData(0x1B);
bcostm 0:e1d164542663 223 ili9341_WriteData(0x04);
bcostm 0:e1d164542663 224 ili9341_WriteData(0x11);
bcostm 0:e1d164542663 225 ili9341_WriteData(0x07);
bcostm 0:e1d164542663 226 ili9341_WriteData(0x31);
bcostm 0:e1d164542663 227 ili9341_WriteData(0x33);
bcostm 0:e1d164542663 228 ili9341_WriteData(0x42);
bcostm 0:e1d164542663 229 ili9341_WriteData(0x05);
bcostm 0:e1d164542663 230 ili9341_WriteData(0x0C);
bcostm 0:e1d164542663 231 ili9341_WriteData(0x0A);
bcostm 0:e1d164542663 232 ili9341_WriteData(0x28);
bcostm 0:e1d164542663 233 ili9341_WriteData(0x2F);
bcostm 0:e1d164542663 234 ili9341_WriteData(0x0F);
bcostm 0:e1d164542663 235
bcostm 0:e1d164542663 236 ili9341_WriteReg(LCD_SLEEP_OUT);
bcostm 0:e1d164542663 237 LCD_Delay(200);
bcostm 0:e1d164542663 238 ili9341_WriteReg(LCD_DISPLAY_ON);
bcostm 0:e1d164542663 239 /* GRAM start writing */
bcostm 0:e1d164542663 240 ili9341_WriteReg(LCD_GRAM);
bcostm 0:e1d164542663 241 }
bcostm 0:e1d164542663 242
bcostm 0:e1d164542663 243 /**
bcostm 0:e1d164542663 244 * @brief Disables the Display.
bcostm 0:e1d164542663 245 * @param None
bcostm 0:e1d164542663 246 * @retval LCD Register Value.
bcostm 0:e1d164542663 247 */
bcostm 0:e1d164542663 248 uint16_t ili9341_ReadID(void)
bcostm 0:e1d164542663 249 {
bcostm 0:e1d164542663 250 LCD_IO_Init();
bcostm 0:e1d164542663 251 return ((uint16_t)ili9341_ReadData(LCD_READ_ID4, LCD_READ_ID4_SIZE));
bcostm 0:e1d164542663 252 }
bcostm 0:e1d164542663 253
bcostm 0:e1d164542663 254 /**
bcostm 0:e1d164542663 255 * @brief Enables the Display.
bcostm 0:e1d164542663 256 * @param None
bcostm 0:e1d164542663 257 * @retval None
bcostm 0:e1d164542663 258 */
bcostm 0:e1d164542663 259 void ili9341_DisplayOn(void)
bcostm 0:e1d164542663 260 {
bcostm 0:e1d164542663 261 /* Display On */
bcostm 0:e1d164542663 262 ili9341_WriteReg(LCD_DISPLAY_ON);
bcostm 0:e1d164542663 263 }
bcostm 0:e1d164542663 264
bcostm 0:e1d164542663 265 /**
bcostm 0:e1d164542663 266 * @brief Disables the Display.
bcostm 0:e1d164542663 267 * @param None
bcostm 0:e1d164542663 268 * @retval None
bcostm 0:e1d164542663 269 */
bcostm 0:e1d164542663 270 void ili9341_DisplayOff(void)
bcostm 0:e1d164542663 271 {
bcostm 0:e1d164542663 272 /* Display Off */
bcostm 0:e1d164542663 273 ili9341_WriteReg(LCD_DISPLAY_OFF);
bcostm 0:e1d164542663 274 }
bcostm 0:e1d164542663 275
bcostm 0:e1d164542663 276 /**
bcostm 0:e1d164542663 277 * @brief Writes to the selected LCD register.
bcostm 0:e1d164542663 278 * @param LCD_Reg: address of the selected register.
bcostm 0:e1d164542663 279 * @retval None
bcostm 0:e1d164542663 280 */
bcostm 0:e1d164542663 281 void ili9341_WriteReg(uint8_t LCD_Reg)
bcostm 0:e1d164542663 282 {
bcostm 0:e1d164542663 283 LCD_IO_WriteReg(LCD_Reg);
bcostm 0:e1d164542663 284 }
bcostm 0:e1d164542663 285
bcostm 0:e1d164542663 286 /**
bcostm 0:e1d164542663 287 * @brief Writes data to the selected LCD register.
bcostm 0:e1d164542663 288 * @param LCD_Reg: address of the selected register.
bcostm 0:e1d164542663 289 * @retval None
bcostm 0:e1d164542663 290 */
bcostm 0:e1d164542663 291 void ili9341_WriteData(uint16_t RegValue)
bcostm 0:e1d164542663 292 {
bcostm 0:e1d164542663 293 LCD_IO_WriteData(RegValue);
bcostm 0:e1d164542663 294 }
bcostm 0:e1d164542663 295
bcostm 0:e1d164542663 296 /**
bcostm 0:e1d164542663 297 * @brief Reads the selected LCD Register.
bcostm 0:e1d164542663 298 * @param RegValue: Address of the register to read
bcostm 0:e1d164542663 299 * @param ReadSize: Number of bytes to read
bcostm 0:e1d164542663 300 * @retval LCD Register Value.
bcostm 0:e1d164542663 301 */
bcostm 0:e1d164542663 302 uint32_t ili9341_ReadData(uint16_t RegValue, uint8_t ReadSize)
bcostm 0:e1d164542663 303 {
bcostm 0:e1d164542663 304 /* Read a max of 4 bytes */
bcostm 0:e1d164542663 305 return (LCD_IO_ReadData(RegValue, ReadSize));
bcostm 0:e1d164542663 306 }
bcostm 0:e1d164542663 307
bcostm 0:e1d164542663 308 /**
bcostm 0:e1d164542663 309 * @brief Get LCD PIXEL WIDTH.
bcostm 0:e1d164542663 310 * @param None
bcostm 0:e1d164542663 311 * @retval LCD PIXEL WIDTH.
bcostm 0:e1d164542663 312 */
bcostm 0:e1d164542663 313 uint16_t ili9341_GetLcdPixelWidth(void)
bcostm 0:e1d164542663 314 {
bcostm 0:e1d164542663 315 /* Return LCD PIXEL WIDTH */
bcostm 0:e1d164542663 316 return ILI9341_LCD_PIXEL_WIDTH;
bcostm 0:e1d164542663 317 }
bcostm 0:e1d164542663 318
bcostm 0:e1d164542663 319 /**
bcostm 0:e1d164542663 320 * @brief Get LCD PIXEL HEIGHT.
bcostm 0:e1d164542663 321 * @param None
bcostm 0:e1d164542663 322 * @retval LCD PIXEL HEIGHT.
bcostm 0:e1d164542663 323 */
bcostm 0:e1d164542663 324 uint16_t ili9341_GetLcdPixelHeight(void)
bcostm 0:e1d164542663 325 {
bcostm 0:e1d164542663 326 /* Return LCD PIXEL HEIGHT */
bcostm 0:e1d164542663 327 return ILI9341_LCD_PIXEL_HEIGHT;
bcostm 0:e1d164542663 328 }
bcostm 0:e1d164542663 329
bcostm 0:e1d164542663 330 /**
bcostm 0:e1d164542663 331 * @}
bcostm 0:e1d164542663 332 */
bcostm 0:e1d164542663 333
bcostm 0:e1d164542663 334 /**
bcostm 0:e1d164542663 335 * @}
bcostm 0:e1d164542663 336 */
bcostm 0:e1d164542663 337
bcostm 0:e1d164542663 338 /**
bcostm 0:e1d164542663 339 * @}
bcostm 0:e1d164542663 340 */
bcostm 0:e1d164542663 341
bcostm 0:e1d164542663 342 /**
bcostm 0:e1d164542663 343 * @}
bcostm 0:e1d164542663 344 */
bcostm 0:e1d164542663 345
bcostm 0:e1d164542663 346 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/