epi.c 77 KB

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