am_hal_iom.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. //*****************************************************************************
  2. //
  3. // am_hal_iom.h
  4. //! @file
  5. //!
  6. //! @brief Functions for accessing and configuring the IO Master module
  7. //!
  8. //! @addtogroup iom2 IO Master (SPI/I2C)
  9. //! @ingroup apollo2hal
  10. //! @{
  11. //*****************************************************************************
  12. //*****************************************************************************
  13. //
  14. // Copyright (c) 2017, Ambiq Micro
  15. // All rights reserved.
  16. //
  17. // Redistribution and use in source and binary forms, with or without
  18. // modification, are permitted provided that the following conditions are met:
  19. //
  20. // 1. Redistributions of source code must retain the above copyright notice,
  21. // this list of conditions and the following disclaimer.
  22. //
  23. // 2. Redistributions in binary form must reproduce the above copyright
  24. // notice, this list of conditions and the following disclaimer in the
  25. // documentation and/or other materials provided with the distribution.
  26. //
  27. // 3. Neither the name of the copyright holder nor the names of its
  28. // contributors may be used to endorse or promote products derived from this
  29. // software without specific prior written permission.
  30. //
  31. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  32. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  33. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  34. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  35. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  36. // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  37. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  38. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  39. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  40. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  41. // POSSIBILITY OF SUCH DAMAGE.
  42. //
  43. // This is part of revision 1.2.9 of the AmbiqSuite Development Package.
  44. //
  45. //*****************************************************************************
  46. #ifndef AM_HAL_IOM_H
  47. #define AM_HAL_IOM_H
  48. //*****************************************************************************
  49. //
  50. // Macro definitions
  51. //
  52. //*****************************************************************************
  53. //*****************************************************************************
  54. //
  55. //! @name IOM Clock Frequencies
  56. //! @brief Macro definitions for common SPI and I2C clock frequencies.
  57. //!
  58. //! These macros may be used with the ui32ClockFrequency member of the
  59. //! am_hal_iom_config_t structure to set the clock frequency of the serial
  60. //! interfaces.
  61. //!
  62. //! This list of frequencies is not exhaustive by any means. If your desired
  63. //! frequency is not in this list, simply set ui32ClockFrequency to the
  64. //! desired frequency (in Hz) when calling am_hal_iom_config().
  65. //
  66. //*****************************************************************************
  67. #define AM_HAL_IOM_24MHZ 24000000
  68. #define AM_HAL_IOM_16MHZ 16000000
  69. #define AM_HAL_IOM_12MHZ 12000000
  70. #define AM_HAL_IOM_8MHZ 8000000
  71. #define AM_HAL_IOM_6MHZ 6000000
  72. #define AM_HAL_IOM_4MHZ 4000000
  73. #define AM_HAL_IOM_3MHZ 3000000
  74. #define AM_HAL_IOM_2MHZ 2000000
  75. #define AM_HAL_IOM_1_5MHZ 1500000
  76. #define AM_HAL_IOM_1MHZ 1000000
  77. #define AM_HAL_IOM_750KHZ 750000
  78. #define AM_HAL_IOM_500KHZ 500000
  79. #define AM_HAL_IOM_400KHZ 400000
  80. #define AM_HAL_IOM_375KHZ 375000
  81. #define AM_HAL_IOM_250KHZ 250000
  82. #define AM_HAL_IOM_125KHZ 125000
  83. #define AM_HAL_IOM_100KHZ 100000
  84. #define AM_HAL_IOM_50KHZ 50000
  85. #define AM_HAL_IOM_10KHZ 10000
  86. // Hardware FIFO Size
  87. #define AM_HAL_IOM_MAX_FIFO_SIZE 128
  88. //*****************************************************************************
  89. //
  90. //! @name IOM Physical Protocols
  91. //! @brief Macro Definitions for general IOM configuration.
  92. //!
  93. //! These macros may be used with the am_hal_iom_config_t structure to set the
  94. //! operating parameters of each serial IO master module. Choose SPIMODE to
  95. //! select the SPI interface, or I2CMODE to select the I2C interface.
  96. //!
  97. //! @{
  98. //
  99. //*****************************************************************************
  100. #define AM_HAL_IOM_SPIMODE AM_REG_IOMSTR_CFG_IFCSEL(1)
  101. #define AM_HAL_IOM_I2CMODE AM_REG_IOMSTR_CFG_IFCSEL(0)
  102. //! @}
  103. //*****************************************************************************
  104. //
  105. //! @name IOM Operations
  106. //! @brief Macro definitions used for ui32Operation parameters.
  107. //!
  108. //! These macros may be used to specify which action an IOM command will
  109. //! execute. The 'OFFSET' operations will cause the IOM hardware to transmit the
  110. //! provided 1-byte 'offset' before executing the rest of the command.
  111. //!
  112. //! @{
  113. //
  114. //*****************************************************************************
  115. #define AM_HAL_IOM_WRITE 0x00000000
  116. #define AM_HAL_IOM_READ 0x80000000
  117. //! @}
  118. //*****************************************************************************
  119. //
  120. //! @name Command Options
  121. //! @brief Macro definitions used for ui32Options parameters.
  122. //!
  123. //! These macros are all related to SPI or I2C command words. They can be used
  124. //! to set specific options on a per-transaction basis.
  125. //!
  126. //! - CS_LOW - Do not raise the CS signal at the end of this SPI command.
  127. //! - NO_STOP - Do not release the I2C bus with a STOP bit after this command.
  128. //! - LSB_FIRST - Reverse the payload bits of this command.
  129. //! - 10BIT_ADDRESS - (I2C only) use a 10-bit I2C address protocol.
  130. //! - RAW - Don't use an offset byte.
  131. //! - OFFSET() - Send this 1-byte offset as the first byte of the transaction.
  132. //! This can be used to access "registers" in external I2C devices, or add a
  133. //! 1-byte write to the beginning of a SPI write or read command. See
  134. //! "normal mode" operation in the I2C/SPI Master section of the datasheet
  135. //! for more information on this parameter.
  136. //!
  137. //! @{
  138. //
  139. //*****************************************************************************
  140. #define AM_HAL_IOM_CS_LOW 0x10000000
  141. #define AM_HAL_IOM_NO_STOP 0x10000000
  142. #define AM_HAL_IOM_LSB_FIRST 0x08000000
  143. #define AM_HAL_IOM_10BIT_ADDRESS 0x04000000
  144. #define AM_HAL_IOM_RAW 0x40000000
  145. #define AM_HAL_IOM_OFFSET(n) (((n) << 8) & 0x0000FF00)
  146. //! @}
  147. //*****************************************************************************
  148. //
  149. //! @name IOM Interrupts
  150. //! @brief Macro definitions for IOM interrupt status bits.
  151. //!
  152. //! These macros correspond to the bits in the IOM interrupt status register.
  153. //! They may be used with any of the \e am_hal_iom_int_x() functions.
  154. //!
  155. //! @{
  156. //
  157. //*****************************************************************************
  158. #define AM_HAL_IOM_INT_ARB AM_REG_IOMSTR_INTEN_ARB_M
  159. #define AM_HAL_IOM_INT_STOP AM_REG_IOMSTR_INTEN_STOP_M
  160. #define AM_HAL_IOM_INT_START AM_REG_IOMSTR_INTEN_START_M
  161. #define AM_HAL_IOM_INT_ICMD AM_REG_IOMSTR_INTEN_ICMD_M
  162. #define AM_HAL_IOM_INT_IACC AM_REG_IOMSTR_INTEN_IACC_M
  163. #define AM_HAL_IOM_INT_WTLEN AM_REG_IOMSTR_INTEN_WTLEN_M
  164. #define AM_HAL_IOM_INT_NAK AM_REG_IOMSTR_INTEN_NAK_M
  165. #define AM_HAL_IOM_INT_FOVFL AM_REG_IOMSTR_INTEN_FOVFL_M
  166. #define AM_HAL_IOM_INT_FUNDFL AM_REG_IOMSTR_INTEN_FUNDFL_M
  167. #define AM_HAL_IOM_INT_THR AM_REG_IOMSTR_INTEN_THR_M
  168. #define AM_HAL_IOM_INT_CMDCMP AM_REG_IOMSTR_INTEN_CMDCMP_M
  169. //! @}
  170. //*****************************************************************************
  171. //
  172. //! @name IOM function errors
  173. //! @brief Return values for IOM HAL function errors, such as with the function
  174. //! am_hal_iom_error_status_get().
  175. //!
  176. //! @{
  177. //
  178. //*****************************************************************************
  179. #define AM_HAL_IOM_ERR_INVALID_MODULE (1 << 30)
  180. //! @}
  181. //*****************************************************************************
  182. //
  183. //! @name Software IOM modules
  184. //! @brief Macro definitions for using the software I2C interface.
  185. //!
  186. //! Use this macro as the module number for standard IOM functions to emulate
  187. //! them using the bit-banged i2c interface.
  188. //!
  189. //! @{
  190. //
  191. //*****************************************************************************
  192. #define AM_HAL_IOM_I2CBB_MODULE AM_REG_IOMSTR_NUM_MODULES
  193. //! @}
  194. //*****************************************************************************
  195. //
  196. //! @brief Union type for a word-aligned, byte-addressable array.
  197. //!
  198. //! This is a convenience macro that may be used to define byte-addressable
  199. //! arrays with 32-bit alignment. This allows the programmer to define SPI or
  200. //! I2C transactions as a series of 8-bit values, but also write them to the
  201. //! IOM FIFO efficiently as a series of 32-bit values.
  202. //!
  203. //! Example usage:
  204. //!
  205. //! @code
  206. //! //
  207. //! // Declare a buffer array with at least 3-bytes worth of space.
  208. //! //
  209. //! am_hal_iom_buffer(3) sBuffer;
  210. //!
  211. //! //
  212. //! // Populate the buffer with a 3-byte command.
  213. //! //
  214. //! sBuffer.bytes[0] = 's';
  215. //! sBuffer.bytes[1] = 'p';
  216. //! sBuffer.bytes[2] = 'i';
  217. //!
  218. //! //
  219. //! // Send the buffer over the spi interface.
  220. //! //
  221. //! am_hal_iom_spi_write(psDevice, sBuffer.words, 3, 0);
  222. //!
  223. //! @endcode
  224. //
  225. //*****************************************************************************
  226. #define am_hal_iom_buffer(A) \
  227. union \
  228. { \
  229. uint32_t words[(A + 3) >> 2]; \
  230. uint8_t bytes[A]; \
  231. }
  232. //*****************************************************************************
  233. //
  234. //! @brief Configuration structure for the IO master module.
  235. //
  236. //*****************************************************************************
  237. typedef struct
  238. {
  239. //
  240. //! @brief Selects the physical protocol for the IO master module. Choose
  241. //! either AM_HAL_IOM_SPIMODE or AM_HAL_IOM_I2CMODE.
  242. //
  243. uint32_t ui32InterfaceMode;
  244. //
  245. //! @brief Selects the output clock frequency for SPI or I2C mode. Choose
  246. //! one of the AM_HAL_IOM_nMHZ or AM_HAL_IOM_nKHZ macros.
  247. //
  248. uint32_t ui32ClockFrequency;
  249. //
  250. //! Select the SPI clock phase (unused in I2C mode).
  251. //
  252. bool bSPHA;
  253. //
  254. //! Select the SPI clock polarity (unused in I2C mode).
  255. //
  256. bool bSPOL;
  257. //
  258. //! @brief Select the FIFO write threshold.
  259. //!
  260. //! The IOM controller will generate a processor interrupt when the number
  261. //! of entries in the FIFO goes *below* this number.
  262. //
  263. uint8_t ui8WriteThreshold;
  264. //
  265. //! @brief Select the FIFO read threshold.
  266. //!
  267. //! The IOM controller will generate a processor interrupt when the number
  268. //! of entries in the FIFO grows *larger* than this number.
  269. //
  270. uint8_t ui8ReadThreshold;
  271. }
  272. am_hal_iom_config_t;
  273. //*****************************************************************************
  274. //
  275. //! Configuration structure for an individual SPI device.
  276. //
  277. //*****************************************************************************
  278. typedef struct
  279. {
  280. //
  281. //! IOM module to use for communicating with this device.
  282. //
  283. uint32_t ui32Module;
  284. //
  285. //! Chip select signal that should be used for this device.
  286. //
  287. uint32_t ui32ChipSelect;
  288. //
  289. //! Additional options that will ALWAYS be ORed into the command word.
  290. //
  291. uint32_t ui32Options;
  292. }
  293. am_hal_iom_spi_device_t;
  294. //*****************************************************************************
  295. //
  296. //! Configuration structure for an individual I2C device.
  297. //
  298. //*****************************************************************************
  299. typedef struct
  300. {
  301. //
  302. //! IOM module to use for communicating with this device.
  303. //
  304. uint32_t ui32Module;
  305. //
  306. //! I2C address associated with this device.
  307. //
  308. uint32_t ui32BusAddress;
  309. //
  310. //! Additional options that will ALWAYS be ORed into the command word.
  311. //
  312. uint32_t ui32Options;
  313. }
  314. am_hal_iom_i2c_device_t;
  315. //*****************************************************************************
  316. //
  317. // Typedef for non-blocking function callbacks.
  318. //
  319. //*****************************************************************************
  320. typedef void (*am_hal_iom_callback_t)(void);
  321. //*****************************************************************************
  322. //
  323. // Typedef for a function that waits until the IOM queue is empty.
  324. //
  325. //*****************************************************************************
  326. typedef void (*am_hal_iom_queue_flush_t)(uint32_t);
  327. extern am_hal_iom_queue_flush_t am_hal_iom_queue_flush;
  328. //*****************************************************************************
  329. //
  330. // Operations
  331. //
  332. //*****************************************************************************
  333. #define AM_HAL_IOM_QUEUE_SPI_WRITE 0
  334. #define AM_HAL_IOM_QUEUE_SPI_READ 1
  335. #define AM_HAL_IOM_QUEUE_I2C_WRITE 2
  336. #define AM_HAL_IOM_QUEUE_I2C_READ 3
  337. //*****************************************************************************
  338. //
  339. // Structure to hold IOM operations.
  340. //
  341. //*****************************************************************************
  342. typedef struct
  343. {
  344. uint32_t ui32Operation;
  345. uint32_t ui32Module;
  346. uint32_t ui32ChipSelect;
  347. uint32_t *pui32Data;
  348. uint32_t ui32NumBytes;
  349. uint32_t ui32Options;
  350. am_hal_iom_callback_t pfnCallback;
  351. }
  352. am_hal_iom_queue_entry_t;
  353. //*****************************************************************************
  354. //
  355. // Structure to hold IOM configuration during module power-down.
  356. //
  357. //*****************************************************************************
  358. typedef struct
  359. {
  360. uint32_t FIFOTHR;
  361. uint32_t CLKCFG;
  362. uint32_t CFG;
  363. uint32_t INTEN;
  364. uint32_t bValid;
  365. }
  366. am_hal_iom_pwrsave_t;
  367. //*****************************************************************************
  368. //
  369. // Global variables
  370. //
  371. //*****************************************************************************
  372. extern am_hal_iom_pwrsave_t am_hal_iom_pwrsave[AM_REG_IOMSTR_NUM_MODULES];
  373. extern uint32_t g_iom_error_status;
  374. //*****************************************************************************
  375. //
  376. // External function definitions
  377. //
  378. //*****************************************************************************
  379. extern void am_hal_iom_pwrctrl_enable(uint32_t ui32Module);
  380. extern void am_hal_iom_pwrctrl_disable(uint32_t ui32Module);
  381. extern void am_hal_iom_power_on_restore(uint32_t ui32Module);
  382. extern void am_hal_iom_power_off_save(uint32_t ui32Module);
  383. extern void am_hal_iom_config(uint32_t ui32Module,
  384. const am_hal_iom_config_t *psConfig);
  385. extern uint32_t am_hal_iom_frequency_get(uint32_t ui32Module);
  386. extern void am_hal_iom_enable(uint32_t ui32Module);
  387. extern void am_hal_iom_disable(uint32_t ui32Module);
  388. extern void am_hal_iom_spi_write(uint32_t ui32Module, uint32_t ui32ChipSelect,
  389. uint32_t *pui32Data, uint32_t ui32NumBytes,
  390. uint32_t ui32Options);
  391. extern void am_hal_iom_spi_read(uint32_t ui32Module, uint32_t ui32ChipSelect,
  392. uint32_t *pui32Data, uint32_t ui32NumBytes,
  393. uint32_t ui32Options);
  394. extern uint32_t am_hal_iom_spi_write_nq(uint32_t ui32Module, uint32_t ui32ChipSelect,
  395. uint32_t *pui32Data, uint32_t ui32NumBytes,
  396. uint32_t ui32Options);
  397. extern uint32_t am_hal_iom_spi_read_nq(uint32_t ui32Module, uint32_t ui32ChipSelect,
  398. uint32_t *pui32Data, uint32_t ui32NumBytes,
  399. uint32_t ui32Options);
  400. extern void am_hal_iom_spi_write_nb(uint32_t ui32Module, uint32_t ui32ChipSelect,
  401. uint32_t *pui32Data, uint32_t ui32NumBytes,
  402. uint32_t ui32Options,
  403. am_hal_iom_callback_t pfnCallback);
  404. extern uint32_t am_hal_iom_spi_read_nb(uint32_t ui32Module, uint32_t ui32ChipSelect,
  405. uint32_t *pui32Data, uint32_t ui32NumBytes,
  406. uint32_t ui32Options,
  407. am_hal_iom_callback_t pfnCallback);
  408. extern void am_hal_iom_spi_cmd_run(uint32_t ui32Operation,
  409. uint32_t ui32Module,
  410. uint32_t ui32ChipSelect,
  411. uint32_t ui32NumBytes,
  412. uint32_t ui32Options);
  413. extern void am_hal_iom_i2c_write(uint32_t ui32Module,
  414. uint32_t ui32BusAddress,
  415. uint32_t *pui32Data,
  416. uint32_t ui32NumBytes,
  417. uint32_t ui32Options);
  418. extern void am_hal_iom_i2c_read(uint32_t ui32Module,
  419. uint32_t ui32BusAddress,
  420. uint32_t *pui32Data,
  421. uint32_t ui32NumBytes,
  422. uint32_t ui32Options);
  423. extern uint32_t am_hal_iom_i2c_write_nq(uint32_t ui32Module,
  424. uint32_t ui32BusAddress,
  425. uint32_t *pui32Data,
  426. uint32_t ui32NumBytes,
  427. uint32_t ui32Options);
  428. extern uint32_t am_hal_iom_i2c_read_nq(uint32_t ui32Module,
  429. uint32_t ui32BusAddress,
  430. uint32_t *pui32Data,
  431. uint32_t ui32NumBytes,
  432. uint32_t ui32Options);
  433. extern void am_hal_iom_i2c_write_nb(uint32_t ui32Module,
  434. uint32_t ui32BusAddress,
  435. uint32_t *pui32Data,
  436. uint32_t ui32NumBytes,
  437. uint32_t ui32Options,
  438. am_hal_iom_callback_t pfnCallback);
  439. extern void am_hal_iom_i2c_read_nb(uint32_t ui32Module,
  440. uint32_t ui32BusAddress,
  441. uint32_t *pui32Data,
  442. uint32_t ui32NumBytes,
  443. uint32_t ui32Options,
  444. am_hal_iom_callback_t pfnCallback);
  445. extern void am_hal_iom_i2c_cmd_run(uint32_t ui32Operation,
  446. uint32_t ui32Module,
  447. uint32_t ui32BusAddress,
  448. uint32_t ui32NumBytes,
  449. uint32_t ui32Options);
  450. extern void am_hal_iom_command_repeat_set(uint32_t ui32Module,
  451. uint32_t ui32CmdCount);
  452. extern uint32_t am_hal_iom_status_get(uint32_t ui32Module);
  453. extern uint32_t am_hal_iom_error_status_get(uint32_t ui32Module);
  454. extern uint32_t am_hal_iom_fifo_write(uint32_t ui32Module, uint32_t *pui32Data,
  455. uint32_t ui32NumBytes);
  456. extern uint32_t am_hal_iom_fifo_read(uint32_t ui32Module, uint32_t *pui32Data,
  457. uint32_t ui32NumBytes);
  458. extern uint8_t am_hal_iom_fifo_empty_slots(uint32_t ui32Module);
  459. extern uint8_t am_hal_iom_fifo_full_slots(uint32_t ui32Module);
  460. extern void am_hal_iom_poll_complete(uint32_t ui32Module);
  461. extern void am_hal_iom_int_service(uint32_t ui32Module, uint32_t ui32Status);
  462. extern void am_hal_iom_int_enable(uint32_t ui32Module, uint32_t ui32Interrupt);
  463. extern uint32_t am_hal_iom_int_enable_get(uint32_t ui32Module);
  464. extern void am_hal_iom_int_disable(uint32_t ui32Module, uint32_t ui32Interrupt);
  465. extern void am_hal_iom_int_clear(uint32_t ui32Module, uint32_t ui32Interrupt);
  466. extern void am_hal_iom_int_set(uint32_t ui32Module, uint32_t ui32Interrupt);
  467. extern uint32_t am_hal_iom_int_status_get(uint32_t ui32Module, bool bEnabledOnly);
  468. extern void am_hal_iom_queue_init(uint32_t ui32ModuleNum,
  469. am_hal_iom_queue_entry_t *psQueueMemory,
  470. uint32_t ui32QueueMemSize);
  471. extern uint32_t am_hal_iom_queue_length_get(uint32_t ui32Module);
  472. extern void am_hal_iom_sleeping_queue_flush(uint32_t ui32Module);
  473. extern void am_hal_iom_queue_spi_write(uint32_t ui32Module, uint32_t ui32ChipSelect,
  474. uint32_t *pui32Data, uint32_t ui32NumBytes,
  475. uint32_t ui32Options,
  476. am_hal_iom_callback_t pfnCallback);
  477. extern void am_hal_iom_queue_spi_read(uint32_t ui32Module, uint32_t ui32ChipSelect,
  478. uint32_t *pui32Data, uint32_t ui32NumBytes,
  479. uint32_t ui32Options,
  480. am_hal_iom_callback_t pfnCallback);
  481. extern void am_hal_iom_queue_i2c_write(uint32_t ui32Module, uint32_t ui32BusAddress,
  482. uint32_t *pui32Data, uint32_t ui32NumBytes,
  483. uint32_t ui32Options,
  484. am_hal_iom_callback_t pfnCallback);
  485. extern void am_hal_iom_queue_i2c_read(uint32_t ui32Module, uint32_t ui32BusAddress,
  486. uint32_t *pui32Data, uint32_t ui32NumBytes,
  487. uint32_t ui32Options,
  488. am_hal_iom_callback_t pfnCallback);
  489. extern void am_hal_iom_queue_start_next_msg(uint32_t ui32Module);
  490. extern void am_hal_iom_queue_service(uint32_t ui32Module, uint32_t ui32Status);
  491. //*****************************************************************************
  492. //
  493. // Helper functions.
  494. //
  495. //*****************************************************************************
  496. #define AM_IOMASTER_ISR_QUEUE(x) \
  497. void am_iomaster##x##_isr(void) \
  498. { \
  499. uint32_t ui32IntStatus; \
  500. g_iom_error_status = am_hal_iom_error_status_get(x); \
  501. ui32IntStatus = am_hal_iom_int_status_get(x, false); \
  502. am_hal_iom_int_clear(x, ui32IntStatus); \
  503. am_hal_iom_queue_service(x, ui32IntStatus); \
  504. }
  505. #define AM_IOMASTER_ISR_NB(x) \
  506. void am_iomaster##x##_isr(void) \
  507. { \
  508. uint32_t ui32IntStatus; \
  509. g_iom_error_status = am_hal_iom_error_status_get(x); \
  510. ui32IntStatus = am_hal_iom_int_status_get(x, false); \
  511. am_hal_iom_int_clear(x, ui32IntStatus); \
  512. am_hal_iom_int_service(x, ui32IntStatus); \
  513. }
  514. #endif // AM_HAL_IOM_H
  515. //*****************************************************************************
  516. //
  517. // End Doxygen group.
  518. //! @}
  519. //
  520. //*****************************************************************************