lcd.c 68 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805
  1. //*****************************************************************************
  2. //
  3. // lcd.c - Defines and Macros for the LCD Controller module.
  4. //
  5. // Copyright (c) 2012-2020 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions
  10. // are met:
  11. //
  12. // Redistributions of source code must retain the above copyright
  13. // notice, this list of conditions and the following disclaimer.
  14. //
  15. // Redistributions in binary form must reproduce the above copyright
  16. // notice, this list of conditions and the following disclaimer in the
  17. // documentation and/or other materials provided with the
  18. // distribution.
  19. //
  20. // Neither the name of Texas Instruments Incorporated nor the names of
  21. // its contributors may be used to endorse or promote products derived
  22. // from this software without specific prior written permission.
  23. //
  24. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  27. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  28. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  29. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. // This is part of revision 2.2.0.295 of the Tiva Peripheral Driver Library.
  37. //
  38. //*****************************************************************************
  39. //*****************************************************************************
  40. //
  41. //! \addtogroup lcd_api
  42. //! @{
  43. //
  44. //*****************************************************************************
  45. #include <stdint.h>
  46. #include <stdbool.h>
  47. #include <stdint.h>
  48. #include "inc/hw_memmap.h"
  49. #include "inc/hw_types.h"
  50. #include "inc/hw_ints.h"
  51. #include "inc/hw_lcd.h"
  52. #include "driverlib/interrupt.h"
  53. #include "driverlib/sysctl.h"
  54. #include "driverlib/lcd.h"
  55. #include "driverlib/debug.h"
  56. //*****************************************************************************
  57. //
  58. // These are currently missing from hw_lcd.h and included here as a stopgap
  59. // until the hardware header is updated.
  60. //
  61. //*****************************************************************************
  62. #ifndef LCD_RASTRTIM0_MSBPPL_S
  63. #define LCD_RASTRTIM0_MSBPPL_S 3
  64. #endif
  65. #ifndef LCD_RASTRTIM2_MSBLPP_S
  66. #define LCD_RASTRTIM2_MSBLPP_S 26
  67. #endif
  68. //*****************************************************************************
  69. //
  70. //! Configures the basic operating mode and clock rate for the LCD controller.
  71. //!
  72. //! \param ui32Base specifies the LCD controller module base address.
  73. //! \param ui8Mode specifies the basic operating mode to be used.
  74. //! \param ui32PixClk specifies the desired LCD controller pixel or master
  75. //! clock rate in Hz.
  76. //! \param ui32SysClk specifies the current system clock rate in Hz.
  77. //!
  78. //! This function sets the basic operating mode of the LCD controller and also
  79. //! its master clock. The \e ui8Mode parameter may be set to either \b
  80. //! LCD_MODE_LIDD or \b LCD_MODE_RASTER. \b LCD_MODE_LIDD is used to select
  81. //! LCD Interface Display Driver mode for character panels connected via
  82. //! an asynchronous interface (CS, WE, OE, ALE, data) and \b LCD_MODE_RASTER
  83. //! is used to communicate with panels via a synchronous video interface using
  84. //! data and sync signals. Additionally, \b LCD_MODE_AUTO_UFLOW_RESTART may
  85. //! be ORed with either of these modes to indicate that the hardware should
  86. //! restart automatically if a data underflow occurs.
  87. //!
  88. //! The \e ui32PixClk parameter specifies the desired master clock for the
  89. //! the LCD controller. In LIDD mode, this value controls the MCLK used in
  90. //! communication with the display and valid values are between \e ui32SysClk
  91. //! and \e ui32SysClk/255. In raster mode, \e ui32PixClk specifies the pixel
  92. //! clock rate for the raster interface and valid values are between \e
  93. //! ui32SysClk/2 and \e ui32SysClk/255. The actual clock rate set may differ
  94. //! slightly from the desired rate due to the fact that only integer dividers
  95. //! are supported. The rate set will, however, be no higher than the requested
  96. //! value.
  97. //!
  98. //! The \e ui32SysClk parameter provides the current system clock rate and is
  99. //! used to allow the LCD controller clock rate divisor to be correctly set
  100. //! to give the desired \e ui32PixClk rate.
  101. //!
  102. //! \return Returns the actual LCD controller pixel clock or MCLK rate set.
  103. //
  104. //*****************************************************************************
  105. uint32_t
  106. LCDModeSet(uint32_t ui32Base, uint8_t ui8Mode, uint32_t ui32PixClk,
  107. uint32_t ui32SysClk)
  108. {
  109. uint32_t ui32Div;
  110. //
  111. // Sanity check parameters.
  112. //
  113. ASSERT(ui32Base == LCD0_BASE);
  114. ASSERT((ui8Mode & ~(LCD_MODE_RASTER | LCD_MODE_LIDD |
  115. LCD_MODE_AUTO_UFLOW_RESTART)) == 0);
  116. //
  117. // Enable clocks to the LCD controller submodules.
  118. //
  119. HWREG(ui32Base + LCD_O_CLKEN) = (LCD_CLKEN_DMA | LCD_CLKEN_CORE |
  120. LCD_CLKEN_LIDD);
  121. //
  122. // Determine the clock divider to use to get as close as possible to the
  123. // desired pixel clock. Note that we set the division up so that we
  124. // round the divisor up and ensure that the clock used is never faster
  125. // than the requested rate.
  126. //
  127. ui32Div = (ui32SysClk + (ui32PixClk - 1)) / ui32PixClk;
  128. //
  129. // Check that the calculated value is valid.
  130. //
  131. ASSERT(ui32Div);
  132. ASSERT(ui32Div < 256);
  133. ASSERT(!((ui8Mode & LCD_MODE_RASTER) && (ui32Div < 2)));
  134. //
  135. // Write the LCDCTL register to set the mode.
  136. //
  137. HWREG(ui32Base + LCD_O_CTL) = (uint32_t)ui8Mode |
  138. (ui32Div << LCD_CTL_CLKDIV_S);
  139. //
  140. // Return the selected clock rate. Finding ui32Div set to 0 should not
  141. // happen unless someone passed pathological arguments and builds without
  142. // the ASSERTS, but we guard against it just in case.
  143. //
  144. return(ui32Div ? (ui32SysClk / ui32Div) : ui32SysClk);
  145. }
  146. //*****************************************************************************
  147. //
  148. //! Resets one or more of the LCD controller clock domains.
  149. //!
  150. //! \param ui32Base specifies the LCD controller module base address.
  151. //! \param ui32Clocks defines the subset of clock domains to be reset.
  152. //!
  153. //! This function allows sub-modules of the LCD controller to be reset under
  154. //! software control. The \e ui32Clocks parameter is the logical OR of the
  155. //! following clocks:
  156. //!
  157. //! - \b LCD_CLOCK_MAIN causes the entire LCD controller module to be reset.
  158. //! - \b LCD_CLOCK_DMA causes the DMA controller submodule to be reset.
  159. //! - \b LCD_CLOCK_LIDD causes the LIDD submodule to be reset.
  160. //! - \b LCD_CLOCK_CORE causes the core module, including the raster logic to
  161. //! be reset.
  162. //!
  163. //! In all cases, LCD controller register values are preserved across these
  164. //! resets.
  165. //!
  166. //! \return None.
  167. //
  168. //*****************************************************************************
  169. void
  170. LCDClockReset(uint32_t ui32Base, uint32_t ui32Clocks)
  171. {
  172. //
  173. // Sanity check parameters.
  174. //
  175. ASSERT(ui32Base == LCD0_BASE);
  176. ASSERT(!(ui32Clocks & ~(LCD_CLOCK_MAIN | LCD_CLOCK_LIDD | LCD_CLOCK_DMA |
  177. LCD_CLOCK_CORE)));
  178. //
  179. // Reset the required LCD controller sub-module(s).
  180. //
  181. HWREG(LCD0_BASE + 0x70) = ui32Clocks;
  182. //
  183. // Wait a while.
  184. //
  185. SysCtlDelay(10);
  186. //
  187. // Remove software reset.
  188. //
  189. HWREG(LCD0_BASE + 0x70) = 0x00000000;
  190. //
  191. // Wait a while.
  192. //
  193. SysCtlDelay(10);
  194. }
  195. //*****************************************************************************
  196. //
  197. //! Sets the LCD controller communication parameters when in LIDD mode.
  198. //!
  199. //! \param ui32Base specifies the LCD controller module base address.
  200. //! \param ui32Config defines the display interface configuration.
  201. //!
  202. //! This function is used when the LCD controller is configured in LIDD
  203. //! mode and specifies the configuration of the interface between the
  204. //! controller and the display panel. The \e ui32Config parameter is
  205. //! comprised of one of the following modes:
  206. //!
  207. //! - \b LIDD_CONFIG_SYNC_MPU68 selects Sync MPU68 mode. LCDCP = EN, LCDLP =
  208. //! DIR, LCDFP = ALE, LCDAC = CS0, LCDMCLK = MCLK.
  209. //! - \b LIDD_CONFIG_ASYNC_MPU68 selects Async MPU68 mode. LCDCP = EN, LCDLP =
  210. //! DIR, LCDFP = ALE, LCDAC = CS0, LCDMCLK = CS1.
  211. //! - \b LIDD_CONFIG_SYNC_MPU80 selects Sync MPU80 mode. LCDCP = RS, LCDLP =
  212. //! WS, LCDFP = ALE, LCDAC = CS0, LCDMCLK = MCLK.
  213. //! - \b LIDD_CONFIG_ASYNC_MPU80 selects Async MPU80 mode. LCDCP = RS, LCDLP =
  214. //! WS, LCDFP = ALE, LCDAC = CS0, LCDMCLK = CS1.
  215. //! - \b LIDD_CONFIG_ASYNC_HITACHI selects Hitachi (async) mode. LCDCP = N/C,
  216. //! LCDLP = DIR, LCDFP = ALE, LCDAC = E0, LCDMCLK = E1.
  217. //!
  218. //! Additional flags may be ORed into \e ui32Config to control the polarities
  219. //! of various control signals:
  220. //!
  221. //! - \b LIDD_CONFIG_INVERT_ALE - Address Latch Enable (ALE) polarity control.
  222. //! By default, ALE is active low. If this flag is set, it becomes active
  223. //! high.
  224. //! - \b LIDD_CONFIG_INVERT_RS_EN - Read Strobe/Enable polarity control. By
  225. //! default, RS is active low and Enable is active high. If this flag is set,
  226. //! RS becomes active high and Enable active low.
  227. //! - \b LIDD_CONFIG_INVERT_WS_DIR - Write Strobe/Direction polarity control.
  228. //! By default, WS is active low and Direction write low/read high. If this
  229. //! flag is set, WS becomes active high and Direction becomes write high/read
  230. //! low.
  231. //! - \b LIDD_CONFIG_INVERT_CS0 - Chip Select 0/Enable 0 polarity control. By
  232. //! default, CS0 and E0 are active high. If this flag is set, they become
  233. //! active low.
  234. //! - \b LIDD_CONFIG_INVERT_CS1 - Chip Select 1/Enable 1 polarity control. By
  235. //! default, CS1 and E1 are active high. If this flag is set, they become
  236. //! active low.
  237. //!
  238. //! \return None.
  239. //
  240. //*****************************************************************************
  241. void
  242. LCDIDDConfigSet(uint32_t ui32Base, uint32_t ui32Config)
  243. {
  244. //
  245. // Sanity check parameters.
  246. //
  247. ASSERT(ui32Base == LCD0_BASE);
  248. ASSERT(!(ui32Config & ~(LIDD_CONFIG_SYNC_MPU68 | LIDD_CONFIG_ASYNC_MPU68 |
  249. LIDD_CONFIG_SYNC_MPU80 | LIDD_CONFIG_ASYNC_MPU80 |
  250. LIDD_CONFIG_ASYNC_HITACHI |
  251. LIDD_CONFIG_INVERT_ALE |
  252. LIDD_CONFIG_INVERT_RS_EN |
  253. LIDD_CONFIG_INVERT_WS_DIR |
  254. LIDD_CONFIG_INVERT_CS0 | LIDD_CONFIG_INVERT_CS1)));
  255. //
  256. // Write the LIDD Control Register.
  257. //
  258. HWREG(ui32Base + LCD_O_LIDDCTL) = ui32Config;
  259. }
  260. //*****************************************************************************
  261. //
  262. //! Sets the LCD controller interface timing when in LIDD mode.
  263. //!
  264. //! \param ui32Base specifies the LCD controller module base address.
  265. //! \param ui32CS specifies the chip select whose timings are to be set.
  266. //! \param pTiming points to a structure containing the desired timing
  267. //! parameters.
  268. //!
  269. //! This function is used in LIDD mode to set the setup, strobe and hold times
  270. //! for the various interface control signals. Independent timings are stored
  271. //! for each of the two supported chip selects offered by the LCD controller.
  272. //!
  273. //! For a definition of the timing parameters required, see the definition of
  274. //! tLCDIDDTiming.
  275. //!
  276. //! \note CS1 is not available when operating in Sync MPU68 or Sync MPU80
  277. //! modes.
  278. //!
  279. //! \return None
  280. //
  281. //*****************************************************************************
  282. void
  283. LCDIDDTimingSet(uint32_t ui32Base, uint32_t ui32CS,
  284. const tLCDIDDTiming *pTiming)
  285. {
  286. uint32_t ui32Val;
  287. //
  288. // Sanity check parameters.
  289. //
  290. ASSERT(ui32Base == LCD0_BASE);
  291. ASSERT((ui32CS == 0) || (ui32CS == 1));
  292. ASSERT(pTiming);
  293. ASSERT(pTiming->ui8WSSetup < 32);
  294. ASSERT(pTiming->ui8WSDuration && (pTiming->ui8WSDuration < 64));
  295. ASSERT(pTiming->ui8WSHold && (pTiming->ui8WSHold < 16));
  296. ASSERT(pTiming->ui8RSSetup < 32);
  297. ASSERT(pTiming->ui8RSDuration && (pTiming->ui8RSDuration < 64));
  298. ASSERT(pTiming->ui8RSHold && (pTiming->ui8RSHold < 16));
  299. ASSERT(pTiming->ui8DelayCycles && (pTiming->ui8DelayCycles < 5));
  300. //
  301. // Convert the timings provided into a value ready for the register.
  302. //
  303. ui32Val =
  304. (((uint32_t)(pTiming->ui8WSSetup) << LCD_LIDDCS0CFG_WRSU_S) |
  305. ((uint32_t)(pTiming->ui8WSDuration) << LCD_LIDDCS0CFG_WRDUR_S) |
  306. ((uint32_t)(pTiming->ui8WSHold) << LCD_LIDDCS0CFG_WRHOLD_S) |
  307. ((uint32_t)(pTiming->ui8RSSetup) << LCD_LIDDCS0CFG_RDSU_S) |
  308. ((uint32_t)(pTiming->ui8RSDuration) << LCD_LIDDCS0CFG_RDDUR_S) |
  309. ((uint32_t)(pTiming->ui8RSHold) << LCD_LIDDCS0CFG_RDHOLD_S) |
  310. ((uint32_t)(pTiming->ui8DelayCycles - 1) << LCD_LIDDCS0CFG_GAP_S));
  311. //
  312. // Write the appropriate LCD LIDD CS configuration register.
  313. //
  314. if(!ui32CS)
  315. {
  316. HWREG(ui32Base + LCD_O_LIDDCS0CFG) = ui32Val;
  317. }
  318. else
  319. {
  320. HWREG(ui32Base + LCD_O_LIDDCS1CFG) = ui32Val;
  321. }
  322. }
  323. //*****************************************************************************
  324. //
  325. //! Disables internal DMA operation when the LCD controller is in LIDD mode.
  326. //!
  327. //! \param ui32Base specifies the LCD controller module base address.
  328. //!
  329. //! When the LCD controller is operating in LCD Interface Display Driver mode,
  330. //! this function must be called after completion of a DMA transaction and
  331. //! before calling LCDIDDCommandWrite(), LCDIDDDataWrite(), LCDIDDStatusRead(),
  332. //! LCDIDDIndexedWrite(), LCDIDDIndexedRead() or LCDIDDDataRead() to disable
  333. //! DMA mode and allow CPU-initiated transactions to the display.
  334. //!
  335. //! \note LIDD DMA mode is enabled automatically when LCDIDDDMAWrite() is
  336. //! called.
  337. //!
  338. //! \return None.
  339. //
  340. //*****************************************************************************
  341. void
  342. LCDIDDDMADisable(uint32_t ui32Base)
  343. {
  344. //
  345. // Sanity check parameters.
  346. //
  347. ASSERT(ui32Base == LCD0_BASE);
  348. //
  349. // Disable DMA.
  350. //
  351. HWREG(ui32Base + LCD_O_LIDDCTL) &= ~LCD_LIDDCTL_DMAEN;
  352. }
  353. //*****************************************************************************
  354. //
  355. //! Writes a command to the display when the LCD controller is in LIDD mode.
  356. //!
  357. //! \param ui32Base specifies the LCD controller module base address.
  358. //! \param ui32CS specifies the chip select to use. Valid values are 0 and 1.
  359. //! \param ui16Cmd is the 16-bit command word to write.
  360. //!
  361. //! This function writes a 16-bit command word to the display when the LCD
  362. //! controller is in LIDD mode. A command write occurs with the ALE signal
  363. //! active.
  364. //!
  365. //! This function must not be called if the LIDD interface is currently
  366. //! configured to expect DMA transactions. If DMA was previously used to
  367. //! write to the panel, LCDIDDDMADisable() must be called before this function
  368. //! can be used.
  369. //!
  370. //! \note CS1 is not available when operating in Sync MPU68 or Sync MPU80
  371. //! modes.
  372. //!
  373. //! \return None.
  374. //
  375. //*****************************************************************************
  376. void
  377. LCDIDDCommandWrite(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Cmd)
  378. {
  379. uint32_t ui32Reg;
  380. //
  381. // Sanity check parameters.
  382. //
  383. ASSERT(ui32Base == LCD0_BASE);
  384. ASSERT((ui32CS == 0) || (ui32CS == 1));
  385. //
  386. // Determine the register to write based on the CS value supplied.
  387. //
  388. ui32Reg = ui32CS ? LCD_O_LIDDCS1ADDR : LCD_O_LIDDCS0ADDR;
  389. //
  390. // Write the command/address to the register.
  391. //
  392. HWREG(ui32Base + ui32Reg) = ui16Cmd;
  393. }
  394. //*****************************************************************************
  395. //
  396. //! Writes a data value to the display when the LCD controller is in LIDD mode.
  397. //!
  398. //! \param ui32Base specifies the LCD controller module base address.
  399. //! \param ui32CS specifies the chip select to use. Valid values are 0 and 1.
  400. //! \param ui16Data is the 16-bit data word to write.
  401. //!
  402. //! This function writes a 16-bit data word to the display when the LCD
  403. //! controller is in LIDD mode. A data write occurs with the ALE signal
  404. //! inactive.
  405. //!
  406. //! This function must not be called if the LIDD interface is currently
  407. //! configured to expect DMA transactions. If DMA was previously used to
  408. //! write to the panel, LCDIDDDMADisable() must be called before this function
  409. //! can be used.
  410. //!
  411. //! \note CS1 is not available when operating in Sync MPU68 or Sync MPU80
  412. //! modes.
  413. //!
  414. //! \return None.
  415. //
  416. //*****************************************************************************
  417. void
  418. LCDIDDDataWrite(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Data)
  419. {
  420. uint32_t ui32Reg;
  421. //
  422. // Sanity check parameters.
  423. //
  424. ASSERT(ui32Base == LCD0_BASE);
  425. ASSERT((ui32CS == 0) || (ui32CS == 1));
  426. //
  427. // Determine the register to write based on the CS value supplied.
  428. //
  429. ui32Reg = ui32CS ? LCD_O_LIDDCS1DATA : LCD_O_LIDDCS0DATA;
  430. //
  431. // Write the data value to the register.
  432. //
  433. HWREG(ui32Base + ui32Reg) = ui16Data;
  434. }
  435. //*****************************************************************************
  436. //
  437. //! Writes data to a given display register when the LCD controller is in LIDD
  438. //! mode.
  439. //!
  440. //! \param ui32Base specifies the LCD controller module base address.
  441. //! \param ui32CS specifies the chip select to use. Valid values are 0 and 1.
  442. //! \param ui16Addr is the address of the display register to write.
  443. //! \param ui16Data is the data to write.
  444. //!
  445. //! This function writes a 16-bit data word to a register in the display when
  446. //! the LCD controller is in LIDD mode and configured to use either the
  447. //! Motorola (\b LIDD_CONFIG_SYNC_MPU68 or \b LIDD_CONFIG_ASYNC_MPU68) or
  448. //! Intel (\b LIDD_CONFIG_SYNC_MPU80 or \b LIDD_CONFIG_ASYNC_MPU80) modes
  449. //! that employ an external address latch.
  450. //!
  451. //! When configured in Hitachi mode (\b LIDD_CONFIG_ASYNC_HITACHI), this
  452. //! function should not be used. In this case the functions
  453. //! LCDIDDCommandWrite() and LCDIDDDataWrite() may be used to transfer
  454. //! command and data bytes to the panel.
  455. //!
  456. //! This function must not be called if the LIDD interface is currently
  457. //! configured to expect DMA transactions. If DMA was previously used to
  458. //! write to the panel, LCDIDDDMADisable() must be called before this function
  459. //! can be used.
  460. //!
  461. //! \note CS1 is not available when operating in Sync MPU68 or Sync MPU80
  462. //! modes.
  463. //!
  464. //! \return None.
  465. //
  466. //*****************************************************************************
  467. void
  468. LCDIDDIndexedWrite(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Addr,
  469. uint16_t ui16Data)
  470. {
  471. uint32_t ui32Addr;
  472. //
  473. // Sanity check parameters.
  474. //
  475. ASSERT(ui32Base == LCD0_BASE);
  476. ASSERT((ui32CS == 0) || (ui32CS == 1));
  477. //
  478. // Determine the address register to write.
  479. //
  480. ui32Addr = ui32CS ? LCD_O_LIDDCS1ADDR : LCD_O_LIDDCS0ADDR;
  481. //
  482. // Write the address.
  483. //
  484. HWREG(ui32Base + ui32Addr) = ui16Addr;
  485. //
  486. // Determine the data register to write.
  487. //
  488. ui32Addr = ui32CS ? LCD_O_LIDDCS1DATA : LCD_O_LIDDCS0DATA;
  489. //
  490. // Write the data.
  491. //
  492. HWREG(ui32Base + ui32Addr) = ui16Data;
  493. }
  494. //*****************************************************************************
  495. //
  496. //! Reads a status word from the display when the LCD controller is in LIDD
  497. //! mode.
  498. //!
  499. //! \param ui32Base specifies the LCD controller module base address.
  500. //! \param ui32CS specifies the chip select to use. Valid values are 0 and 1.
  501. //!
  502. //! This function reads the 16-bit status word from the display when the LCD
  503. //! controller is in LIDD mode. A status read occurs with the ALE signal
  504. //! active. If the interface is configured in Hitachi mode (\b
  505. //! LIDD_CONFIG_ASYNC_HITACHI), this operation corresponds to a command mode
  506. //! read.
  507. //!
  508. //! This function must not be called if the LIDD interface is currently
  509. //! configured to expect DMA transactions. If DMA was previously used to
  510. //! write to the panel, LCDIDDDMADisable() must be called before this function
  511. //! can be used.
  512. //!
  513. //! \note CS1 is not available when operating in Sync MPU68 or Sync MPU80
  514. //! modes.
  515. //!
  516. //! \return Returns the status word read from the display panel.
  517. //
  518. //*****************************************************************************
  519. uint16_t
  520. LCDIDDStatusRead(uint32_t ui32Base, uint32_t ui32CS)
  521. {
  522. uint32_t ui32Reg;
  523. //
  524. // Sanity check parameters.
  525. //
  526. ASSERT(ui32Base == LCD0_BASE);
  527. ASSERT((ui32CS == 0) || (ui32CS == 1));
  528. //
  529. // Determine the register to read based on the CS value supplied.
  530. //
  531. ui32Reg = ui32CS ? LCD_O_LIDDCS1ADDR : LCD_O_LIDDCS0ADDR;
  532. //
  533. // Read the relevant status register.
  534. //
  535. return((uint16_t)HWREG(ui32Base + ui32Reg));
  536. }
  537. //*****************************************************************************
  538. //
  539. //! Reads a data word from the display when the LCD controller is in LIDD
  540. //! mode.
  541. //!
  542. //! \param ui32Base specifies the LCD controller module base address.
  543. //! \param ui32CS specifies the chip select to use. Valid values are 0 and 1.
  544. //!
  545. //! This function reads the 16-bit data word from the display when the LCD
  546. //! controller is in LIDD mode. A data read occurs with the ALE signal
  547. //! inactive.
  548. //!
  549. //! This function must not be called if the LIDD interface is currently
  550. //! configured to expect DMA transactions. If DMA was previously used to
  551. //! write to the panel, LCDIDDDMADisable() must be called before this function
  552. //! can be used.
  553. //!
  554. //! \note CS1 is not available when operating in Sync MPU68 or Sync MPU80
  555. //! modes.
  556. //!
  557. //! \return Returns the status word read from the display panel.
  558. //
  559. //*****************************************************************************
  560. uint16_t
  561. LCDIDDDataRead(uint32_t ui32Base, uint32_t ui32CS)
  562. {
  563. uint32_t ui32Reg;
  564. //
  565. // Sanity check parameters.
  566. //
  567. ASSERT(ui32Base == LCD0_BASE);
  568. ASSERT((ui32CS == 0) || (ui32CS == 1));
  569. //
  570. // Determine the register to read based on the CS value supplied.
  571. //
  572. ui32Reg = ui32CS ? LCD_O_LIDDCS1DATA : LCD_O_LIDDCS0DATA;
  573. //
  574. // Read the relevant data register.
  575. //
  576. return((uint16_t)HWREG(ui32Base + ui32Reg));
  577. }
  578. //*****************************************************************************
  579. //
  580. //! Reads a given display register when the LCD controller is in LIDD mode.
  581. //!
  582. //! \param ui32Base specifies the LCD controller module base address.
  583. //! \param ui32CS specifies the chip select to use. Valid values are 0 and 1.
  584. //! \param ui16Addr is the address of the display register to read.
  585. //!
  586. //! This function reads a 16-bit word from a register in the display when
  587. //! the LCD controller is in LIDD mode and configured to use either the
  588. //! Motorola (\b LIDD_CONFIG_SYNC_MPU68 or \b LIDD_CONFIG_ASYNC_MPU68) or
  589. //! Intel (\b LIDD_CONFIG_SYNC_MPU80 or \b LIDD_CONFIG_ASYNC_MPU80) modes
  590. //! that employ an external address latch.
  591. //!
  592. //! When configured in Hitachi mode (\b LIDD_CONFIG_ASYNC_HITACHI), this
  593. //! function should not be used. In this case, the functions
  594. //! LCDIDDStatusRead() and LCDIDDDataRead() may be used to read status
  595. //! and data bytes from the panel.
  596. //!
  597. //! This function must not be called if the LIDD interface is currently
  598. //! configured to expect DMA transactions. If DMA was previously used to
  599. //! write to the panel, LCDIDDDMADisable() must be called before this function
  600. //! can be used.
  601. //!
  602. //! \note CS1 is not available when operating in Sync MPU68 or Sync MPU80
  603. //! modes.
  604. //!
  605. //! \return None.
  606. //
  607. //*****************************************************************************
  608. uint16_t
  609. LCDIDDIndexedRead(uint32_t ui32Base, uint32_t ui32CS, uint16_t ui16Addr)
  610. {
  611. uint32_t ui32Addr;
  612. //
  613. // Sanity check parameters.
  614. //
  615. ASSERT(ui32Base == LCD0_BASE);
  616. ASSERT((ui32CS == 0) || (ui32CS == 1));
  617. //
  618. // Determine the address register to write.
  619. //
  620. ui32Addr = ui32CS ? LCD_O_LIDDCS1ADDR : LCD_O_LIDDCS0ADDR;
  621. //
  622. // Write the address.
  623. //
  624. HWREG(ui32Base + ui32Addr) = ui16Addr;
  625. //
  626. // Determine the data register to read.
  627. //
  628. ui32Addr = ui32CS ? LCD_O_LIDDCS1DATA : LCD_O_LIDDCS0DATA;
  629. //
  630. // Return the data read.
  631. //
  632. return((uint16_t)HWREG(ui32Base + ui32Addr));
  633. }
  634. //*****************************************************************************
  635. //
  636. //! Writes a block of data to the display using DMA when the LCD controller is
  637. //! in LIDD mode.
  638. //!
  639. //! \param ui32Base specifies the LCD controller module base address.
  640. //! \param ui32CS specifies the chip select to use. Valid values are 0 and 1.
  641. //! \param pui32Data is the address of the first 16-bit word to write. This
  642. //! address must be aligned on a 32-bit word boundary.
  643. //! \param ui32Count is the number of 16-bit words to write. This value must
  644. //! be a multiple of 2.
  645. //!
  646. //! This function writes a block of 16-bit data words to the display using
  647. //! DMA. It is only valid when the LCD controller is in LIDD mode.
  648. //! Completion of the DMA transfer is signaled by the \b
  649. //! LCD_INT_DMA_DONE interrupt.
  650. //!
  651. //! This function enables DMA mode prior to starting the transfer. The
  652. //! caller is responsible for ensuring that any earlier DMA transfer has
  653. //! completed before initiating another transfer.
  654. //!
  655. //! During the time that DMA is enabled, none of the other LCD LIDD data
  656. //! transfer functions may be called. When the DMA transfer is complete and
  657. //! the application wishes to use the CPU to communicate with the display,
  658. //! LCDIDDDMADisable() must be called to disable DMA access prior to calling
  659. //! LCDIDDCommandWrite(), LCDIDDDataWrite(), LCDIDDStatusRead(),
  660. //! LCDIDDIndexedWrite(), LCDIDDIndexedRead() or LCDIDDDataRead().
  661. //!
  662. //! \note CS1 is not available when operating in Sync MPU68 or Sync MPU80
  663. //! modes.
  664. //!
  665. //! \return None.
  666. //
  667. //*****************************************************************************
  668. void
  669. LCDIDDDMAWrite(uint32_t ui32Base, uint32_t ui32CS, const uint32_t *pui32Data,
  670. uint32_t ui32Count)
  671. {
  672. //
  673. // Sanity check parameters.
  674. //
  675. ASSERT(ui32Base == LCD0_BASE);
  676. ASSERT((ui32CS == 0) || (ui32CS == 1));
  677. ASSERT(!((uint32_t)pui32Data & 3));
  678. ASSERT(!(ui32Count & 1));
  679. //
  680. // Make sure DMA is disabled so that enabling it triggers this new
  681. // transfer.
  682. //
  683. HWREG(ui32Base + LCD_O_LIDDCTL) &= ~LCD_LIDDCTL_DMAEN;
  684. //
  685. // Set up the transfer. Note that the ceiling register must contain the
  686. // address of the last word which contains data we want transfered and NOT
  687. // the first location after the data we want written.
  688. //
  689. HWREG(ui32Base + LCD_O_DMABAFB0) = (uint32_t)pui32Data;
  690. HWREG(ui32Base + LCD_O_DMACAFB0) = ((uint32_t)pui32Data +
  691. (ui32Count * 2) - 4);
  692. //
  693. // Tell the controller which CS to use for the DMA transaction.
  694. //
  695. if(!ui32CS)
  696. {
  697. //
  698. // Use CS0.
  699. //
  700. HWREG(ui32Base + LCD_O_LIDDCTL) &= ~LCD_LIDDCTL_DMACS;
  701. }
  702. else
  703. {
  704. //
  705. // Use CS1.
  706. //
  707. HWREG(ui32Base + LCD_O_LIDDCTL) |= LCD_LIDDCTL_DMACS;
  708. }
  709. //
  710. // Enable the DMA engine and start the transaction.
  711. //
  712. HWREG(ui32Base + LCD_O_LIDDCTL) |= LCD_LIDDCTL_DMAEN;
  713. }
  714. //*****************************************************************************
  715. //
  716. //! Sets the LCD controller interface timing when in raster mode.
  717. //!
  718. //! \param ui32Base specifies the LCD controller module base address.
  719. //! \param ui32Config specifies properties of the raster interface and the
  720. //! attached display panel.
  721. //! \param ui8PalLoadDelay specifies the number of system clocks to wait
  722. //! between each 16 halfword (16-bit) burst when loading the palette from
  723. //! SRAM into the internal palette RAM of the controller.
  724. //!
  725. //! This function configures the basic operating mode of the raster interface
  726. //! and specifies the type of panel that the controller is to drive.
  727. //!
  728. //! The \e ui32Config parameter must be defined as one of the following to
  729. //! select the required target panel type and output pixel format:
  730. //!
  731. //! - \b RASTER_FMT_ACTIVE_24BPP_PACKED selects an active matrix display
  732. //! and uses a packed 24-bit per pixel packet frame buffer where 4 pixels
  733. //! are described within 3 consecutive 32-bit words.
  734. //! - \b RASTER_FMT_ACTIVE_24BPP_UNPACKED selects an active matrix display
  735. //! and uses an unpacked 24-bit per pixel packet frame buffer where each
  736. //! 32-bit word contains a single pixel and 8 bits of padding.
  737. //! - \b RASTER_FMT_ACTIVE_16BPP selects an active matrix display
  738. //! and uses a 16-bit per pixel frame buffer with 2 pixels in each 32-bit
  739. //! word.
  740. //! - \b RASTER_FMT_ACTIVE_PALETTIZED_12BIT selects an active matrix display
  741. //! and uses a 1, 2, 4 or 8bpp frame buffer with palette lookup. Output color
  742. //! data is described in 12-bit format using bits 11:0 of the data bus. The
  743. //! frame buffer pixel format is defined by the value passed in the \e ui32Type
  744. //! parameter to LCDRasterPaletteSet().
  745. //! - \b RASTER_FMT_ACTIVE_PALETTIZED_16BIT selects an active matrix display
  746. //! and uses a 1, 2, 4 or 8bpp frame buffer with palette lookup. Output color
  747. //! data is described in 16-bit 5:6:5 format. The frame buffer pixel format is
  748. //! defined by the value passed in the \e ui32Type parameter to
  749. //! LCDRasterPaletteSet().
  750. //! - \b RASTER_FMT_PASSIVE_MONO_4PIX selects a monochrome, passive matrix
  751. //! display that outputs 4 pixels on each pixel clock.
  752. //! - \b RASTER_FMT_PASSIVE_MONO_8PIX selects a monochrome, passive matrix
  753. //! display that outputs 8 pixels on each pixel clock.
  754. //! - \b RASTER_FMT_PASSIVE_COLOR_12BIT selects a passive matrix display
  755. //! and uses a 12bpp frame buffer. The palette is bypassed and 12-bit pixel
  756. //! data is sent to the grayscaler for the display.
  757. //! - \b RASTER_FMT_PASSIVE_COLOR_16BIT selects a passive matrix display
  758. //! and uses a 16bpp frame buffer with pixels in 5:6:5 format. Only the 4
  759. //! most significant bits of each color component are sent to the grayscaler
  760. //! for the display.
  761. //!
  762. //! Additionally, the following flags may be ORed into \e ui32Config:
  763. //!
  764. //! - \b RASTER_ACTVID_DURING_BLANK sets Actvid to toggle during vertical
  765. //! blanking.
  766. //! - \b RASTER_NIBBLE_MODE_ENABLED enables nibble mode. This parameter works
  767. //! with \b RASTER_READ_ORDER_REVERSED to determine how 1, 2 and 4bpp pixels
  768. //! are extracted from words read from the frame buffer. If specified, words
  769. //! read from the frame buffer are byte swapped prior to individual pixels
  770. //! being parsed from them.
  771. //! - \b RASTER_LOAD_DATA_ONLY tells the controller to read only pixel data
  772. //! from the frame buffer and to use the last palette read. No palette load
  773. //! is performed.
  774. //! - \b RASTER_LOAD_PALETTE_ONLY tells the controller to read only the palette
  775. //! data from the frame buffer.
  776. //! - \b RASTER_READ_ORDER_REVERSED when using 1, 2, 4 and 8bpp frame buffers,
  777. //! this option reverses the order in which frame buffer words are parsed.
  778. //! When this option is specified, the leftmost pixel in a word is taken from
  779. //! the most significant bits. When absent, the leftmost pixel is parsed from
  780. //! the least significant bits.
  781. //!
  782. //! If the LCD controller's raster engine is enabled when this function is
  783. //! called, it is disabled as a result of the call.
  784. //!
  785. //! \return None.
  786. //
  787. //*****************************************************************************
  788. void
  789. LCDRasterConfigSet(uint32_t ui32Base, uint32_t ui32Config,
  790. uint8_t ui8PalLoadDelay)
  791. {
  792. //
  793. // Sanity check parameters.
  794. //
  795. ASSERT(ui32Base == LCD0_BASE);
  796. ASSERT(!(ui32Config & ~(RASTER_FMT_ACTIVE_24BPP_PACKED |
  797. RASTER_FMT_ACTIVE_24BPP_UNPACKED |
  798. RASTER_FMT_ACTIVE_PALETTIZED_12BIT |
  799. RASTER_FMT_ACTIVE_PALETTIZED_16BIT |
  800. RASTER_FMT_PASSIVE_MONO_4PIX |
  801. RASTER_FMT_PASSIVE_MONO_8PIX |
  802. RASTER_FMT_PASSIVE_PALETTIZED |
  803. RASTER_FMT_PASSIVE_COLOR_12BIT |
  804. RASTER_FMT_PASSIVE_COLOR_16BIT |
  805. RASTER_ACTVID_DURING_BLANK |
  806. RASTER_NIBBLE_MODE_ENABLED |
  807. RASTER_LOAD_DATA_ONLY |
  808. RASTER_LOAD_PALETTE_ONLY |
  809. RASTER_READ_ORDER_REVERSED)));
  810. //
  811. // Write the raster control register.
  812. //
  813. HWREG(ui32Base + LCD_O_RASTRCTL) = (ui32Config |
  814. ((uint32_t)ui8PalLoadDelay <<
  815. LCD_RASTRCTL_REQDLY_S));
  816. }
  817. //*****************************************************************************
  818. //
  819. //! Sets the LCD controller interface timing when in raster mode.
  820. //!
  821. //! \param ui32Base specifies the LCD controller module base address.
  822. //! \param pTiming points to a structure containing the desired timing
  823. //! parameters.
  824. //!
  825. //! This function is used in raster mode to set the panel size and sync timing
  826. //! parameters.
  827. //!
  828. //! For a definition of the timing parameters required, see the definition of
  829. //! tLCDRasterTiming.
  830. //!
  831. //! \return None
  832. //
  833. //*****************************************************************************
  834. void
  835. LCDRasterTimingSet(uint32_t ui32Base, const tLCDRasterTiming *pTiming)
  836. {
  837. uint32_t ui32T0, ui32T1, ui32T2;
  838. //
  839. // Sanity check parameters.
  840. //
  841. ASSERT(ui32Base == LCD0_BASE);
  842. ASSERT(pTiming);
  843. ASSERT(!(pTiming->ui32Flags & ~(RASTER_TIMING_SYNCS_OPPOSITE_PIXCLK |
  844. RASTER_TIMING_SYNCS_ON_FALLING_PIXCLK |
  845. RASTER_TIMING_SYNCS_ON_RISING_PIXCLK |
  846. RASTER_TIMING_ACTIVE_LOW_OE |
  847. RASTER_TIMING_ACTIVE_LOW_PIXCLK |
  848. RASTER_TIMING_ACTIVE_LOW_HSYNC |
  849. RASTER_TIMING_ACTIVE_LOW_VSYNC)));
  850. ASSERT(pTiming->ui16PanelWidth && (pTiming->ui16PanelWidth <= 2048) &&
  851. ((pTiming->ui16PanelWidth % 16) == 0));
  852. ASSERT(pTiming->ui16PanelHeight && (pTiming->ui16PanelHeight <= 2048));
  853. ASSERT(pTiming->ui16HFrontPorch && (pTiming->ui16HFrontPorch <= 1024));
  854. ASSERT(pTiming->ui16HBackPorch && (pTiming->ui16HBackPorch <= 1024));
  855. ASSERT(pTiming->ui16HSyncWidth && (pTiming->ui16HSyncWidth <= 1024));
  856. ASSERT(pTiming->ui8VSyncWidth && (pTiming->ui8VSyncWidth <= 64));
  857. //
  858. // Construct the values we need for the three raster timing registers.
  859. //
  860. ui32T0 = ((uint32_t)((pTiming->ui16HBackPorch - 1) & 0xFF) <<
  861. LCD_RASTRTIM0_HBP_S) |
  862. ((uint32_t)((pTiming->ui16HFrontPorch - 1) & 0xFF) <<
  863. LCD_RASTRTIM0_HFP_S) |
  864. ((uint32_t)((pTiming->ui16HSyncWidth - 1) & 0x3F) <<
  865. LCD_RASTRTIM0_HSW_S) |
  866. (((uint32_t)((pTiming->ui16PanelWidth - 1) & 0x3F0) >> 4) <<
  867. LCD_RASTRTIM0_PPL_S) |
  868. (((uint32_t)((pTiming->ui16PanelWidth - 1) & 0x400) >> 10) <<
  869. LCD_RASTRTIM0_MSBPPL_S);
  870. ui32T1 = ((uint32_t)pTiming->ui8VBackPorch << LCD_RASTRTIM1_VBP_S) |
  871. ((uint32_t)pTiming->ui8VFrontPorch << LCD_RASTRTIM1_VFP_S) |
  872. ((uint32_t)((pTiming->ui8VSyncWidth - 1) & 0x3F) <<
  873. LCD_RASTRTIM1_VSW_S) |
  874. ((uint32_t)(pTiming->ui16PanelHeight - 1) & 0x3FF) <<
  875. LCD_RASTRTIM1_LPP_S;
  876. ui32T2 = pTiming->ui32Flags |
  877. ((((pTiming->ui16HSyncWidth - 1) & 0x3C0) >> 6) <<
  878. LCD_RASTRTIM2_HSW_S) |
  879. ((((pTiming->ui16PanelHeight - 1) & 0x400) >> 10) <<
  880. LCD_RASTRTIM2_MSBLPP_S) |
  881. ((((pTiming->ui16HBackPorch - 1) & 0x300) >> 8) <<
  882. LCD_RASTRTIM2_MSBHBP_S) |
  883. ((((pTiming->ui16HFrontPorch - 1) & 0x300) >> 8) <<
  884. LCD_RASTRTIM2_MSBHFP_S) |
  885. (pTiming->ui8ACBiasLineCount << LCD_RASTRTIM2_ACBF_S);
  886. //
  887. // Write the timing registers, taking care to preserve any existing value
  888. // in the AC Bias interrupt field of RASTRTIM2.
  889. //
  890. HWREG(ui32Base + LCD_O_RASTRTIM0) = ui32T0;
  891. HWREG(ui32Base + LCD_O_RASTRTIM1) = ui32T1;
  892. HWREG(ui32Base + LCD_O_RASTRTIM2) = (HWREG(ui32Base + LCD_O_RASTRTIM2) &
  893. LCD_RASTRTIM2_ACBI_M) | ui32T2;
  894. }
  895. //*****************************************************************************
  896. //
  897. //! Sets the number of AC bias pin transitions per interrupt.
  898. //!
  899. //! \param ui32Base is the base address of the controller.
  900. //! \param ui8Count is the number of AC bias pin transitions to count before
  901. //! the AC bias count interrupt is asserted. Valid values are from 0 to 15.
  902. //!
  903. //! This function is used to set the number of AC bias transitions between
  904. //! each AC bias count interrupt (\b LCD_INT_AC_BIAS_CNT). If \e ui8Count is
  905. //! 0, no AC bias count interrupt is generated.
  906. //!
  907. //! \return None.
  908. //
  909. //*****************************************************************************
  910. void
  911. LCDRasterACBiasIntCountSet(uint32_t ui32Base, uint8_t ui8Count)
  912. {
  913. uint32_t ui32Val;
  914. //
  915. // Sanity check parameters.
  916. //
  917. ASSERT(ui32Base == LCD0_BASE);
  918. ASSERT(ui8Count < 16);
  919. //
  920. // Get the existing raster timing 2 register value and mask in the new
  921. // AC Bias interrupt count.
  922. //
  923. ui32Val = HWREG(ui32Base + LCD_O_RASTRTIM2);
  924. ui32Val &= ~LCD_RASTRTIM2_ACBI_M;
  925. ui32Val |= ((ui8Count << LCD_RASTRTIM2_ACBI_S) & LCD_RASTRTIM2_ACBI_M);
  926. //
  927. // Write the new value back to the register.
  928. //
  929. HWREG(ui32Base + LCD_O_RASTRTIM2) = ui32Val;
  930. }
  931. //*****************************************************************************
  932. //
  933. //! Enables the raster output.
  934. //!
  935. //! \param ui32Base is the base address of the controller.
  936. //!
  937. //! This function enables the LCD controller raster output and starts
  938. //! displaying the content of the current frame buffer on the attached panel.
  939. //! Prior to enabling the raster output, LCDModeSet(), LCDRasterConfigSet(),
  940. //! LCDDMAConfigSet(), LCDRasterTimingSet(), LCDRasterPaletteSet() and
  941. //! LCDRasterFrameBufferSet() must have been called.
  942. //!
  943. //! \return None.
  944. //
  945. //*****************************************************************************
  946. void
  947. LCDRasterEnable(uint32_t ui32Base)
  948. {
  949. //
  950. // Sanity check parameters.
  951. //
  952. ASSERT(ui32Base == LCD0_BASE);
  953. //
  954. // Reset the module prior to starting the raster. This is required to
  955. // ensure correct operation of the raster engine.
  956. //
  957. LCDClockReset(ui32Base, LCD_CLOCK_MAIN);
  958. //
  959. // Enable the raster engine.
  960. //
  961. HWREG(ui32Base + LCD_O_RASTRCTL) |= LCD_RASTRCTL_LCDEN;
  962. }
  963. //*****************************************************************************
  964. //
  965. //! Determines whether or not the raster output is currently enabled.
  966. //!
  967. //! \param ui32Base is the base address of the controller.
  968. //!
  969. //! This function may be used to query whether or not the raster output is
  970. //! currently enabled.
  971. //!
  972. //! \return Returns \b true if the raster is enabled or \b false if it is
  973. //! disabled.
  974. //
  975. //*****************************************************************************
  976. bool
  977. LCDRasterEnabled(uint32_t ui32Base)
  978. {
  979. //
  980. // Sanity check parameters.
  981. //
  982. ASSERT(ui32Base == LCD0_BASE);
  983. //
  984. // Return the current raster engine status.
  985. //
  986. return((HWREG(ui32Base + LCD_O_RASTRCTL) & LCD_RASTRCTL_LCDEN) ?
  987. true : false);
  988. }
  989. //*****************************************************************************
  990. //
  991. //! Disables the raster output.
  992. //!
  993. //! \param ui32Base is the base address of the controller.
  994. //!
  995. //! This function disables the LCD controller raster output and stops driving
  996. //! the attached display.
  997. //!
  998. //! \note Once disabled, the raster engine continues to scan data until the
  999. //! end of the current frame. If the display is to be re-enabled, wait until
  1000. //! after the final \b LCD_INT_RASTER_FRAME_DONE has been received, indicating
  1001. //! that the raster engine has stopped.
  1002. //!
  1003. //! \return None.
  1004. //
  1005. //*****************************************************************************
  1006. void
  1007. LCDRasterDisable(uint32_t ui32Base)
  1008. {
  1009. //
  1010. // Sanity check parameters.
  1011. //
  1012. ASSERT(ui32Base == LCD0_BASE);
  1013. //
  1014. // Disable the raster engine.
  1015. //
  1016. HWREG(ui32Base + LCD_O_RASTRCTL) &= ~LCD_RASTRCTL_LCDEN;
  1017. }
  1018. //*****************************************************************************
  1019. //
  1020. //! Sets the position and size of the subpanel on the raster display.
  1021. //!
  1022. //! \param ui32Base is the base address of the controller.
  1023. //! \param ui32Flags may be either \b LCD_SUBPANEL_AT_TOP to show frame buffer
  1024. //! image data in the top portion of the display and default color in the
  1025. //! bottom portion, or \b LCD_SUBPANEL_AT_BOTTOM to show image data at the
  1026. //! bottom of the display and default color at the top.
  1027. //! \param ui32BottomLines defines the number of lines comprising the bottom
  1028. //! portion of the display. If \b LCD_SUBPANEL_AT_TOP is set in \e ui32Flags,
  1029. //! these lines contain the default pixel color when the subpanel is
  1030. //! enabled, otherwise they contain image data.
  1031. //! \param ui32DefaultPixel is the 24-bit RGB color to show in the portion of
  1032. //! the display not configured to show image data.
  1033. //!
  1034. //! The LCD controller provides a feature that allows a portion of the display
  1035. //! to be filled with a default color rather than image data from the frame
  1036. //! buffer. This feature reduces SRAM bandwidth requirements because no data
  1037. //! is fetched for lines containing the default color. This feature is only
  1038. //! available when the LCD controller is in raster mode and configured to drive
  1039. //! an active matrix display.
  1040. //!
  1041. //! The subpanel area containing image data from the frame buffer may be
  1042. //! positioned either at the top or bottom of the display as controlled by
  1043. //! the value of \e ui32Flags. The height of the bottom portion of the display
  1044. //! is defined by \e ui32BottomLines.
  1045. //!
  1046. //! When a subpanel is configured, the application must also reconfigure the
  1047. //! frame buffer to ensure that it contains the correct number of lines for
  1048. //! the subpanel size in use. This configuration can be achieved by calling
  1049. //! LCDRasterFrameBufferSet() with the \e ui32NumBytes parameter set
  1050. //! appropriately to describe the required number of active video lines in
  1051. //! the subpanel area.
  1052. //!
  1053. //! The subpanel display mode is not enabled using this function. To enable
  1054. //! the subpanel once it has been configured, call LCDRasterSubPanelEnable().
  1055. //!
  1056. //! \return None.
  1057. //
  1058. //*****************************************************************************
  1059. void
  1060. LCDRasterSubPanelConfigSet(uint32_t ui32Base, uint32_t ui32Flags,
  1061. uint32_t ui32BottomLines, uint32_t ui32DefaultPixel)
  1062. {
  1063. //
  1064. // Sanity check parameters.
  1065. //
  1066. ASSERT(ui32Base == LCD0_BASE);
  1067. ASSERT((ui32Flags == LCD_SUBPANEL_AT_TOP) ||
  1068. (ui32Flags == LCD_SUBPANEL_AT_BOTTOM));
  1069. ASSERT(ui32BottomLines && (ui32BottomLines <= 2048));
  1070. //
  1071. // Adjust the line count into the 0-2047 range.
  1072. //
  1073. ui32BottomLines--;
  1074. //
  1075. // Set the first subpanel configuration register, taking care to leave the
  1076. // subpanel enabled if it already was.
  1077. //
  1078. HWREG(ui32Base + LCD_O_RASTRSUBP1) = (HWREG(ui32Base + LCD_O_RASTRSUBP1) &
  1079. LCD_RASTRSUBP1_SPEN) | ui32Flags |
  1080. ((ui32DefaultPixel & 0xFFFF) <<
  1081. LCD_RASTRSUBP1_DPDLSB_S) |
  1082. ((ui32BottomLines <<
  1083. LCD_RASTRSUBP1_LPPT_S) &
  1084. LCD_RASTRSUBP1_LPPT_M);
  1085. //
  1086. // Set the second subpanel configuration register.
  1087. //
  1088. HWREG(ui32Base + LCD_O_RASTRSUBP2) =
  1089. ((ui32DefaultPixel >> 16) & LCD_RASTRSUBP2_DPDMSB_M) |
  1090. (((ui32BottomLines >> LCD_RASTRSUBP1_LPPT_S) & 1) << 8);
  1091. }
  1092. //*****************************************************************************
  1093. //
  1094. //! Enables subpanel display mode.
  1095. //!
  1096. //! \param ui32Base is the base address of the controller.
  1097. //!
  1098. //! This function enables subpanel display mode and displays a default color
  1099. //! rather than image data in the number of lines and at the position specified
  1100. //! by a previous call to LCDRasterSubPanelConfigSet(). Prior to calling
  1101. //! LCDRasterSubPanelEnable(), the frame buffer should have been reconfigured
  1102. //! to match the desired subpanel size using a call to
  1103. //! LCDRasterFrameBufferSet().
  1104. //!
  1105. //! Subpanel display is only possible when the LCD controller is in raster
  1106. //! mode and is configured to drive an active matrix display.
  1107. //!
  1108. //! \return None.
  1109. //
  1110. //*****************************************************************************
  1111. void
  1112. LCDRasterSubPanelEnable(uint32_t ui32Base)
  1113. {
  1114. //
  1115. // Sanity check parameters.
  1116. //
  1117. ASSERT(ui32Base == LCD0_BASE);
  1118. //
  1119. // Enable the subpanel.
  1120. //
  1121. HWREG(ui32Base + LCD_O_RASTRSUBP1) |= LCD_RASTRSUBP1_SPEN;
  1122. }
  1123. //*****************************************************************************
  1124. //
  1125. //! Disables subpanel display mode.
  1126. //!
  1127. //! \param ui32Base is the base address of the controller.
  1128. //!
  1129. //! This function disables subpanel display mode and reverts to showing the
  1130. //! entire frame buffer image on the display. After the subpanel is disabled,
  1131. //! the frame buffer size must be reconfigured to match the full dimensions of
  1132. //! the display area by calling LCDRasterFrameBufferSet() with an appropriate
  1133. //! value for the \e ui32NumBytes parameter.
  1134. //!
  1135. //! \return None.
  1136. //
  1137. //*****************************************************************************
  1138. void
  1139. LCDRasterSubPanelDisable(uint32_t ui32Base)
  1140. {
  1141. //
  1142. // Sanity check parameters.
  1143. //
  1144. ASSERT(ui32Base == LCD0_BASE);
  1145. //
  1146. // Disable the subpanel.
  1147. //
  1148. HWREG(ui32Base + LCD_O_RASTRSUBP1) &= ~LCD_RASTRSUBP1_SPEN;
  1149. }
  1150. //*****************************************************************************
  1151. //
  1152. //! Configures the LCD controller's internal DMA engine.
  1153. //!
  1154. //! \param ui32Base is the base address of the controller.
  1155. //! \param ui32Config provides flags defining the desired DMA parameters.
  1156. //!
  1157. //! This function is used to configure the DMA engine within the LCD
  1158. //! controller. This engine is responsible for performing bulk data transfers
  1159. //! to the display when in LIDD mode or for transferring palette and pixel data
  1160. //! from SRAM to the display panel when in raster mode.
  1161. //!
  1162. //! The \e ui32Config parameter is a logical OR of various flags. It must
  1163. //! contain one value from each of the following groups.
  1164. //!
  1165. //! The first group of flags set the number of words that have to be in the
  1166. //! FIFO before it signals that it is ready:
  1167. //!
  1168. //! - \b LCD_DMA_FIFORDY_8_WORDS
  1169. //! - \b LCD_DMA_FIFORDY_16_WORDS
  1170. //! - \b LCD_DMA_FIFORDY_32_WORDS
  1171. //! - \b LCD_DMA_FIFORDY_64_WORDS
  1172. //! - \b LCD_DMA_FIFORDY_128_WORDS
  1173. //! - \b LCD_DMA_FIFORDY_256_WORDS
  1174. //! - \b LCD_DMA_FIFORDY_512_WORDS
  1175. //!
  1176. //! The second group of flags set the number of 32-bit words in each DMA burst
  1177. //! transfer:
  1178. //!
  1179. //! - \b LCD_DMA_BURST_1
  1180. //! - \b LCD_DMA_BURST_2
  1181. //! - \b LCD_DMA_BURST_4
  1182. //! - \b LCD_DMA_BURST_8
  1183. //! - \b LCD_DMA_BURST_16
  1184. //!
  1185. //! The final group of flags set internal byte lane controls and allow byte
  1186. //! swapping within the DMA engine. The label represents the output byte order
  1187. //! for an input 32-bit word ordered ``0123''.
  1188. //!
  1189. //! - \b LCD_DMA_BYTE_ORDER_0123
  1190. //! - \b LCD_DMA_BYTE_ORDER_1023
  1191. //! - \b LCD_DMA_BYTE_ORDER_3210
  1192. //! - \b LCD_DMA_BYTE_ORDER_2301
  1193. //!
  1194. //! Additionally, \b LCD_DMA_PING_PONG may be specified. This flag configures
  1195. //! the controller to operate in double-buffered mode. When data is scanned
  1196. //! out from the first frame buffer, the DMA engine immediately moves to
  1197. //! the second frame buffer and scans from there before moving back to the
  1198. //! first. If this flag is clear, the DMA engine uses a single frame buffer,
  1199. //! restarting the scan from the beginning of the buffer each time it completes
  1200. //! a frame.
  1201. //!
  1202. //! \note DMA burst size \b LCD_DMA_BURST_16 should be set when using frame
  1203. //! buffers in external, EPI-connected memory. Using a smaller burst size in
  1204. //! this case is likely to result in occasional FIFO underflows and associated
  1205. //! display glitches.
  1206. //!
  1207. //! \return None.
  1208. //
  1209. //*****************************************************************************
  1210. void
  1211. LCDDMAConfigSet(uint32_t ui32Base, uint32_t ui32Config)
  1212. {
  1213. //
  1214. // Sanity check parameters.
  1215. //
  1216. ASSERT(ui32Base == LCD0_BASE);
  1217. ASSERT(!(ui32Config & ~(LCD_DMACTL_FIFORDY_M | LCD_DMACTL_BURSTSZ_M |
  1218. LCD_DMACTL_BYTESWAP | LCD_DMACTL_BIGDEND |
  1219. LCD_DMACTL_FMODE)));
  1220. //
  1221. // Write the DMA control register.
  1222. //
  1223. HWREG(ui32Base + LCD_O_DMACTL) = ui32Config;
  1224. }
  1225. //*****************************************************************************
  1226. //
  1227. //! Initializes the color palette in a frame buffer.
  1228. //!
  1229. //! \param ui32Base is the base address of the controller.
  1230. //! \param ui32Type specifies the type of pixel data to be held in the frame
  1231. //! buffer and also the format of the source color values passed.
  1232. //! \param pui32Addr points to the start of the frame buffer into which the
  1233. //! palette information is to be written.
  1234. //! \param pui32SrcColors points to the first color value that is to be
  1235. //! written into the frame buffer palette.
  1236. //! \param ui32Start specifies the index of the first color in the palette
  1237. //! to update.
  1238. //! \param ui32Count specifies the number of source colors to be copied into
  1239. //! the frame buffer palette.
  1240. //!
  1241. //! This function is used to initialize the color palette stored at the
  1242. //! beginning of a frame buffer. It writes the relevant pixel type into the
  1243. //! first entry of the frame buffer and copies the requested number of colors
  1244. //! from a source buffer into the palette starting at the required index,
  1245. //! optionally converting them from 24-bit color format into the 12-bit format
  1246. //! used by the LCD controller.
  1247. //!
  1248. //! \e ui32Type must be set to one of the following values to indicate the
  1249. //! type of frame buffer for which the palette is being initialized:
  1250. //!
  1251. //! - \b LCD_PALETTE_TYPE_1BPP indicates a 1 bit per pixel
  1252. //! (monochrome) frame buffer. This format requires a 2 entry palette.
  1253. //! - \b LCD_PALETTE_TYPE_2BPP indicates a 2 bit per pixel frame
  1254. //! buffer. This format requires a 4 entry palette.
  1255. //! - \b LCD_PALETTE_TYPE_4BPP indicates a 4 bit per pixel frame
  1256. //! buffer. This format requires a 4 entry palette.
  1257. //! - \b LCD_PALETTE_TYPE_8BPP indicates an 8 bit per pixel frame
  1258. //! buffer. This format requires a 256 entry palette.
  1259. //! - \b LCD_PALETTE_TYPE_DIRECT indicates a direct color (12, 16 or
  1260. //! 24 bit per pixel). The color palette is not used in these modes, but the
  1261. //! frame buffer type must still be initialized to ensure that the hardware
  1262. //! uses the correct pixel type. When this value is used, the format of the
  1263. //! pixels in the frame buffer is defined by the \e ui32Config parameter
  1264. //! previously passed to LCDRasterConfigSet().
  1265. //!
  1266. //! Optionally, the \b LCD_PALETTE_SRC_24BIT flag may be ORed into \e ui32Type
  1267. //! to indicate that the supplied colors in the \e pui32SrcColors array are in
  1268. //! the 24-bit format as used by the TivaWare Graphics Library with one color
  1269. //! stored in each 32-bit word. In this case, the colors read from the source
  1270. //! array are converted to the 12-bit format used by the LCD controller before
  1271. //! being written into the frame buffer palette.
  1272. //!
  1273. //! If \b LCD_PALETTE_SRC_24BIT is not present, it is assumed that the
  1274. //! \e pui32SrcColors array contains 12-bit colors in the format required by
  1275. //! the LCD controller with 2 colors stored in each 32-bit word. In this case,
  1276. //! the values are copied directly into the frame buffer palette without any
  1277. //! reformatting.
  1278. //!
  1279. //! \return None.
  1280. //
  1281. //*****************************************************************************
  1282. void
  1283. LCDRasterPaletteSet(uint32_t ui32Base, uint32_t ui32Type, uint32_t *pui32Addr,
  1284. const uint32_t *pui32SrcColors, uint32_t ui32Start,
  1285. uint32_t ui32Count)
  1286. {
  1287. uint16_t *pui16Pal;
  1288. uint16_t *pui16Src;
  1289. uint32_t ui32Loop;
  1290. //
  1291. // Sanity check parameters.
  1292. //
  1293. ASSERT(ui32Base == LCD0_BASE);
  1294. ASSERT(ui32Start < 256);
  1295. ASSERT((ui32Start + ui32Count) <= 256);
  1296. ASSERT(pui32Addr);
  1297. ASSERT((pui32SrcColors) || (ui32Count == 0));
  1298. ASSERT(!(ui32Type & ~(LCD_PALETTE_SRC_24BIT | LCD_PALETTE_TYPE_DIRECT |
  1299. LCD_PALETTE_TYPE_8BPP | LCD_PALETTE_TYPE_4BPP |
  1300. LCD_PALETTE_TYPE_2BPP | LCD_PALETTE_TYPE_1BPP)));
  1301. //
  1302. // Get a pointer to the start of the palette.
  1303. //
  1304. pui16Pal = (uint16_t *)pui32Addr;
  1305. //
  1306. // Are we converting the palette color format?
  1307. //
  1308. if(ui32Type & LCD_PALETTE_SRC_24BIT)
  1309. {
  1310. //
  1311. // Yes - loop through each of the supplied 24-bit colors converting
  1312. // and storing each.
  1313. //
  1314. ui32Loop = 0;
  1315. while(ui32Count)
  1316. {
  1317. pui16Pal[ui32Start + ui32Loop] =
  1318. PAL_FROM_RGB(pui32SrcColors[ui32Loop]);
  1319. ui32Loop++;
  1320. ui32Count--;
  1321. }
  1322. }
  1323. else
  1324. {
  1325. //
  1326. // No - loop through the supplied 12-bit colors storing each.
  1327. //
  1328. pui16Src = (uint16_t *)pui32SrcColors;
  1329. while(ui32Count)
  1330. {
  1331. pui16Pal[ui32Start] = pui16Src[ui32Start];
  1332. ui32Start++;
  1333. ui32Count--;
  1334. }
  1335. }
  1336. //
  1337. // Write the pixel type into the first palette entry.
  1338. //
  1339. pui16Pal[0] &= ~(LCD_PALETTE_TYPE_8BPP | LCD_PALETTE_TYPE_DIRECT);
  1340. pui16Pal[0] |= (ui32Type & ~LCD_PALETTE_SRC_24BIT);
  1341. }
  1342. //*****************************************************************************
  1343. //
  1344. //! Sets the LCD controller frame buffer start address and size in raster mode.
  1345. //!
  1346. //! \param ui32Base is the base address of the controller.
  1347. //! \param ui8Buffer specifies which frame buffer to configure. Valid values
  1348. //! are 0 and 1.
  1349. //! \param pui32Addr points to the first byte of the frame buffer. This
  1350. //! pointer must be aligned on a 32-bit (word) boundary.
  1351. //! \param ui32NumBytes specifies the size of the frame buffer in bytes. This
  1352. //! value must be a multiple of 4.
  1353. //!
  1354. //! This function is used to configure the position and size of one of the
  1355. //! two supported frame buffers while in raster mode. The second frame buffer
  1356. //! (configured when ui8Buffer is set to 1) is only used if the controller
  1357. //! is set to operate in ping-pong mode (by specifying the \b LCD_DMA_PING_PONG
  1358. //! configuration flag on a call to LCDDMAConfigSet()).
  1359. //!
  1360. //! The format of the frame buffer depends on the image type in use and
  1361. //! the current raster configuration settings. If \b RASTER_LOAD_DATA_ONLY
  1362. //! was specified in a previous call to LCDRasterConfigSet(), the frame buffer
  1363. //! contains only packed pixel data in the required bit depth and format.
  1364. //! In other cases, the frame buffer comprises a palette of either 8 or 128
  1365. //! 32-bit words followed by the packed pixel data. The palette size is 8
  1366. //! words (16 16-bit entries) for all pixel formats other than 8bpp which
  1367. //! uses a palette of 128 words (256 16-bit entries). Note that the 8 word
  1368. //! palette is still present even for 12, 16 and 24-bit formats, which do not
  1369. //! use the lookup table.
  1370. //!
  1371. //! The frame buffer size, specified using the \e ui32NumBytes parameter, must
  1372. //! be the palette size (if any) plus the size of the image bitmap required
  1373. //! for the currently configured display resolution.
  1374. //!
  1375. //! \e ui32NumBytes = (Palette Size) + ((Width * Height) * BPP) / 8)
  1376. //!
  1377. //! If \b RASTER_LOAD_DATA_ONLY is not specified, frame buffers passed to this
  1378. //! function must be initialized using a call to LCDRasterPaletteSet() prior to
  1379. //! enabling the raster output. If this is not done, the pixel format
  1380. //! identifier and color table required by the hardware is not present
  1381. //! and the results are unpredictable.
  1382. //!
  1383. //! \return None.
  1384. //*****************************************************************************
  1385. void
  1386. LCDRasterFrameBufferSet(uint32_t ui32Base, uint8_t ui8Buffer,
  1387. uint32_t *pui32Addr, uint32_t ui32NumBytes)
  1388. {
  1389. //
  1390. // Sanity check parameters.
  1391. //
  1392. ASSERT(ui32Base == LCD0_BASE);
  1393. ASSERT(!((uint32_t)pui32Addr & 3));
  1394. ASSERT(!(ui32NumBytes & 3));
  1395. ASSERT(ui8Buffer < 2);
  1396. //
  1397. // Are we setting the values for frame buffer 0?
  1398. //
  1399. if(!ui8Buffer)
  1400. {
  1401. //
  1402. // Yes - set the registers for frame buffer 0.
  1403. //
  1404. HWREG(ui32Base + LCD_O_DMABAFB0) = (uint32_t)pui32Addr;
  1405. HWREG(ui32Base + LCD_O_DMACAFB0) = (uint32_t)pui32Addr +
  1406. ui32NumBytes - 4;
  1407. }
  1408. else
  1409. {
  1410. //
  1411. // No - set the registers for frame buffer 1.
  1412. //
  1413. HWREG(ui32Base + LCD_O_DMABAFB1) = (uint32_t)pui32Addr;
  1414. HWREG(ui32Base + LCD_O_DMACAFB1) = (uint32_t)pui32Addr +
  1415. ui32NumBytes - 4;
  1416. }
  1417. }
  1418. //*****************************************************************************
  1419. //
  1420. //! Enables individual LCD controller interrupt sources.
  1421. //!
  1422. //! \param ui32Base is the base address of the controller.
  1423. //! \param ui32IntFlags is the bit mask of the interrupt sources to be enabled.
  1424. //!
  1425. //! This function enables the indicated LCD controller interrupt sources.
  1426. //! Only the sources that are enabled can be reflected to the processor
  1427. //! interrupt; disabled sources have no effect on the processor.
  1428. //!
  1429. //! The \e ui32IntFlags parameter is the logical OR of any of the following:
  1430. //!
  1431. //! - \b LCD_INT_DMA_DONE - indicates that a LIDD DMA transfer is complete.
  1432. //! - \b LCD_INT_RASTER_FRAME_DONE - indicates that a raster-mode frame is
  1433. //! complete.
  1434. //! - \b LCD_INT_SYNC_LOST - indicates that frame synchronization was lost.
  1435. //! - \b LCD_INT_AC_BIAS_CNT - indicates that that AC bias transition counter
  1436. //! has decremented to zero and is is valid for passive matrix panels only.
  1437. //! The counter, set by a call to LCDRasterACBiasIntCountSet(), is reloaded
  1438. //! but remains disabled until this interrupt is cleared.
  1439. //! - \b LCD_INT_UNDERFLOW - indicates that a data underflow occurred. The
  1440. //! internal FIFO was empty when the output logic attempted to read data to
  1441. //! send to the display.
  1442. //! - \b LCD_INT_PAL_LOAD - indicates that the color palette has been loaded.
  1443. //! - \b LCD_INT_EOF0 - indicates that the raw End-of-Frame 0 has been
  1444. //! signaled.
  1445. //! - \b LCD_INT_EOF2 - indicates that the raw End-of-Frame 1 has been
  1446. //! signaled.
  1447. //!
  1448. //! \return None.
  1449. //
  1450. //*****************************************************************************
  1451. void
  1452. LCDIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags)
  1453. {
  1454. ASSERT(ui32Base == LCD0_BASE);
  1455. ASSERT(!(ui32IntFlags & ~(LCD_INT_DMA_DONE | LCD_INT_SYNC_LOST |
  1456. LCD_INT_AC_BIAS_CNT | LCD_INT_UNDERFLOW |
  1457. LCD_INT_PAL_LOAD | LCD_INT_EOF0 | LCD_INT_EOF1 |
  1458. LCD_INT_RASTER_FRAME_DONE)));
  1459. //
  1460. // Enable the interrupt sources by setting the appropriate bits in the
  1461. // mask register.
  1462. //
  1463. HWREG(ui32Base + LCD_O_IM) = ui32IntFlags;
  1464. }
  1465. //*****************************************************************************
  1466. //
  1467. //! Disables individual LCD controller interrupt sources.
  1468. //!
  1469. //! \param ui32Base is the base address of the controller.
  1470. //! \param ui32IntFlags is the bit mask of the interrupt sources to be
  1471. //! disabled.
  1472. //!
  1473. //! This function disables the indicated LCD controller interrupt sources.
  1474. //! Only the sources that are enabled can be reflected to the processor
  1475. //! interrupt; disabled sources have no effect on the processor.
  1476. //!
  1477. //! The \e ui32IntFlags parameter is the logical OR of any of the following:
  1478. //!
  1479. //! - \b LCD_INT_DMA_DONE - indicates that a LIDD DMA transfer is complete.
  1480. //! - \b LCD_INT_RASTER_FRAME_DONE - indicates that a raster-mode frame is
  1481. //! complete.
  1482. //! - \b LCD_INT_SYNC_LOST - indicates that frame synchronization was lost.
  1483. //! - \b LCD_INT_AC_BIAS_CNT - indicates that that AC bias transition counter
  1484. //! has decremented to zero and is is valid for passive matrix panels only.
  1485. //! The counter, set by a call to LCDRasterACBiasIntCountSet(), is reloaded
  1486. //! but remains disabled until this interrupt is cleared.
  1487. //! - \b LCD_INT_UNDERFLOW - indicates that a data underflow occurred. The
  1488. //! internal FIFO was empty when the output logic attempted to read data to
  1489. //! send to the display.
  1490. //! - \b LCD_INT_PAL_LOAD - indicates that the color palette has been loaded.
  1491. //! - \b LCD_INT_EOF0 - indicates that the raw End-of-Frame 0 has been
  1492. //! signaled.
  1493. //! - \b LCD_INT_EOF2 - indicates that the raw End-of-Frame 1 has been
  1494. //! signaled.
  1495. //!
  1496. //! \return None.
  1497. //
  1498. //*****************************************************************************
  1499. void
  1500. LCDIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags)
  1501. {
  1502. ASSERT(ui32Base == LCD0_BASE);
  1503. ASSERT(!(ui32IntFlags & ~(LCD_INT_DMA_DONE | LCD_INT_SYNC_LOST |
  1504. LCD_INT_AC_BIAS_CNT | LCD_INT_UNDERFLOW |
  1505. LCD_INT_PAL_LOAD | LCD_INT_EOF0 | LCD_INT_EOF1 |
  1506. LCD_INT_RASTER_FRAME_DONE)));
  1507. //
  1508. // Disable the interrupt sources by clearing the appropriate bits in the
  1509. // mask register.
  1510. //
  1511. HWREG(ui32Base + LCD_O_IENC) = ui32IntFlags;
  1512. }
  1513. //*****************************************************************************
  1514. //
  1515. //! Gets the current LCD controller interrupt status.
  1516. //!
  1517. //! \param ui32Base is the base address of the controller.
  1518. //! \param bMasked is false if the raw interrupt status is required and true
  1519. //! if the masked interrupt status is required.
  1520. //!
  1521. //! This function returns the interrupt status for the LCD controller.
  1522. //! Either the raw interrupt status or the status of interrupts that are
  1523. //! allowed to reflect to the processor can be returned.
  1524. //!
  1525. //! \return Returns the current interrupt status as the logical OR of any of
  1526. //! the following:
  1527. //!
  1528. //! - \b LCD_INT_DMA_DONE - indicates that a LIDD DMA transfer is complete.
  1529. //! - \b LCD_INT_RASTER_FRAME_DONE - indicates that a raster-mode frame is
  1530. //! complete.
  1531. //! - \b LCD_INT_SYNC_LOST - indicates that frame synchronization was lost.
  1532. //! - \b LCD_INT_AC_BIAS_CNT - indicates that that AC bias transition counter
  1533. //! has decremented to zero and is is valid for passive matrix panels only.
  1534. //! The counter, set by a call to LCDRasterACBiasIntCountSet(), is reloaded
  1535. //! but remains disabled until this interrupt is cleared.
  1536. //! - \b LCD_INT_UNDERFLOW - indicates that a data underflow occurred. The
  1537. //! internal FIFO was empty when the output logic attempted to read data to
  1538. //! send to the display.
  1539. //! - \b LCD_INT_PAL_LOAD - indicates that the color palette has been loaded.
  1540. //! - \b LCD_INT_EOF0 - indicates that the raw End-of-Frame 0 has been
  1541. //! signaled.
  1542. //! - \b LCD_INT_EOF2 - indicates that the raw End-of-Frame 1 has been
  1543. //! signaled.
  1544. //
  1545. //*****************************************************************************
  1546. uint32_t
  1547. LCDIntStatus(uint32_t ui32Base, bool bMasked)
  1548. {
  1549. ASSERT(ui32Base == LCD0_BASE);
  1550. //
  1551. // Were we asked for the masked or raw interrupt status?
  1552. //
  1553. if(bMasked)
  1554. {
  1555. //
  1556. // Return the masked interrupt status.
  1557. //
  1558. return(HWREG(ui32Base + LCD_O_MISCLR));
  1559. }
  1560. else
  1561. {
  1562. //
  1563. // Return the raw interrupts status.
  1564. //
  1565. return(HWREG(ui32Base + LCD_O_RISSET));
  1566. }
  1567. }
  1568. //*****************************************************************************
  1569. //
  1570. //! Clears LCD controller interrupt sources.
  1571. //!
  1572. //! \param ui32Base is the base address of the controller.
  1573. //! \param ui32IntFlags is a bit mask of the interrupt sources to be cleared.
  1574. //!
  1575. //! The specified LCD controller interrupt sources are cleared so that they no
  1576. //! longer assert. This function must be called in the interrupt handler to
  1577. //! keep the interrupt from being triggered again immediately upon exit.
  1578. //!
  1579. //! The \e ui32IntFlags parameter is the logical OR of any of the following:
  1580. //!
  1581. //! - \b LCD_INT_DMA_DONE - indicates that a LIDD DMA transfer is complete.
  1582. //! - \b LCD_INT_RASTER_FRAME_DONE - indicates that a raster-mode frame is
  1583. //! complete.
  1584. //! - \b LCD_INT_SYNC_LOST - indicates that frame synchronization was lost.
  1585. //! - \b LCD_INT_AC_BIAS_CNT - indicates that that AC bias transition counter
  1586. //! has decremented to zero and is is valid for passive matrix panels only.
  1587. //! The counter, set by a call to LCDRasterACBiasIntCountSet(), is reloaded
  1588. //! but remains disabled until this interrupt is cleared.
  1589. //! - \b LCD_INT_UNDERFLOW - indicates that a data underflow occurred. The
  1590. //! internal FIFO was empty when the output logic attempted to read data to
  1591. //! send to the display.
  1592. //! - \b LCD_INT_PAL_LOAD - indicates that the color palette has been loaded.
  1593. //! - \b LCD_INT_EOF0 - indicates that the raw End-of-Frame 0 has been
  1594. //! signaled.
  1595. //! - \b LCD_INT_EOF2 - indicates that the raw End-of-Frame 1 has been
  1596. //! signaled.
  1597. //!
  1598. //! \note Because there is a write buffer in the Cortex-M processor, it may
  1599. //! take several clock cycles before the interrupt source is actually cleared.
  1600. //! Therefore, it is recommended that the interrupt source be cleared early in
  1601. //! the interrupt handler (as opposed to the very last action) to avoid
  1602. //! returning from the interrupt handler before the interrupt source is
  1603. //! actually cleared. Failure to do so may result in the interrupt handler
  1604. //! being immediately reentered (because the interrupt controller still sees
  1605. //! the interrupt source asserted).
  1606. //!
  1607. //! \return None.
  1608. //
  1609. //*****************************************************************************
  1610. void
  1611. LCDIntClear(uint32_t ui32Base, uint32_t ui32IntFlags)
  1612. {
  1613. ASSERT(ui32Base == LCD0_BASE);
  1614. ASSERT(!(ui32IntFlags & ~(LCD_INT_DMA_DONE | LCD_INT_SYNC_LOST |
  1615. LCD_INT_AC_BIAS_CNT | LCD_INT_UNDERFLOW |
  1616. LCD_INT_PAL_LOAD | LCD_INT_EOF0 | LCD_INT_EOF1 |
  1617. LCD_INT_RASTER_FRAME_DONE)));
  1618. //
  1619. // Clear the requested interrupts.
  1620. //
  1621. HWREG(ui32Base + LCD_O_MISCLR) = ui32IntFlags;
  1622. }
  1623. //*****************************************************************************
  1624. //
  1625. //! Registers an interrupt handler for the LCD controller module.
  1626. //!
  1627. //! \param ui32Base specifies the LCD controller module base address.
  1628. //! \param pfnHandler is a pointer to the function to be called when the LCD
  1629. //! controller interrupt occurs.
  1630. //!
  1631. //! This function registers the handler to be called when the LCD controller
  1632. //! module interrupt occurs.
  1633. //!
  1634. //! \note This function need not be called if the appropriate interrupt vector
  1635. //! is statically linked into the vector table in the application startup code.
  1636. //!
  1637. //! \sa IntRegister() for important information about registering interrupt
  1638. //! handlers.
  1639. //!
  1640. //! \return None.
  1641. //
  1642. //*****************************************************************************
  1643. void
  1644. LCDIntRegister(uint32_t ui32Base, void (*pfnHandler)(void))
  1645. {
  1646. //
  1647. // Check the arguments.
  1648. //
  1649. ASSERT(ui32Base == LCD0_BASE);
  1650. ASSERT(pfnHandler);
  1651. //
  1652. // Register the interrupt handler.
  1653. //
  1654. IntRegister(INT_LCD0_TM4C129, pfnHandler);
  1655. //
  1656. // Enable the interrupt in the interrupt controller.
  1657. //
  1658. IntEnable(INT_LCD0_TM4C129);
  1659. }
  1660. //*****************************************************************************
  1661. //
  1662. //! Unregisters the interrupt handler for the LCD controller module.
  1663. //!
  1664. //! \param ui32Base specifies the LCD controller module base address.
  1665. //!
  1666. //! This function unregisters the interrupt handler and disables the global LCD
  1667. //! controller interrupt in the interrupt controller.
  1668. //!
  1669. //! \note This function need not be called if the appropriate interrupt vector
  1670. //! is statically linked into the vector table in the application startup code.
  1671. //!
  1672. //! \sa IntRegister() for important information about registering interrupt
  1673. //! handlers.
  1674. //!
  1675. //! \return None.
  1676. //
  1677. //*****************************************************************************
  1678. void
  1679. LCDIntUnregister(uint32_t ui32Base)
  1680. {
  1681. //
  1682. // Check the arguments.
  1683. //
  1684. ASSERT(ui32Base == LCD0_BASE);
  1685. //
  1686. // Disable the interrupt in the interrupt controller.
  1687. //
  1688. IntDisable(INT_LCD0_TM4C129);
  1689. //
  1690. // Unregister the interrupt handler.
  1691. //
  1692. IntUnregister(INT_LCD0_TM4C129);
  1693. }
  1694. //*****************************************************************************
  1695. //
  1696. // Close the Doxygen group.
  1697. //! @}
  1698. //
  1699. //*****************************************************************************