epi.c 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176
  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 8049 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 will enable 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 functions 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 upon 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 yield 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:8]. If absent,
  283. //! all data transfers use bits [7: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
  354. //! \e ulConfig is the logical OR of any of the following:
  355. //!
  356. //! - \b EPI_GPMODE_CLKPIN - interface clock is output on a pin
  357. //! - \b EPI_GPMODE_CLKGATE - clock is stopped when there is no transaction,
  358. //! otherwise it is free-running
  359. //! - \b EPI_GPMODE_RDYEN - the external peripheral drives an iRDY signal into
  360. //! pin EPI0S27. If absent, the peripheral is assumed to be ready at all times.
  361. //! This flag may only be used with a free-running clock (\b EPI_GPMODE_CLKGATE
  362. //! is absent).
  363. //! - \b EPI_GPMODE_FRAMEPIN - framing signal is emitted on a pin
  364. //! - \b EPI_GPMODE_FRAME50 - framing signal is 50/50 duty cycle, otherwise it
  365. //! is a pulse
  366. //! - \b EPI_GPMODE_READWRITE - read and write strobes are emitted on pins
  367. //! - \b EPI_GPMODE_WRITE2CYCLE - a two cycle write is used, otherwise a
  368. //! single-cycle write is used
  369. //! - \b EPI_GPMODE_READ2CYCLE - a two cycle read is used, otherwise a
  370. //! single-cycle read is used
  371. //! - \b EPI_GPMODE_ASIZE_NONE, \b EPI_GPMODE_ASIZE_4,
  372. //! \b EPI_GPMODE_ASIZE_12, or \b EPI_GPMODE_ASIZE_20 to choose no address
  373. //! bus, or and address bus size of 4, 12, or 20 bits
  374. //! - \b EPI_GPMODE_DSIZE_8, \b EPI_GPMODE_DSIZE_16,
  375. //! \b EPI_GPMODE_DSIZE_24, or \b EPI_GPMODE_DSIZE_32 to select a data bus
  376. //! size of 8, 16, 24, or 32 bits
  377. //! - \b EPI_GPMODE_WORD_ACCESS - use Word Access mode to route bytes to the
  378. //! correct byte lanes allowing data to be stored in the upper bits of the word
  379. //! when necessary.
  380. //!
  381. //! The parameter \e ulFrameCount is the number of clocks used to form the
  382. //! framing signal, if the framing signal is used. The behavior depends on
  383. //! whether the frame signal is a pulse or a 50/50 duty cycle. This value
  384. //! is not used if the framing signal is not enabled with the option
  385. //! \b EPI_GPMODE_FRAMEPIN.
  386. //!
  387. //! The parameter \e ulMaxWait is used if the external clock enable is turned
  388. //! on with the \b EPI_GPMODE_CLKENA option is used. In the case that
  389. //! external clock enable is used, this parameter determines the maximum
  390. //! number of clocks to wait when the external clock enable signal is holding
  391. //! off a transaction. A value of 0 means to wait forever. If a non-zero
  392. //! value is used and exceeded, an interrupt will occur and the transaction
  393. //! aborted.
  394. //!
  395. //! \return None.
  396. //
  397. //*****************************************************************************
  398. void
  399. EPIConfigGPModeSet(unsigned long ulBase, unsigned long ulConfig,
  400. unsigned long ulFrameCount, unsigned long ulMaxWait)
  401. {
  402. //
  403. // Check the arguments.
  404. //
  405. ASSERT(ulBase == EPI0_BASE);
  406. ASSERT(ulFrameCount < 16);
  407. ASSERT(ulMaxWait < 256);
  408. //
  409. // Set the word access mode.
  410. //
  411. HWREG(ulBase + EPI_O_GPCFG2) = ((ulConfig & EPI_GPMODE_WORD_ACCESS) ?
  412. EPI_GPCFG2_WORD : 0);
  413. //
  414. // Fill in the frame count field of the configuration word.
  415. //
  416. ulConfig &= ~EPI_GPCFG_FRMCNT_M;
  417. ulConfig |= ulFrameCount << EPI_GPCFG_FRMCNT_S;
  418. //
  419. // Fill in the max wait field of the configuration word.
  420. //
  421. ulConfig &= ~EPI_GPCFG_MAXWAIT_M;
  422. ulConfig |= ulMaxWait << EPI_GPCFG_MAXWAIT_S;
  423. //
  424. // Write the non-moded configuration register.
  425. //
  426. HWREG(ulBase + EPI_O_GPCFG) = ulConfig;
  427. }
  428. //*****************************************************************************
  429. //
  430. //! Configures the address map for the external interface.
  431. //!
  432. //! \param ulBase is the EPI module base address.
  433. //! \param ulMap is the address mapping configuration.
  434. //!
  435. //! This function is used to configure the address mapping for the external
  436. //! interface. This determines the base address of the external memory or
  437. //! device within the processor peripheral and/or memory space.
  438. //!
  439. //! The parameter \e ulMap is the logical OR of the following:
  440. //!
  441. //! - \b EPI_ADDR_PER_SIZE_256B, \b EPI_ADDR_PER_SIZE_64KB,
  442. //! \b EPI_ADDR_PER_SIZE_16MB, or \b EPI_ADDR_PER_SIZE_512MB to choose a
  443. //! peripheral address space of 256 bytes, 64 Kbytes, 16 Mbytes or 512 Mbytes
  444. //! - \b EPI_ADDR_PER_BASE_NONE, \b EPI_ADDR_PER_BASE_A, or
  445. //! \b EPI_ADDR_PER_BASE_C to choose the base address of the peripheral
  446. //! space as none, 0xA0000000, or 0xC0000000
  447. //! - \b EPI_ADDR_RAM_SIZE_256B, \b EPI_ADDR_RAM_SIZE_64KB,
  448. //! \b EPI_ADDR_RAM_SIZE_16MB, or \b EPI_ADDR_RAM_SIZE_512MB to choose a
  449. //! RAM address space of 256 bytes, 64 Kbytes, 16 Mbytes or 512 Mbytes
  450. //! - \b EPI_ADDR_RAM_BASE_NONE, \b EPI_ADDR_RAM_BASE_6, or
  451. //! \b EPI_ADDR_RAM_BASE_8 to choose the base address of the RAM space
  452. //! as none, 0x60000000, or 0x80000000
  453. //!
  454. //! \return None.
  455. //
  456. //*****************************************************************************
  457. void
  458. EPIAddressMapSet(unsigned long ulBase, unsigned long ulMap)
  459. {
  460. //
  461. // Check the arguments.
  462. //
  463. ASSERT(ulBase == EPI0_BASE);
  464. ASSERT(ulMap < 0x100);
  465. //
  466. // Set the value of the address mapping register.
  467. //
  468. HWREG(ulBase + EPI_O_ADDRMAP) = ulMap;
  469. }
  470. //*****************************************************************************
  471. //
  472. //! Configures a non-blocking read transaction.
  473. //!
  474. //! \param ulBase is the EPI module base address.
  475. //! \param ulChannel is the read channel (0 or 1).
  476. //! \param ulDataSize is the size of the data items to read.
  477. //! \param ulAddress is the starting address to read.
  478. //!
  479. //! This function is used to configure a non-blocking read channel for a
  480. //! transaction. Two channels are available which can be used in a ping-pong
  481. //! method for continuous reading. It is not necessary to use both channels
  482. //! to perform a non-blocking read.
  483. //!
  484. //! The parameter \e ulDataSize is one of \b EPI_NBCONFIG_SIZE_8,
  485. //! \b EPI_NBCONFIG_SIZE_16, or \b EPI_NBCONFIG_SIZE_32 for 8-bit, 16-bit,
  486. //! or 32-bit sized data transfers.
  487. //!
  488. //! The parameter \e ulAddress is the starting address for the read, relative
  489. //! to the external device. The start of the device is address 0.
  490. //!
  491. //! Once configured, the non-blocking read is started by calling
  492. //! EPINonBlockingReadStart(). If the addresses to be read from the device
  493. //! are in a sequence, it is not necessary to call this function multiple
  494. //! times. Until it is changed, the EPI module will remember the last address
  495. //! that was used for a non-blocking read (per channel).
  496. //!
  497. //! \return None.
  498. //
  499. //*****************************************************************************
  500. void
  501. EPINonBlockingReadConfigure(unsigned long ulBase, unsigned long ulChannel,
  502. unsigned long ulDataSize, unsigned long ulAddress)
  503. {
  504. unsigned long ulOffset;
  505. //
  506. // Check the arguments.
  507. //
  508. ASSERT(ulBase == EPI0_BASE);
  509. ASSERT(ulChannel < 2);
  510. ASSERT(ulDataSize < 4);
  511. ASSERT(ulAddress < 0x20000000);
  512. //
  513. // Compute the offset needed to select the correct channel regs.
  514. //
  515. ulOffset = ulChannel * (EPI_O_RSIZE1 - EPI_O_RSIZE0);
  516. //
  517. // Write the data size register for the channel.
  518. //
  519. HWREG(ulBase + EPI_O_RSIZE0 + ulOffset) = ulDataSize;
  520. //
  521. // Write the starting address register for the channel.
  522. //
  523. HWREG(ulBase + EPI_O_RADDR0 + ulOffset) = ulAddress;
  524. }
  525. //*****************************************************************************
  526. //
  527. //! Starts a non-blocking read transaction.
  528. //!
  529. //! \param ulBase is the EPI module base address.
  530. //! \param ulChannel is the read channel (0 or 1).
  531. //! \param ulCount is the number of items to read (1-4095).
  532. //!
  533. //! This function starts a non-blocking read that was previously configured
  534. //! with the function EPINonBlockingReadConfigure(). Once this function is
  535. //! called, the EPI module will begin reading data from the external device
  536. //! into the read FIFO. The EPI will stop reading when the FIFO fills up
  537. //! and resume reading when the application drains the FIFO, until the
  538. //! total specified count of data items has been read.
  539. //!
  540. //! Once a read transaction is completed and the FIFO drained, another
  541. //! transaction can be started from the next address by calling this
  542. //! function again.
  543. //!
  544. //! \return None.
  545. //
  546. //*****************************************************************************
  547. void
  548. EPINonBlockingReadStart(unsigned long ulBase, unsigned long ulChannel,
  549. unsigned long ulCount)
  550. {
  551. unsigned long ulOffset;
  552. //
  553. // Check the arguments.
  554. //
  555. ASSERT(ulBase == EPI0_BASE);
  556. ASSERT(ulChannel < 2);
  557. ASSERT(ulCount < 4096);
  558. //
  559. // Compute the offset needed to select the correct channel regs.
  560. //
  561. ulOffset = ulChannel * (EPI_O_RPSTD1 - EPI_O_RPSTD0);
  562. //
  563. // Write to the read count register.
  564. //
  565. HWREG(ulBase + EPI_O_RPSTD0 + ulOffset) = ulCount;
  566. }
  567. //*****************************************************************************
  568. //
  569. //! Stops a non-blocking read transaction.
  570. //!
  571. //! \param ulBase is the EPI module base address.
  572. //! \param ulChannel is the read channel (0 or 1).
  573. //!
  574. //! This function cancels a non-blocking read transaction that is already
  575. //! in progress.
  576. //!
  577. //! \return None.
  578. //
  579. //*****************************************************************************
  580. void
  581. EPINonBlockingReadStop(unsigned long ulBase, unsigned long ulChannel)
  582. {
  583. unsigned long ulOffset;
  584. //
  585. // Check the arguments.
  586. //
  587. ASSERT(ulBase == EPI0_BASE);
  588. ASSERT(ulChannel < 2);
  589. //
  590. // Compute the offset needed to select the correct channel regs.
  591. //
  592. ulOffset = ulChannel * (EPI_O_RPSTD1 - EPI_O_RPSTD0);
  593. //
  594. // Write a 0 to the read count register, which will cancel the transaction.
  595. //
  596. HWREG(ulBase + EPI_O_RPSTD0 + ulOffset) = 0;
  597. }
  598. //*****************************************************************************
  599. //
  600. //! Get the count remaining for a non-blocking transaction.
  601. //!
  602. //! \param ulBase is the EPI module base address.
  603. //! \param ulChannel is the read channel (0 or 1).
  604. //!
  605. //! This function gets the remaining count of items for a non-blocking read
  606. //! transaction.
  607. //!
  608. //! \return The number of items remaining in the non-blocking read transaction.
  609. //
  610. //*****************************************************************************
  611. unsigned long
  612. EPINonBlockingReadCount(unsigned long ulBase, unsigned long ulChannel)
  613. {
  614. unsigned long ulOffset;
  615. //
  616. // Check the arguments.
  617. //
  618. ASSERT(ulBase == EPI0_BASE);
  619. ASSERT(ulChannel < 2);
  620. //
  621. // Compute the offset needed to select the correct channel regs.
  622. //
  623. ulOffset = ulChannel * (EPI_O_RPSTD1 - EPI_O_RPSTD0);
  624. //
  625. // Read the count remaining and return the value to the caller.
  626. //
  627. return(HWREG(ulBase + EPI_O_RPSTD0 + ulOffset));
  628. }
  629. //*****************************************************************************
  630. //
  631. //! Get the count of items available in the read FIFO.
  632. //!
  633. //! \param ulBase is the EPI module base address.
  634. //!
  635. //! This function gets the number of items that are available to read in
  636. //! the read FIFO. The read FIFO is filled by a non-blocking read transaction
  637. //! which is configured by the functions EPINonBlockingReadConfigure() and
  638. //! EPINonBlockingReadStart().
  639. //!
  640. //! \return The number of items available to read in the read FIFO.
  641. //
  642. //*****************************************************************************
  643. unsigned long
  644. EPINonBlockingReadAvail(unsigned long ulBase)
  645. {
  646. //
  647. // Check the arguments.
  648. //
  649. ASSERT(ulBase == EPI0_BASE);
  650. //
  651. // Read the FIFO count and return it to the caller.
  652. //
  653. return(HWREG(ulBase + EPI_O_RFIFOCNT));
  654. }
  655. //*****************************************************************************
  656. //
  657. //! Read available data from the read FIFO, as 32-bit data items.
  658. //!
  659. //! \param ulBase is the EPI module base address.
  660. //! \param ulCount is the maximum count of items to read.
  661. //! \param pulBuf is the caller supplied buffer where the read data should
  662. //! be stored.
  663. //!
  664. //! This function reads 32-bit data items from the read FIFO and stores
  665. //! the values in a caller supplied buffer. The function will read and store
  666. //! data from the FIFO until there is no more data in the FIFO or the maximum
  667. //! count is reached as specified in the parameter \e ulCount. The actual
  668. //! count of items is returned.
  669. //!
  670. //! \return The number of items read from the FIFO.
  671. //
  672. //*****************************************************************************
  673. unsigned long
  674. EPINonBlockingReadGet32(unsigned long ulBase, unsigned long ulCount,
  675. unsigned long *pulBuf)
  676. {
  677. unsigned long ulCountRead = 0;
  678. //
  679. // Check the arguments.
  680. //
  681. ASSERT(ulBase == EPI0_BASE);
  682. ASSERT(ulCount < 4096);
  683. ASSERT(pulBuf);
  684. //
  685. // Read from the FIFO while there are any items to read, and
  686. // the callers specified count is not exceeded.
  687. //
  688. while(HWREG(ulBase + EPI_O_RFIFOCNT) && ulCount--)
  689. {
  690. //
  691. // Read from the FIFO and store in the caller supplied buffer.
  692. //
  693. *pulBuf = HWREG(ulBase + EPI_O_READFIFO);
  694. //
  695. // Update the caller's buffer pointer and the count of items read.
  696. //
  697. pulBuf++;
  698. ulCountRead++;
  699. }
  700. //
  701. // Return the count of items read to the caller.
  702. //
  703. return(ulCountRead);
  704. }
  705. //*****************************************************************************
  706. //
  707. //! Read available data from the read FIFO, as 16-bit data items.
  708. //!
  709. //! \param ulBase is the EPI module base address.
  710. //! \param ulCount is the maximum count of items to read.
  711. //! \param pusBuf is the caller supplied buffer where the read data should
  712. //! be stored.
  713. //!
  714. //! This function reads 16-bit data items from the read FIFO and stores
  715. //! the values in a caller supplied buffer. The function will read and store
  716. //! data from the FIFO until there is no more data in the FIFO or the maximum
  717. //! count is reached as specified in the parameter \e ulCount. The actual
  718. //! count of items is returned.
  719. //!
  720. //! \return The number of items read from the FIFO.
  721. //
  722. //*****************************************************************************
  723. unsigned long
  724. EPINonBlockingReadGet16(unsigned long ulBase, unsigned long ulCount,
  725. unsigned short *pusBuf)
  726. {
  727. unsigned long ulCountRead = 0;
  728. //
  729. // Check the arguments.
  730. //
  731. ASSERT(ulBase == EPI0_BASE);
  732. ASSERT(ulCount < 4096);
  733. ASSERT(pusBuf);
  734. //
  735. // Read from the FIFO while there are any items to read, and
  736. // the callers specified count is not exceeded.
  737. //
  738. while(HWREG(ulBase + EPI_O_RFIFOCNT) && ulCount--)
  739. {
  740. //
  741. // Read from the FIFO and store in the caller supplied buffer.
  742. //
  743. *pusBuf = (unsigned short)HWREG(ulBase + EPI_O_READFIFO);
  744. //
  745. // Update the caller's buffer pointer and the count of items read.
  746. //
  747. pusBuf++;
  748. ulCountRead++;
  749. }
  750. //
  751. // Return the count of items read to the caller.
  752. //
  753. return(ulCountRead);
  754. }
  755. //*****************************************************************************
  756. //
  757. //! Read available data from the read FIFO, as 8-bit data items.
  758. //!
  759. //! \param ulBase is the EPI module base address.
  760. //! \param ulCount is the maximum count of items to read.
  761. //! \param pucBuf is the caller supplied buffer where the read data should
  762. //! be stored.
  763. //!
  764. //! This function reads 8-bit data items from the read FIFO and stores
  765. //! the values in a caller supplied buffer. The function will read and store
  766. //! data from the FIFO until there is no more data in the FIFO or the maximum
  767. //! count is reached as specified in the parameter \e ulCount. The actual
  768. //! count of items is returned.
  769. //!
  770. //! \return The number of items read from the FIFO.
  771. //
  772. //*****************************************************************************
  773. unsigned long
  774. EPINonBlockingReadGet8(unsigned long ulBase, unsigned long ulCount,
  775. unsigned char *pucBuf)
  776. {
  777. unsigned long ulCountRead = 0;
  778. //
  779. // Check the arguments.
  780. //
  781. ASSERT(ulBase == EPI0_BASE);
  782. ASSERT(ulCount < 4096);
  783. ASSERT(pucBuf);
  784. //
  785. // Read from the FIFO while there are any items to read, and
  786. // the callers specified count is not exceeded.
  787. //
  788. while(HWREG(ulBase + EPI_O_RFIFOCNT) && ulCount--)
  789. {
  790. //
  791. // Read from the FIFO and store in the caller supplied buffer.
  792. //
  793. *pucBuf = (unsigned char)HWREG(ulBase + EPI_O_READFIFO);
  794. //
  795. // Update the caller's buffer pointer and the count of items read.
  796. //
  797. pucBuf++;
  798. ulCountRead++;
  799. }
  800. //
  801. // Return the count of items read to the caller.
  802. //
  803. return(ulCountRead);
  804. }
  805. //*****************************************************************************
  806. //
  807. //! Configures the read FIFO.
  808. //!
  809. //! \param ulBase is the EPI module base address.
  810. //! \param ulConfig is the FIFO configuration.
  811. //!
  812. //! This function configures the FIFO trigger levels and error
  813. //! generation. The parameter \e ulConfig is the logical OR of the
  814. //! following:
  815. //!
  816. //! - \b EPI_FIFO_CONFIG_WTFULLERR - enables an error interrupt when a write is
  817. //! attempted and the write FIFO is full
  818. //! - \b EPI_FIFO_CONFIG_RSTALLERR - enables an error interrupt when a read is
  819. //! stalled due to an interleaved write or other reason
  820. //! - \b EPI_FIFO_CONFIG_TX_EMPTY, \b EPI_FIFO_CONFIG_TX_1_4,
  821. //! \b EPI_FIFO_CONFIG_TX_1_2, or \b EPI_FIFO_CONFIG_TX_3_4 to set the
  822. //! TX FIFO trigger level to empty, 1/4, 1/2, or 3/4 level
  823. //! - \b EPI_FIFO_CONFIG_RX_1_8, \b EPI_FIFO_CONFIG_RX_1_4,
  824. //! \b EPI_FIFO_CONFIG_RX_1_2, \b EPI_FIFO_CONFIG_RX_3_4,
  825. //! \b EPI_FIFO_CONFIG_RX_7_8, or \b EPI_FIFO_CONFIG_RX_FULL to set the
  826. //! RX FIFO trigger level to 1/8, 1/4, 1/2, 3/4, 7/8 or full level
  827. //!
  828. //! \return None.
  829. //
  830. //*****************************************************************************
  831. void
  832. EPIFIFOConfig(unsigned long ulBase, unsigned long ulConfig)
  833. {
  834. //
  835. // Check the arguments.
  836. //
  837. ASSERT(ulBase == EPI0_BASE);
  838. ASSERT(ulConfig == (ulConfig & 0x00030077));
  839. //
  840. // Load the configuration into the FIFO config reg.
  841. //
  842. HWREG(ulBase + EPI_O_FIFOLVL) = ulConfig;
  843. }
  844. //*****************************************************************************
  845. //
  846. //! Reads the number of empty slots in the write transaction FIFO.
  847. //!
  848. //! \param ulBase is the EPI module base address.
  849. //!
  850. //! This function returns the number of slots available in the transaction
  851. //! FIFO. It can be used in a polling method to avoid attempting a write
  852. //! that would stall.
  853. //!
  854. //! \return The number of empty slots in the transaction FIFO.
  855. //
  856. //*****************************************************************************
  857. unsigned long
  858. EPIWriteFIFOCountGet(unsigned long ulBase)
  859. {
  860. //
  861. // Check the arguments.
  862. //
  863. ASSERT(ulBase == EPI0_BASE);
  864. //
  865. // Read the FIFO count and return it to the caller.
  866. //
  867. return(HWREG(ulBase + EPI_O_WFIFOCNT));
  868. }
  869. //*****************************************************************************
  870. //
  871. //! Enables EPI interrupt sources.
  872. //!
  873. //! \param ulBase is the EPI module base address.
  874. //! \param ulIntFlags is a bit mask of the interrupt sources to be enabled.
  875. //!
  876. //! This function enables the specified EPI sources to generate interrupts.
  877. //! The \e ulIntFlags parameter can be the logical OR of any of the following
  878. //! values:
  879. //!
  880. //! - \b EPI_INT_TXREQ - transmit FIFO is below the trigger level
  881. //! - \b EPI_INT_RXREQ - read FIFO is above the trigger level
  882. //! - \b EPI_INT_ERR - an error condition occurred
  883. //!
  884. //! \return Returns None.
  885. //
  886. //*****************************************************************************
  887. void
  888. EPIIntEnable(unsigned long ulBase, unsigned long ulIntFlags)
  889. {
  890. //
  891. // Check the arguments.
  892. //
  893. ASSERT(ulBase == EPI0_BASE);
  894. ASSERT(ulIntFlags < 16);
  895. //
  896. // Write the interrupt flags mask to the mask register.
  897. //
  898. HWREG(ulBase + EPI_O_IM) |= ulIntFlags;
  899. }
  900. //*****************************************************************************
  901. //
  902. //! Disables EPI interrupt sources.
  903. //!
  904. //! \param ulBase is the EPI module base address.
  905. //! \param ulIntFlags is a bit mask of the interrupt sources to be disabled.
  906. //!
  907. //! This function disables the specified EPI sources for interrupt
  908. //! generation. The \e ulIntFlags parameter can be the logical OR
  909. //! of any of the following values: \b EPI_INT_RXREQ, \b EPI_INT_TXREQ, or
  910. //! \b I2S_INT_ERR.
  911. //!
  912. //! \return Returns None.
  913. //
  914. //*****************************************************************************
  915. void
  916. EPIIntDisable(unsigned long ulBase, unsigned long ulIntFlags)
  917. {
  918. //
  919. // Check the arguments.
  920. //
  921. ASSERT(ulBase == EPI0_BASE);
  922. ASSERT(ulIntFlags < 16);
  923. //
  924. // Write the interrupt flags mask to the mask register.
  925. //
  926. HWREG(ulBase + EPI_O_IM) &= ~ulIntFlags;
  927. }
  928. //*****************************************************************************
  929. //
  930. //! Gets the EPI interrupt status.
  931. //!
  932. //! \param ulBase is the EPI module base address.
  933. //! \param bMasked is set \b true to get the masked interrupt status, or
  934. //! \b false to get the raw interrupt status.
  935. //!
  936. //! This function returns the EPI interrupt status. It can return either
  937. //! the raw or masked interrupt status.
  938. //!
  939. //! \return Returns the masked or raw EPI interrupt status, as a bit field
  940. //! of any of the following values: \b EPI_INT_TXREQ, \b EPI_INT_RXREQ,
  941. //! or \b EPI_INT_ERR
  942. //
  943. //*****************************************************************************
  944. unsigned long
  945. EPIIntStatus(unsigned long ulBase, tBoolean bMasked)
  946. {
  947. //
  948. // Check the arguments.
  949. //
  950. ASSERT(ulBase == EPI0_BASE);
  951. //
  952. // Return either the interrupt status or the raw interrupt status as
  953. // requested.
  954. //
  955. if(bMasked)
  956. {
  957. return(HWREG(ulBase + EPI_O_MIS));
  958. }
  959. else
  960. {
  961. return(HWREG(ulBase + EPI_O_RIS));
  962. }
  963. }
  964. //*****************************************************************************
  965. //
  966. //! Gets the EPI error interrupt status.
  967. //!
  968. //! \param ulBase is the EPI module base address.
  969. //!
  970. //! This function returns the error status of the EPI. If the return value of
  971. //! the function EPIIntStatus() has the flag \b EPI_INT_ERR set, then this
  972. //! function can be used to determine the cause of the error.
  973. //!
  974. //! This function returns a bit mask of error flags, which can be the logical
  975. //! OR of any of the following:
  976. //!
  977. //! - \b EPI_INT_ERR_WTFULL - occurs when a write stalled when the transaction
  978. //! FIFO was full
  979. //! - \b EPI_INT_ERR_RSTALL - occurs when a read stalled
  980. //! - \b EPI_INT_ERR_TIMEOUT - occurs when the external clock enable held
  981. //! off a transaction longer than the configured maximum wait time
  982. //!
  983. //! \return Returns the interrupt error flags as the logical OR of any of
  984. //! the following: \b EPI_INT_ERR_WTFULL, \b EPI_INT_ERR_RSTALL, or
  985. //! \b EPI_INT_ERR_TIMEOUT.
  986. //
  987. //*****************************************************************************
  988. unsigned long
  989. EPIIntErrorStatus(unsigned long ulBase)
  990. {
  991. //
  992. // Check the arguments.
  993. //
  994. ASSERT(ulBase == EPI0_BASE);
  995. //
  996. // Read the error status and return to caller.
  997. //
  998. return(HWREG(ulBase + EPI_O_EISC));
  999. }
  1000. //*****************************************************************************
  1001. //
  1002. //! Clears pending EPI error sources.
  1003. //!
  1004. //! \param ulBase is the EPI module base address.
  1005. //! \param ulErrFlags is a bit mask of the error sources to be cleared.
  1006. //!
  1007. //! This function clears the specified pending EPI errors. The \e ulErrFlags
  1008. //! parameter can be the logical OR of any of the following values:
  1009. //! \b EPI_INT_ERR_WTFULL, \b EPI_INT_ERR_RSTALL, or \b EPI_INT_ERR_TIMEOUT.
  1010. //!
  1011. //! \return Returns None.
  1012. //
  1013. //*****************************************************************************
  1014. void
  1015. EPIIntErrorClear(unsigned long ulBase, unsigned long ulErrFlags)
  1016. {
  1017. //
  1018. // Check the arguments.
  1019. //
  1020. ASSERT(ulBase == EPI0_BASE);
  1021. ASSERT(ulErrFlags < 16);
  1022. //
  1023. // Write the error flags to the register to clear the pending errors.
  1024. //
  1025. HWREG(ulBase + EPI_O_EISC) = ulErrFlags;
  1026. }
  1027. //*****************************************************************************
  1028. //
  1029. //! Registers an interrupt handler for the EPI module.
  1030. //!
  1031. //! \param ulBase is the EPI module base address.
  1032. //! \param pfnHandler is a pointer to the function to be called when the
  1033. //! interrupt is activated.
  1034. //!
  1035. //! This sets and enables the handler to be called when the EPI module
  1036. //! generates an interrupt. Specific EPI interrupts must still be enabled
  1037. //! with the EPIIntEnable() function.
  1038. //!
  1039. //! \sa IntRegister() for important information about registering interrupt
  1040. //! handlers.
  1041. //!
  1042. //! \return None.
  1043. //
  1044. //*****************************************************************************
  1045. void
  1046. EPIIntRegister(unsigned long ulBase, void (*pfnHandler)(void))
  1047. {
  1048. //
  1049. // Check the arguments.
  1050. //
  1051. ASSERT(ulBase == EPI0_BASE);
  1052. ASSERT(pfnHandler);
  1053. //
  1054. // Register the interrupt handler.
  1055. //
  1056. IntRegister(INT_EPI0, pfnHandler);
  1057. //
  1058. // Enable the EPI interface interrupt.
  1059. //
  1060. IntEnable(INT_EPI0);
  1061. }
  1062. //*****************************************************************************
  1063. //
  1064. //! Unregisters an interrupt handler for the EPI module.
  1065. //!
  1066. //! \param ulBase is the EPI module base address.
  1067. //!
  1068. //! This function will disable and clear the handler to be called when the
  1069. //! EPI interrupt occurs.
  1070. //!
  1071. //! \sa IntRegister() for important information about registering interrupt
  1072. //! handlers.
  1073. //!
  1074. //! \return None.
  1075. //
  1076. //*****************************************************************************
  1077. void
  1078. EPIIntUnregister(unsigned long ulBase)
  1079. {
  1080. //
  1081. // Check the arguments.
  1082. //
  1083. ASSERT(ulBase == EPI0_BASE);
  1084. //
  1085. // Disable the EPI interface interrupt.
  1086. //
  1087. IntDisable(INT_EPI0);
  1088. //
  1089. // Unregister the interrupt handler.
  1090. //
  1091. IntUnregister(INT_EPI0);
  1092. }
  1093. //*****************************************************************************
  1094. //
  1095. // Close the Doxygen group.
  1096. //! @}
  1097. //
  1098. //*****************************************************************************