epi.c 41 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175
  1. //*****************************************************************************
  2. //
  3. // epi.c - Driver for the EPI module.
  4. //
  5. // Copyright (c) 2008-2011 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Texas Instruments (TI) is supplying this software for use solely and
  9. // exclusively on TI's microcontroller products. The software is owned by
  10. // TI and/or its suppliers, and is protected under applicable copyright
  11. // laws. You may not combine this software with "viral" open-source
  12. // software in order to form a larger program.
  13. //
  14. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  15. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  16. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  18. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  19. // DAMAGES, FOR ANY REASON WHATSOEVER.
  20. //
  21. // This is part of revision 8264 of the Stellaris Peripheral Driver Library.
  22. //
  23. //*****************************************************************************
  24. #include "inc/hw_epi.h"
  25. #include "inc/hw_ints.h"
  26. #include "inc/hw_memmap.h"
  27. #include "inc/hw_types.h"
  28. #include "driverlib/debug.h"
  29. #include "driverlib/epi.h"
  30. #include "driverlib/interrupt.h"
  31. //*****************************************************************************
  32. //
  33. //! \addtogroup epi_api
  34. //! @{
  35. //
  36. //*****************************************************************************
  37. //*****************************************************************************
  38. //
  39. //! Sets the usage mode of the EPI module.
  40. //!
  41. //! \param ulBase is the EPI module base address.
  42. //! \param ulMode is the usage mode of the EPI module.
  43. //!
  44. //! This functions sets the operating mode of the EPI module. The parameter
  45. //! \e ulMode must be one of the following:
  46. //!
  47. //! - \b EPI_MODE_GENERAL - use for general-purpose mode operation
  48. //! - \b EPI_MODE_SDRAM - use with SDRAM device
  49. //! - \b EPI_MODE_HB8 - use with host-bus 8-bit interface
  50. //! - \b EPI_MODE_HB16 - use with host-bus 16-bit interface
  51. //! - \b EPI_MODE_DISABLE - disable the EPI module
  52. //!
  53. //! Selection of any of the above modes enables the EPI module, except
  54. //! for \b EPI_MODE_DISABLE which should be used to disable the module.
  55. //!
  56. //! \return None.
  57. //
  58. //*****************************************************************************
  59. void
  60. EPIModeSet(unsigned long ulBase, unsigned long ulMode)
  61. {
  62. //
  63. // Check the arguments.
  64. //
  65. ASSERT(ulBase == EPI0_BASE);
  66. ASSERT((ulMode == EPI_MODE_GENERAL) ||
  67. (ulMode == EPI_MODE_SDRAM) ||
  68. (ulMode == EPI_MODE_HB8) ||
  69. (ulMode == EPI_MODE_HB16) ||
  70. (ulMode == EPI_MODE_DISABLE));
  71. //
  72. // Write the mode word to the register.
  73. //
  74. HWREG(ulBase + EPI_O_CFG) = ulMode;
  75. }
  76. //*****************************************************************************
  77. //
  78. //! Sets the clock divider for the EPI module.
  79. //!
  80. //! \param ulBase is the EPI module base address.
  81. //! \param ulDivider is the value of the clock divider to be applied to
  82. //! the external interface (0-65535).
  83. //!
  84. //! This function sets the clock divider(s) that is used to determine the
  85. //! clock rate of the external interface. The \e ulDivider value is used to
  86. //! derive the EPI clock rate from the system clock based on the following
  87. //! formula.
  88. //!
  89. //! EPIClock = (Divider == 0) ? SysClk : (SysClk / (((Divider / 2) + 1) * 2))
  90. //!
  91. //! For example, a divider value of 1 results in an EPI clock rate of half
  92. //! the system clock, value of 2 or 3 yields one quarter of the system clock and
  93. //! a value of 4 results in one sixth of the system clock rate.
  94. //!
  95. //! In cases where a dual chip select mode is in use and different clock rates
  96. //! are required for each chip select, the \e ulDivider parameter must contain
  97. //! two dividers. The lower 16 bits define the divider to be used with CS0n
  98. //! and the upper 16 bits define the divider for CS1n.
  99. //!
  100. //! \return None.
  101. //
  102. //*****************************************************************************
  103. void
  104. EPIDividerSet(unsigned long ulBase, unsigned long ulDivider)
  105. {
  106. //
  107. // Check the arguments.
  108. //
  109. ASSERT(ulBase == EPI0_BASE);
  110. //
  111. // Write the divider value to the register.
  112. //
  113. HWREG(ulBase + EPI_O_BAUD) = ulDivider;
  114. }
  115. //*****************************************************************************
  116. //
  117. //! Configures the SDRAM mode of operation.
  118. //!
  119. //! \param ulBase is the EPI module base address.
  120. //! \param ulConfig is the SDRAM interface configuration.
  121. //! \param ulRefresh is the refresh count in core clocks (0-2047).
  122. //!
  123. //! This function is used to configure the SDRAM interface, when the SDRAM
  124. //! mode is chosen with the function EPIModeSet(). The parameter \e ulConfig
  125. //! is the logical OR of several sets of choices:
  126. //!
  127. //! The processor core frequency must be specified with one of the following:
  128. //!
  129. //! - \b EPI_SDRAM_CORE_FREQ_0_15 - core clock is 0 MHz < clk <= 15 MHz
  130. //! - \b EPI_SDRAM_CORE_FREQ_15_30 - core clock is 15 MHz < clk <= 30 MHz
  131. //! - \b EPI_SDRAM_CORE_FREQ_30_50 - core clock is 30 MHz < clk <= 50 MHz
  132. //! - \b EPI_SDRAM_CORE_FREQ_50_100 - core clock is 50 MHz < clk <= 100 MHz
  133. //!
  134. //! The low power mode is specified with one of the following:
  135. //!
  136. //! - \b EPI_SDRAM_LOW_POWER - enter low power, self-refresh state
  137. //! - \b EPI_SDRAM_FULL_POWER - normal operating state
  138. //!
  139. //! The SDRAM device size is specified with one of the following:
  140. //!
  141. //! - \b EPI_SDRAM_SIZE_64MBIT - 64 Mbit device (8 MB)
  142. //! - \b EPI_SDRAM_SIZE_128MBIT - 128 Mbit device (16 MB)
  143. //! - \b EPI_SDRAM_SIZE_256MBIT - 256 Mbit device (32 MB)
  144. //! - \b EPI_SDRAM_SIZE_512MBIT - 512 Mbit device (64 MB)
  145. //!
  146. //! The parameter \e ulRefresh sets the refresh counter in units of core
  147. //! clock ticks. It is an 11-bit value with a range of 0 - 2047 counts.
  148. //!
  149. //! \return None.
  150. //
  151. //*****************************************************************************
  152. void
  153. EPIConfigSDRAMSet(unsigned long ulBase, unsigned long ulConfig,
  154. unsigned long ulRefresh)
  155. {
  156. //
  157. // Check the arguments.
  158. //
  159. ASSERT(ulBase == EPI0_BASE);
  160. ASSERT(ulRefresh < 2048);
  161. //
  162. // Fill in the refresh count field of the configuration word.
  163. //
  164. ulConfig &= ~EPI_SDRAMCFG_RFSH_M;
  165. ulConfig |= ulRefresh << EPI_SDRAMCFG_RFSH_S;
  166. //
  167. // Write the SDRAM configuration register.
  168. //
  169. HWREG(ulBase + EPI_O_SDRAMCFG) = ulConfig;
  170. }
  171. //*****************************************************************************
  172. //
  173. //! Configures the interface for Host-bus 8 operation.
  174. //!
  175. //! \param ulBase is the EPI module base address.
  176. //! \param ulConfig is the interface configuration.
  177. //! \param ulMaxWait is the maximum number of external clocks to wait
  178. //! if a FIFO ready signal is holding off the transaction.
  179. //!
  180. //! This function is used to configure the interface when used in Host-bus 8
  181. //! operation as chosen with the function EPIModeSet(). The parameter
  182. //! \e ulConfig is the logical OR of any of the following:
  183. //!
  184. //! - one of \b EPI_HB8_MODE_ADMUX, \b EPI_HB8_MODE_ADDEMUX,
  185. //! \b EPI_HB8_MODE_SRAM, or \b EPI_HB8_MODE_FIFO to select the HB8 mode
  186. //! - \b EPI_HB8_USE_TXEMPTY - enable TXEMPTY signal with FIFO
  187. //! - \b EPI_HB8_USE_RXFULL - enable RXFULL signal with FIFO
  188. //! - \b EPI_HB8_WRHIGH - use active high write strobe, otherwise it is
  189. //! active low
  190. //! - \b EPI_HB8_RDHIGH - use active high read strobe, otherwise it is
  191. //! active low
  192. //! - one of \b EPI_HB8_WRWAIT_0, \b EPI_HB8_WRWAIT_1, \b EPI_HB8_WRWAIT_2,
  193. //! or \b EPI_HB8_WRWAIT_3 to select the number of write wait states (default
  194. //! is 0 wait states)
  195. //! - one of \b EPI_HB8_RDWAIT_0, \b EPI_HB8_RDWAIT_1, \b EPI_HB8_RDWAIT_2,
  196. //! or \b EPI_HB8_RDWAIT_3 to select the number of read wait states (default
  197. //! is 0 wait states)
  198. //! - \b EPI_HB8_WORD_ACCESS - use Word Access mode to route bytes to the
  199. //! correct byte lanes allowing data to be stored in bits [31:8]. If absent,
  200. //! all data transfers use bits [7:0].
  201. //! - \b EPI_HB8_CSBAUD_DUAL - use different baud rates when accessing devices
  202. //! on each CSn. CS0n uses the baud rate specified by the lower 16 bits of the
  203. //! divider passed to EPIDividerSet() and CS1n uses the divider passed in the
  204. //! upper 16 bits. If this option is absent, both chip selects use the baud
  205. //! rate resulting from the divider in the lower 16 bits of the parameter passed
  206. //! to EPIDividerSet().
  207. //! - one of \b EPI_HB8_CSCFG_CS, \b EPI_HB8_CSCFG_ALE,
  208. //! \b EPI_HB8_CSCFG_DUAL_CS or \b EPI_HB8_CSCFG_ALE_DUAL_CS.
  209. //! \b EPI_HB8_CSCFG_CS sets EPI30 to operate as a Chip Select (CSn) signal.
  210. //! \b EPI_HB8_CSCFG_ALE sets EPI30 to operate as an address latch (ALE).
  211. //! \b EPI_HB8_CSCFG_DUAL_CS sets EPI30 to operate as CS0n and EPI27 as CS1n
  212. //! with the asserted chip select determined from the most significant address
  213. //! bit for the respective external address map. \b EPI_HB8_CSCFG_ALE_DUAL_CS
  214. //! sets EPI30 as an address latch (ALE), EPI27 as CS0n and EPI26 as CS1n with
  215. //! the asserted chip select determined from the most significant address bit
  216. //! for the respective external address map.
  217. //!
  218. //! The parameter \e ulMaxWait is used if the FIFO mode is chosen. If a
  219. //! FIFO is used along with RXFULL or TXEMPTY ready signals, then this
  220. //! parameter determines the maximum number of clocks to wait when the
  221. //! transaction is being held off by by the FIFO using one of these ready
  222. //! signals. A value of 0 means to wait forever.
  223. //!
  224. //! \return None.
  225. //
  226. //*****************************************************************************
  227. void
  228. EPIConfigHB8Set(unsigned long ulBase, unsigned long ulConfig,
  229. unsigned long ulMaxWait)
  230. {
  231. //
  232. // Check the arguments.
  233. //
  234. ASSERT(ulBase == EPI0_BASE);
  235. ASSERT(ulMaxWait < 256);
  236. //
  237. // Determine the CS and word access modes.
  238. //
  239. HWREG(ulBase + EPI_O_HB8CFG2) = (((ulConfig & EPI_HB8_WORD_ACCESS) ?
  240. EPI_HB8CFG2_WORD : 0) |
  241. ((ulConfig & EPI_HB8_CSBAUD_DUAL) ?
  242. EPI_HB8CFG2_CSBAUD : 0) |
  243. ((ulConfig & EPI_HB8_CSCFG_MASK) << 15));
  244. //
  245. // Fill in the max wait field of the configuration word.
  246. //
  247. ulConfig &= ~EPI_HB8CFG_MAXWAIT_M;
  248. ulConfig |= ulMaxWait << EPI_HB8CFG_MAXWAIT_S;
  249. //
  250. // Write the main HostBus8 configuration register.
  251. //
  252. HWREG(ulBase + EPI_O_HB8CFG) = ulConfig;
  253. }
  254. //*****************************************************************************
  255. //
  256. //! Configures the interface for Host-bus 16 operation.
  257. //!
  258. //! \param ulBase is the EPI module base address.
  259. //! \param ulConfig is the interface configuration.
  260. //! \param ulMaxWait is the maximum number of external clocks to wait
  261. //! if a FIFO ready signal is holding off the transaction.
  262. //!
  263. //! This function is used to configure the interface when used in Host-bus 16
  264. //! operation as chosen with the function EPIModeSet(). The parameter
  265. //! \e ulConfig is the logical OR of any of the following:
  266. //!
  267. //! - one of \b EPI_HB16_MODE_ADMUX, \b EPI_HB16_MODE_ADDEMUX,
  268. //! \b EPI_HB16_MODE_SRAM, or \b EPI_HB16_MODE_FIFO to select the HB16 mode
  269. //! - \b EPI_HB16_USE_TXEMPTY - enable TXEMPTY signal with FIFO
  270. //! - \b EPI_HB16_USE_RXFULL - enable RXFULL signal with FIFO
  271. //! - \b EPI_HB16_WRHIGH - use active high write strobe, otherwise it is
  272. //! active low
  273. //! - \b EPI_HB16_RDHIGH - use active high read strobe, otherwise it is
  274. //! active low
  275. //! - one of \b EPI_HB16_WRWAIT_0, \b EPI_HB16_WRWAIT_1, \b EPI_HB16_WRWAIT_2,
  276. //! or \b EPI_HB16_WRWAIT_3 to select the number of write wait states (default
  277. //! is 0 wait states)
  278. //! - one of \b EPI_HB16_RDWAIT_0, \b EPI_HB16_RDWAIT_1, \b EPI_HB16_RDWAIT_2,
  279. //! or \b EPI_HB16_RDWAIT_3 to select the number of read wait states (default
  280. //! is 0 wait states)
  281. //! - \b EPI_HB16_WORD_ACCESS - use Word Access mode to route bytes to the
  282. //! correct byte lanes allowing data to be stored in bits [31:16]. If absent,
  283. //! all data transfers use bits [15:0].
  284. //! - \b EPI_HB16_BSEL - enables byte selects. In this mode, two EPI signals
  285. //! operate as byte selects allowing 8-bit transfers. If this flag is not
  286. //! specified, data must be read and written using only 16-bit transfers.
  287. //! - \b EPI_HB16_CSBAUD_DUAL - use different baud rates when accessing devices
  288. //! on each CSn. CS0n uses the baud rate specified by the lower 16 bits of the
  289. //! divider passed to EPIDividerSet() and CS1n uses the divider passed in the
  290. //! upper 16 bits. If this option is absent, both chip selects use the baud
  291. //! rate resulting from the divider in the lower 16 bits of the parameter passed
  292. //! to EPIDividerSet().
  293. //! - one of \b EPI_HB16_CSCFG_CS, \b EPI_HB16_CSCFG_ALE,
  294. //! \b EPI_HB16_CSCFG_DUAL_CS or \b EPI_HB16_CSCFG_ALE_DUAL_CS.
  295. //! \b EPI_HB16_CSCFG_CS sets EPI30 to operate as a Chip Select (CSn) signal.
  296. //! \b EPI_HB16_CSCFG_ALE sets EPI30 to operate as an address latch (ALE).
  297. //! \b EPI_HB16_CSCFG_DUAL_CS sets EPI30 to operate as CS0n and EPI27 as CS1n
  298. //! with the asserted chip select determined from the most significant address
  299. //! bit for the respective external address map. \b EPI_HB16_CSCFG_ALE_DUAL_CS
  300. //! sets EPI30 as an address latch (ALE), EPI27 as CS0n and EPI26 as CS1n with
  301. //! the asserted chip select determined from the most significant address bit
  302. //! for the respective external address map.
  303. //!
  304. //! The parameter \e ulMaxWait is used if the FIFO mode is chosen. If a
  305. //! FIFO is used along with RXFULL or TXEMPTY ready signals, then this
  306. //! parameter determines the maximum number of clocks to wait when the
  307. //! transaction is being held off by by the FIFO using one of these ready
  308. //! signals. A value of 0 means to wait forever.
  309. //!
  310. //! \return None.
  311. //
  312. //*****************************************************************************
  313. void
  314. EPIConfigHB16Set(unsigned long ulBase, unsigned long ulConfig,
  315. unsigned long ulMaxWait)
  316. {
  317. //
  318. // Check the arguments.
  319. //
  320. ASSERT(ulBase == EPI0_BASE);
  321. ASSERT(ulMaxWait < 256);
  322. //
  323. // Determine the CS and word access modes.
  324. //
  325. HWREG(ulBase + EPI_O_HB16CFG2) = (((ulConfig & EPI_HB16_WORD_ACCESS) ?
  326. EPI_HB16CFG2_WORD : 0) |
  327. ((ulConfig & EPI_HB16_CSBAUD_DUAL) ?
  328. EPI_HB16CFG2_CSBAUD : 0) |
  329. ((ulConfig & EPI_HB16_CSCFG_MASK) << 15));
  330. //
  331. // Fill in the max wait field of the configuration word.
  332. //
  333. ulConfig &= ~EPI_HB16CFG_MAXWAIT_M;
  334. ulConfig |= ulMaxWait << EPI_HB16CFG_MAXWAIT_S;
  335. //
  336. // Write the main HostBus16 configuration register.
  337. //
  338. HWREG(ulBase + EPI_O_HB16CFG) = ulConfig;
  339. }
  340. //*****************************************************************************
  341. //
  342. //! Configures the interface for general-purpose mode operation.
  343. //!
  344. //! \param ulBase is the EPI module base address.
  345. //! \param ulConfig is the interface configuration.
  346. //! \param ulFrameCount is the frame size in clocks, if the frame signal
  347. //! is used (0-15).
  348. //! \param ulMaxWait is the maximum number of external clocks to wait
  349. //! when the external clock enable is holding off the transaction (0-255).
  350. //!
  351. //! This function is used to configure the interface when used in
  352. //! general-purpose operation as chosen with the function EPIModeSet(). The
  353. //! parameter \e ulConfig is the logical OR of any of the following:
  354. //!
  355. //! - \b EPI_GPMODE_CLKPIN - interface clock is output on a pin
  356. //! - \b EPI_GPMODE_CLKGATE - clock is stopped when there is no transaction,
  357. //! otherwise it is free-running
  358. //! - \b EPI_GPMODE_RDYEN - the external peripheral drives an iRDY signal into
  359. //! pin EPI0S27. If absent, the peripheral is assumed to be ready at all times.
  360. //! This flag may only be used with a free-running clock (\b EPI_GPMODE_CLKGATE
  361. //! is absent).
  362. //! - \b EPI_GPMODE_FRAMEPIN - framing signal is emitted on a pin
  363. //! - \b EPI_GPMODE_FRAME50 - framing signal is 50/50 duty cycle, otherwise it
  364. //! is a pulse
  365. //! - \b EPI_GPMODE_READWRITE - read and write strobes are emitted on pins
  366. //! - \b EPI_GPMODE_WRITE2CYCLE - a two-cycle write is used, otherwise a
  367. //! single-cycle write is used
  368. //! - \b EPI_GPMODE_READ2CYCLE - a two-cycle read is used, otherwise a
  369. //! single-cycle read is used
  370. //! - \b EPI_GPMODE_ASIZE_NONE, \b EPI_GPMODE_ASIZE_4,
  371. //! \b EPI_GPMODE_ASIZE_12, or \b EPI_GPMODE_ASIZE_20 to choose no address
  372. //! bus or an address bus size of 4, 12, or 20 bits
  373. //! - \b EPI_GPMODE_DSIZE_8, \b EPI_GPMODE_DSIZE_16,
  374. //! \b EPI_GPMODE_DSIZE_24, or \b EPI_GPMODE_DSIZE_32 to select a data bus
  375. //! size of 8, 16, 24, or 32 bits
  376. //! - \b EPI_GPMODE_WORD_ACCESS - use Word Access mode to route bytes to the
  377. //! correct byte lanes allowing data to be stored in the upper bits of the word
  378. //! when necessary.
  379. //!
  380. //! The parameter \e ulFrameCount is the number of clocks used to form the
  381. //! framing signal, if the framing signal is used. The behavior depends on
  382. //! whether the frame signal is a pulse or a 50/50 duty cycle. This value
  383. //! is not used if the framing signal is not enabled with the option
  384. //! \b EPI_GPMODE_FRAMEPIN.
  385. //!
  386. //! The parameter \e ulMaxWait is used if the external clock enable is turned
  387. //! on with the \b EPI_GPMODE_CLKENA option is used. In the case that
  388. //! external clock enable is used, this parameter determines the maximum
  389. //! number of clocks to wait when the external clock enable signal is holding
  390. //! off a transaction. A value of 0 means to wait forever. If a non-zero
  391. //! value is used and exceeded, an interrupt occurs and the transaction
  392. //! aborted.
  393. //!
  394. //! \return None.
  395. //
  396. //*****************************************************************************
  397. void
  398. EPIConfigGPModeSet(unsigned long ulBase, unsigned long ulConfig,
  399. unsigned long ulFrameCount, unsigned long ulMaxWait)
  400. {
  401. //
  402. // Check the arguments.
  403. //
  404. ASSERT(ulBase == EPI0_BASE);
  405. ASSERT(ulFrameCount < 16);
  406. ASSERT(ulMaxWait < 256);
  407. //
  408. // Set the word access mode.
  409. //
  410. HWREG(ulBase + EPI_O_GPCFG2) = ((ulConfig & EPI_GPMODE_WORD_ACCESS) ?
  411. EPI_GPCFG2_WORD : 0);
  412. //
  413. // Fill in the frame count field of the configuration word.
  414. //
  415. ulConfig &= ~EPI_GPCFG_FRMCNT_M;
  416. ulConfig |= ulFrameCount << EPI_GPCFG_FRMCNT_S;
  417. //
  418. // Fill in the max wait field of the configuration word.
  419. //
  420. ulConfig &= ~EPI_GPCFG_MAXWAIT_M;
  421. ulConfig |= ulMaxWait << EPI_GPCFG_MAXWAIT_S;
  422. //
  423. // Write the non-moded configuration register.
  424. //
  425. HWREG(ulBase + EPI_O_GPCFG) = ulConfig;
  426. }
  427. //*****************************************************************************
  428. //
  429. //! Configures the address map for the external interface.
  430. //!
  431. //! \param ulBase is the EPI module base address.
  432. //! \param ulMap is the address mapping configuration.
  433. //!
  434. //! This function is used to configure the address mapping for the external
  435. //! interface. This determines the base address of the external memory or
  436. //! device within the processor peripheral and/or memory space.
  437. //!
  438. //! The parameter \e ulMap is the logical OR of the following:
  439. //!
  440. //! - \b EPI_ADDR_PER_SIZE_256B, \b EPI_ADDR_PER_SIZE_64KB,
  441. //! \b EPI_ADDR_PER_SIZE_16MB, or \b EPI_ADDR_PER_SIZE_512MB to choose a
  442. //! peripheral address space of 256 bytes, 64 Kbytes, 16 Mbytes or 512 Mbytes
  443. //! - \b EPI_ADDR_PER_BASE_NONE, \b EPI_ADDR_PER_BASE_A, or
  444. //! \b EPI_ADDR_PER_BASE_C to choose the base address of the peripheral
  445. //! space as none, 0xA0000000, or 0xC0000000
  446. //! - \b EPI_ADDR_RAM_SIZE_256B, \b EPI_ADDR_RAM_SIZE_64KB,
  447. //! \b EPI_ADDR_RAM_SIZE_16MB, or \b EPI_ADDR_RAM_SIZE_512MB to choose a
  448. //! RAM address space of 256 bytes, 64 Kbytes, 16 Mbytes or 512 Mbytes
  449. //! - \b EPI_ADDR_RAM_BASE_NONE, \b EPI_ADDR_RAM_BASE_6, or
  450. //! \b EPI_ADDR_RAM_BASE_8 to choose the base address of the RAM space
  451. //! as none, 0x60000000, or 0x80000000
  452. //!
  453. //! \return None.
  454. //
  455. //*****************************************************************************
  456. void
  457. EPIAddressMapSet(unsigned long ulBase, unsigned long ulMap)
  458. {
  459. //
  460. // Check the arguments.
  461. //
  462. ASSERT(ulBase == EPI0_BASE);
  463. ASSERT(ulMap < 0x100);
  464. //
  465. // Set the value of the address mapping register.
  466. //
  467. HWREG(ulBase + EPI_O_ADDRMAP) = ulMap;
  468. }
  469. //*****************************************************************************
  470. //
  471. //! Configures a non-blocking read transaction.
  472. //!
  473. //! \param ulBase is the EPI module base address.
  474. //! \param ulChannel is the read channel (0 or 1).
  475. //! \param ulDataSize is the size of the data items to read.
  476. //! \param ulAddress is the starting address to read.
  477. //!
  478. //! This function is used to configure a non-blocking read channel for a
  479. //! transaction. Two channels are available which can be used in a ping-pong
  480. //! method for continuous reading. It is not necessary to use both channels
  481. //! to perform a non-blocking read.
  482. //!
  483. //! The parameter \e ulDataSize is one of \b EPI_NBCONFIG_SIZE_8,
  484. //! \b EPI_NBCONFIG_SIZE_16, or \b EPI_NBCONFIG_SIZE_32 for 8-bit, 16-bit,
  485. //! or 32-bit sized data transfers.
  486. //!
  487. //! The parameter \e ulAddress is the starting address for the read, relative
  488. //! to the external device. The start of the device is address 0.
  489. //!
  490. //! Once configured, the non-blocking read is started by calling
  491. //! EPINonBlockingReadStart(). If the addresses to be read from the device
  492. //! are in a sequence, it is not necessary to call this function multiple
  493. //! times. Until it is changed, the EPI module stores the last address
  494. //! that was used for a non-blocking read (per channel).
  495. //!
  496. //! \return None.
  497. //
  498. //*****************************************************************************
  499. void
  500. EPINonBlockingReadConfigure(unsigned long ulBase, unsigned long ulChannel,
  501. unsigned long ulDataSize, unsigned long ulAddress)
  502. {
  503. unsigned long ulOffset;
  504. //
  505. // Check the arguments.
  506. //
  507. ASSERT(ulBase == EPI0_BASE);
  508. ASSERT(ulChannel < 2);
  509. ASSERT(ulDataSize < 4);
  510. ASSERT(ulAddress < 0x20000000);
  511. //
  512. // Compute the offset needed to select the correct channel regs.
  513. //
  514. ulOffset = ulChannel * (EPI_O_RSIZE1 - EPI_O_RSIZE0);
  515. //
  516. // Write the data size register for the channel.
  517. //
  518. HWREG(ulBase + EPI_O_RSIZE0 + ulOffset) = ulDataSize;
  519. //
  520. // Write the starting address register for the channel.
  521. //
  522. HWREG(ulBase + EPI_O_RADDR0 + ulOffset) = ulAddress;
  523. }
  524. //*****************************************************************************
  525. //
  526. //! Starts a non-blocking read transaction.
  527. //!
  528. //! \param ulBase is the EPI module base address.
  529. //! \param ulChannel is the read channel (0 or 1).
  530. //! \param ulCount is the number of items to read (1-4095).
  531. //!
  532. //! This function starts a non-blocking read that was previously configured
  533. //! with the function EPINonBlockingReadConfigure(). Once this function is
  534. //! called, the EPI module begins reading data from the external device
  535. //! into the read FIFO. The EPI stops reading when the FIFO fills up
  536. //! and resumes reading when the application drains the FIFO, until the
  537. //! total specified count of data items has been read.
  538. //!
  539. //! Once a read transaction is completed and the FIFO drained, another
  540. //! transaction can be started from the next address by calling this
  541. //! function again.
  542. //!
  543. //! \return None.
  544. //
  545. //*****************************************************************************
  546. void
  547. EPINonBlockingReadStart(unsigned long ulBase, unsigned long ulChannel,
  548. unsigned long ulCount)
  549. {
  550. unsigned long ulOffset;
  551. //
  552. // Check the arguments.
  553. //
  554. ASSERT(ulBase == EPI0_BASE);
  555. ASSERT(ulChannel < 2);
  556. ASSERT(ulCount < 4096);
  557. //
  558. // Compute the offset needed to select the correct channel regs.
  559. //
  560. ulOffset = ulChannel * (EPI_O_RPSTD1 - EPI_O_RPSTD0);
  561. //
  562. // Write to the read count register.
  563. //
  564. HWREG(ulBase + EPI_O_RPSTD0 + ulOffset) = ulCount;
  565. }
  566. //*****************************************************************************
  567. //
  568. //! Stops a non-blocking read transaction.
  569. //!
  570. //! \param ulBase is the EPI module base address.
  571. //! \param ulChannel is the read channel (0 or 1).
  572. //!
  573. //! This function cancels a non-blocking read transaction that is already
  574. //! in progress.
  575. //!
  576. //! \return None.
  577. //
  578. //*****************************************************************************
  579. void
  580. EPINonBlockingReadStop(unsigned long ulBase, unsigned long ulChannel)
  581. {
  582. unsigned long ulOffset;
  583. //
  584. // Check the arguments.
  585. //
  586. ASSERT(ulBase == EPI0_BASE);
  587. ASSERT(ulChannel < 2);
  588. //
  589. // Compute the offset needed to select the correct channel regs.
  590. //
  591. ulOffset = ulChannel * (EPI_O_RPSTD1 - EPI_O_RPSTD0);
  592. //
  593. // Write a 0 to the read count register, which cancels the transaction.
  594. //
  595. HWREG(ulBase + EPI_O_RPSTD0 + ulOffset) = 0;
  596. }
  597. //*****************************************************************************
  598. //
  599. //! Get the count remaining for a non-blocking transaction.
  600. //!
  601. //! \param ulBase is the EPI module base address.
  602. //! \param ulChannel is the read channel (0 or 1).
  603. //!
  604. //! This function gets the remaining count of items for a non-blocking read
  605. //! transaction.
  606. //!
  607. //! \return The number of items remaining in the non-blocking read transaction.
  608. //
  609. //*****************************************************************************
  610. unsigned long
  611. EPINonBlockingReadCount(unsigned long ulBase, unsigned long ulChannel)
  612. {
  613. unsigned long ulOffset;
  614. //
  615. // Check the arguments.
  616. //
  617. ASSERT(ulBase == EPI0_BASE);
  618. ASSERT(ulChannel < 2);
  619. //
  620. // Compute the offset needed to select the correct channel regs.
  621. //
  622. ulOffset = ulChannel * (EPI_O_RPSTD1 - EPI_O_RPSTD0);
  623. //
  624. // Read the count remaining and return the value to the caller.
  625. //
  626. return(HWREG(ulBase + EPI_O_RPSTD0 + ulOffset));
  627. }
  628. //*****************************************************************************
  629. //
  630. //! Get the count of items available in the read FIFO.
  631. //!
  632. //! \param ulBase is the EPI module base address.
  633. //!
  634. //! This function gets the number of items that are available to read in
  635. //! the read FIFO. The read FIFO is filled by a non-blocking read transaction
  636. //! which is configured by the functions EPINonBlockingReadConfigure() and
  637. //! EPINonBlockingReadStart().
  638. //!
  639. //! \return The number of items available to read in the read FIFO.
  640. //
  641. //*****************************************************************************
  642. unsigned long
  643. EPINonBlockingReadAvail(unsigned long ulBase)
  644. {
  645. //
  646. // Check the arguments.
  647. //
  648. ASSERT(ulBase == EPI0_BASE);
  649. //
  650. // Read the FIFO count and return it to the caller.
  651. //
  652. return(HWREG(ulBase + EPI_O_RFIFOCNT));
  653. }
  654. //*****************************************************************************
  655. //
  656. //! Read available data from the read FIFO, as 32-bit data items.
  657. //!
  658. //! \param ulBase is the EPI module base address.
  659. //! \param ulCount is the maximum count of items to read.
  660. //! \param pulBuf is the caller supplied buffer where the read data should
  661. //! be stored.
  662. //!
  663. //! This function reads 32-bit data items from the read FIFO and stores
  664. //! the values in a caller-supplied buffer. The function reads and stores
  665. //! data from the FIFO until there is no more data in the FIFO or the maximum
  666. //! count is reached as specified in the parameter \e ulCount. The actual
  667. //! count of items is returned.
  668. //!
  669. //! \return The number of items read from the FIFO.
  670. //
  671. //*****************************************************************************
  672. unsigned long
  673. EPINonBlockingReadGet32(unsigned long ulBase, unsigned long ulCount,
  674. unsigned long *pulBuf)
  675. {
  676. unsigned long ulCountRead = 0;
  677. //
  678. // Check the arguments.
  679. //
  680. ASSERT(ulBase == EPI0_BASE);
  681. ASSERT(ulCount < 4096);
  682. ASSERT(pulBuf);
  683. //
  684. // Read from the FIFO while there are any items to read and
  685. // the caller's specified count is not exceeded.
  686. //
  687. while(HWREG(ulBase + EPI_O_RFIFOCNT) && ulCount--)
  688. {
  689. //
  690. // Read from the FIFO and store in the caller supplied buffer.
  691. //
  692. *pulBuf = HWREG(ulBase + EPI_O_READFIFO);
  693. //
  694. // Update the caller's buffer pointer and the count of items read.
  695. //
  696. pulBuf++;
  697. ulCountRead++;
  698. }
  699. //
  700. // Return the count of items read to the caller.
  701. //
  702. return(ulCountRead);
  703. }
  704. //*****************************************************************************
  705. //
  706. //! Read available data from the read FIFO, as 16-bit data items.
  707. //!
  708. //! \param ulBase is the EPI module base address.
  709. //! \param ulCount is the maximum count of items to read.
  710. //! \param pusBuf is the caller-supplied buffer where the read data should
  711. //! be stored.
  712. //!
  713. //! This function reads 16-bit data items from the read FIFO and stores
  714. //! the values in a caller-supplied buffer. The function reads and stores
  715. //! data from the FIFO until there is no more data in the FIFO or the maximum
  716. //! count is reached as specified in the parameter \e ulCount. The actual
  717. //! count of items is returned.
  718. //!
  719. //! \return The number of items read from the FIFO.
  720. //
  721. //*****************************************************************************
  722. unsigned long
  723. EPINonBlockingReadGet16(unsigned long ulBase, unsigned long ulCount,
  724. unsigned short *pusBuf)
  725. {
  726. unsigned long ulCountRead = 0;
  727. //
  728. // Check the arguments.
  729. //
  730. ASSERT(ulBase == EPI0_BASE);
  731. ASSERT(ulCount < 4096);
  732. ASSERT(pusBuf);
  733. //
  734. // Read from the FIFO while there are any items to read, and
  735. // the caller's specified count is not exceeded.
  736. //
  737. while(HWREG(ulBase + EPI_O_RFIFOCNT) && ulCount--)
  738. {
  739. //
  740. // Read from the FIFO and store in the caller-supplied buffer.
  741. //
  742. *pusBuf = (unsigned short)HWREG(ulBase + EPI_O_READFIFO);
  743. //
  744. // Update the caller's buffer pointer and the count of items read.
  745. //
  746. pusBuf++;
  747. ulCountRead++;
  748. }
  749. //
  750. // Return the count of items read to the caller.
  751. //
  752. return(ulCountRead);
  753. }
  754. //*****************************************************************************
  755. //
  756. //! Read available data from the read FIFO, as 8-bit data items.
  757. //!
  758. //! \param ulBase is the EPI module base address.
  759. //! \param ulCount is the maximum count of items to read.
  760. //! \param pucBuf is the caller-supplied buffer where the read data should
  761. //! be stored.
  762. //!
  763. //! This function reads 8-bit data items from the read FIFO and stores
  764. //! the values in a caller-supplied buffer. The function reads and stores
  765. //! data from the FIFO until there is no more data in the FIFO or the maximum
  766. //! count is reached as specified in the parameter \e ulCount. The actual
  767. //! count of items is returned.
  768. //!
  769. //! \return The number of items read from the FIFO.
  770. //
  771. //*****************************************************************************
  772. unsigned long
  773. EPINonBlockingReadGet8(unsigned long ulBase, unsigned long ulCount,
  774. unsigned char *pucBuf)
  775. {
  776. unsigned long ulCountRead = 0;
  777. //
  778. // Check the arguments.
  779. //
  780. ASSERT(ulBase == EPI0_BASE);
  781. ASSERT(ulCount < 4096);
  782. ASSERT(pucBuf);
  783. //
  784. // Read from the FIFO while there are any items to read, and
  785. // the caller's specified count is not exceeded.
  786. //
  787. while(HWREG(ulBase + EPI_O_RFIFOCNT) && ulCount--)
  788. {
  789. //
  790. // Read from the FIFO and store in the caller supplied buffer.
  791. //
  792. *pucBuf = (unsigned char)HWREG(ulBase + EPI_O_READFIFO);
  793. //
  794. // Update the caller's buffer pointer and the count of items read.
  795. //
  796. pucBuf++;
  797. ulCountRead++;
  798. }
  799. //
  800. // Return the count of items read to the caller.
  801. //
  802. return(ulCountRead);
  803. }
  804. //*****************************************************************************
  805. //
  806. //! Configures the read FIFO.
  807. //!
  808. //! \param ulBase is the EPI module base address.
  809. //! \param ulConfig is the FIFO configuration.
  810. //!
  811. //! This function configures the FIFO trigger levels and error
  812. //! generation. The parameter \e ulConfig is the logical OR of the
  813. //! following:
  814. //!
  815. //! - \b EPI_FIFO_CONFIG_WTFULLERR - enables an error interrupt when a write is
  816. //! attempted and the write FIFO is full
  817. //! - \b EPI_FIFO_CONFIG_RSTALLERR - enables an error interrupt when a read is
  818. //! stalled due to an interleaved write or other reason
  819. //! - \b EPI_FIFO_CONFIG_TX_EMPTY, \b EPI_FIFO_CONFIG_TX_1_4,
  820. //! \b EPI_FIFO_CONFIG_TX_1_2, or \b EPI_FIFO_CONFIG_TX_3_4 to set the
  821. //! TX FIFO trigger level to empty, 1/4, 1/2, or 3/4 level
  822. //! - \b EPI_FIFO_CONFIG_RX_1_8, \b EPI_FIFO_CONFIG_RX_1_4,
  823. //! \b EPI_FIFO_CONFIG_RX_1_2, \b EPI_FIFO_CONFIG_RX_3_4,
  824. //! \b EPI_FIFO_CONFIG_RX_7_8, or \b EPI_FIFO_CONFIG_RX_FULL to set the
  825. //! RX FIFO trigger level to 1/8, 1/4, 1/2, 3/4, 7/8 or full level
  826. //!
  827. //! \return None.
  828. //
  829. //*****************************************************************************
  830. void
  831. EPIFIFOConfig(unsigned long ulBase, unsigned long ulConfig)
  832. {
  833. //
  834. // Check the arguments.
  835. //
  836. ASSERT(ulBase == EPI0_BASE);
  837. ASSERT(ulConfig == (ulConfig & 0x00030077));
  838. //
  839. // Load the configuration into the FIFO config reg.
  840. //
  841. HWREG(ulBase + EPI_O_FIFOLVL) = ulConfig;
  842. }
  843. //*****************************************************************************
  844. //
  845. //! Reads the number of empty slots in the write transaction FIFO.
  846. //!
  847. //! \param ulBase is the EPI module base address.
  848. //!
  849. //! This function returns the number of slots available in the transaction
  850. //! FIFO. It can be used in a polling method to avoid attempting a write
  851. //! that would stall.
  852. //!
  853. //! \return The number of empty slots in the transaction FIFO.
  854. //
  855. //*****************************************************************************
  856. unsigned long
  857. EPIWriteFIFOCountGet(unsigned long ulBase)
  858. {
  859. //
  860. // Check the arguments.
  861. //
  862. ASSERT(ulBase == EPI0_BASE);
  863. //
  864. // Read the FIFO count and return it to the caller.
  865. //
  866. return(HWREG(ulBase + EPI_O_WFIFOCNT));
  867. }
  868. //*****************************************************************************
  869. //
  870. //! Enables EPI interrupt sources.
  871. //!
  872. //! \param ulBase is the EPI module base address.
  873. //! \param ulIntFlags is a bit mask of the interrupt sources to be enabled.
  874. //!
  875. //! This function enables the specified EPI sources to generate interrupts.
  876. //! The \e ulIntFlags parameter can be the logical OR of any of the following
  877. //! values:
  878. //!
  879. //! - \b EPI_INT_TXREQ - transmit FIFO is below the trigger level
  880. //! - \b EPI_INT_RXREQ - read FIFO is above the trigger level
  881. //! - \b EPI_INT_ERR - an error condition occurred
  882. //!
  883. //! \return Returns None.
  884. //
  885. //*****************************************************************************
  886. void
  887. EPIIntEnable(unsigned long ulBase, unsigned long ulIntFlags)
  888. {
  889. //
  890. // Check the arguments.
  891. //
  892. ASSERT(ulBase == EPI0_BASE);
  893. ASSERT(ulIntFlags < 16);
  894. //
  895. // Write the interrupt flags mask to the mask register.
  896. //
  897. HWREG(ulBase + EPI_O_IM) |= ulIntFlags;
  898. }
  899. //*****************************************************************************
  900. //
  901. //! Disables EPI interrupt sources.
  902. //!
  903. //! \param ulBase is the EPI module base address.
  904. //! \param ulIntFlags is a bit mask of the interrupt sources to be disabled.
  905. //!
  906. //! This function disables the specified EPI sources for interrupt
  907. //! generation. The \e ulIntFlags parameter can be the logical OR
  908. //! of any of the following values: \b EPI_INT_RXREQ, \b EPI_INT_TXREQ, or
  909. //! \b I2S_INT_ERR.
  910. //!
  911. //! \return Returns None.
  912. //
  913. //*****************************************************************************
  914. void
  915. EPIIntDisable(unsigned long ulBase, unsigned long ulIntFlags)
  916. {
  917. //
  918. // Check the arguments.
  919. //
  920. ASSERT(ulBase == EPI0_BASE);
  921. ASSERT(ulIntFlags < 16);
  922. //
  923. // Write the interrupt flags mask to the mask register.
  924. //
  925. HWREG(ulBase + EPI_O_IM) &= ~ulIntFlags;
  926. }
  927. //*****************************************************************************
  928. //
  929. //! Gets the EPI interrupt status.
  930. //!
  931. //! \param ulBase is the EPI module base address.
  932. //! \param bMasked is set \b true to get the masked interrupt status, or
  933. //! \b false to get the raw interrupt status.
  934. //!
  935. //! This function returns the EPI interrupt status. It can return either
  936. //! the raw or masked interrupt status.
  937. //!
  938. //! \return Returns the masked or raw EPI interrupt status, as a bit field
  939. //! of any of the following values: \b EPI_INT_TXREQ, \b EPI_INT_RXREQ,
  940. //! or \b EPI_INT_ERR
  941. //
  942. //*****************************************************************************
  943. unsigned long
  944. EPIIntStatus(unsigned long ulBase, tBoolean bMasked)
  945. {
  946. //
  947. // Check the arguments.
  948. //
  949. ASSERT(ulBase == EPI0_BASE);
  950. //
  951. // Return either the interrupt status or the raw interrupt status as
  952. // requested.
  953. //
  954. if(bMasked)
  955. {
  956. return(HWREG(ulBase + EPI_O_MIS));
  957. }
  958. else
  959. {
  960. return(HWREG(ulBase + EPI_O_RIS));
  961. }
  962. }
  963. //*****************************************************************************
  964. //
  965. //! Gets the EPI error interrupt status.
  966. //!
  967. //! \param ulBase is the EPI module base address.
  968. //!
  969. //! This function returns the error status of the EPI. If the return value of
  970. //! the function EPIIntStatus() has the flag \b EPI_INT_ERR set, then this
  971. //! function can be used to determine the cause of the error.
  972. //!
  973. //! This function returns a bit mask of error flags, which can be the logical
  974. //! OR of any of the following:
  975. //!
  976. //! - \b EPI_INT_ERR_WTFULL - occurs when a write stalled when the transaction
  977. //! FIFO was full
  978. //! - \b EPI_INT_ERR_RSTALL - occurs when a read stalled
  979. //! - \b EPI_INT_ERR_TIMEOUT - occurs when the external clock enable held
  980. //! off a transaction longer than the configured maximum wait time
  981. //!
  982. //! \return Returns the interrupt error flags as the logical OR of any of
  983. //! the following: \b EPI_INT_ERR_WTFULL, \b EPI_INT_ERR_RSTALL, or
  984. //! \b EPI_INT_ERR_TIMEOUT.
  985. //
  986. //*****************************************************************************
  987. unsigned long
  988. EPIIntErrorStatus(unsigned long ulBase)
  989. {
  990. //
  991. // Check the arguments.
  992. //
  993. ASSERT(ulBase == EPI0_BASE);
  994. //
  995. // Read the error status and return to caller.
  996. //
  997. return(HWREG(ulBase + EPI_O_EISC));
  998. }
  999. //*****************************************************************************
  1000. //
  1001. //! Clears pending EPI error sources.
  1002. //!
  1003. //! \param ulBase is the EPI module base address.
  1004. //! \param ulErrFlags is a bit mask of the error sources to be cleared.
  1005. //!
  1006. //! This function clears the specified pending EPI errors. The \e ulErrFlags
  1007. //! parameter can be the logical OR of any of the following values:
  1008. //! \b EPI_INT_ERR_WTFULL, \b EPI_INT_ERR_RSTALL, or \b EPI_INT_ERR_TIMEOUT.
  1009. //!
  1010. //! \return Returns None.
  1011. //
  1012. //*****************************************************************************
  1013. void
  1014. EPIIntErrorClear(unsigned long ulBase, unsigned long ulErrFlags)
  1015. {
  1016. //
  1017. // Check the arguments.
  1018. //
  1019. ASSERT(ulBase == EPI0_BASE);
  1020. ASSERT(ulErrFlags < 16);
  1021. //
  1022. // Write the error flags to the register to clear the pending errors.
  1023. //
  1024. HWREG(ulBase + EPI_O_EISC) = ulErrFlags;
  1025. }
  1026. //*****************************************************************************
  1027. //
  1028. //! Registers an interrupt handler for the EPI module.
  1029. //!
  1030. //! \param ulBase is the EPI module base address.
  1031. //! \param pfnHandler is a pointer to the function to be called when the
  1032. //! interrupt is activated.
  1033. //!
  1034. //! This sets and enables the handler to be called when the EPI module
  1035. //! generates an interrupt. Specific EPI interrupts must still be enabled
  1036. //! with the EPIIntEnable() function.
  1037. //!
  1038. //! \sa IntRegister() for important information about registering interrupt
  1039. //! handlers.
  1040. //!
  1041. //! \return None.
  1042. //
  1043. //*****************************************************************************
  1044. void
  1045. EPIIntRegister(unsigned long ulBase, void (*pfnHandler)(void))
  1046. {
  1047. //
  1048. // Check the arguments.
  1049. //
  1050. ASSERT(ulBase == EPI0_BASE);
  1051. ASSERT(pfnHandler);
  1052. //
  1053. // Register the interrupt handler.
  1054. //
  1055. IntRegister(INT_EPI0, pfnHandler);
  1056. //
  1057. // Enable the EPI interface interrupt.
  1058. //
  1059. IntEnable(INT_EPI0);
  1060. }
  1061. //*****************************************************************************
  1062. //
  1063. //! Unregisters an interrupt handler for the EPI module.
  1064. //!
  1065. //! \param ulBase is the EPI module base address.
  1066. //!
  1067. //! This function disables and clears the handler to be called when the
  1068. //! EPI interrupt occurs.
  1069. //!
  1070. //! \sa IntRegister() for important information about registering interrupt
  1071. //! handlers.
  1072. //!
  1073. //! \return None.
  1074. //
  1075. //*****************************************************************************
  1076. void
  1077. EPIIntUnregister(unsigned long ulBase)
  1078. {
  1079. //
  1080. // Check the arguments.
  1081. //
  1082. ASSERT(ulBase == EPI0_BASE);
  1083. //
  1084. // Disable the EPI interface interrupt.
  1085. //
  1086. IntDisable(INT_EPI0);
  1087. //
  1088. // Unregister the interrupt handler.
  1089. //
  1090. IntUnregister(INT_EPI0);
  1091. }
  1092. //*****************************************************************************
  1093. //
  1094. // Close the Doxygen group.
  1095. //! @}
  1096. //
  1097. //*****************************************************************************