epi.c 80 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187
  1. //*****************************************************************************
  2. //
  3. // epi.c - Driver for the EPI module.
  4. //
  5. // Copyright (c) 2008-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. #include <stdbool.h>
  40. #include <stdint.h>
  41. #include "inc/hw_epi.h"
  42. #include "inc/hw_ints.h"
  43. #include "inc/hw_memmap.h"
  44. #include "inc/hw_sysctl.h"
  45. #include "inc/hw_types.h"
  46. #include "driverlib/debug.h"
  47. #include "driverlib/epi.h"
  48. #include "driverlib/interrupt.h"
  49. //*****************************************************************************
  50. //
  51. //! \addtogroup epi_api
  52. //! @{
  53. //
  54. //*****************************************************************************
  55. //*****************************************************************************
  56. //
  57. // Helper masks for chip select configuration options.
  58. //
  59. //*****************************************************************************
  60. #define EPI_HB8_CS_MASK (EPI_HB8_MODE_FIFO | EPI_HB8_RDWAIT_3 | \
  61. EPI_HB8_WRWAIT_3 | EPI_HB8_RDHIGH | \
  62. EPI_HB8_WRHIGH | EPI_HB8_ALE_HIGH)
  63. #define EPI_HB16_CS_MASK (EPI_HB8_CS_MASK | EPI_HB16_BURST_TRAFFIC)
  64. //*****************************************************************************
  65. //
  66. // Ensure that erratum workaround inline functions have a public version
  67. // available in exactly one object module (this one).
  68. //
  69. //*****************************************************************************
  70. //*****************************************************************************
  71. //
  72. //! Safely writes a word to the EPI 0x10000000 address space.
  73. //!
  74. //! \param pui32Addr is the address which is to be written.
  75. //! \param ui32Value is the 32-bit word to write.
  76. //!
  77. //! This function must be used when writing words to EPI-attached memory
  78. //! configured to use the address space at 0x10000000 on devices affected by
  79. //! the EPI#01 erratum. Direct access to memory in these cases can cause data
  80. //! corruption depending upon memory accesses immediately before or after the
  81. //! EPI access but using this function will allow EPI accesses to complete
  82. //! correctly. The function is defined as ``inline'' in epi.h.
  83. //!
  84. //! Use of this function on a device not affected by the erratum is safe but
  85. //! will impact performance due to an additional overhead of at least 2 cycles
  86. //! per access. This erratum affects only the 0x10000000 address space
  87. //! typically used to store the LCD controller frame buffer. The 0x60000000
  88. //! address space is not affected and applications using this address mapping
  89. //! need not use this function.
  90. //!
  91. //! \return None.
  92. //
  93. //*****************************************************************************
  94. extern void EPIWorkaroundWordWrite(uint32_t *pui32Addr, uint32_t ui32Value);
  95. //*****************************************************************************
  96. //
  97. //! Safely reads a word from the EPI 0x10000000 address space.
  98. //!
  99. //! \param pui32Addr is the address which is to be read.
  100. //!
  101. //! This function must be used when reading words from EPI-attached memory
  102. //! configured to use the address space at 0x10000000 on devices affected by
  103. //! the EPI#01 erratum. Direct access to memory in these cases can cause data
  104. //! corruption depending upon memory accesses immediately before or after the
  105. //! EPI access but using this function will allow EPI accesses to complete
  106. //! correctly. The function is defined as ``inline'' in epi.h.
  107. //!
  108. //! Use of this function on a device not affected by the erratum is safe but
  109. //! will impact performance due to an additional overhead of at least 2 cycles
  110. //! per access. This erratum affects only the 0x10000000 address space
  111. //! typically used to store the LCD controller frame buffer. The 0x60000000
  112. //! address space is not affected and applications using this address mapping
  113. //! need not use this function.
  114. //!
  115. //! \return The 32-bit word stored at address \e pui32Addr.
  116. //
  117. //*****************************************************************************
  118. extern uint32_t EPIWorkaroundWordRead(uint32_t *pui32Addr);
  119. //*****************************************************************************
  120. //
  121. //! Safely writes a half-word to the EPI 0x10000000 address space.
  122. //!
  123. //! \param pui16Addr is the address which is to be written.
  124. //! \param ui16Value is the 16-bit half-word to write.
  125. //!
  126. //! This function must be used when writing half-words to EPI-attached memory
  127. //! configured to use the address space at 0x10000000 on devices affected by
  128. //! the EPI#01 erratum. Direct access to memory in these cases can cause data
  129. //! corruption depending upon memory accesses immediately before or after the
  130. //! EPI access but using this function will allow EPI accesses to complete
  131. //! correctly. The function is defined as ``inline'' in epi.h.
  132. //!
  133. //! Use of this function on a device not affected by the erratum is safe but
  134. //! will impact performance due to an additional overhead of at least 2 cycles
  135. //! per access. This erratum affects only the 0x10000000 address space
  136. //! typically used to store the LCD controller frame buffer. The 0x60000000
  137. //! address space is not affected and applications using this address mapping
  138. //! need not use this function.
  139. //!
  140. //! \return None.
  141. //
  142. //*****************************************************************************
  143. extern void EPIWorkaroundHWordWrite(uint16_t *pui16Addr, uint16_t ui16Value);
  144. //*****************************************************************************
  145. //
  146. //! Safely reads a half-word from the EPI 0x10000000 address space.
  147. //!
  148. //! \param pui16Addr is the address which is to be read.
  149. //!
  150. //! This function must be used when reading half-words from EPI-attached memory
  151. //! configured to use the address space at 0x10000000 on devices affected by
  152. //! the EPI#01 erratum. Direct access to memory in these cases can cause data
  153. //! corruption depending upon memory accesses immediately before or after the
  154. //! EPI access but using this function will allow EPI accesses to complete
  155. //! correctly. The function is defined as ``inline'' in epi.h.
  156. //!
  157. //! Use of this function on a device not affected by the erratum is safe but
  158. //! will impact performance due to an additional overhead of at least 2 cycles
  159. //! per access. This erratum affects only the 0x10000000 address space
  160. //! typically used to store the LCD controller frame buffer. The 0x60000000
  161. //! address space is not affected and applications using this address mapping
  162. //! need not use this function.
  163. //!
  164. //! \return The 16-bit word stored at address \e pui16Addr.
  165. //
  166. //*****************************************************************************
  167. extern uint16_t EPIWorkaroundHWordRead(uint16_t *pui16Addr);
  168. //*****************************************************************************
  169. //
  170. //! Safely writes a byte to the EPI 0x10000000 address space.
  171. //!
  172. //! \param pui8Addr is the address which is to be written.
  173. //! \param ui8Value is the 8-bit byte to write.
  174. //!
  175. //! This function must be used when writing bytes to EPI-attached memory
  176. //! configured to use the address space at 0x10000000 on devices affected by
  177. //! the EPI#01 erratum. Direct access to memory in these cases can cause data
  178. //! corruption depending upon memory accesses immediately before or after the
  179. //! EPI access but using this function will allow EPI accesses to complete
  180. //! correctly. The function is defined as ``inline'' in epi.h.
  181. //!
  182. //! Use of this function on a device not affected by the erratum is safe but
  183. //! will impact performance due to an additional overhead of at least 2 cycles
  184. //! per access. This erratum affects only the 0x10000000 address space
  185. //! typically used to store the LCD controller frame buffer. The 0x60000000
  186. //! address space is not affected and applications using this address mapping
  187. //! need not use this function.
  188. //!
  189. //! \return None.
  190. //
  191. //*****************************************************************************
  192. extern void EPIWorkaroundByteWrite(uint8_t *pui8Addr, uint8_t ui8Value);
  193. //*****************************************************************************
  194. //
  195. //! Safely reads a byte from the EPI 0x10000000 address space.
  196. //!
  197. //! \param pui8Addr is the address which is to be read.
  198. //!
  199. //! This function must be used when reading bytes from EPI-attached memory
  200. //! configured to use the address space at 0x10000000 on devices affected by
  201. //! the EPI#01 erratum. Direct access to memory in these cases can cause data
  202. //! corruption depending upon memory accesses immediately before or after the
  203. //! EPI access but using this function will allow EPI accesses to complete
  204. //! correctly. The function is defined as ``inline'' in epi.h.
  205. //!
  206. //! Use of this function on a device not affected by the erratum is safe but
  207. //! will impact performance due to an additional overhead of at least 2 cycles
  208. //! per access. This erratum affects only the 0x10000000 address space
  209. //! typically used to store the LCD controller frame buffer. The 0x60000000
  210. //! address space is not affected and applications using this address mapping
  211. //! need not use this function.
  212. //!
  213. //! \return The 8-bit byte stored at address \e pui8Addr.
  214. //
  215. //*****************************************************************************
  216. extern uint8_t EPIWorkaroundByteRead(uint8_t *pui8Addr);
  217. //*****************************************************************************
  218. //
  219. //! Sets the usage mode of the EPI module.
  220. //!
  221. //! \param ui32Base is the EPI module base address.
  222. //! \param ui32Mode is the usage mode of the EPI module.
  223. //!
  224. //! This functions sets the operating mode of the EPI module. The parameter
  225. //! \e ui32Mode must be one of the following:
  226. //!
  227. //! - \b EPI_MODE_GENERAL - use for general-purpose mode operation
  228. //! - \b EPI_MODE_SDRAM - use with SDRAM device
  229. //! - \b EPI_MODE_HB8 - use with host-bus 8-bit interface
  230. //! - \b EPI_MODE_HB16 - use with host-bus 16-bit interface
  231. //! - \b EPI_MODE_DISABLE - disable the EPI module
  232. //!
  233. //! Selection of any of the above modes enables the EPI module, except
  234. //! for \b EPI_MODE_DISABLE, which is used to disable the module.
  235. //!
  236. //! \return None.
  237. //
  238. //*****************************************************************************
  239. void
  240. EPIModeSet(uint32_t ui32Base, uint32_t ui32Mode)
  241. {
  242. //
  243. // Check the arguments.
  244. //
  245. ASSERT(ui32Base == EPI0_BASE);
  246. ASSERT((ui32Mode == EPI_MODE_GENERAL) ||
  247. (ui32Mode == EPI_MODE_SDRAM) ||
  248. (ui32Mode == EPI_MODE_HB8) ||
  249. (ui32Mode == EPI_MODE_HB16) ||
  250. (ui32Mode == EPI_MODE_DISABLE));
  251. //
  252. // Write the mode word to the register.
  253. //
  254. HWREG(ui32Base + EPI_O_CFG) = ui32Mode;
  255. }
  256. //*****************************************************************************
  257. //
  258. //! Sets the clock divider for the EPI module's CS0n/CS1n.
  259. //!
  260. //! \param ui32Base is the EPI module base address.
  261. //! \param ui32Divider is the value of the clock divider to be applied to
  262. //! the external interface (0-65535).
  263. //!
  264. //! This function sets the clock divider(s) that is used to determine the
  265. //! clock rate of the external interface. The \e ui32Divider value is used to
  266. //! derive the EPI clock rate from the system clock based on the following
  267. //! formula.
  268. //!
  269. //! EPIClk = (Divider == 0) ? SysClk : (SysClk / (((Divider / 2) + 1) * 2))
  270. //!
  271. //! For example, a divider value of 1 results in an EPI clock rate of half
  272. //! the system clock, value of 2 or 3 yields one quarter of the system clock
  273. //! and a value of 4 results in one sixth of the system clock rate.
  274. //!
  275. //! In cases where a dual chip select mode is in use and different clock rates
  276. //! are required for each chip select, the \e ui32Divider parameter must
  277. //! contain two dividers. The lower 16 bits define the divider to be used with
  278. //! CS0n and the upper 16 bits define the divider for CS1n.
  279. //!
  280. //! \return None.
  281. //
  282. //*****************************************************************************
  283. void
  284. EPIDividerSet(uint32_t ui32Base, uint32_t ui32Divider)
  285. {
  286. //
  287. // Check the arguments.
  288. //
  289. ASSERT(ui32Base == EPI0_BASE);
  290. //
  291. // Write the divider value to the register.
  292. //
  293. HWREG(ui32Base + EPI_O_BAUD) = ui32Divider;
  294. }
  295. //*****************************************************************************
  296. //
  297. //! Sets the clock divider for the specified CS in the EPI module.
  298. //!
  299. //! \param ui32Base is the EPI module base address.
  300. //! \param ui32CS is the chip select to modify and has a valid range of 0-3.
  301. //! \param ui32Divider is the value of the clock divider to be applied to
  302. //! the external interface (0-65535).
  303. //!
  304. //! This function sets the clock divider(s) for the specified CS that is used
  305. //! to determine the clock rate of the external interface. The \e ui32Divider
  306. //! value is used to derive the EPI clock rate from the system clock based on
  307. //! the following formula.
  308. //!
  309. //! EPIClk = (Divider == 0) ? SysClk : (SysClk / (((Divider / 2) + 1) * 2))
  310. //!
  311. //! For example, a divider value of 1 results in an EPI clock rate of half
  312. //! the system clock, value of 2 or 3 yields one quarter of the system clock
  313. //! and a value of 4 results in one sixth of the system clock rate.
  314. //!
  315. //! \note The availability of CS2n and CS3n varies based on the Tiva part
  316. //! in use. Please consult the data sheet to determine if this feature is
  317. //! available.
  318. //!
  319. //! \return None.
  320. //
  321. //*****************************************************************************
  322. void
  323. EPIDividerCSSet(uint32_t ui32Base, uint32_t ui32CS,
  324. uint32_t ui32Divider)
  325. {
  326. uint32_t ui32Reg;
  327. //
  328. // Check the arguments.
  329. //
  330. ASSERT(ui32Base == EPI0_BASE);
  331. ASSERT(ui32CS < 4);
  332. //
  333. // Write the divider value to the register bitfield.
  334. //
  335. if(ui32CS < 2)
  336. {
  337. ui32Reg = HWREG(ui32Base + EPI_O_BAUD) & ~(0xffff << (16 * ui32CS));
  338. ui32Reg |= ((ui32Divider & 0xffff) << (16 * ui32CS));
  339. HWREG(ui32Base + EPI_O_BAUD) = ui32Reg;
  340. }
  341. else
  342. {
  343. ui32Reg = (HWREG(ui32Base + EPI_O_BAUD2) &
  344. ~(0xffff << (16 * (ui32CS - 2))));
  345. ui32Reg |= ((ui32Divider & 0xffff) << (16 * (ui32CS - 2)));
  346. HWREG(ui32Base + EPI_O_BAUD2) = ui32Reg;
  347. }
  348. }
  349. //*****************************************************************************
  350. //
  351. //! Sets the transfer count for uDMA transmit operations on EPI.
  352. //!
  353. //! \param ui32Base is the EPI module base address.
  354. //! \param ui32Count is the number of units to transmit by uDMA to WRFIFO.
  355. //!
  356. //! This function is used to help configure the EPI uDMA transmit operations.
  357. //! A non-zero transmit count in combination with a FIFO threshold trigger
  358. //! asserts an EPI uDMA transmit.
  359. //!
  360. //! Note that, although the EPI peripheral can handle counts of up to 65535,
  361. //! a single uDMA transfer has a maximum length of 1024 units so \e ui32Count
  362. //! should be set to values less than or equal to 1024.
  363. //!
  364. //! \note The availability of the EPI DMA TX count varies based on the
  365. //! Tiva part in use. Please consult the data sheet to determine if this
  366. //! feature is available.
  367. //!
  368. //! \return None.
  369. //
  370. //*****************************************************************************
  371. void
  372. EPIDMATxCount(uint32_t ui32Base, uint32_t ui32Count)
  373. {
  374. //
  375. // Check the arguments.
  376. //
  377. ASSERT(ui32Base == EPI0_BASE);
  378. ASSERT(ui32Count <= 1024);
  379. //
  380. // Assign the DMA TX count value provided.
  381. //
  382. HWREG(ui32Base + EPI_O_DMATXCNT) = ui32Count & 0xffff;
  383. }
  384. //*****************************************************************************
  385. //
  386. //! Configures the SDRAM mode of operation.
  387. //!
  388. //! \param ui32Base is the EPI module base address.
  389. //! \param ui32Config is the SDRAM interface configuration.
  390. //! \param ui32Refresh is the refresh count in core clocks (0-2047).
  391. //!
  392. //! This function is used to configure the SDRAM interface, when the SDRAM
  393. //! mode is chosen with the function EPIModeSet(). The parameter
  394. //! \e ui32Config is the logical OR of several sets of choices:
  395. //!
  396. //! The processor core frequency must be specified with one of the following:
  397. //!
  398. //! - \b EPI_SDRAM_CORE_FREQ_0_15 defines core clock as 0 MHz < clk <= 15 MHz
  399. //! - \b EPI_SDRAM_CORE_FREQ_15_30 defines core clock as 15 MHz < clk <= 30 MHz
  400. //! - \b EPI_SDRAM_CORE_FREQ_30_50 defines core clock as 30 MHz < clk <= 50 MHz
  401. //! - \b EPI_SDRAM_CORE_FREQ_50_100 defines core clock as 50 MHz < clk <=
  402. //! 100 MHz
  403. //!
  404. //! The low power mode is specified with one of the following:
  405. //!
  406. //! - \b EPI_SDRAM_LOW_POWER enter low power, self-refresh state.
  407. //! - \b EPI_SDRAM_FULL_POWER normal operating state.
  408. //!
  409. //! The SDRAM device size is specified with one of the following:
  410. //!
  411. //! - \b EPI_SDRAM_SIZE_64MBIT size is a 64 Mbit device (8 MB).
  412. //! - \b EPI_SDRAM_SIZE_128MBIT size is a 128 Mbit device (16 MB).
  413. //! - \b EPI_SDRAM_SIZE_256MBIT size is a 256 Mbit device (32 MB).
  414. //! - \b EPI_SDRAM_SIZE_512MBIT size is a 512 Mbit device (64 MB).
  415. //!
  416. //! The parameter \e ui16Refresh sets the refresh counter in units of core
  417. //! clock ticks. It is an 11-bit value with a range of 0 - 2047 counts.
  418. //!
  419. //! \return None.
  420. //
  421. //*****************************************************************************
  422. void
  423. EPIConfigSDRAMSet(uint32_t ui32Base, uint32_t ui32Config,
  424. uint32_t ui32Refresh)
  425. {
  426. //
  427. // Check the arguments.
  428. //
  429. ASSERT(ui32Base == EPI0_BASE);
  430. ASSERT(ui32Refresh < 2048);
  431. //
  432. // Fill in the refresh count field of the configuration word.
  433. //
  434. ui32Config &= ~EPI_SDRAMCFG_RFSH_M;
  435. ui32Config |= ui32Refresh << EPI_SDRAMCFG_RFSH_S;
  436. //
  437. // Write the SDRAM configuration register.
  438. //
  439. HWREG(ui32Base + EPI_O_SDRAMCFG) = ui32Config;
  440. }
  441. //*****************************************************************************
  442. //
  443. //! Configures the interface for Host-bus 8 operation.
  444. //!
  445. //! \param ui32Base is the EPI module base address.
  446. //! \param ui32Config is the interface configuration.
  447. //! \param ui32MaxWait is the maximum number of external clocks to wait
  448. //! if a FIFO ready signal is holding off the transaction, 0-255.
  449. //!
  450. //! This function is used to configure the interface when used in host-bus 8
  451. //! operation as chosen with the function EPIModeSet(). The parameter
  452. //! \e ui32Config is the logical OR of the following:
  453. //!
  454. //! - Host-bus 8 submode, select one of:
  455. //! - \b EPI_HB8_MODE_ADMUX sets data and address muxed, AD[7:0]
  456. //! - \b EPI_HB8_MODE_ADDEMUX sets up data and address separate, D[7:0]
  457. //! - \b EPI_HB8_MODE_SRAM as \b EPI_HB8_MODE_ADDEMUX, but uses address
  458. //! switch for multiple reads instead of OEn strobing, D[7:0]
  459. //! - \b EPI_HB8_MODE_FIFO adds XFIFO with sense of XFIFO full and XFIFO
  460. //! empty, D[7:0]
  461. //!
  462. //! - \b EPI_HB8_USE_TXEMPTY enables TXEMPTY signal with FIFO
  463. //! - \b EPI_HB8_USE_RXFULL enables RXFULL signal with FIFO
  464. //! - \b EPI_HB8_WRHIGH sets active high write strobe, otherwise it is
  465. //! active low
  466. //! - \b EPI_HB8_RDHIGH sets active high read strobe, otherwise it is
  467. //! active low
  468. //!
  469. //! - Write wait state when \b EPI_HB8_BAUD is used, select one of:
  470. //! - \b EPI_HB8_WRWAIT_0 sets write wait state to 2 EPI clocks (default)
  471. //! - \b EPI_HB8_WRWAIT_1 sets write wait state to 4 EPI clocks
  472. //! - \b EPI_HB8_WRWAIT_2 sets write wait state to 6 EPI clocks
  473. //! - \b EPI_HB8_WRWAIT_3 sets write wait state to 8 EPI clocks
  474. //!
  475. //! - Read wait state when \b EPI_HB8_BAUD is used, select one of:
  476. //! - \b EPI_HB8_RDWAIT_0 sets read wait state to 2 EPI clocks (default)
  477. //! - \b EPI_HB8_RDWAIT_1 sets read wait state to 4 EPI clocks
  478. //! - \b EPI_HB8_RDWAIT_2 sets read wait state to 6 EPI clocks
  479. //! - \b EPI_HB8_RDWAIT_3 sets read wait state to 8 EPI clocks
  480. //!
  481. //! - \b EPI_HB8_WORD_ACCESS - use Word Access mode to route bytes to the
  482. //! correct byte lanes allowing data to be stored in bits [31:8]. If absent,
  483. //! all data transfers use bits [7:0].
  484. //!
  485. //! - \b EPI_HB8_CLOCK_GATE_IDLE sets the EPI clock to be held low when no data
  486. //! is available to read or write
  487. //! - \b EPI_HB8_CLOCK_INVERT inverts the EPI clock
  488. //! - \b EPI_HB8_IN_READY_EN sets EPIS032 as a ready/stall signal, active high
  489. //! - \b EPI_HB8_IN_READY_EN_INVERT sets EPIS032 as ready/stall signal, active
  490. //! low
  491. //! - \b EPI_HB8_ALE_HIGH sets the address latch active high (default)
  492. //! - \b EPI_HB8_ALE_LOW sets address latch active low
  493. //! - \b EPI_HB8_CSBAUD use different baud rates when accessing devices on each
  494. //! chip select. CS0n uses the baud rate specified by the lower 16 bits
  495. //! of the divider passed to EPIDividerSet() and CS1n uses the divider passed
  496. //! in the upper 16 bits. If this option is absent, both chip selects use
  497. //! the baud rate resulting from the divider in the lower 16 bits of the
  498. //! parameter passed to EPIDividerSet().
  499. //!
  500. //! In addition, some parts support CS2n and CS3n for a total of 4 chip
  501. //! selects. If \b EPI_HB8_CSBAUD is configured, EPIDividerCSSet() should be
  502. //! used to to configure the divider for CS2n and CS3n. They both also use the
  503. //! lower 16 bits passed to EPIDividerSet() if this option is absent.
  504. //!
  505. //! The use of \b EPI_HB8_CSBAUD also allows for unique chip select
  506. //! configurations. CS0n, CS1n, CS2n, and CS3n can each be configured by
  507. //! calling EPIConfigHB8CSSet() if \b EPI_HB8_CSBAUD is used. Otherwise, the
  508. //! configuration provided in \e ui32Config is used for all chip selects
  509. //! enabled.
  510. //!
  511. //! - Chip select configuration, select one of:
  512. //! - \b EPI_HB8_CSCFG_CS sets EPIS030 to operate as a chip select signal.
  513. //! - \b EPI_HB8_CSCFG_ALE sets EPIS030 to operate as an address latch
  514. //! (ALE).
  515. //! - \b EPI_HB8_CSCFG_DUAL_CS sets EPIS030 to operate as CS0n and EPIS027
  516. //! as CS1n with the asserted chip select determined from the most
  517. //! significant address bit for the respective external address map.
  518. //! - \b EPI_HB8_CSCFG_ALE_DUAL_CS sets EPIS030 as an address latch (ALE),
  519. //! EPIS027 as CS0n and EPIS026 as CS1n with the asserted chip select
  520. //! determined from the most significant address bit for the respective
  521. //! external address map.
  522. //! - \b EPI_HB8_CSCFG_ALE_SINGLE_CS sets EPIS030 to operate as an address
  523. //! latch (ALE) and EPIS027 is used as a chip select.
  524. //! - \b EPI_HB8_CSCFG_QUAD_CS sets EPIS030 as CS0n, EPIS027 as CS1n,
  525. //! EPIS034 as CS2n and EPIS033 as CS3n.
  526. //! - \b EPI_HB8_CSCFG_ALE_QUAD_CS sets EPIS030 as an address latch (ALE),
  527. //! EPIS026 as CS0n, EPIS027 as CS1n, EPIS034 as CS2n and EPIS033 as CS3n.
  528. //! \note Dual or quad chip select configurations cannot be used with
  529. //! EPI_HB8_MODE_SRAM.
  530. //!
  531. //! The parameter \e ui32MaxWait is used if the FIFO mode is chosen. If a
  532. //! FIFO is used aint32_t with RXFULL or TXEMPTY ready signals, then this
  533. //! parameter determines the maximum number of clocks to wait when the
  534. //! transaction is being held off by by the FIFO using one of these ready
  535. //! signals. A value of 0 means to wait forever.
  536. //!
  537. //! \note Availability of configuration options varies based on the Tiva
  538. //! part in use. Please consult the data sheet to determine if the features
  539. //! desired are available.
  540. //!
  541. //! \return None.
  542. //
  543. //*****************************************************************************
  544. void
  545. EPIConfigHB8Set(uint32_t ui32Base, uint32_t ui32Config,
  546. uint32_t ui32MaxWait)
  547. {
  548. //
  549. // Check the arguments.
  550. //
  551. ASSERT(ui32Base == EPI0_BASE);
  552. ASSERT(ui32MaxWait < 256);
  553. //
  554. // Determine the CS and word access modes.
  555. //
  556. HWREG(ui32Base + EPI_O_HB8CFG2) =
  557. ((ui32Config & EPI_HB8_CSBAUD) ? EPI_HB8CFG2_CSBAUD : 0) |
  558. ((ui32Config & EPI_HB8_CSCFG_MASK) << 15);
  559. //
  560. // Fill in the max wait field of the configuration word.
  561. //
  562. ui32Config &= ~EPI_HB8CFG_MAXWAIT_M;
  563. ui32Config |= ui32MaxWait << EPI_HB8CFG_MAXWAIT_S;
  564. //
  565. // Write the main HostBus8 configuration register.
  566. //
  567. HWREG(ui32Base + EPI_O_HB8CFG) = ui32Config;
  568. }
  569. //*****************************************************************************
  570. //
  571. //! Configures the interface for Host-bus 16 operation.
  572. //!
  573. //! \param ui32Base is the EPI module base address.
  574. //! \param ui32Config is the interface configuration.
  575. //! \param ui32MaxWait is the maximum number of external clocks to wait
  576. //! if a FIFO ready signal is holding off the transaction.
  577. //!
  578. //! This function is used to configure the interface when used in Host-bus 16
  579. //! operation as chosen with the function EPIModeSet(). The parameter
  580. //! \e ui32Config is the logical OR of the following:
  581. //! - Host-bus 16 submode, select one of:
  582. //! - \b EPI_HB16_MODE_ADMUX sets data and address muxed, AD[15:0].
  583. //! - \b EPI_HB16_MODE_ADDEMUX sets up data and address as separate,
  584. //! D[15:0].
  585. //! - \b EPI_HB16_MODE_SRAM sets as \b EPI_HB16_MODE_ADDEMUX but uses
  586. //! address switch for multiple reads instead of OEn strobing, D[15:0].
  587. //! - \b EPI_HB16_MODE_FIFO addes XFIFO controls with sense of XFIFO full
  588. //! and XFIFO empty, D[15:0]. This submode uses no address or ALE.
  589. //!
  590. //! - \b EPI_HB16_USE_TXEMPTY enables TXEMPTY signal with FIFO.
  591. //! - \b EPI_HB16_USE_RXFULL enables RXFULL signal with FIFO.
  592. //! - \b EPI_HB16_WRHIGH use active high write strobe, otherwise it is
  593. //! active low.
  594. //! - \b EPI_HB16_RDHIGH use active high read strobe, otherwise it is
  595. //! active low.
  596. //! - Write wait state, select one of:
  597. //! - \b EPI_HB16_WRWAIT_0 sets write wait state to 2 EPI clocks.
  598. //! - \b EPI_HB16_WRWAIT_1 sets write wait state to 4 EPI clocks.
  599. //! - \b EPI_HB16_WRWAIT_2 sets write wait state to 6 EPI clocks.
  600. //! - \b EPI_HB16_WRWAIT_3 sets write wait state to 8 EPI clocks.
  601. //!
  602. //! - Read wait state, select one of:
  603. //! - \b EPI_HB16_RDWAIT_0 sets read wait state to 2 EPI clocks.
  604. //! - \b EPI_HB16_RDWAIT_1 sets read wait state to 4 EPI clocks.
  605. //! - \b EPI_HB16_RDWAIT_2 sets read wait state to 6 EPI clocks.
  606. //! - \b EPI_HB16_RDWAIT_3 sets read wait state to 8 EPI clocks.
  607. //!
  608. //! - \b EPI_HB16_WORD_ACCESS use Word Access mode to route bytes to the
  609. //! correct byte lanes allowing data to be stored in bits [31:16]. If
  610. //! absent, all data transfers use bits [15:0].
  611. //!
  612. //! \note \b EPI_HB16_WORD_ACCESS is not available on all parts. Please
  613. //! consult the data sheet to determine if this feature is available.
  614. //!
  615. //! - \b EPI_HB16_CLOCK_GATE_IDLE holds the EPI clock low when no data is
  616. //! available to read or write.
  617. //! - \b EPI_HB16_CLOCK_INVERT inverts the EPI clock.
  618. //! - \b EPI_HB16_IN_READY_EN sets EPIS032 as a ready/stall signal, active
  619. //! high.
  620. //! - \b EPI_HB16_IN_READY_EN_INVERTED sets EPIS032 as ready/stall signal,
  621. //! active low.
  622. //! - Address latch logic, select one of:
  623. //! - \b EPI_HB16_ALE_HIGH sets the address latch active high (default).
  624. //! - \b EPI_HB16_ALE_LOW sets address latch active low.
  625. //!
  626. //! - \b EPI_HB16_BURST_TRAFFIC enables burst traffic. Only valid with
  627. //! \b EPI_HB16_MODE_ADMUX and a chip select configuration that utilizes an
  628. //! ALE.
  629. //! - \b EPI_HB16_BSEL enables byte selects. In this mode, two EPI signals
  630. //! operate as byte selects allowing 8-bit transfers. If this flag is not
  631. //! specified, data must be read and written using only 16-bit transfers.
  632. //! - \b EPI_HB16_CSBAUD use different baud rates when accessing devices
  633. //! on each chip select. CS0n uses the baud rate specified by the lower 16
  634. //! bits of the divider passed to EPIDividerSet() and CS1n uses the divider
  635. //! passed in the upper 16 bits. If this option is absent, both chip selects
  636. //! use the baud rate resulting from the divider in the lower 16 bits of the
  637. //! parameter passed to EPIDividerSet().
  638. //!
  639. //! In addition, some parts support CS2n and CS3n for a total of 4 chip
  640. //! selects. If \b EPI_HB16_CSBAUD is configured, EPIDividerCSSet() should be
  641. //! used to to configure the divider for CS2n and CS3n. They both also use the
  642. //! lower 16 bits passed to EPIDividerSet() if this option is absent.
  643. //!
  644. //! The use of \b EPI_HB16_CSBAUD also allows for unique chip select
  645. //! configurations. CS0n, CS1n, CS2n, and CS3n can each be configured by
  646. //! calling EPIConfigHB16CSSet() if \b EPI_HB16_CSBAUD is used. Otherwise, the
  647. //! configuration provided in \e ui32Config is used for all chip selects.
  648. //!
  649. //! - Chip select configuration, select one of:
  650. //! - \b EPI_HB16_CSCFG_CS sets EPIS030 to operate as a chip select signal.
  651. //! - \b EPI_HB16_CSCFG_ALE sets EPIS030 to operate as an address latch
  652. //! (ALE).
  653. //! - \b EPI_HB16_CSCFG_DUAL_CS sets EPIS030 to operate as CS0n and EPIS027
  654. //! as CS1n with the asserted chip select determined from the most
  655. //! significant address bit for the respective external address map.
  656. //! - \b EPI_HB16_CSCFG_ALE_DUAL_CS sets EPIS030 as an address latch (ALE),
  657. //! EPIS027 as CS0n and EPIS026 as CS1n with the asserted chip select
  658. //! determined from the most significant address bit for the respective
  659. //! external address map.
  660. //! - \b EPI_HB16_CSCFG_ALE_SINGLE_CS sets EPIS030 to operate as an address
  661. //! latch (ALE) and EPIS027 is used as a chip select.
  662. //! - \b EPI_HB16_CSCFG_QUAD_CS sets EPIS030 as CS0n, EPIS027 as CS1n,
  663. //! EPIS034 as CS2n and EPIS033 as CS3n.
  664. //! - \b EPI_HB16_CSCFG_ALE_QUAD_CS sets EPIS030 as an address latch
  665. //! (ALE), EPIS026 as CS0n, EPIS027 as CS1n, EPIS034 as CS2n and EPIS033
  666. //! as CS3n.
  667. //! \note Dual or quad chip select configurations cannot be used with
  668. //! EPI_HB16_MODE_SRAM.
  669. //!
  670. //! The parameter \e ui32MaxWait is used if the FIFO mode is chosen. If a
  671. //! FIFO is used along with RXFULL or TXEMPTY ready signals, then this
  672. //! parameter determines the maximum number of clocks to wait when the
  673. //! transaction is being held off by by the FIFO using one of these ready
  674. //! signals. A value of 0 means to wait forever.
  675. //!
  676. //! \note Availability of configuration options varies based on the Tiva
  677. //! part in use. Please consult the data sheet to determine if the features
  678. //! desired are available.
  679. //!
  680. //! \return None.
  681. //
  682. //*****************************************************************************
  683. void
  684. EPIConfigHB16Set(uint32_t ui32Base, uint32_t ui32Config, uint32_t ui32MaxWait)
  685. {
  686. //
  687. // Check the arguments.
  688. //
  689. ASSERT(ui32Base == EPI0_BASE);
  690. ASSERT(ui32MaxWait < 256);
  691. //
  692. // Determine the CS and word access modes.
  693. //
  694. HWREG(ui32Base + EPI_O_HB16CFG2) =
  695. ((ui32Config & EPI_HB16_CSBAUD) ? EPI_HB16CFG2_CSBAUD : 0) |
  696. ((ui32Config & EPI_HB16_CSCFG_MASK) << 15);
  697. //
  698. // Fill in the max wait field of the configuration word.
  699. //
  700. ui32Config &= ~EPI_HB16CFG_MAXWAIT_M;
  701. ui32Config |= ui32MaxWait << EPI_HB16CFG_MAXWAIT_S;
  702. //
  703. // Write the main HostBus16 configuration register.
  704. //
  705. HWREG(ui32Base + EPI_O_HB16CFG) = ui32Config;
  706. }
  707. //*****************************************************************************
  708. //
  709. //! Sets the individual chip select configuration for the Host-bus 8 interface.
  710. //!
  711. //! \param ui32Base is the EPI module base address.
  712. //! \param ui32CS is the chip select value to configure.
  713. //! \param ui32Config is the configuration settings.
  714. //!
  715. //! This function is used to configure individual chip select settings for the
  716. //! Host-bus 8 interface mode. EPIConfigHB8Set() must have been setup with
  717. //! the \b EPI_HB8_CSBAUD flag for the individual chip select configuration
  718. //! option to be available.
  719. //!
  720. //! The \e ui32Base parameter is the base address for the EPI hardware module.
  721. //! The \e ui32CS parameter specifies the chip select to configure and has a
  722. //! valid range of 0-3. The parameter \e ui32Config is the logical OR of the
  723. //! following:
  724. //!
  725. //! - Host-bus 8 submode, select one of:
  726. //! - \b EPI_HB8_MODE_ADMUX sets data and address muxed, AD[7:0].
  727. //! - \b EPI_HB8_MODE_ADDEMUX sets up data and address separate, D[7:0].
  728. //! - \b EPI_HB8_MODE_SRAM as \b EPI_HB8_MODE_ADDEMUX, but uses address
  729. //! switch for multiple reads instead of OEn strobing, D[7:0].
  730. //! - \b EPI_HB8_MODE_FIFO adds XFIFO with sense of XFIFO full and XFIFO
  731. //! empty, D[7:0]. This is only available for CS0n and CS1n.
  732. //!
  733. //! - \b EPI_HB8_WRHIGH sets active high write strobe, otherwise it is
  734. //! active low.
  735. //! - \b EPI_HB8_RDHIGH sets active high read strobe, otherwise it is
  736. //! active low.
  737. //! - Write wait state when \b EPI_HB8_BAUD is used, select one of:
  738. //! - \b EPI_HB8_WRWAIT_0 sets write wait state to 2 EPI clocks (default).
  739. //! - \b EPI_HB8_WRWAIT_1 sets write wait state to 4 EPI clocks.
  740. //! - \b EPI_HB8_WRWAIT_2 sets write wait state to 6 EPI clocks.
  741. //! - \b EPI_HB8_WRWAIT_3 sets write wait state to 8 EPI clocks.
  742. //! - Read wait state when \b EPI_HB8_BAUD is used, select one of:
  743. //! - \b EPI_HB8_RDWAIT_0 sets read wait state to 2 EPI clocks (default).
  744. //! - \b EPI_HB8_RDWAIT_1 sets read wait state to 4 EPI clocks.
  745. //! - \b EPI_HB8_RDWAIT_2 sets read wait state to 6 EPI clocks.
  746. //! - \b EPI_HB8_RDWAIT_3 sets read wait state to 8 EPI clocks.
  747. //! - \b EPI_HB8_ALE_HIGH sets the address latch active high (default).
  748. //! - \b EPI_HB8_ALE_LOW sets address latch active low.
  749. //!
  750. //! \note The availability of a unique chip select configuration within
  751. //! Host-bus 8 interface mode varies based on the Tiva part in use.
  752. //! Please consult the data sheet to determine if this feature is available.
  753. //!
  754. //! \return None.
  755. //
  756. //*****************************************************************************
  757. void
  758. EPIConfigHB8CSSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Config)
  759. {
  760. uint32_t ui32Offset, ui32Reg;
  761. //
  762. // Check the arguments.
  763. //
  764. ASSERT(ui32Base == EPI0_BASE);
  765. ASSERT(ui32CS < 4);
  766. //
  767. // Determine the register offset based on the ui32CS provided.
  768. //
  769. if(ui32CS < 2)
  770. {
  771. ui32Offset = EPI_O_HB8CFG + (ui32CS << 2);
  772. }
  773. else
  774. {
  775. ui32Offset = EPI_O_HB8CFG3 + ((ui32CS - 2) << 2);
  776. }
  777. //
  778. // Preserve the bits that will not be modified.
  779. //
  780. ui32Reg = HWREG(ui32Base + ui32Offset) & ~EPI_HB8_CS_MASK;
  781. //
  782. // Write the target chip select HostBus8 configuration fields.
  783. //
  784. HWREG(ui32Base + ui32Offset) = (ui32Reg | ui32Config);
  785. }
  786. //*****************************************************************************
  787. //
  788. //! Sets the individual chip select configuration for the Host-bus 16
  789. //! interface.
  790. //!
  791. //! \param ui32Base is the EPI module base address.
  792. //! \param ui32CS is the chip select value to configure.
  793. //! \param ui32Config is the configuration settings.
  794. //!
  795. //! This function is used to configure individual chip select settings for the
  796. //! Host-bus 16 interface mode. EPIConfigHB16Set() must have been set up with
  797. //! the \b EPI_HB16_CSBAUD flag for the individual chip select configuration
  798. //! option to be available.
  799. //!
  800. //! The \e ui32Base parameter is the base address for the EPI hardware module.
  801. //! The \e ui32CS parameter specifies the chip select to configure and has a
  802. //! valid range of 0-3. The parameter \e ui32Config is the logical OR the
  803. //! following:
  804. //!
  805. //! - Host-bus 16 submode, select one of:
  806. //! - \b EPI_HB16_MODE_ADMUX sets data and address muxed, AD[15:0].
  807. //! - \b EPI_HB16_MODE_ADDEMUX sets up data and address separate, D[15:0].
  808. //! - \b EPI_HB16_MODE_SRAM same as \b EPI_HB8_MODE_ADDEMUX, but uses
  809. //! address switch for multiple reads instead of OEn strobing, D[15:0].
  810. //! - \b EPI_HB16_MODE_FIFO adds XFIFO with sense of XFIFO full and XFIFO
  811. //! empty, D[15:0]. This feature is only available on CS0n and CS1n.
  812. //! - \b EPI_HB16_WRHIGH sets active high write strobe, otherwise it is
  813. //! active low.
  814. //! - \b EPI_HB16_RDHIGH sets active high read strobe, otherwise it is
  815. //! active low.
  816. //! - Write wait state when \b EPI_HB16_BAUD is used, select one of:
  817. //! - \b EPI_HB16_WRWAIT_0 sets write wait state to 2 EPI clocks (default).
  818. //! - \b EPI_HB16_WRWAIT_1 sets write wait state to 4 EPI clocks.
  819. //! - \b EPI_HB16_WRWAIT_2 sets write wait state to 6 EPI clocks.
  820. //! - \b EPI_HB16_WRWAIT_3 sets write wait state to 8 EPI clocks.
  821. //! - Read wait state when \b EPI_HB16_BAUD is used, select one of:
  822. //! - \b EPI_HB16_RDWAIT_0 sets read wait state to 2 EPI clocks (default).
  823. //! - \b EPI_HB16_RDWAIT_1 sets read wait state to 4 EPI clocks.
  824. //! - \b EPI_HB16_RDWAIT_2 sets read wait state to 6 EPI clocks.
  825. //! - \b EPI_HB16_RDWAIT_3 sets read wait state to 8 EPI clocks.
  826. //! - \b EPI_HB16_ALE_HIGH sets the address latch active high (default).
  827. //! - \b EPI_HB16_ALE_LOW sets address latch active low.
  828. //! - \b EPI_HB16_BURST_TRAFFIC enables burst traffic. Only valid with
  829. //! \b EPI_HB16_MODE_ADMUX and a chip select configuration that utilizes an
  830. //! ALE.
  831. //!
  832. //! \note The availability of the unique chip select configuration within the
  833. //! Host-bus 16 interface mode varies based on the Tiva part in use.
  834. //! Please consult the data sheet to determine if this feature is available.
  835. //!
  836. //! \return None.
  837. //
  838. //*****************************************************************************
  839. void
  840. EPIConfigHB16CSSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Config)
  841. {
  842. uint32_t ui32Offset, ui32Reg;
  843. //
  844. // Check the arguments.
  845. //
  846. ASSERT(ui32Base == EPI0_BASE);
  847. ASSERT(ui32CS < 4);
  848. //
  849. // Determine the register offset based on the ui32CS provided.
  850. //
  851. if(ui32CS < 2)
  852. {
  853. ui32Offset = EPI_O_HB16CFG + (ui32CS << 2);
  854. }
  855. else
  856. {
  857. ui32Offset = EPI_O_HB16CFG3 + ((ui32CS - 2) << 2);
  858. }
  859. //
  860. // Preserve the bits that will not be modified.
  861. //
  862. ui32Reg = HWREG(ui32Base + ui32Offset) & ~EPI_HB16_CS_MASK;
  863. //
  864. // Write the target chip select HostBus16 configuration fields.
  865. //
  866. HWREG(ui32Base + ui32Offset) = (ui32Reg | ui32Config);
  867. }
  868. //*****************************************************************************
  869. //
  870. //! Sets the individual chip select timing settings for the Host-bus 8
  871. //! interface.
  872. //!
  873. //! \param ui32Base is the EPI module base address.
  874. //! \param ui32CS is the chip select value to configure.
  875. //! \param ui32Config is the configuration settings.
  876. //!
  877. //! This function is used to set individual chip select timings for the
  878. //! Host-bus 8 interface mode.
  879. //!
  880. //! The \e ui32Base parameter is the base address for the EPI hardware module.
  881. //! The \e ui32CS parameter specifies the chip select to configure and has a
  882. //! valid range of 0-3. The parameter \e ui32Config is the logical OR of the
  883. //! following:
  884. //!
  885. //! - Input ready stall delay, select one of:
  886. //! - \b EPI_HB8_IN_READY_DELAY_1 sets the stall on input ready (EPIS032)
  887. //! to start 1 EPI clock after signaled.
  888. //! - \b EPI_HB8_IN_READY_DELAY_2 sets the stall on input ready (EPIS032)
  889. //! to start 2 EPI clocks after signaled.
  890. //! - \b EPI_HB8_IN_READY_DELAY_3 sets the stall on input ready (EPIS032)
  891. //! to start 3 EPI clocks after signaled.
  892. //!
  893. //! - Host bus transfer delay, select one of:
  894. //! - \b EPI_HB8_CAP_WIDTH_1 defines the inter-transfer capture width to
  895. //! create a delay of 1 EPI clock.
  896. //! - \b EPI_HB8_CAP_WIDTH_2 defines the inter-transfer capture width
  897. //! to create a delay of 2 EPI clocks.
  898. //!
  899. //! - \b EPI_HB8_WRWAIT_MINUS_DISABLE disables the additional write wait state
  900. //! reduction.
  901. //! - \b EPI_HB8_WRWAIT_MINUS_ENABLE enables a 1 EPI clock write wait state
  902. //! reduction.
  903. //! - \b EPI_HB8_RDWAIT_MINUS_DISABLE disables the additional read wait state
  904. //! reduction.
  905. //! - \b EPI_HB8_RDWAIT_MINUS_ENABLE enables a 1 EPI clock read wait state
  906. //!reduction.
  907. //!
  908. //! \note The availability of unique chip select timings within Host-bus 8
  909. //! interface mode varies based on the Tiva part in use. Please consult
  910. //! the data sheet to determine if this feature is available.
  911. //!
  912. //! \return None.
  913. //
  914. //*****************************************************************************
  915. void
  916. EPIConfigHB8TimingSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Config)
  917. {
  918. //
  919. // Check the arguments.
  920. //
  921. ASSERT(ui32Base == EPI0_BASE);
  922. ASSERT(ui32CS < 4);
  923. //
  924. // Write the target chip select HostBus8 timing register.
  925. //
  926. HWREG(ui32Base + (EPI_O_HB8TIME + (ui32CS << 2))) = ui32Config;
  927. }
  928. //*****************************************************************************
  929. //
  930. //! Sets the individual chip select timing settings for the Host-bus 16
  931. //! interface.
  932. //!
  933. //! \param ui32Base is the EPI module base address.
  934. //! \param ui32CS is the chip select value to configure.
  935. //! \param ui32Config is the configuration settings.
  936. //!
  937. //! This function is used to set individual chip select timings for the
  938. //! Host-bus 16 interface mode.
  939. //!
  940. //! The \e ui32Base parameter is the base address for the EPI hardware module.
  941. //! The \e ui32CS parameter specifies the chip select to configure and has a
  942. //! valid range of 0-3. The parameter \e ui32Config is the logical OR of the
  943. //! following:
  944. //!
  945. //! - Input ready stall delay, select one of:
  946. //! - \b EPI_HB16_IN_READY_DELAY_1 sets the stall on input ready (EPIS032)
  947. //! to start 1 EPI clock after signaled.
  948. //! - \b EPI_HB16_IN_READY_DELAY_2 sets the stall on input ready (EPIS032)
  949. //! to start 2 EPI clocks after signaled.
  950. //! - \b EPI_HB16_IN_READY_DELAY_3 sets the stall on input ready (EPIS032)
  951. //! to start 3 EPI clocks after signaled.
  952. //!
  953. //! - PSRAM size limitation, select one of:
  954. //! - \b EPI_HB16_PSRAM_NO_LIMIT defines no row size limitation.
  955. //! - \b EPI_HB16_PSRAM_128 defines the PSRAM row size to 128 bytes.
  956. //! - \b EPI_HB16_PSRAM_256 defines the PSRAM row size to 256 bytes.
  957. //! - \b EPI_HB16_PSRAM_512 defines the PSRAM row size to 512 bytes.
  958. //! - \b EPI_HB16_PSRAM_1024 defines the PSRAM row size to 1024 bytes.
  959. //! - \b EPI_HB16_PSRAM_2048 defines the PSRAM row size to 2048 bytes.
  960. //! - \b EPI_HB16_PSRAM_4096 defines the PSRAM row size to 4096 bytes.
  961. //! - \b EPI_HB16_PSRAM_8192 defines the PSRAM row size to 8192 bytes.
  962. //!
  963. //! - Host bus transfer delay, select one of:
  964. //! - \b EPI_HB16_CAP_WIDTH_1 defines the inter-transfer capture width to
  965. //! create a delay of 1 EPI clock
  966. //! - \b EPI_HB16_CAP_WIDTH_2 defines the inter-transfer capture width
  967. //! to create a delay of 2 EPI clocks.
  968. //!
  969. //! - Write wait state timing reduction, select one of:
  970. //! - \b EPI_HB16_WRWAIT_MINUS_DISABLE disables the additional write wait
  971. //! state reduction.
  972. //! - \b EPI_HB16_WRWAIT_MINUS_ENABLE enables a 1 EPI clock write wait
  973. //! state reduction.
  974. //!
  975. //! - Read wait state timing reduction, select one of:
  976. //! - \b EPI_HB16_RDWAIT_MINUS_DISABLE disables the additional read wait
  977. //! state reduction.
  978. //! - \b EPI_HB16_RDWAIT_MINUS_ENABLE enables a 1 EPI clock read wait state
  979. //! reduction.
  980. //!
  981. //! \note The availability of unique chip select timings within Host-bus 16
  982. //! interface mode varies based on the Tiva part in use. Please consult
  983. //! the data sheet to determine if this feature is available.
  984. //!
  985. //! \return None.
  986. //
  987. //*****************************************************************************
  988. void
  989. EPIConfigHB16TimingSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32Config)
  990. {
  991. //
  992. // Check the arguments.
  993. //
  994. ASSERT(ui32Base == EPI0_BASE);
  995. ASSERT(ui32CS < 4);
  996. //
  997. // Write the target chip select HostBus16 timing register.
  998. //
  999. HWREG(ui32Base + (EPI_O_HB16TIME + (ui32CS << 2))) = ui32Config;
  1000. }
  1001. //*****************************************************************************
  1002. //
  1003. //! Sets the PSRAM configuration register.
  1004. //!
  1005. //! \param ui32Base is the EPI module base address.
  1006. //! \param ui32CS is the chip select target.
  1007. //! \param ui32CR is the PSRAM configuration register value.
  1008. //!
  1009. //! This function sets the PSRAM's configuration register by using the PSRAM
  1010. //! configuration register enable signal. The Host-bus 16 interface mode
  1011. //! should be configured prior to calling this function.
  1012. //!
  1013. //! The \e ui32Base parameter is the base address for the EPI hardware module.
  1014. //! The \e ui32CS parameter specifies the chip select to configure and has a
  1015. //! valid range of 0-3. The parameter \e ui32CR value is determined by
  1016. //! consulting the PSRAM's data sheet.
  1017. //!
  1018. //! \note The availability of PSRAM support varies based on the Tiva part
  1019. //! in use. Please consult the data sheet to determine if this feature is
  1020. //! available.
  1021. //!
  1022. //! \return None.
  1023. //
  1024. //*****************************************************************************
  1025. void
  1026. EPIPSRAMConfigRegSet(uint32_t ui32Base, uint32_t ui32CS, uint32_t ui32CR)
  1027. {
  1028. uint32_t ui32Offset;
  1029. //
  1030. // Check the arguments.
  1031. //
  1032. ASSERT(ui32Base == EPI0_BASE);
  1033. ASSERT(ui32CS < 4);
  1034. //
  1035. // Determine the register offset based on the ui32CS provided.
  1036. //
  1037. if(ui32CS < 2)
  1038. {
  1039. ui32Offset = EPI_O_HB16CFG + (ui32CS << 2);
  1040. }
  1041. else
  1042. {
  1043. ui32Offset = EPI_O_HB16CFG3 + ((ui32CS - 2) << 2);
  1044. }
  1045. //
  1046. // Setup for the PSRAM configuration register write. Only 21 bits are
  1047. // valid on a write.
  1048. //
  1049. HWREG(ui32Base + EPI_O_HBPSRAM) = (ui32CR & 0x1fffff);
  1050. //
  1051. // Set the PSRAM configuration register write enable.
  1052. //
  1053. HWREG(ui32Base + ui32Offset) |= EPI_HB16CFG_WRCRE;
  1054. }
  1055. //*****************************************************************************
  1056. //
  1057. //! Requests a configuration register read from the PSRAM.
  1058. //!
  1059. //! \param ui32Base is the EPI module base address.
  1060. //! \param ui32CS is the chip select target.
  1061. //!
  1062. //! This function requests a read of the PSRAM's configuration register. The
  1063. //! Host-bus 16 interface mode should be configured prior to calling this
  1064. //! function.
  1065. //! The EPIPSRAMConfigRegGet() and EPIPSRAMConfigRegGetNonBlocking() can
  1066. //! be used to retrieve the configuration register value.
  1067. //!
  1068. //! The \e ui32Base parameter is the base address for the EPI hardware module.
  1069. //! The \e ui32CS parameter specifies the chip select to configure and has a
  1070. //! valid range of 0-3.
  1071. //!
  1072. //! \note The availability of PSRAM support varies based on the Tiva part
  1073. //! in use. Please consult the data sheet to determine if this feature is
  1074. //! available.
  1075. //!
  1076. //! \return none.
  1077. //
  1078. //*****************************************************************************
  1079. void
  1080. EPIPSRAMConfigRegRead(uint32_t ui32Base, uint32_t ui32CS)
  1081. {
  1082. uint32_t ui32Offset;
  1083. //
  1084. // Check the arguments.
  1085. //
  1086. ASSERT(ui32Base == EPI0_BASE);
  1087. ASSERT(ui32CS < 4);
  1088. //
  1089. // Determine the register offset based on the ui32CS provided.
  1090. //
  1091. if(ui32CS < 2)
  1092. {
  1093. ui32Offset = EPI_O_HB16CFG + (ui32CS << 2);
  1094. }
  1095. else
  1096. {
  1097. ui32Offset = EPI_O_HB16CFG3 + ((ui32CS - 2) << 2);
  1098. }
  1099. //
  1100. // Set the PSRAM configuration register read enable.
  1101. //
  1102. HWREG(ui32Base + ui32Offset) |= EPI_HB16CFG_RDCRE;
  1103. }
  1104. //*****************************************************************************
  1105. //
  1106. //! Retrieves the contents of the EPI PSRAM configuration register.
  1107. //!
  1108. //! \param ui32Base is the EPI module base address.
  1109. //! \param ui32CS is the chip select target.
  1110. //! \param pui32CR is the provided storage used to hold the register value.
  1111. //!
  1112. //! This function copies the contents of the EPI PSRAM configuration register
  1113. //! to the provided storage if the PSRAM read configuration register enable
  1114. //! is no longer asserted. Otherwise the provided storage is not modified.
  1115. //!
  1116. //! The Host-bus 16 interface mode should be set up and EPIPSRAMConfigRegRead()
  1117. //! should be called prior to calling this function.
  1118. //!
  1119. //! The \e ui32Base parameter is the base address for the EPI hardware module.
  1120. //! The \e ui32CS parameter specifies the chip select to configure and has a
  1121. //! valid range of 0-3. The \e pui32CR parameter is a pointer to provided
  1122. //! storage used to hold the register value.
  1123. //!
  1124. //! \note The availability of PSRAM support varies based on the Tiva part
  1125. //! in use. Please consult the data sheet to determine if this feature is
  1126. //! available.
  1127. //!
  1128. //! \return \b true if the value was copied to the provided storage and
  1129. //! \b false if it was not.
  1130. //
  1131. //*****************************************************************************
  1132. bool
  1133. EPIPSRAMConfigRegGetNonBlocking(uint32_t ui32Base, uint32_t ui32CS,
  1134. uint32_t *pui32CR)
  1135. {
  1136. uint32_t ui32Offset;
  1137. //
  1138. // Check the arguments.
  1139. //
  1140. ASSERT(ui32Base == EPI0_BASE);
  1141. ASSERT(ui32CS < 4);
  1142. //
  1143. // Determine the register offset based on the ui32CS provided.
  1144. //
  1145. if(ui32CS < 2)
  1146. {
  1147. ui32Offset = EPI_O_HB16CFG + (ui32CS << 2);
  1148. }
  1149. else
  1150. {
  1151. ui32Offset = EPI_O_HB16CFG3 + ((ui32CS - 2) << 2);
  1152. }
  1153. //
  1154. // Verify PSRAM read enable is not asserted.
  1155. //
  1156. if(HWREG(ui32Base + ui32Offset) & EPI_HB16CFG_RDCRE)
  1157. {
  1158. return(false);
  1159. }
  1160. //
  1161. // Copy the PSRAM configuration register value to the provided storage.
  1162. // Only the lower 16 bits are valid on a read.
  1163. //
  1164. *pui32CR = HWREG(ui32Base + EPI_O_HBPSRAM) & 0xffff;
  1165. //
  1166. // Notify caller the provided storage holds the EPI PSRAM configuration
  1167. // register contents.
  1168. //
  1169. return(true);
  1170. }
  1171. //*****************************************************************************
  1172. //
  1173. //! Retrieves the contents of the EPI PSRAM configuration register.
  1174. //!
  1175. //! \param ui32Base is the EPI module base address.
  1176. //! \param ui32CS is the chip select target.
  1177. //!
  1178. //! This function retrieves the EPI PSRAM configuration register. The register
  1179. //! is read once the EPI PSRAM configuration register read enable signal is
  1180. //! de-asserted.
  1181. //!
  1182. //! The Host-bus 16 interface mode should be set up and EPIPSRAMConfigRegRead()
  1183. //! should be called prior to calling this function.
  1184. //!
  1185. //! The \e ui32Base parameter is the base address for the EPI hardware module.
  1186. //! The \e ui32CS parameter specifies the chip select to configure and has a
  1187. //! valid range of 0-3.
  1188. //!
  1189. //! \note The availability of PSRAM support varies based on the Tiva part
  1190. //! in use. Please consult the data sheet to determine if this feature is
  1191. //! available.
  1192. //!
  1193. //! \return none.
  1194. //
  1195. //*****************************************************************************
  1196. uint32_t
  1197. EPIPSRAMConfigRegGet(uint32_t ui32Base, uint32_t ui32CS)
  1198. {
  1199. uint32_t ui32Offset;
  1200. //
  1201. // Check the arguments.
  1202. //
  1203. ASSERT(ui32Base == EPI0_BASE);
  1204. ASSERT(ui32CS < 4);
  1205. //
  1206. // Determine the register offset based on the ui32CS provided.
  1207. //
  1208. if(ui32CS < 2)
  1209. {
  1210. ui32Offset = EPI_O_HB16CFG + (ui32CS << 2);
  1211. }
  1212. else
  1213. {
  1214. ui32Offset = EPI_O_HB16CFG3 + ((ui32CS - 2) << 2);
  1215. }
  1216. //
  1217. // Wait for PSRAM read enable to deassert if necessary.
  1218. //
  1219. while(HWREG(ui32Base + ui32Offset) & EPI_HB16CFG_RDCRE)
  1220. {
  1221. }
  1222. //
  1223. // Return the EPI PSRAM configuration register contents.
  1224. // Only the lower 16 bits are valid on a read.
  1225. //
  1226. return(HWREG(ui32Base + EPI_O_HBPSRAM) & 0xffff);
  1227. }
  1228. //*****************************************************************************
  1229. //
  1230. //! Configures the interface for general-purpose mode operation.
  1231. //!
  1232. //! \param ui32Base is the EPI module base address.
  1233. //! \param ui32Config is the interface configuration.
  1234. //! \param ui32FrameCount is the frame size in clocks, if the frame signal
  1235. //! is used (0-15).
  1236. //! \param ui32MaxWait is currently not used.
  1237. //!
  1238. //! This function is used to configure the interface when used in
  1239. //! general-purpose operation as chosen with the function EPIModeSet(). The
  1240. //! parameter \e ui32Config is the logical OR of the following:
  1241. //!
  1242. //! - \b EPI_GPMODE_CLKPIN interface clock as output on a pin.
  1243. //! - \b EPI_GPMODE_CLKGATE clock is stopped when there is no transaction,
  1244. //! otherwise it is free-running.
  1245. //! - \b EPI_GPMODE_FRAME50 framing signal is 50/50 duty cycle, otherwise it
  1246. //! is a pulse.
  1247. //! - \b EPI_GPMODE_WRITE2CYCLE a two-cycle write is used, otherwise a
  1248. //! single-cycle write is used.
  1249. //! - Address bus size, select one of:
  1250. //! - \b EPI_GPMODE_ASIZE_NONE sets no address bus.
  1251. //! - \b EPI_GPMODE_ASIZE_4 sets an address bus size of 4 bits.
  1252. //! - \b EPI_GPMODE_ASIZE_12 sets an address bus size of 12 bits.
  1253. //! - \b EPI_GPMODE_ASIZE_20 sets an address bus size of 20 bits.
  1254. //! - Data bus size, select one of:
  1255. //! - \b EPI_GPMODE_DSIZE_8 sets a data bus size of 8 bits.
  1256. //! - \b EPI_GPMODE_DSIZE_16 sets a data bus size of 16 bits.
  1257. //! - \b EPI_GPMODE_DSIZE_24 sets a data bus size of 24 bits.
  1258. //! - \b EPI_GPMODE_DSIZE_32 sets a data bus size of 32 bits.
  1259. //!
  1260. //! The parameter \e ui32FrameCount is the number of clocks used to form the
  1261. //! framing signal, if the framing signal is used. The behavior depends on
  1262. //! whether the frame signal is a pulse or a 50/50 duty cycle.
  1263. //!
  1264. //!
  1265. //! \return None.
  1266. //
  1267. //*****************************************************************************
  1268. void
  1269. EPIConfigGPModeSet(uint32_t ui32Base, uint32_t ui32Config,
  1270. uint32_t ui32FrameCount, uint32_t ui32MaxWait)
  1271. {
  1272. //
  1273. // Check the arguments.
  1274. //
  1275. ASSERT(ui32Base == EPI0_BASE);
  1276. ASSERT(ui32FrameCount < 16);
  1277. ASSERT(ui32MaxWait < 256);
  1278. //
  1279. // Fill in the frame count field of the configuration word.
  1280. //
  1281. ui32Config &= ~EPI_GPCFG_FRMCNT_M;
  1282. ui32Config |= ui32FrameCount << EPI_GPCFG_FRMCNT_S;
  1283. //
  1284. // Write the non-moded configuration register.
  1285. //
  1286. HWREG(ui32Base + EPI_O_GPCFG) = ui32Config;
  1287. }
  1288. //*****************************************************************************
  1289. //
  1290. //! Configures the address map for the external interface.
  1291. //!
  1292. //! \param ui32Base is the EPI module base address.
  1293. //! \param ui32Map is the address mapping configuration.
  1294. //!
  1295. //! This function is used to configure the address mapping for the external
  1296. //! interface, which then determines the base address of the external memory or
  1297. //! device within the processor peripheral and/or memory space.
  1298. //!
  1299. //! The parameter \e ui32Map is the logical OR of the following:
  1300. //!
  1301. //! - Peripheral address space size, select one of:
  1302. //! - \b EPI_ADDR_PER_SIZE_256B sets the peripheral address space to 256
  1303. //! bytes.
  1304. //! - \b EPI_ADDR_PER_SIZE_64KB sets the peripheral address space to 64
  1305. //! Kbytes.
  1306. //! - \b EPI_ADDR_PER_SIZE_16MB sets the peripheral address space to 16
  1307. //! Mbytes.
  1308. //! - \b EPI_ADDR_PER_SIZE_256MB sets the peripheral address space to 256
  1309. //! Mbytes.
  1310. //! - Peripheral base address, select one of:
  1311. //! - \b EPI_ADDR_PER_BASE_NONE sets the peripheral base address to none.
  1312. //! - \b EPI_ADDR_PER_BASE_A sets the peripheral base address to
  1313. //! 0xA0000000.
  1314. //! - \b EPI_ADDR_PER_BASE_C sets the peripheral base address to
  1315. //! 0xC0000000.
  1316. //! - RAM address space, select one of:
  1317. //! - \b EPI_ADDR_RAM_SIZE_256B sets the RAM address space to 256 bytes.
  1318. //! - \b EPI_ADDR_RAM_SIZE_64KB sets the RAM address space to 64 Kbytes.
  1319. //! - \b EPI_ADDR_RAM_SIZE_16MB sets the RAM address space to 16 Mbytes.
  1320. //! - \b EPI_ADDR_RAM_SIZE_256MB sets the RAM address space to 256 Mbytes.
  1321. //! - RAM base address, select one of:
  1322. //! - \b EPI_ADDR_RAM_BASE_NONE sets the RAM space address to none.
  1323. //! - \b EPI_ADDR_RAM_BASE_6 sets the RAM space address to 0x60000000.
  1324. //! - \b EPI_ADDR_RAM_BASE_8 sets the RAM space address to 0x80000000.
  1325. //! - \b EPI_ADDR_RAM_QUAD_MODE maps CS0n to 0x60000000, CS1n to 0x80000000,
  1326. //! CS2n to 0xA0000000, and CS3n to 0xC0000000.
  1327. //! - \b EPI_ADDR_CODE_SIZE_256B sets an external code size of 256 bytes, range
  1328. //! 0x00 to 0xFF.
  1329. //! - \b EPI_ADDR_CODE_SIZE_64KB sets an external code size of 64 Kbytes, range
  1330. //! 0x0000 to 0xFFFF.
  1331. //! - \b EPI_ADDR_CODE_SIZE_16MB sets an external code size of 16 Mbytes, range
  1332. //! 0x000000 to 0xFFFFFF.
  1333. //! - \b EPI_ADDR_CODE_SIZE_256MB sets an external code size of 256 Mbytes,
  1334. //! range 0x0000000 to 0xFFFFFFF.
  1335. //! - \b EPI_ADDR_CODE_BASE_NONE sets external code base to not mapped.
  1336. //! - \b EPI_ADDR_CODE_BASE_1 sets external code base to 0x10000000.
  1337. //!
  1338. //! \note The availability of \b EPI_ADDR_RAM_QUAD_MODE and \b EPI_ADDR_CODE_*
  1339. //! varies based on the Tiva part in use. Please consult the data sheet
  1340. //! to determine if these features are available.
  1341. //!
  1342. //! \return None.
  1343. //
  1344. //*****************************************************************************
  1345. void
  1346. EPIAddressMapSet(uint32_t ui32Base, uint32_t ui32Map)
  1347. {
  1348. //
  1349. // Check the arguments.
  1350. //
  1351. ASSERT(ui32Base == EPI0_BASE);
  1352. ASSERT(ui32Map < 0x1000);
  1353. //
  1354. // Set the value of the address mapping register.
  1355. //
  1356. HWREG(ui32Base + EPI_O_ADDRMAP) = ui32Map;
  1357. }
  1358. //*****************************************************************************
  1359. //
  1360. //! Configures a non-blocking read transaction.
  1361. //!
  1362. //! \param ui32Base is the EPI module base address.
  1363. //! \param ui32Channel is the read channel (0 or 1).
  1364. //! \param ui32DataSize is the size of the data items to read.
  1365. //! \param ui32Address is the starting address to read.
  1366. //!
  1367. //! This function is used to configure a non-blocking read channel for a
  1368. //! transaction. Two channels are available that can be used in a ping-pong
  1369. //! method for continuous reading. It is not necessary to use both channels
  1370. //! to perform a non-blocking read.
  1371. //!
  1372. //! The parameter \e ui8DataSize is one of \b EPI_NBCONFIG_SIZE_8,
  1373. //! \b EPI_NBCONFIG_SIZE_16, or \b EPI_NBCONFIG_SIZE_32 for 8-bit, 16-bit,
  1374. //! or 32-bit sized data transfers.
  1375. //!
  1376. //! The parameter \e ui32Address is the starting address for the read, relative
  1377. //! to the external device. The start of the device is address 0.
  1378. //!
  1379. //! Once configured, the non-blocking read is started by calling
  1380. //! EPINonBlockingReadStart(). If the addresses to be read from the device
  1381. //! are in a sequence, it is not necessary to call this function multiple
  1382. //! times. Until it is changed, the EPI module stores the last address
  1383. //! that was used for a non-blocking read (per channel).
  1384. //!
  1385. //! \return None.
  1386. //
  1387. //*****************************************************************************
  1388. void
  1389. EPINonBlockingReadConfigure(uint32_t ui32Base, uint32_t ui32Channel,
  1390. uint32_t ui32DataSize, uint32_t ui32Address)
  1391. {
  1392. uint32_t ui32Offset;
  1393. //
  1394. // Check the arguments.
  1395. //
  1396. ASSERT(ui32Base == EPI0_BASE);
  1397. ASSERT(ui32Channel < 2);
  1398. ASSERT(ui32DataSize < 4);
  1399. ASSERT(ui32Address < 0x20000000);
  1400. //
  1401. // Compute the offset needed to select the correct channel regs.
  1402. //
  1403. ui32Offset = ui32Channel * (EPI_O_RSIZE1 - EPI_O_RSIZE0);
  1404. //
  1405. // Write the data size register for the channel.
  1406. //
  1407. HWREG(ui32Base + EPI_O_RSIZE0 + ui32Offset) = ui32DataSize;
  1408. //
  1409. // Write the starting address register for the channel.
  1410. //
  1411. HWREG(ui32Base + EPI_O_RADDR0 + ui32Offset) = ui32Address;
  1412. }
  1413. //*****************************************************************************
  1414. //
  1415. //! Starts a non-blocking read transaction.
  1416. //!
  1417. //! \param ui32Base is the EPI module base address.
  1418. //! \param ui32Channel is the read channel (0 or 1).
  1419. //! \param ui32Count is the number of items to read (1-4095).
  1420. //!
  1421. //! This function starts a non-blocking read that was previously configured
  1422. //! with the function EPINonBlockingReadConfigure(). Once this function is
  1423. //! called, the EPI module begins reading data from the external device
  1424. //! into the read FIFO. The EPI stops reading when the FIFO fills up
  1425. //! and resumes reading when the application drains the FIFO, until the
  1426. //! total specified count of data items has been read.
  1427. //!
  1428. //! Once a read transaction is completed and the FIFO drained, another
  1429. //! transaction can be started from the next address by calling this
  1430. //! function again.
  1431. //!
  1432. //! \return None.
  1433. //
  1434. //*****************************************************************************
  1435. void
  1436. EPINonBlockingReadStart(uint32_t ui32Base, uint32_t ui32Channel,
  1437. uint32_t ui32Count)
  1438. {
  1439. uint32_t ui32Offset;
  1440. //
  1441. // Check the arguments.
  1442. //
  1443. ASSERT(ui32Base == EPI0_BASE);
  1444. ASSERT(ui32Channel < 2);
  1445. ASSERT(ui32Count < 4096);
  1446. //
  1447. // Compute the offset needed to select the correct channel regs.
  1448. //
  1449. ui32Offset = ui32Channel * (EPI_O_RPSTD1 - EPI_O_RPSTD0);
  1450. //
  1451. // Write to the read count register.
  1452. //
  1453. HWREG(ui32Base + EPI_O_RPSTD0 + ui32Offset) = ui32Count;
  1454. }
  1455. //*****************************************************************************
  1456. //
  1457. //! Stops a non-blocking read transaction.
  1458. //!
  1459. //! \param ui32Base is the EPI module base address.
  1460. //! \param ui32Channel is the read channel (0 or 1).
  1461. //!
  1462. //! This function cancels a non-blocking read transaction that is already
  1463. //! in progress.
  1464. //!
  1465. //! \return None.
  1466. //
  1467. //*****************************************************************************
  1468. void
  1469. EPINonBlockingReadStop(uint32_t ui32Base, uint32_t ui32Channel)
  1470. {
  1471. uint32_t ui32Offset;
  1472. //
  1473. // Check the arguments.
  1474. //
  1475. ASSERT(ui32Base == EPI0_BASE);
  1476. ASSERT(ui32Channel < 2);
  1477. //
  1478. // Compute the offset needed to select the correct channel regs.
  1479. //
  1480. ui32Offset = ui32Channel * (EPI_O_RPSTD1 - EPI_O_RPSTD0);
  1481. //
  1482. // Write a 0 to the read count register, which cancels the transaction.
  1483. //
  1484. HWREG(ui32Base + EPI_O_RPSTD0 + ui32Offset) = 0;
  1485. }
  1486. //*****************************************************************************
  1487. //
  1488. //! Get the count remaining for a non-blocking transaction.
  1489. //!
  1490. //! \param ui32Base is the EPI module base address.
  1491. //! \param ui32Channel is the read channel (0 or 1).
  1492. //!
  1493. //! This function gets the remaining count of items for a non-blocking read
  1494. //! transaction.
  1495. //!
  1496. //! \return The number of items remaining in the non-blocking read transaction.
  1497. //
  1498. //*****************************************************************************
  1499. uint32_t
  1500. EPINonBlockingReadCount(uint32_t ui32Base, uint32_t ui32Channel)
  1501. {
  1502. uint32_t ui32Offset;
  1503. //
  1504. // Check the arguments.
  1505. //
  1506. ASSERT(ui32Base == EPI0_BASE);
  1507. ASSERT(ui32Channel < 2);
  1508. //
  1509. // Compute the offset needed to select the correct channel regs.
  1510. //
  1511. ui32Offset = ui32Channel * (EPI_O_RPSTD1 - EPI_O_RPSTD0);
  1512. //
  1513. // Read the count remaining and return the value to the caller.
  1514. //
  1515. return(HWREG(ui32Base + EPI_O_RPSTD0 + ui32Offset));
  1516. }
  1517. //*****************************************************************************
  1518. //
  1519. //! Get the count of items available in the read FIFO.
  1520. //!
  1521. //! \param ui32Base is the EPI module base address.
  1522. //!
  1523. //! This function gets the number of items that are available to read in
  1524. //! the read FIFO. The read FIFO is filled by a non-blocking read transaction
  1525. //! which is configured by the functions EPINonBlockingReadConfigure() and
  1526. //! EPINonBlockingReadStart().
  1527. //!
  1528. //! \return The number of items available to read in the read FIFO.
  1529. //
  1530. //*****************************************************************************
  1531. uint32_t
  1532. EPINonBlockingReadAvail(uint32_t ui32Base)
  1533. {
  1534. //
  1535. // Check the arguments.
  1536. //
  1537. ASSERT(ui32Base == EPI0_BASE);
  1538. //
  1539. // Read the FIFO count and return it to the caller.
  1540. //
  1541. return(HWREG(ui32Base + EPI_O_RFIFOCNT));
  1542. }
  1543. //*****************************************************************************
  1544. //
  1545. //! Read available data from the read FIFO, as 32-bit data items.
  1546. //!
  1547. //! \param ui32Base is the EPI module base address.
  1548. //! \param ui32Count is the maximum count of items to read.
  1549. //! \param pui32Buf is the caller supplied buffer where the read data is
  1550. //! stored.
  1551. //!
  1552. //! This function reads 32-bit data items from the read FIFO and stores
  1553. //! the values in a caller-supplied buffer. The function reads and stores
  1554. //! data from the FIFO until there is no more data in the FIFO or the maximum
  1555. //! count is reached as specified in the parameter \e ui32Count. The actual
  1556. //! count of items is returned.
  1557. //!
  1558. //! \return The number of items read from the FIFO.
  1559. //
  1560. //*****************************************************************************
  1561. uint32_t
  1562. EPINonBlockingReadGet32(uint32_t ui32Base, uint32_t ui32Count,
  1563. uint32_t *pui32Buf)
  1564. {
  1565. uint32_t ui32CountRead = 0;
  1566. //
  1567. // Check the arguments.
  1568. //
  1569. ASSERT(ui32Base == EPI0_BASE);
  1570. ASSERT(ui32Count < 4096);
  1571. ASSERT(pui32Buf);
  1572. //
  1573. // Read from the FIFO while there are any items to read and
  1574. // the caller's specified count is not exceeded.
  1575. //
  1576. while(HWREG(ui32Base + EPI_O_RFIFOCNT) && ui32Count--)
  1577. {
  1578. //
  1579. // Read from the FIFO and store in the caller supplied buffer.
  1580. //
  1581. *pui32Buf = HWREG(ui32Base + EPI_O_READFIFO0);
  1582. //
  1583. // Update the caller's buffer pointer and the count of items read.
  1584. //
  1585. pui32Buf++;
  1586. ui32CountRead++;
  1587. }
  1588. //
  1589. // Return the count of items read to the caller.
  1590. //
  1591. return(ui32CountRead);
  1592. }
  1593. //*****************************************************************************
  1594. //
  1595. //! Read available data from the read FIFO, as 16-bit data items.
  1596. //!
  1597. //! \param ui32Base is the EPI module base address.
  1598. //! \param ui32Count is the maximum count of items to read.
  1599. //! \param pui16Buf is the caller-supplied buffer where the read data is
  1600. //! stored.
  1601. //!
  1602. //! This function reads 16-bit data items from the read FIFO and stores
  1603. //! the values in a caller-supplied buffer. The function reads and stores
  1604. //! data from the FIFO until there is no more data in the FIFO or the maximum
  1605. //! count is reached as specified in the parameter \e ui32Count. The actual
  1606. //! count of items is returned.
  1607. //!
  1608. //! \return The number of items read from the FIFO.
  1609. //
  1610. //*****************************************************************************
  1611. uint32_t
  1612. EPINonBlockingReadGet16(uint32_t ui32Base, uint32_t ui32Count,
  1613. uint16_t *pui16Buf)
  1614. {
  1615. uint32_t ui32CountRead = 0;
  1616. //
  1617. // Check the arguments.
  1618. //
  1619. ASSERT(ui32Base == EPI0_BASE);
  1620. ASSERT(ui32Count < 4096);
  1621. ASSERT(pui16Buf);
  1622. //
  1623. // Read from the FIFO while there are any items to read, and
  1624. // the caller's specified count is not exceeded.
  1625. //
  1626. while(HWREG(ui32Base + EPI_O_RFIFOCNT) && ui32Count--)
  1627. {
  1628. //
  1629. // Read from the FIFO and store in the caller-supplied buffer.
  1630. //
  1631. *pui16Buf = (uint16_t)HWREG(ui32Base + EPI_O_READFIFO0);
  1632. //
  1633. // Update the caller's buffer pointer and the count of items read.
  1634. //
  1635. pui16Buf++;
  1636. ui32CountRead++;
  1637. }
  1638. //
  1639. // Return the count of items read to the caller.
  1640. //
  1641. return(ui32CountRead);
  1642. }
  1643. //*****************************************************************************
  1644. //
  1645. //! Read available data from the read FIFO, as 8-bit data items.
  1646. //!
  1647. //! \param ui32Base is the EPI module base address.
  1648. //! \param ui32Count is the maximum count of items to read.
  1649. //! \param pui8Buf is the caller-supplied buffer where the read data is
  1650. //! stored.
  1651. //!
  1652. //! This function reads 8-bit data items from the read FIFO and stores
  1653. //! the values in a caller-supplied buffer. The function reads and stores
  1654. //! data from the FIFO until there is no more data in the FIFO or the maximum
  1655. //! count is reached as specified in the parameter \e ui32Count. The actual
  1656. //! count of items is returned.
  1657. //!
  1658. //! \return The number of items read from the FIFO.
  1659. //
  1660. //*****************************************************************************
  1661. uint32_t
  1662. EPINonBlockingReadGet8(uint32_t ui32Base, uint32_t ui32Count,
  1663. uint8_t *pui8Buf)
  1664. {
  1665. uint32_t ui32CountRead = 0;
  1666. //
  1667. // Check the arguments.
  1668. //
  1669. ASSERT(ui32Base == EPI0_BASE);
  1670. ASSERT(ui32Count < 4096);
  1671. ASSERT(pui8Buf);
  1672. //
  1673. // Read from the FIFO while there are any items to read, and
  1674. // the caller's specified count is not exceeded.
  1675. //
  1676. while(HWREG(ui32Base + EPI_O_RFIFOCNT) && ui32Count--)
  1677. {
  1678. //
  1679. // Read from the FIFO and store in the caller supplied buffer.
  1680. //
  1681. *pui8Buf = (uint8_t)HWREG(ui32Base + EPI_O_READFIFO0);
  1682. //
  1683. // Update the caller's buffer pointer and the count of items read.
  1684. //
  1685. pui8Buf++;
  1686. ui32CountRead++;
  1687. }
  1688. //
  1689. // Return the count of items read to the caller.
  1690. //
  1691. return(ui32CountRead);
  1692. }
  1693. //*****************************************************************************
  1694. //
  1695. //! Configures the read FIFO.
  1696. //!
  1697. //! \param ui32Base is the EPI module base address.
  1698. //! \param ui32Config is the FIFO configuration.
  1699. //!
  1700. //! This function configures the FIFO trigger levels and error
  1701. //! generation. The parameter \e ui32Config is the logical OR of the
  1702. //! following:
  1703. //!
  1704. //! - \b EPI_FIFO_CONFIG_WTFULLERR enables an error interrupt when a write is
  1705. //! attempted and the write FIFO is full
  1706. //! - \b EPI_FIFO_CONFIG_RSTALLERR enables an error interrupt when a read is
  1707. //! stalled due to an interleaved write or other reason
  1708. //! - FIFO TX trigger level, select one of:
  1709. //! - \b EPI_FIFO_CONFIG_TX_EMPTY sets the FIFO TX trigger level to empty.
  1710. //! - \b EPI_FIFO_CONFIG_TX_1_4 sets the FIFO TX trigger level to 1/4.
  1711. //! - \b EPI_FIFO_CONFIG_TX_1_2 sets the FIFO TX trigger level to 1/2.
  1712. //! - \b EPI_FIFO_CONFIG_TX_3_4 sets the FIFO TX trigger level to 3/4.
  1713. //! - FIFO RX trigger level, select one of:
  1714. //! - \b EPI_FIFO_CONFIG_RX_1_8 sets the FIFO RX trigger level to 1/8.
  1715. //! - \b EPI_FIFO_CONFIG_RX_1_4 sets the FIFO RX trigger level to 1/4.
  1716. //! - \b EPI_FIFO_CONFIG_RX_1_2 sets the FIFO RX trigger level to 1/2.
  1717. //! - \b EPI_FIFO_CONFIG_RX_3_4 sets the FIFO RX trigger level to 3/4.
  1718. //! - \b EPI_FIFO_CONFIG_RX_7_8 sets the FIFO RX trigger level to 7/8.
  1719. //! - \b EPI_FIFO_CONFIG_RX_FULL sets the FIFO RX trigger level to full.
  1720. //!
  1721. //! \return None.
  1722. //
  1723. //*****************************************************************************
  1724. void
  1725. EPIFIFOConfig(uint32_t ui32Base, uint32_t ui32Config)
  1726. {
  1727. //
  1728. // Check the arguments.
  1729. //
  1730. ASSERT(ui32Base == EPI0_BASE);
  1731. ASSERT(ui32Config == (ui32Config & 0x00030077));
  1732. //
  1733. // Load the configuration into the FIFO config reg.
  1734. //
  1735. HWREG(ui32Base + EPI_O_FIFOLVL) = ui32Config;
  1736. }
  1737. //*****************************************************************************
  1738. //
  1739. //! Reads the number of empty slots in the write transaction FIFO.
  1740. //!
  1741. //! \param ui32Base is the EPI module base address.
  1742. //!
  1743. //! This function returns the number of slots available in the transaction
  1744. //! FIFO. It can be used in a polling method to avoid attempting a write
  1745. //! that would stall.
  1746. //!
  1747. //! \return The number of empty slots in the transaction FIFO.
  1748. //
  1749. //*****************************************************************************
  1750. uint32_t
  1751. EPIWriteFIFOCountGet(uint32_t ui32Base)
  1752. {
  1753. //
  1754. // Check the arguments.
  1755. //
  1756. ASSERT(ui32Base == EPI0_BASE);
  1757. //
  1758. // Read the FIFO count and return it to the caller.
  1759. //
  1760. return(HWREG(ui32Base + EPI_O_WFIFOCNT));
  1761. }
  1762. //*****************************************************************************
  1763. //
  1764. //! Enables EPI interrupt sources.
  1765. //!
  1766. //! \param ui32Base is the EPI module base address.
  1767. //! \param ui32IntFlags is a bit mask of the interrupt sources to be enabled.
  1768. //!
  1769. //! This function enables the specified EPI sources to generate interrupts.
  1770. //! The \e ui32IntFlags parameter can be the logical OR of any of the following
  1771. //! values:
  1772. //!
  1773. //! - \b EPI_INT_TXREQ interrupt when transmit FIFO is below the trigger level.
  1774. //! - \b EPI_INT_RXREQ interrupt when read FIFO is above the trigger level.
  1775. //! - \b EPI_INT_ERR interrupt when an error condition occurs.
  1776. //! - \b EPI_INT_DMA_TX_DONE interrupt when the transmit DMA completes.
  1777. //! - \b EPI_INT_DMA_RX_DONE interrupt when the read DMA completes.
  1778. //!
  1779. //! \return Returns None.
  1780. //
  1781. //*****************************************************************************
  1782. void
  1783. EPIIntEnable(uint32_t ui32Base, uint32_t ui32IntFlags)
  1784. {
  1785. //
  1786. // Check the arguments.
  1787. //
  1788. ASSERT(ui32Base == EPI0_BASE);
  1789. ASSERT(ui32IntFlags < 17);
  1790. //
  1791. // Write the interrupt flags mask to the mask register.
  1792. //
  1793. HWREG(ui32Base + EPI_O_IM) |= ui32IntFlags;
  1794. }
  1795. //*****************************************************************************
  1796. //
  1797. //! Disables EPI interrupt sources.
  1798. //!
  1799. //! \param ui32Base is the EPI module base address.
  1800. //! \param ui32IntFlags is a bit mask of the interrupt sources to be disabled.
  1801. //!
  1802. //! This function disables the specified EPI sources for interrupt
  1803. //! generation. The \e ui32IntFlags parameter can be the logical OR of any of
  1804. //! the following values:
  1805. //!
  1806. //! - \b EPI_INT_TXREQ interrupt when transmit FIFO is below the trigger level.
  1807. //! - \b EPI_INT_RXREQ interrupt when read FIFO is above the trigger level.
  1808. //! - \b EPI_INT_ERR interrupt when an error condition occurs.
  1809. //! - \b EPI_INT_DMA_TX_DONE interrupt when the transmit DMA completes.
  1810. //! - \b EPI_INT_DMA_RX_DONE interrupt when the read DMA completes.
  1811. //!
  1812. //! \return Returns None.
  1813. //
  1814. //*****************************************************************************
  1815. void
  1816. EPIIntDisable(uint32_t ui32Base, uint32_t ui32IntFlags)
  1817. {
  1818. //
  1819. // Check the arguments.
  1820. //
  1821. ASSERT(ui32Base == EPI0_BASE);
  1822. ASSERT(ui32IntFlags < 17);
  1823. //
  1824. // Write the interrupt flags mask to the mask register.
  1825. //
  1826. HWREG(ui32Base + EPI_O_IM) &= ~ui32IntFlags;
  1827. }
  1828. //*****************************************************************************
  1829. //
  1830. //! Gets the EPI interrupt status.
  1831. //!
  1832. //! \param ui32Base is the EPI module base address.
  1833. //! \param bMasked is set \b true to get the masked interrupt status, or
  1834. //! \b false to get the raw interrupt status.
  1835. //!
  1836. //! This function returns the EPI interrupt status. It can return either
  1837. //! the raw or masked interrupt status.
  1838. //!
  1839. //! \return Returns the masked or raw EPI interrupt status, as a bit field
  1840. //! of any of the following values:
  1841. //!
  1842. //! - \b EPI_INT_TXREQ interrupt when transmit FIFO is below the trigger level.
  1843. //! - \b EPI_INT_RXREQ interrupt when read FIFO is above the trigger level.
  1844. //! - \b EPI_INT_ERR interrupt when an error condition occurs.
  1845. //! - \b EPI_INT_DMA_TX_DONE interrupt when the transmit DMA completes.
  1846. //! - \b EPI_INT_DMA_RX_DONE interrupt when the read DMA completes.
  1847. //
  1848. //*****************************************************************************
  1849. uint32_t
  1850. EPIIntStatus(uint32_t ui32Base, bool bMasked)
  1851. {
  1852. //
  1853. // Check the arguments.
  1854. //
  1855. ASSERT(ui32Base == EPI0_BASE);
  1856. //
  1857. // Return either the interrupt status or the raw interrupt status as
  1858. // requested.
  1859. //
  1860. if(bMasked)
  1861. {
  1862. return(HWREG(ui32Base + EPI_O_MIS));
  1863. }
  1864. else
  1865. {
  1866. return(HWREG(ui32Base + EPI_O_RIS));
  1867. }
  1868. }
  1869. //*****************************************************************************
  1870. //
  1871. //! Gets the EPI error interrupt status.
  1872. //!
  1873. //! \param ui32Base is the EPI module base address.
  1874. //!
  1875. //! This function returns the error status of the EPI. If the return value of
  1876. //! the function EPIIntStatus() has the flag \b EPI_INT_ERR set, then this
  1877. //! function can be used to determine the cause of the error.
  1878. //!
  1879. //! \return Returns a bit mask of error flags, which can be the logical
  1880. //! OR of any of the following:
  1881. //!
  1882. //! - \b EPI_INT_ERR_WTFULL occurs when a write stalled when the transaction
  1883. //! FIFO was full
  1884. //! - \b EPI_INT_ERR_RSTALL occurs when a read stalled
  1885. //! - \b EPI_INT_ERR_TIMEOUT occurs when the external clock enable held
  1886. //! off a transaction longer than the configured maximum wait time
  1887. //
  1888. //*****************************************************************************
  1889. uint32_t
  1890. EPIIntErrorStatus(uint32_t ui32Base)
  1891. {
  1892. //
  1893. // Check the arguments.
  1894. //
  1895. ASSERT(ui32Base == EPI0_BASE);
  1896. //
  1897. // Read the error status and return to caller.
  1898. //
  1899. return(HWREG(ui32Base + EPI_O_EISC));
  1900. }
  1901. //*****************************************************************************
  1902. //
  1903. //! Clears pending EPI error sources.
  1904. //!
  1905. //! \param ui32Base is the EPI module base address.
  1906. //! \param ui32ErrFlags is a bit mask of the error sources to be cleared.
  1907. //!
  1908. //! This function clears the specified pending EPI errors. The \e ui32ErrFlags
  1909. //! parameter can be the logical OR of any of the following values:
  1910. //!
  1911. //! - \b EPI_INT_ERR_DMAWRIC clears the EPI_INT_DMA_TX_DONE as an interrupt
  1912. //! source
  1913. //! - \b EPI_INT_ERR_DMARDIC clears the EPI_INT_DMA_RX_DONE as an interrupt
  1914. //! source
  1915. //! - \b EPI_INT_ERR_WTFULL occurs when a write stalled when the transaction
  1916. //! FIFO was full
  1917. //! - \b EPI_INT_ERR_RSTALL occurs when a read stalled
  1918. //! - \b EPI_INT_ERR_TIMEOUT occurs when the external clock enable held
  1919. //! off a transaction longer than the configured maximum wait time
  1920. //!
  1921. //! \return Returns None.
  1922. //
  1923. //*****************************************************************************
  1924. void
  1925. EPIIntErrorClear(uint32_t ui32Base, uint32_t ui32ErrFlags)
  1926. {
  1927. //
  1928. // Check the arguments.
  1929. //
  1930. ASSERT(ui32Base == EPI0_BASE);
  1931. ASSERT(ui32ErrFlags < 0x20);
  1932. //
  1933. // Write the error flags to the register to clear the pending errors.
  1934. //
  1935. HWREG(ui32Base + EPI_O_EISC) = ui32ErrFlags;
  1936. }
  1937. //*****************************************************************************
  1938. //
  1939. //! Returns the interrupt number for a given EPI base address.
  1940. //!
  1941. //! \param ui32Base is the base address of the EPI module.
  1942. //!
  1943. //! This function returns the interrupt number for the EPI module with the base
  1944. //! address passed in the \e ui32Base parameter.
  1945. //!
  1946. //! \return Returns the EPI interrupt number or 0 if the interrupt does not
  1947. //! exist.
  1948. //
  1949. //*****************************************************************************
  1950. static uint32_t
  1951. _EPIIntNumberGet(uint32_t ui32Base)
  1952. {
  1953. uint32_t ui32Int;
  1954. //
  1955. // Check the arguments.
  1956. //
  1957. ASSERT(ui32Base == EPI0_BASE);
  1958. //
  1959. // By default, assume EPI is not supported.
  1960. //
  1961. ui32Int = 0;
  1962. if(CLASS_IS_TM4C129)
  1963. {
  1964. ui32Int = INT_EPI0_TM4C129;
  1965. }
  1966. return(ui32Int);
  1967. }
  1968. //*****************************************************************************
  1969. //
  1970. //! Registers an interrupt handler for the EPI module.
  1971. //!
  1972. //! \param ui32Base is the EPI module base address.
  1973. //! \param pfnHandler is a pointer to the function to be called when the
  1974. //! interrupt is activated.
  1975. //!
  1976. //! This sets and enables the handler to be called when the EPI module
  1977. //! generates an interrupt. Specific EPI interrupts must still be enabled
  1978. //! with the EPIIntEnable() function.
  1979. //!
  1980. //! \sa IntRegister() for important information about registering interrupt
  1981. //! handlers.
  1982. //!
  1983. //! \return None.
  1984. //
  1985. //*****************************************************************************
  1986. void
  1987. EPIIntRegister(uint32_t ui32Base, void (*pfnHandler)(void))
  1988. {
  1989. uint32_t ui32Int;
  1990. //
  1991. // Check the arguments.
  1992. //
  1993. ASSERT(ui32Base == EPI0_BASE);
  1994. ASSERT(pfnHandler);
  1995. //
  1996. // Get the interrupt number for the EPI interface.
  1997. //
  1998. ui32Int = _EPIIntNumberGet(ui32Base);
  1999. ASSERT(ui32Int != 0);
  2000. //
  2001. // Register the interrupt handler.
  2002. //
  2003. IntRegister(ui32Int, pfnHandler);
  2004. //
  2005. // Enable the EPI interface interrupt.
  2006. //
  2007. IntEnable(ui32Int);
  2008. }
  2009. //*****************************************************************************
  2010. //
  2011. //! Removes a registered interrupt handler for the EPI module.
  2012. //!
  2013. //! \param ui32Base is the EPI module base address.
  2014. //!
  2015. //! This function disables and clears the handler to be called when the
  2016. //! EPI interrupt occurs.
  2017. //!
  2018. //! \sa IntRegister() for important information about registering interrupt
  2019. //! handlers.
  2020. //!
  2021. //! \return None.
  2022. //
  2023. //*****************************************************************************
  2024. void
  2025. EPIIntUnregister(uint32_t ui32Base)
  2026. {
  2027. uint32_t ui32Int;
  2028. //
  2029. // Check the arguments.
  2030. //
  2031. ASSERT(ui32Base == EPI0_BASE);
  2032. //
  2033. // Get the interrupt number for the EPI interface.
  2034. //
  2035. ui32Int = _EPIIntNumberGet(ui32Base);
  2036. ASSERT(ui32Int != 0);
  2037. //
  2038. // Disable the EPI interface interrupt.
  2039. //
  2040. IntDisable(ui32Int);
  2041. //
  2042. // Unregister the interrupt handler.
  2043. //
  2044. IntUnregister(ui32Int);
  2045. }
  2046. //*****************************************************************************
  2047. //
  2048. // Close the Doxygen group.
  2049. //! @}
  2050. //
  2051. //*****************************************************************************