Advertisement
Guest User

Untitled

a guest
May 1st, 2016
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 42.11 KB | None | 0 0
  1. //*****************************************************************************
  2. //
  3. // Kentec320x240x16_ssd2119_8bit.c - Display driver for the Kentec
  4. // K350QVG-V2-F TFT display with an SSD2119
  5. // controller. This version assumes an
  6. // 8080-8bit interface between the micro
  7. // and display (PS3-0 = 0011b).
  8. //
  9. // Copyright (c) 2012-2015 Texas Instruments Incorporated. All rights reserved.
  10. // Software License Agreement
  11. //
  12. // Texas Instruments (TI) is supplying this software for use solely and
  13. // exclusively on TI's microcontroller products. The software is owned by
  14. // TI and/or its suppliers, and is protected under applicable copyright
  15. // laws. You may not combine this software with "viral" open-source
  16. // software in order to form a larger program.
  17. //
  18. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  19. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  20. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  22. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  23. // DAMAGES, FOR ANY REASON WHATSOEVER.
  24. //
  25. // This is part of revision 2.1.2.111 of the EK-TM4C1294XL Firmware Package.
  26. //
  27. //*****************************************************************************
  28.  
  29. //*****************************************************************************
  30. //
  31. //! \addtogroup display_api
  32. //! @{
  33. //
  34. //*****************************************************************************
  35.  
  36. #include <stdbool.h>
  37. #include <stdint.h>
  38. #include "inc/hw_gpio.h"
  39. #include "inc/hw_ints.h"
  40. #include "inc/hw_memmap.h"
  41. #include "inc/hw_types.h"
  42. #include "driverlib/gpio.h"
  43. #include "driverlib/epi.h"
  44. #include "driverlib/interrupt.h"
  45. #include "driverlib/sysctl.h"
  46. #include "driverlib/timer.h"
  47. #include "driverlib/rom.h"
  48. #include "grlib/grlib.h"
  49. #include "drivers/Kentec320x240x16_ssd2119_8bit.h"
  50.  
  51. //*****************************************************************************
  52. //
  53. // This driver operates in four different screen orientations. They are:
  54. //
  55. // * Portrait - The screen is taller than it is wide, and the flex connector is
  56. // on the left of the display. This is selected by defining
  57. // PORTRAIT.
  58. //
  59. // * Landscape - The screen is wider than it is tall, and the flex connector is
  60. // on the bottom of the display. This is selected by defining
  61. // LANDSCAPE.
  62. //
  63. // * Portrait flip - The screen is taller than it is wide, and the flex
  64. // connector is on the right of the display. This is
  65. // selected by defining PORTRAIT_FLIP.
  66. //
  67. // * Landscape flip - The screen is wider than it is tall, and the flex
  68. // connector is on the top of the display. This is
  69. // selected by defining LANDSCAPE_FLIP.
  70. //
  71. // These can also be imagined in terms of screen rotation; if portrait mode is
  72. // 0 degrees of screen rotation, landscape is 90 degrees of counter-clockwise
  73. // rotation, portrait flip is 180 degrees of rotation, and landscape flip is
  74. // 270 degress of counter-clockwise rotation.
  75. //
  76. // If no screen orientation is selected, "landscape flip" mode will be used.
  77. //
  78. //*****************************************************************************
  79. #if ! defined(PORTRAIT) && ! defined(PORTRAIT_FLIP) && \
  80. ! defined(LANDSCAPE) && ! defined(LANDSCAPE_FLIP)
  81. #define LANDSCAPE
  82. //#define PORTRAIT
  83. #endif
  84.  
  85.  
  86. //*****************************************************************************
  87. //
  88. // Various definitions controlling coordinate space mapping and drawing
  89. // direction in the four supported orientations.
  90. //
  91. //*****************************************************************************
  92. #ifdef PORTRAIT
  93. #define HORIZ_DIRECTION 0x28
  94. #define VERT_DIRECTION 0x20
  95. #define MAPPED_X(x, y) (319 - (y))
  96. #define MAPPED_Y(x, y) (x)
  97. #endif
  98. #ifdef LANDSCAPE
  99. #define HORIZ_DIRECTION 0x00
  100. #define VERT_DIRECTION 0x08
  101. #define MAPPED_X(x, y) (319 - (x))
  102. #define MAPPED_Y(x, y) (239 - (y))
  103. #endif
  104. #ifdef PORTRAIT_FLIP
  105. #define HORIZ_DIRECTION 0x18
  106. #define VERT_DIRECTION 0x10
  107. #define MAPPED_X(x, y) (y)
  108. #define MAPPED_Y(x, y) (239 - (x))
  109. #endif
  110. #ifdef LANDSCAPE_FLIP
  111. #define HORIZ_DIRECTION 0x30
  112. #define VERT_DIRECTION 0x38
  113. #define MAPPED_X(x, y) (x)
  114. #define MAPPED_Y(x, y) (y)
  115. #endif
  116.  
  117. //*****************************************************************************
  118. //
  119. // Defines for the pins that are used to communicate with the SSD2119.
  120. //
  121. //*****************************************************************************
  122.  
  123. //
  124. // LCD Data line GPIO definitions.
  125. //
  126. #define LCD_DATAH_PERIPH_Q SYSCTL_PERIPH_GPIOQ
  127. #define LCD_DATAH_BASE_Q GPIO_PORTQ_BASE
  128. #define LCD_DATAH_D7 0x40066010
  129. #define LCD_DATAH_D7_S(a) ((a) >> 5)
  130. #define LCD_DATAH_D6 0x40066020
  131. #define LCD_DATAH_D6_S(a) ((a) >> 3)
  132. #define LCD_DATAH_D4 0x40066004
  133. #define LCD_DATAH_D4_S(a) ((a) >> 4)
  134. #define LCD_DATAH_PERIPH_D SYSCTL_PERIPH_GPIOD
  135. #define LCD_DATAH_BASE_D GPIO_PORTD_AHB_BASE
  136. #define LCD_DATAH_D5_S(a) ((a) >> 3)
  137. #define LCD_DATAH_D5 0x4005B010
  138. #define LCD_DATAH_PERIPH_K SYSCTL_PERIPH_GPIOK
  139. #define LCD_DATAH_BASE_K GPIO_PORTK_BASE
  140. #define LCD_DATAH_D3_S(a) ((a) << 2)
  141. #define LCD_DATAH_D3 0x40061080
  142. #define LCD_DATAH_PERIPH_M SYSCTL_PERIPH_GPIOM
  143. #define LCD_DATAH_BASE_M GPIO_PORTM_BASE
  144. #define LCD_DATAH_D2_S(a) ((a) << 5)
  145. #define LCD_DATAH_D2 0x40063200
  146. #define LCD_DATAH_PERIPH_P SYSCTL_PERIPH_GPIOP
  147. #define LCD_DATAH_BASE_P GPIO_PORTP_BASE
  148. #define LCD_DATAH_D1_S(a) (a)
  149. #define LCD_DATAH_D1 0x40065008
  150. #define LCD_DATAH_D0_S(a) (a)
  151. #define LCD_DATAH_D0 0x40065004
  152.  
  153. #define LCD_DATAH_PIN_7 GPIO_PIN_2
  154. #define LCD_DATAH_PIN_6 GPIO_PIN_3
  155. #define LCD_DATAH_PIN_5 GPIO_PIN_2
  156. #define LCD_DATAH_PIN_4 GPIO_PIN_0
  157. #define LCD_DATAH_PIN_3 GPIO_PIN_5
  158. #define LCD_DATAH_PIN_2 GPIO_PIN_7
  159. #define LCD_DATAH_PIN_1 GPIO_PIN_1
  160. #define LCD_DATAH_PIN_0 GPIO_PIN_0
  161.  
  162. //
  163. // LCD control line GPIO definitions.
  164. //
  165. #define LCD_CS_PERIPH SYSCTL_PERIPH_GPION
  166. #define LCD_CS_BASE GPIO_PORTN_BASE
  167. #define LCD_CS_PIN GPIO_PIN_4
  168. #define LCD_CS_PIN_REG 0x40064040
  169. #define LCD_DC_PERIPH SYSCTL_PERIPH_GPION
  170. #define LCD_DC_BASE GPIO_PORTN_BASE
  171. #define LCD_DC_PIN GPIO_PIN_5
  172. #define LCD_DC_PIN_REG 0x40064080
  173. #define LCD_WR_PERIPH SYSCTL_PERIPH_GPIOP
  174. #define LCD_WR_BASE GPIO_PORTP_BASE
  175. #define LCD_WR_PIN GPIO_PIN_4
  176. #define LCD_WR_PIN_REG 0x40065040
  177. #define LCD_RD_PERIPH SYSCTL_PERIPH_GPIOP
  178. #define LCD_RD_BASE GPIO_PORTP_BASE
  179. #define LCD_RD_PIN GPIO_PIN_3
  180. #define LCD_RD_PIN_REG 0x40065020
  181.  
  182. //*****************************************************************************
  183. //
  184. // Backlight control GPIO used with the Flash/SRAM/LCD daughter board.
  185. //
  186. //*****************************************************************************
  187. #define LCD_BACKLIGHT_PERIPH SYSCTL_PERIPH_GPIOG
  188. #define LCD_BACKLIGHT_BASE GPIO_PORTG_AHB_BASE
  189. #define LCD_BACKLIGHT_PIN GPIO_PIN_1
  190.  
  191. #define USER_LED_PERIPH SYSCTL_PERIPH_GPION
  192. #define USER_LED_BASE GPIO_PORTN_BASE
  193. #define USER_LED_1_PIN GPIO_PIN_0
  194. #define USER_LED_2_PIN GPIO_PIN_1
  195.  
  196. //*****************************************************************************
  197. //
  198. // Macro used to set the LCD data bus in preparation for writing a byte to the
  199. // device.
  200. //
  201. //*****************************************************************************
  202. #define SET_LCD_DATA(ui8Byte) \
  203. { \
  204. HWREG(LCD_DATAH_D7) = LCD_DATAH_D7_S(ui8Byte); \
  205. HWREG(LCD_DATAH_D6) = LCD_DATAH_D6_S(ui8Byte); \
  206. HWREG(LCD_DATAH_D5) = LCD_DATAH_D5_S(ui8Byte); \
  207. HWREG(LCD_DATAH_D4) = LCD_DATAH_D4_S(ui8Byte); \
  208. HWREG(LCD_DATAH_D3) = LCD_DATAH_D3_S(ui8Byte); \
  209. HWREG(LCD_DATAH_D2) = LCD_DATAH_D2_S(ui8Byte); \
  210. HWREG(LCD_DATAH_D1) = LCD_DATAH_D1_S(ui8Byte); \
  211. HWREG(LCD_DATAH_D0) = LCD_DATAH_D0_S(ui8Byte); \
  212. }
  213.  
  214. //*****************************************************************************
  215. //
  216. // Various internal SD2119 registers name labels
  217. //
  218. //*****************************************************************************
  219. //#define SSD2119_DEVICE_CODE_READ_REG 0x00
  220. //#define SSD2119_OSC_START_REG 0x00
  221. //#define SSD2119_OUTPUT_CTRL_REG 0x01
  222. //#define SSD2119_LCD_DRIVE_AC_CTRL_REG 0x02
  223. //#define SSD2119_PWR_CTRL_1_REG 0x03
  224. //#define SSD2119_DISPLAY_CTRL_REG 0x07
  225. //#define SSD2119_FRAME_CYCLE_CTRL_REG 0x0B
  226. //#define SSD2119_PWR_CTRL_2_REG 0x0C
  227. //#define SSD2119_PWR_CTRL_3_REG 0x0D
  228. //#define SSD2119_PWR_CTRL_4_REG 0x0E
  229. //#define SSD2119_GATE_SCAN_START_REG 0x0F
  230. //#define SSD2119_SLEEP_MODE_REG 0x10
  231. //#define SSD2119_ENTRY_MODE_REG 0x11
  232. //#define SSD2119_GEN_IF_CTRL_REG 0x15
  233. //#define SSD2119_PWR_CTRL_5_REG 0x1E
  234. //#define SSD2119_RAM_DATA_REG 0x22
  235. //#define SSD2119_FRAME_FREQ_REG 0x25
  236. //#define SSD2119_VCOM_OTP_1_REG 0x28
  237. //#define SSD2119_VCOM_OTP_2_REG 0x29
  238. //#define SSD2119_GAMMA_CTRL_1_REG 0x30
  239. //#define SSD2119_GAMMA_CTRL_2_REG 0x31
  240. //#define SSD2119_GAMMA_CTRL_3_REG 0x32
  241. //#define SSD2119_GAMMA_CTRL_4_REG 0x33
  242. //#define SSD2119_GAMMA_CTRL_5_REG 0x34
  243. //#define SSD2119_GAMMA_CTRL_6_REG 0x35
  244. //#define SSD2119_GAMMA_CTRL_7_REG 0x36
  245. //#define SSD2119_GAMMA_CTRL_8_REG 0x37
  246. //#define SSD2119_GAMMA_CTRL_9_REG 0x3A
  247. //#define SSD2119_GAMMA_CTRL_10_REG 0x3B
  248. //#define SSD2119_V_RAM_POS_REG 0x44
  249. //#define SSD2119_H_RAM_START_REG 0x45
  250. //#define SSD2119_H_RAM_END_REG 0x46
  251. //#define SSD2119_X_RAM_ADDR_REG 0x4E
  252. //#define SSD2119_Y_RAM_ADDR_REG 0x4F
  253.  
  254. #define ENTRY_MODE_DEFAULT 0x6830
  255. #define MAKE_ENTRY_MODE(x) ((ENTRY_MODE_DEFAULT & 0xFF00) | (x))
  256.  
  257. //*****************************************************************************
  258. //
  259. // The dimensions of the LCD panel.
  260. //
  261. //*****************************************************************************
  262. #define LCD_VERTICAL_MAX 240
  263. #define LCD_HORIZONTAL_MAX 320
  264.  
  265. //*****************************************************************************
  266. //
  267. // Translates a 24-bit RGB color to a display driver-specific color.
  268. //
  269. // \param c is the 24-bit RGB color. The least-significant byte is the blue
  270. // channel, the next byte is the green channel, and the third byte is the red
  271. // channel.
  272. //
  273. // This macro translates a 24-bit RGB color into a value that can be written
  274. // into the display's frame buffer in order to reproduce that color, or the
  275. // closest possible approximation of that color.
  276. //
  277. // \return Returns the display-driver specific color.
  278. //
  279. //*****************************************************************************
  280. #define DPYCOLORTRANSLATE(c) ((((c) & 0x00f80000) >> 8) | \
  281. (((c) & 0x0000fc00) >> 5) | \
  282. (((c) & 0x000000f8) >> 3))
  283.  
  284. //*****************************************************************************
  285. //
  286. // Function pointer types for low level LCD controller access functions.
  287. //
  288. //*****************************************************************************
  289. typedef void (*pfnWriteData)(uint16_t ui16Data);
  290. typedef void (*pfnWriteCommand)(uint8_t ui8Data);
  291.  
  292. //*****************************************************************************
  293. //
  294. // Function pointers for low level LCD controller access functions.
  295. //
  296. //*****************************************************************************
  297.  
  298. static void WriteDataGPIO(uint16_t ui16Data);
  299. static void WriteCommandGPIO(uint8_t ui8Data);
  300.  
  301. pfnWriteData WriteData = WriteDataGPIO;
  302. pfnWriteCommand WriteCommand = WriteCommandGPIO;
  303.  
  304. void LED_ON(void)
  305. {
  306. HWREG(LCD_BACKLIGHT_BASE + GPIO_O_DATA + (LCD_BACKLIGHT_PIN << 2)) = 0;
  307. HWREG(USER_LED_BASE + GPIO_O_DATA + (USER_LED_1_PIN << 2)) =
  308. USER_LED_1_PIN;
  309. }
  310.  
  311. void LED_OFF(void)
  312. {
  313. HWREG(LCD_BACKLIGHT_BASE + GPIO_O_DATA + (LCD_BACKLIGHT_PIN << 2)) =
  314. LCD_BACKLIGHT_PIN;
  315. HWREG(USER_LED_BASE + GPIO_O_DATA + (USER_LED_1_PIN << 2)) = 0;
  316. }
  317.  
  318. //*****************************************************************************
  319. //
  320. // Writes a data word to the SSD2119. This function implements the basic GPIO
  321. // interface to the LCD display.
  322. //
  323. //*****************************************************************************
  324. static void
  325. WriteDataGPIO(uint16_t ui16Data)
  326. {
  327. //
  328. // Write the most significant byte of the data to the bus.
  329. //
  330. SET_LCD_DATA(ui16Data >> 8);
  331. SysCtlDelay(3);
  332.  
  333. //
  334. // Pull CS Low.
  335. //
  336. HWREG(LCD_CS_PIN_REG) = 0;
  337. SysCtlDelay(3);
  338.  
  339. //
  340. // Assert the write enable signal.
  341. // Delay for at least 60nS (at 120 Mhz) to meet Display timing.
  342. //
  343. HWREG(LCD_WR_PIN_REG) = 0;
  344. SysCtlDelay(3);
  345.  
  346. //
  347. // Deassert the write enable signal.
  348. //
  349. HWREG(LCD_WR_PIN_REG) = 0xFF;
  350. SysCtlDelay(3);
  351.  
  352. //
  353. // Write the least significant byte of the data to the bus.
  354. //
  355. SET_LCD_DATA(ui16Data);
  356. SysCtlDelay(3);
  357.  
  358. //
  359. // Assert the write enable signal.
  360. // Delay for at least 60nS (at 120 Mhz) to meet Display timing.
  361. //
  362. HWREG(LCD_WR_PIN_REG) = 0;
  363. SysCtlDelay(3);
  364.  
  365. //
  366. // Deassert the write enable signal.
  367. //
  368. HWREG(LCD_WR_PIN_REG) = 0xFF;
  369. SysCtlDelay(3);
  370.  
  371. //
  372. // Deassert the chip select pin.
  373. //
  374. HWREG(LCD_CS_PIN_REG) = 0xFF;
  375. SysCtlDelay(3);
  376. }
  377.  
  378. //*****************************************************************************
  379. //
  380. // Writes a command to the SSD2119. This function implements the basic GPIO
  381. // interface to the LCD display.
  382. //
  383. //*****************************************************************************
  384. static void
  385. WriteCommandGPIO(uint8_t ui8Data)
  386. {
  387. //
  388. // Write the most significant byte of the data to the bus. This is always
  389. // 0 since commands are no more than 8 bits currently.
  390. //
  391. SET_LCD_DATA(0);
  392. SysCtlDelay(3);
  393.  
  394. //
  395. // Pull CS Low
  396. //
  397. HWREG(LCD_CS_PIN_REG) = 0;
  398. SysCtlDelay(3);
  399.  
  400. //
  401. // Assert the write enable and DC signals. Do this 3 times to slow things
  402. // down a bit.
  403. //
  404. HWREG(LCD_DC_PIN_REG) = 0;
  405. HWREG(LCD_WR_PIN_REG) = 0;
  406. SysCtlDelay(3);
  407.  
  408. //
  409. // Deassert the write enable and DC signals. We need to leave WR high for
  410. // at least 50nS so, again, stick in dummy writes to pad the timing.
  411. //
  412. HWREG(LCD_DC_PIN_REG) = 0xFF;
  413. HWREG(LCD_WR_PIN_REG) = 0xFF;
  414. SysCtlDelay(3);
  415.  
  416. //
  417. // Write the least significant byte of the data to the bus.
  418. //
  419. SET_LCD_DATA(ui8Data);
  420. SysCtlDelay(3);
  421.  
  422. //
  423. // Assert the write enable signal. With delay to meet timing requirements.
  424. //
  425. HWREG(LCD_DC_PIN_REG) = 0;
  426. HWREG(LCD_WR_PIN_REG) = 0;
  427. SysCtlDelay(3);
  428.  
  429.  
  430. //
  431. // Deassert the write enable and DC signals. Make sure we add padding here
  432. // too since some compilers inline this function.
  433. //
  434. HWREG(LCD_DC_PIN_REG) = 0xFF;
  435. HWREG(LCD_WR_PIN_REG) = 0xFF;
  436. SysCtlDelay(3);
  437.  
  438. HWREG(LCD_CS_PIN_REG) = 0xFF;
  439. SysCtlDelay(3);
  440. }
  441.  
  442. //*****************************************************************************
  443. //
  444. // Initializes the pins required for the GPIO-based LCD interface.
  445. //
  446. // This function configures the GPIO pins used to control the LCD display
  447. // when the basic GPIO interface is in use. On exit, the LCD controller
  448. // has been reset and is ready to receive command and data writes.
  449. //
  450. // \return None.
  451. //
  452. //*****************************************************************************
  453. static void
  454. InitGPIOLCDInterface(uint32_t ui32ClockMS)
  455. {
  456. //
  457. // Configure the pins that connect to the LCD as GPIO outputs.
  458. //
  459. SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOA);
  460. SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOD);
  461. SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOQ);
  462. SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOK);
  463. SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOM);
  464. SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPIOP);
  465. SysCtlGPIOAHBEnable(SYSCTL_PERIPH_GPION);
  466.  
  467. GPIOPinTypeGPIOOutput(LCD_DATAH_BASE_D, LCD_DATAH_PIN_5);
  468. GPIOPinTypeGPIOOutput(LCD_DATAH_BASE_Q, LCD_DATAH_PIN_4 |
  469. LCD_DATAH_PIN_7 | LCD_DATAH_PIN_6);
  470. GPIOPinTypeGPIOOutput(LCD_DATAH_BASE_K, LCD_DATAH_PIN_3);
  471. GPIOPinTypeGPIOOutput(LCD_DATAH_BASE_M, LCD_DATAH_PIN_2);
  472. GPIOPinTypeGPIOOutput(LCD_DATAH_BASE_P, LCD_DATAH_PIN_1 | LCD_DATAH_PIN_0);
  473.  
  474. GPIOPadConfigSet(LCD_DATAH_BASE_D, LCD_DATAH_PIN_5, GPIO_STRENGTH_12MA,
  475. GPIO_PIN_TYPE_STD);
  476. GPIOPadConfigSet(LCD_DATAH_BASE_Q, LCD_DATAH_PIN_7 | LCD_DATAH_PIN_6 |
  477. LCD_DATAH_PIN_4, GPIO_STRENGTH_12MA, GPIO_PIN_TYPE_STD);
  478. GPIOPadConfigSet(LCD_DATAH_BASE_K, LCD_DATAH_PIN_3, GPIO_STRENGTH_12MA,
  479. GPIO_PIN_TYPE_STD);
  480. GPIOPadConfigSet(LCD_DATAH_BASE_M, LCD_DATAH_PIN_2, GPIO_STRENGTH_12MA,
  481. GPIO_PIN_TYPE_STD);
  482. GPIOPadConfigSet(LCD_DATAH_BASE_P, LCD_DATAH_PIN_1 | LCD_DATAH_PIN_0,
  483. GPIO_STRENGTH_12MA, GPIO_PIN_TYPE_STD);
  484.  
  485. GPIOPinTypeGPIOOutput(LCD_DC_BASE, LCD_DC_PIN);
  486. GPIOPinTypeGPIOOutput(LCD_RD_BASE, LCD_RD_PIN);
  487. GPIOPinTypeGPIOOutput(LCD_WR_BASE, LCD_WR_PIN);
  488. GPIOPinTypeGPIOOutput(LCD_CS_BASE, LCD_CS_PIN);
  489. GPIOPinTypeGPIOOutput(LCD_BACKLIGHT_BASE, LCD_BACKLIGHT_PIN);
  490.  
  491. //
  492. // Set the LCD control pins to their default values.
  493. //
  494. GPIOPinWrite(LCD_CS_BASE, LCD_CS_PIN, LCD_CS_PIN);
  495. GPIOPinWrite(LCD_DATAH_BASE_D, LCD_DATAH_PIN_5, 0x00);
  496. GPIOPinWrite(LCD_DATAH_BASE_Q, LCD_DATAH_PIN_7 | LCD_DATAH_PIN_6 |
  497. LCD_DATAH_PIN_4, 0x00);
  498. GPIOPinWrite(LCD_DATAH_BASE_K, LCD_DATAH_PIN_3, 0x00);
  499. GPIOPinWrite(LCD_DATAH_BASE_M, LCD_DATAH_PIN_2, 0x00);
  500. GPIOPinWrite(LCD_DATAH_BASE_P, LCD_DATAH_PIN_1 | LCD_DATAH_PIN_0, 0x00);
  501.  
  502. GPIOPinWrite(LCD_DC_BASE, LCD_DC_PIN, 0x00);
  503. GPIOPinWrite(LCD_RD_BASE, LCD_RD_PIN, LCD_RD_PIN);
  504. GPIOPinWrite(LCD_WR_BASE, LCD_WR_PIN, LCD_WR_PIN);
  505. GPIOPinWrite(LCD_CS_BASE, LCD_CS_PIN, 0);
  506.  
  507. //
  508. // Delay for 1ms.
  509. //
  510. SysCtlDelay(ui32ClockMS);
  511.  
  512. //
  513. // Deassert the LCD reset signal.
  514. //
  515. //GPIOPinWrite(LCD_RST_BASE, LCD_RST_PIN, LCD_RST_PIN);
  516.  
  517. //
  518. // Delay for 1ms while the LCD comes out of reset.
  519. //
  520. SysCtlDelay(ui32ClockMS);
  521. }
  522.  
  523. //*****************************************************************************
  524. //
  525. //! Initializes the display driver.
  526. //!
  527. //! \param ui32SysClockSpeed is the system clock speed of the MCU.
  528. //!
  529. //! This function initializes the SSD2119 display controller on the panel,
  530. //! preparing it to display data.
  531. //!
  532. //! \return None.
  533. //
  534. //*****************************************************************************
  535. void
  536. Kentec320x240x16_SSD2119Init(uint32_t ui32SysClockSpeed)
  537. {
  538. uint32_t ui32ClockMS, ui32Count;
  539.  
  540. //
  541. // Get the current processor clock frequency.
  542. //
  543. ui32ClockMS = ui32SysClockSpeed / (3 * 1000);
  544.  
  545. //
  546. // Enable the GPIO peripherals used to interface to the SSD2119.
  547. //
  548. SysCtlPeripheralEnable(LCD_DATAH_PERIPH_D);
  549. SysCtlPeripheralEnable(LCD_DATAH_PERIPH_Q);
  550. SysCtlPeripheralEnable(LCD_DATAH_PERIPH_K);
  551. SysCtlPeripheralEnable(LCD_DATAH_PERIPH_M);
  552. SysCtlPeripheralEnable(LCD_DATAH_PERIPH_P);
  553. SysCtlPeripheralEnable(LCD_DC_PERIPH);
  554. SysCtlPeripheralEnable(LCD_RD_PERIPH);
  555. SysCtlPeripheralEnable(LCD_WR_PERIPH);
  556. SysCtlPeripheralEnable(LCD_CS_PERIPH);
  557. SysCtlPeripheralEnable(LCD_BACKLIGHT_PERIPH);
  558.  
  559. //
  560. // Perform low level interface initialization depending upon how the LCD
  561. // is connected to the Tiva C Series microcontroller. This varies
  562. // depending upon the daughter board connected it is possible that a
  563. // daughter board can drive the LCD directly rather than via the basic GPIO
  564. // interface.
  565. //
  566. {
  567. //
  568. // Initialize the GPIOs used to interface to the LCD controller.
  569. //
  570. InitGPIOLCDInterface(ui32ClockMS);
  571. }
  572.  
  573. //
  574. // Enter sleep mode (if we are not already there).
  575. //
  576. WriteCommand(SSD2119_SLEEP_MODE_REG);
  577. WriteData(0x0001);
  578.  
  579. //
  580. // Set initial power parameters.
  581. //
  582. WriteCommand(SSD2119_PWR_CTRL_5_REG);
  583. WriteData(0x00BA);
  584. WriteCommand(SSD2119_VCOM_OTP_1_REG);
  585. WriteData(0x0006);
  586.  
  587. //
  588. // Start the oscillator.
  589. //
  590. WriteCommand(SSD2119_OSC_START_REG);
  591. WriteData(0x0001);
  592.  
  593. //
  594. // Set pixel format and basic display orientation (scanning direction).
  595. //
  596. WriteCommand(SSD2119_OUTPUT_CTRL_REG);
  597. WriteData(0x30EF);
  598. WriteCommand(SSD2119_LCD_DRIVE_AC_CTRL_REG);
  599. WriteData(0x0600);
  600.  
  601. //
  602. // Exit sleep mode.
  603. //
  604. WriteCommand(SSD2119_SLEEP_MODE_REG);
  605. WriteData(0x0000);
  606.  
  607. //
  608. // Delay 30mS
  609. //
  610. SysCtlDelay(30 * ui32ClockMS);
  611.  
  612. //
  613. // Configure pixel color format and MCU interface parameters.
  614. //
  615. WriteCommand(SSD2119_ENTRY_MODE_REG);
  616. WriteData(ENTRY_MODE_DEFAULT);
  617.  
  618. //
  619. // Enable the display.
  620. //
  621. WriteCommand(SSD2119_DISPLAY_CTRL_REG);
  622. WriteData(0x0033);
  623.  
  624. //
  625. // Set VCIX2 voltage to 6.1V.
  626. //
  627. WriteCommand(SSD2119_PWR_CTRL_2_REG);
  628. WriteData(0x0005);
  629.  
  630. //
  631. // Configure gamma correction.
  632. //
  633. WriteCommand(SSD2119_GAMMA_CTRL_1_REG);
  634. WriteData(0x0000);
  635. WriteCommand(SSD2119_GAMMA_CTRL_2_REG);
  636. WriteData(0x0400);
  637. WriteCommand(SSD2119_GAMMA_CTRL_3_REG);
  638. WriteData(0x0106);
  639. WriteCommand(SSD2119_GAMMA_CTRL_4_REG);
  640. WriteData(0x0700);
  641. WriteCommand(SSD2119_GAMMA_CTRL_5_REG);
  642. WriteData(0x0002);
  643. WriteCommand(SSD2119_GAMMA_CTRL_6_REG);
  644. WriteData(0x0702);
  645. WriteCommand(SSD2119_GAMMA_CTRL_7_REG);
  646. WriteData(0x0707);
  647. WriteCommand(SSD2119_GAMMA_CTRL_8_REG);
  648. WriteData(0x0203);
  649. WriteCommand(SSD2119_GAMMA_CTRL_9_REG);
  650. WriteData(0x1400);
  651. WriteCommand(SSD2119_GAMMA_CTRL_10_REG);
  652. WriteData(0x0F03);
  653.  
  654. //
  655. // Configure Vlcd63 and VCOMl.
  656. //
  657. WriteCommand(SSD2119_PWR_CTRL_3_REG);
  658. WriteData(0x0007);
  659. WriteCommand(SSD2119_PWR_CTRL_4_REG);
  660. WriteData(0x3100);
  661.  
  662. //
  663. // Set the display size and ensure that the GRAM window is set to allow
  664. // access to the full display buffer.
  665. //
  666. WriteCommand(SSD2119_V_RAM_POS_REG);
  667. WriteData((LCD_VERTICAL_MAX-1) << 8);
  668. WriteCommand(SSD2119_H_RAM_START_REG);
  669. WriteData(0x0000);
  670. WriteCommand(SSD2119_H_RAM_END_REG);
  671. WriteData(LCD_HORIZONTAL_MAX-1);
  672. WriteCommand(SSD2119_X_RAM_ADDR_REG);
  673. WriteData(0x00);
  674. WriteCommand(SSD2119_Y_RAM_ADDR_REG);
  675. WriteData(0x00);
  676.  
  677. //
  678. // Clear the contents of the display buffer.
  679. //
  680. WriteCommand(SSD2119_RAM_DATA_REG);
  681. for(ui32Count = 0; ui32Count < (320 * 240); ui32Count++)
  682. {
  683. WriteData(0x0000);
  684. }
  685. }
  686.  
  687. //*****************************************************************************
  688. //
  689. //! Draws a pixel on the screen.
  690. //!
  691. //! \param pvDisplayData is a pointer to the driver-specific data for this
  692. //! display driver.
  693. //! \param i32X is the X coordinate of the pixel.
  694. //! \param i32Y is the Y coordinate of the pixel.
  695. //! \param ui32Value is the color of the pixel.
  696. //!
  697. //! This function sets the given pixel to a particular color. The coordinates
  698. //! of the pixel are assumed to be within the extents of the display.
  699. //!
  700. //! \return None.
  701. //
  702. //*****************************************************************************
  703. static void
  704. Kentec320x240x16_SSD2119PixelDraw(void *pvDisplayData, int32_t i32X,
  705. int32_t i32Y,
  706. uint32_t ui32Value)
  707. {
  708. //
  709. // Set the X address of the display cursor.
  710. //
  711. WriteCommand(SSD2119_X_RAM_ADDR_REG);
  712. WriteData(MAPPED_X(i32X, i32Y));
  713.  
  714. //
  715. // Set the Y address of the display cursor.
  716. //
  717. WriteCommand(SSD2119_Y_RAM_ADDR_REG);
  718. WriteData(MAPPED_Y(i32X, i32Y));
  719.  
  720. //
  721. // Write the pixel value.
  722. //
  723. WriteCommand(SSD2119_RAM_DATA_REG);
  724. WriteData(ui32Value);
  725. }
  726.  
  727. //*****************************************************************************
  728. //
  729. //! Draws a horizontal sequence of pixels on the screen.
  730. //!
  731. //! \param pvDisplayData is a pointer to the driver-specific data for this
  732. //! display driver.
  733. //! \param i32X is the X coordinate of the first pixel.
  734. //! \param i32Y is the Y coordinate of the first pixel.
  735. //! \param i32X0 is sub-pixel offset within the pixel data, which is valid for
  736. //! 1 or 4 bit per pixel formats.
  737. //! \param i32Count is the number of pixels to draw.
  738. //! \param i32BPP is the number of bits per pixel; must be 1, 4, or 8,
  739. //! optionally OR'ed with flags that a driver may use to aid performance.
  740. //! \param pui8Data is a pointer to the pixel data. For 1 and 4 bit per pixel
  741. //! formats, the most significant bit(s) represent the left-most pixel.
  742. //! \param pui8Palette is a pointer to the palette used to draw the pixels.
  743. //!
  744. //! This function draws a horizontal sequence of pixels on the screen, using
  745. //! the supplied palette. For 1 bit per pixel format, the palette contains
  746. //! pre-translated colors; for 4 and 8 bit per pixel formats, the palette
  747. //! contains 24-bit RGB values that must be translated before being written to
  748. //! the display.
  749. //!
  750. //! \return None.
  751. //
  752. //*****************************************************************************
  753. static void
  754. Kentec320x240x16_SSD2119PixelDrawMultiple(void *pvDisplayData, int32_t i32X,
  755. int32_t i32Y, int32_t i32X0,
  756. int32_t i32Count,
  757. int32_t i32BPP,
  758. const uint8_t *pui8Data,
  759. const uint8_t *pui8Palette)
  760. {
  761. uint32_t ui32Byte;
  762.  
  763. //
  764. // Set the cursor increment to left to right, followed by top to bottom.
  765. //
  766. WriteCommand(SSD2119_ENTRY_MODE_REG);
  767. WriteData(MAKE_ENTRY_MODE(HORIZ_DIRECTION));
  768.  
  769. //
  770. // Set the starting X address of the display cursor.
  771. //
  772. WriteCommand(SSD2119_X_RAM_ADDR_REG);
  773. WriteData(MAPPED_X(i32X, i32Y));
  774.  
  775. //
  776. // Set the Y address of the display cursor.
  777. //
  778. WriteCommand(SSD2119_Y_RAM_ADDR_REG);
  779. WriteData(MAPPED_Y(i32X, i32Y));
  780.  
  781. //
  782. // Write the data RAM write command.
  783. //
  784. WriteCommand(SSD2119_RAM_DATA_REG);
  785.  
  786. //
  787. // Determine how to interpret the pixel data based on the number of bits
  788. // per pixel.
  789. //
  790. switch(i32BPP & 0xFF)
  791. {
  792. //
  793. // The pixel data is in 1 bit per pixel format.
  794. //
  795. case 1:
  796. {
  797. //
  798. // Loop while there are more pixels to draw.
  799. //
  800. while(i32Count)
  801. {
  802. //
  803. // Get the next byte of image data.
  804. //
  805. ui32Byte = *pui8Data++;
  806.  
  807. //
  808. // Loop through the pixels in this byte of image data.
  809. //
  810. for(; (i32X0 < 8) && i32Count; i32X0++, i32Count--)
  811. {
  812. //
  813. // Draw this pixel in the appropriate color.
  814. //
  815. WriteData(((uint32_t *)pui8Palette)[(ui32Byte >>
  816. (7 - i32X0)) & 1]);
  817. }
  818.  
  819. //
  820. // Start at the beginning of the next byte of image data.
  821. //
  822. i32X0 = 0;
  823. }
  824.  
  825. //
  826. // The image data has been drawn.
  827. //
  828. break;
  829. }
  830.  
  831. //
  832. // The pixel data is in 4 bit per pixel format.
  833. //
  834. case 4:
  835. {
  836. //
  837. // Loop while there are more pixels to draw. "Duff's device"
  838. // is used to jump into the middle of the loop if the first
  839. // nibble of the pixel data should not be used. Duff's device
  840. // makes use of the fact that a case statement is legal
  841. // anywhere within a sub-block of a switch statement. See
  842. // http://en.wikipedia.org/wiki/Duff's_device for detailed
  843. // information about Duff's device.
  844. //
  845. switch(i32X0 & 1)
  846. {
  847. case 0:
  848. while(i32Count)
  849. {
  850. //
  851. // Get the upper nibble of the next byte of pixel
  852. // data and extract the corresponding entry from
  853. // the palette.
  854. //
  855. ui32Byte = (*pui8Data >> 4) * 3;
  856. ui32Byte = (*(uint32_t *)(pui8Palette + ui32Byte) &
  857. 0x00ffffff);
  858.  
  859. //
  860. // Translate this palette entry and write it to the
  861. // screen.
  862. //
  863. WriteData(DPYCOLORTRANSLATE(ui32Byte));
  864.  
  865. //
  866. // Decrement the count of pixels to draw.
  867. //
  868. i32Count--;
  869.  
  870. //
  871. // See if there is another pixel to draw.
  872. //
  873. if(i32Count)
  874. {
  875. case 1:
  876. //
  877. // Get the lower nibble of the next byte of
  878. // pixel data and extract the corresponding
  879. // entry from the palette.
  880. //
  881. ui32Byte = (*pui8Data++ & 15) * 3;
  882. ui32Byte = (*(uint32_t *)(pui8Palette +
  883. ui32Byte) & 0x00ffffff);
  884.  
  885. //
  886. // Translate this palette entry and write
  887. // it to the screen.
  888. //
  889. WriteData(DPYCOLORTRANSLATE(ui32Byte));
  890.  
  891. //
  892. // Decrement the count of pixels to draw.
  893. //
  894. i32Count--;
  895. }
  896. }
  897. }
  898.  
  899. //
  900. // The image data has been drawn.
  901. //
  902. break;
  903. }
  904.  
  905. //
  906. // The pixel data is in 8 bit per pixel format.
  907. //
  908. case 8:
  909. {
  910. //
  911. // Loop while there are more pixels to draw.
  912. //
  913. while(i32Count--)
  914. {
  915. //
  916. // Get the next byte of pixel data and extract the
  917. // corresponding entry from the palette.
  918. //
  919. ui32Byte = *pui8Data++ * 3;
  920. ui32Byte = *(uint32_t *)(pui8Palette + ui32Byte) &
  921. 0x00ffffff;
  922.  
  923. //
  924. // Translate this palette entry and write it to the screen.
  925. //
  926. WriteData(DPYCOLORTRANSLATE(ui32Byte));
  927. }
  928.  
  929. //
  930. // The image data has been drawn.
  931. //
  932. break;
  933. }
  934.  
  935. //
  936. // We are being passed data in the display's native format. Merely
  937. // write it directly to the display. This is a special case which
  938. // is not used by the graphics library but which is helpful to
  939. // applications which may want to handle, for example, JPEG images.
  940. //
  941. case 16:
  942. {
  943. uint16_t ui16Byte;
  944.  
  945. //
  946. // Loop while there are more pixels to draw.
  947. //
  948. while(i32Count--)
  949. {
  950. //
  951. // Get the next byte of pixel data and extract the
  952. // corresponding entry from the palette.
  953. //
  954. ui16Byte = *((uint16_t *)pui8Data);
  955. pui8Data += 2;
  956.  
  957. //
  958. // Translate this palette entry and write it to the screen.
  959. //
  960. WriteData(ui16Byte);
  961. }
  962. }
  963. }
  964. }
  965.  
  966. //*****************************************************************************
  967. //
  968. //! Draws a horizontal line.
  969. //!
  970. //! \param pvDisplayData is a pointer to the driver-specific data for this
  971. //! display driver.
  972. //! \param i32X1 is the X coordinate of the start of the line.
  973. //! \param i32X2 is the X coordinate of the end of the line.
  974. //! \param i32Y is the Y coordinate of the line.
  975. //! \param ui32Value is the color of the line.
  976. //!
  977. //! This function draws a horizontal line on the display. The coordinates of
  978. //! the line are assumed to be within the extents of the display.
  979. //!
  980. //! \return None.
  981. //
  982. //*****************************************************************************
  983. static void
  984. Kentec320x240x16_SSD2119LineDrawH(void *pvDisplayData, int32_t i32X1,
  985. int32_t i32X2, int32_t i32Y,
  986. uint32_t ui32Value)
  987. {
  988. //
  989. // Set the cursor increment to left to right, followed by top to bottom.
  990. //
  991. WriteCommand(SSD2119_ENTRY_MODE_REG);
  992. WriteData(MAKE_ENTRY_MODE(HORIZ_DIRECTION));
  993.  
  994. //
  995. // Set the starting X address of the display cursor.
  996. //
  997. WriteCommand(SSD2119_X_RAM_ADDR_REG);
  998. WriteData(MAPPED_X(i32X1, i32Y));
  999.  
  1000. //
  1001. // Set the Y address of the display cursor.
  1002. //
  1003. WriteCommand(SSD2119_Y_RAM_ADDR_REG);
  1004. WriteData(MAPPED_Y(i32X1, i32Y));
  1005.  
  1006. //
  1007. // Write the data RAM write command.
  1008. //
  1009. WriteCommand(SSD2119_RAM_DATA_REG);
  1010.  
  1011. //
  1012. // Loop through the pixels of this horizontal line.
  1013. //
  1014. while(i32X1++ <= i32X2)
  1015. {
  1016. //
  1017. // Write the pixel value.
  1018. //
  1019. WriteData(ui32Value);
  1020. }
  1021. }
  1022.  
  1023. //*****************************************************************************
  1024. //
  1025. //! Draws a vertical line.
  1026. //!
  1027. //! \param pvDisplayData is a pointer to the driver-specific data for this
  1028. //! display driver.
  1029. //! \param i32X is the X coordinate of the line.
  1030. //! \param i32Y1 is the Y coordinate of the start of the line.
  1031. //! \param i32Y2 is the Y coordinate of the end of the line.
  1032. //! \param ui32Value is the color of the line.
  1033. //!
  1034. //! This function draws a vertical line on the display. The coordinates of the
  1035. //! line are assumed to be within the extents of the display.
  1036. //!
  1037. //! \return None.
  1038. //
  1039. //*****************************************************************************
  1040. static void
  1041. Kentec320x240x16_SSD2119LineDrawV(void *pvDisplayData, int32_t i32X,
  1042. int32_t i32Y1,
  1043. int32_t i32Y2, uint32_t ui32Value)
  1044. {
  1045. //
  1046. // Set the cursor increment to top to bottom, followed by left to right.
  1047. //
  1048. WriteCommand(SSD2119_ENTRY_MODE_REG);
  1049. WriteData(MAKE_ENTRY_MODE(VERT_DIRECTION));
  1050.  
  1051. //
  1052. // Set the X address of the display cursor.
  1053. //
  1054. WriteCommand(SSD2119_X_RAM_ADDR_REG);
  1055. WriteData(MAPPED_X(i32X, i32Y1));
  1056.  
  1057. //
  1058. // Set the starting Y address of the display cursor.
  1059. //
  1060. WriteCommand(SSD2119_Y_RAM_ADDR_REG);
  1061. WriteData(MAPPED_Y(i32X, i32Y1));
  1062.  
  1063. //
  1064. // Write the data RAM write command.
  1065. //
  1066. WriteCommand(SSD2119_RAM_DATA_REG);
  1067.  
  1068. //
  1069. // Loop through the pixels of this vertical line.
  1070. //
  1071. while(i32Y1++ <= i32Y2)
  1072. {
  1073. //
  1074. // Write the pixel value.
  1075. //
  1076. WriteData(ui32Value);
  1077. }
  1078. }
  1079.  
  1080. //*****************************************************************************
  1081. //
  1082. //! Fills a rectangle.
  1083. //!
  1084. //! \param pvDisplayData is a pointer to the driver-specific data for this
  1085. //! display driver.
  1086. //! \param pRect is a pointer to the structure describing the rectangle.
  1087. //! \param ui32Value is the color of the rectangle.
  1088. //!
  1089. //! This function fills a rectangle on the display. The coordinates of the
  1090. //! rectangle are assumed to be within the extents of the display, and the
  1091. //! rectangle specification is fully inclusive (in other words, both i16XMin
  1092. //! and i16XMax are drawn, along with i16YMin and i16YMax).
  1093. //!
  1094. //! \return None.
  1095. //
  1096. //*****************************************************************************
  1097. static void
  1098. Kentec320x240x16_SSD2119RectFill(void *pvDisplayData, const tRectangle *pRect,
  1099. uint32_t ui32Value)
  1100. {
  1101. int32_t i32Count;
  1102.  
  1103. //
  1104. // Write the Y extents of the rectangle.
  1105. //
  1106. WriteCommand(SSD2119_ENTRY_MODE_REG);
  1107. WriteData(MAKE_ENTRY_MODE(HORIZ_DIRECTION));
  1108.  
  1109. //
  1110. // Write the X extents of the rectangle.
  1111. //
  1112. WriteCommand(SSD2119_H_RAM_START_REG);
  1113. #if (defined PORTRAIT) || (defined LANDSCAPE)
  1114. WriteData(MAPPED_X(pRect->i16XMax, pRect->i16YMax));
  1115. #else
  1116. WriteData(MAPPED_X(pRect->i16XMin, pRect->sMin));
  1117. #endif
  1118.  
  1119. WriteCommand(SSD2119_H_RAM_END_REG);
  1120. #if (defined PORTRAIT) || (defined LANDSCAPE)
  1121. WriteData(MAPPED_X(pRect->i16XMin, pRect->i16YMin));
  1122. #else
  1123. WriteData(MAPPED_X(pRect->i16XMax, pRect->i16YMax));
  1124. #endif
  1125.  
  1126. //
  1127. // Write the Y extents of the rectangle
  1128. //
  1129. WriteCommand(SSD2119_V_RAM_POS_REG);
  1130. #if (defined LANDSCAPE_FLIP) || (defined PORTRAIT)
  1131. WriteData(MAPPED_Y(pRect->i16XMin, pRect->i16YMin) |
  1132. (MAPPED_Y(pRect->i16XMax, pRect->i16YMax) << 8));
  1133. #else
  1134. WriteData(MAPPED_Y(pRect->i16XMax, pRect->i16YMax) |
  1135. (MAPPED_Y(pRect->i16XMin, pRect->i16YMin) << 8));
  1136. #endif
  1137.  
  1138. //
  1139. // Set the display cursor to the upper left of the rectangle (in
  1140. // application coordinate space).
  1141. //
  1142. WriteCommand(SSD2119_X_RAM_ADDR_REG);
  1143. WriteData(MAPPED_X(pRect->i16XMin, pRect->i16YMin));
  1144.  
  1145. WriteCommand(SSD2119_Y_RAM_ADDR_REG);
  1146. WriteData(MAPPED_Y(pRect->i16XMin, pRect->i16YMin));
  1147.  
  1148. //
  1149. // Tell the controller we are about to write data into its RAM.
  1150. //
  1151. WriteCommand(SSD2119_RAM_DATA_REG);
  1152.  
  1153. //
  1154. // Loop through the pixels of this filled rectangle.
  1155. //
  1156. for(i32Count = ((pRect->i16XMax - pRect->i16XMin + 1) *
  1157. (pRect->i16YMax - pRect->i16YMin + 1));
  1158. i32Count >= 0; i32Count--)
  1159. {
  1160. //
  1161. // Write the pixel value.
  1162. //
  1163. WriteData(ui32Value);
  1164. }
  1165.  
  1166. //
  1167. // Reset the X extents to the entire screen.
  1168. //
  1169. WriteCommand(SSD2119_H_RAM_START_REG);
  1170. WriteData(0x0000);
  1171. WriteCommand(SSD2119_H_RAM_END_REG);
  1172. WriteData(0x013F);
  1173.  
  1174. //
  1175. // Reset the Y extent to the full screen
  1176. //
  1177. WriteCommand(SSD2119_V_RAM_POS_REG);
  1178. WriteData(0xEF00);
  1179. }
  1180.  
  1181. //*****************************************************************************
  1182. //
  1183. //! Translates a 24-bit RGB color to a display driver-specific color.
  1184. //!
  1185. //! \param pvDisplayData is a pointer to the driver-specific data for this
  1186. //! display driver.
  1187. //! \param ui32Value is the 24-bit RGB color. The least-significant byte is
  1188. //! the blue channel, the next byte is the green channel, and the third byte is
  1189. //! the red channel.
  1190. //!
  1191. //! This function translates a 24-bit RGB color into a value that can be
  1192. //! written into the display's frame buffer in order to reproduce that color,
  1193. //! or the closest possible approximation of that color.
  1194. //!
  1195. //! \return Returns the display-driver specific color.
  1196. //
  1197. //*****************************************************************************
  1198. static uint32_t
  1199. Kentec320x240x16_SSD2119ColorTranslate(void *pvDisplayData,
  1200. uint32_t ui32Value)
  1201. {
  1202. //
  1203. // Translate from a 24-bit RGB color to a 5-6-5 RGB color.
  1204. //
  1205. return(DPYCOLORTRANSLATE(ui32Value));
  1206. }
  1207.  
  1208. //*****************************************************************************
  1209. //
  1210. //! Flushes any cached drawing operations.
  1211. //!
  1212. //! \param pvDisplayData is a pointer to the driver-specific data for this
  1213. //! display driver.
  1214. //!
  1215. //! This functions flushes any cached drawing operations to the display. This
  1216. //! is useful when a local frame buffer is used for drawing operations, and the
  1217. //! flush would copy the local frame buffer to the display. For the SSD2119
  1218. //! driver, the flush is a no operation.
  1219. //!
  1220. //! \return None.
  1221. //
  1222. //*****************************************************************************
  1223. static void
  1224. Kentec320x240x16_SSD2119Flush(void *pvDisplayData)
  1225. {
  1226. //
  1227. // There is nothing to be done.
  1228. //
  1229. }
  1230.  
  1231. //*****************************************************************************
  1232. //
  1233. //! The display structure that describes the driver for the Kentec
  1234. //! K350QVG-V2-F TFT panel with an SSD2119 controller.
  1235. //
  1236. //*****************************************************************************
  1237. const tDisplay g_sKentec320x240x16_SSD2119 =
  1238. {
  1239. sizeof(tDisplay),
  1240. 0,
  1241. #if defined(PORTRAIT) || defined(PORTRAIT_FLIP)
  1242. 240,
  1243. 320,
  1244. #else
  1245. 320,
  1246. 240,
  1247. #endif
  1248. Kentec320x240x16_SSD2119PixelDraw,
  1249. Kentec320x240x16_SSD2119PixelDrawMultiple,
  1250. Kentec320x240x16_SSD2119LineDrawH,
  1251. Kentec320x240x16_SSD2119LineDrawV,
  1252. Kentec320x240x16_SSD2119RectFill,
  1253. Kentec320x240x16_SSD2119ColorTranslate,
  1254. Kentec320x240x16_SSD2119Flush
  1255. };
  1256.  
  1257. //*****************************************************************************
  1258. //
  1259. // Close the Doxygen group.
  1260. //! @}
  1261. //
  1262. //*****************************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement