hpm_i2c_drv.h 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634
  1. /*
  2. * Copyright (c) 2021 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_I2C_DRV_H
  8. #define HPM_I2C_DRV_H
  9. #include "hpm_common.h"
  10. #include "hpm_i2c_regs.h"
  11. #include "hpm_soc_feature.h"
  12. /**
  13. * @brief I2C driver APIs
  14. * @defgroup i2c_interface I2C driver APIs
  15. * @ingroup io_interfaces
  16. * @{
  17. */
  18. /**
  19. * @brief I2C status
  20. */
  21. enum {
  22. status_i2c_no_ack = MAKE_STATUS(status_group_i2c, 1),
  23. status_i2c_invalid_data = MAKE_STATUS(status_group_i2c, 2),
  24. status_i2c_no_addr_hit = MAKE_STATUS(status_group_i2c, 3),
  25. status_i2c_transmit_not_completed = MAKE_STATUS(status_group_i2c, 4),
  26. status_i2c_not_supported = MAKE_STATUS(status_group_i2c, 9),
  27. };
  28. /* convert data count value into CTRL[DATACNT] value map */
  29. /* x range from 1 to I2C_SOC_TRANSFER_COUNT_MAX */
  30. /* 0 for I2C_SOC_TRANSFER_COUNT_MAX */
  31. #define I2C_DATACNT_MAP(x) (((x) == I2C_SOC_TRANSFER_COUNT_MAX) ? 0 : x)
  32. /**
  33. * @brief I2C CMD
  34. */
  35. #define I2C_CMD_NO_ACTION (I2C_CMD_CMD_SET(0))
  36. #define I2C_CMD_ISSUE_DATA_TRANSMISSION (I2C_CMD_CMD_SET(1))
  37. #define I2C_CMD_ACK (I2C_CMD_CMD_SET(2))
  38. #define I2C_CMD_NACK (I2C_CMD_CMD_SET(3))
  39. #define I2C_CMD_CLEAR_FIFO (I2C_CMD_CMD_SET(4))
  40. #define I2C_CMD_RESET (I2C_CMD_CMD_SET(5))
  41. /**
  42. * @brief I2C data direction
  43. */
  44. #define I2C_DIR_MASTER_WRITE (0U)
  45. #define I2C_DIR_MASTER_READ (1U)
  46. #define I2C_DIR_SLAVE_READ (0U)
  47. #define I2C_DIR_SLAVE_WRITE (1U)
  48. /**
  49. * @brief I2C events for interrupt enable and status check
  50. */
  51. #define I2C_EVENT_TRANSACTION_COMPLETE I2C_INTEN_CMPL_MASK
  52. #define I2C_EVENT_BYTE_RECEIVED I2C_INTEN_BYTERECV_MASK
  53. #define I2C_EVENT_BYTE_TRANSMIT I2C_INTEN_BYTETRANS_MASK
  54. #define I2C_EVENT_START_CONDITION I2C_INTEN_START_MASK
  55. #define I2C_EVENT_STOP_CONDITION I2C_INTEN_STOP_MASK
  56. #define I2C_EVENT_LOSS_ARBITRATION I2C_INTEN_ARBLOSE_MASK
  57. #define I2C_EVENT_ADDRESS_HIT I2C_INTEN_ADDRHIT_MASK
  58. #define I2C_EVENT_FIFO_HALF I2C_INTEN_FIFOHALF_MASK
  59. #define I2C_EVENT_FIFO_FULL I2C_INTEN_FIFOFULL_MASK
  60. #define I2C_EVENT_FIFO_EMPTY I2C_INTEN_FIFOEMPTY_MASK
  61. #define I2C_EVENT_ALL_MASK (I2C_INTEN_CMPL_MASK \
  62. | I2C_INTEN_BYTERECV_MASK \
  63. | I2C_INTEN_BYTETRANS_MASK \
  64. | I2C_INTEN_START_MASK \
  65. | I2C_INTEN_STOP_MASK \
  66. | I2C_INTEN_ARBLOSE_MASK \
  67. | I2C_INTEN_ADDRHIT_MASK \
  68. | I2C_INTEN_FIFOHALF_MASK \
  69. | I2C_INTEN_FIFOFULL_MASK \
  70. | I2C_INTEN_FIFOEMPTY_MASK)
  71. /**
  72. * @brief I2C status for status check only
  73. */
  74. #define I2C_STATUS_LINE_SDA I2C_STATUS_LINESDA_MASK
  75. #define I2C_STATUS_LINE_SCL I2C_STATUS_LINESCL_MASK
  76. #define I2C_STATUS_GENERAL_CALL I2C_STATUS_GENCALL_MASK
  77. #define I2C_STATUS_BUS_BUSY I2C_STATUS_BUSBUSY_MASK
  78. #define I2C_STATUS_ACK I2C_STATUS_ACK_MASK
  79. /**
  80. * @brief I2C config
  81. */
  82. typedef struct {
  83. bool is_10bit_addressing;
  84. uint8_t i2c_mode;
  85. } i2c_config_t;
  86. /**
  87. * @brief I2C mode
  88. */
  89. typedef enum i2c_mode {
  90. i2c_mode_normal,
  91. i2c_mode_fast,
  92. i2c_mode_fast_plus,
  93. } i2c_mode_t;
  94. /**
  95. * @brief I2c sequential transfer options
  96. * @arg: i2c_frist_frame: has start signal
  97. * @arg: i2c_next_frame: middle transfer
  98. * @arg: i2c_last_frame: has stop signal
  99. */
  100. typedef enum i2c_seq_transfer_opt {
  101. i2c_frist_frame = 0,
  102. i2c_next_frame,
  103. i2c_last_frame,
  104. } i2c_seq_transfer_opt_t;
  105. #ifdef __cplusplus
  106. extern "C" {
  107. #endif
  108. /**
  109. * @brief respond NACK
  110. *
  111. * @param [in] ptr I2C base address
  112. */
  113. static inline void i2c_respond_Nack(I2C_Type *ptr)
  114. {
  115. ptr->CMD = I2C_CMD_NACK;
  116. }
  117. /**
  118. * @brief respond ACK
  119. *
  120. * @param [in] ptr I2C base address
  121. */
  122. static inline void i2c_respond_ack(I2C_Type *ptr)
  123. {
  124. ptr->CMD = I2C_CMD_ACK;
  125. }
  126. /**
  127. * @brief clear I2C fifo
  128. *
  129. * @param [in] ptr I2C base address
  130. */
  131. static inline void i2c_clear_fifo(I2C_Type *ptr)
  132. {
  133. ptr->CMD = I2C_CMD_CLEAR_FIFO;
  134. }
  135. /**
  136. * @brief check data count
  137. *
  138. * @details It indicates number of bytes to transfer
  139. *
  140. * @param [in] ptr I2C base address
  141. * @retval data count value in byte
  142. */
  143. static inline uint8_t i2c_get_data_count(I2C_Type *ptr)
  144. {
  145. return I2C_CTRL_DATACNT_GET(ptr->CTRL);
  146. }
  147. /**
  148. * @brief check if I2C FIFO is full
  149. *
  150. * @param [in] ptr I2C base address
  151. * @retval true if FIFO is full
  152. */
  153. static inline bool i2c_fifo_is_full(I2C_Type *ptr)
  154. {
  155. return ptr->STATUS & I2C_STATUS_FIFOFULL_MASK;
  156. }
  157. /**
  158. * @brief check if I2C FIFO is half
  159. *
  160. * @note When I2C is transmitting data, it indicates if fifo is half-empty;
  161. * @note When I2C is receiving data, it indicates if fifo is half full.
  162. *
  163. * @param [in] ptr I2C base address
  164. * @retval true if FIFO is half empty or full
  165. */
  166. static inline bool i2c_fifo_is_half(I2C_Type *ptr)
  167. {
  168. return ptr->STATUS & I2C_STATUS_FIFOHALF_MASK;
  169. }
  170. /**
  171. * @brief check if I2C FIFO is empty
  172. *
  173. * @param [in] ptr I2C base address
  174. * @retval true if FIFO is empty
  175. */
  176. static inline bool i2c_fifo_is_empty(I2C_Type *ptr)
  177. {
  178. return ptr->STATUS & I2C_STATUS_FIFOEMPTY_MASK;
  179. }
  180. /**
  181. * @brief check if I2C is writing
  182. *
  183. * @param [in] ptr I2C base address
  184. * @retval bool value
  185. * @arg true: receive data if master mode, send data in slave mode
  186. * @arg false: send data if master mode, reveive data in slave mode
  187. *
  188. */
  189. static inline bool i2c_is_writing(I2C_Type *ptr)
  190. {
  191. return (ptr->CTRL & I2C_CTRL_DIR_MASK);
  192. }
  193. /**
  194. * @brief check if I2C is reading
  195. *
  196. * @param [in] ptr I2C base address
  197. * @retval bool value
  198. * @arg true: send data if master mode, receive data in slave mode
  199. * @arg false: receive data if master mode, send data in slave mode
  200. *
  201. */
  202. static inline bool i2c_is_reading(I2C_Type *ptr)
  203. {
  204. return !i2c_is_writing(ptr);
  205. }
  206. /**
  207. * @brief get i2c sda line status
  208. *
  209. * @param [in] ptr I2C base address
  210. * @retval bool value
  211. * @arg true: the sda line is high
  212. * @arg false: the sda line is low
  213. *
  214. */
  215. static inline bool i2c_get_line_sda_status(I2C_Type *ptr)
  216. {
  217. return I2C_STATUS_LINESDA_GET(ptr->STATUS);
  218. }
  219. /**
  220. * @brief get i2c scl line status
  221. *
  222. * @param [in] ptr I2C base address
  223. * @retval bool value
  224. * @arg true: the scl line is high
  225. * @arg false: the scl line is low
  226. *
  227. */
  228. static inline bool i2c_get_line_scl_status(I2C_Type *ptr)
  229. {
  230. return I2C_STATUS_LINESCL_GET(ptr->STATUS);
  231. }
  232. /**
  233. * @brief clear status
  234. *
  235. * @details Clear status based on mask
  236. *
  237. * @param [in] ptr I2C base address
  238. * @param [in] mask mask to clear status
  239. */
  240. static inline void i2c_clear_status(I2C_Type *ptr, uint32_t mask)
  241. {
  242. ptr->STATUS |= (mask & I2C_EVENT_ALL_MASK);
  243. }
  244. /**
  245. * @brief get status
  246. *
  247. * @details Get current I2C status bits
  248. *
  249. * @param [in] ptr I2C base address
  250. * @retval current I2C status
  251. */
  252. static inline uint32_t i2c_get_status(I2C_Type *ptr)
  253. {
  254. return ptr->STATUS;
  255. }
  256. /**
  257. * @brief i2c get interrupts setting
  258. *
  259. * @details Get interrupt setting register value
  260. *
  261. * @param [in] ptr I2C base address
  262. * @retval [out] uint32_t interrupt setting register value
  263. */
  264. static inline uint32_t i2c_get_irq_setting(I2C_Type *ptr)
  265. {
  266. return ptr->INTEN;
  267. }
  268. /**
  269. * @brief disable interrupts
  270. *
  271. * @details Disable interrupts based on given mask
  272. *
  273. * @param [in] ptr I2C base address
  274. * @param [in] mask interrupt mask to be disabled
  275. */
  276. static inline void i2c_disable_irq(I2C_Type *ptr, uint32_t mask)
  277. {
  278. ptr->INTEN &= ~mask;
  279. }
  280. /**
  281. * @brief enable interrupts
  282. *
  283. * @details Enable interrupts based on given mask
  284. *
  285. * @param [in] ptr I2C base address
  286. * @param [in] mask interrupt mask to be enabled
  287. */
  288. static inline void i2c_enable_irq(I2C_Type *ptr, uint32_t mask)
  289. {
  290. ptr->INTEN |= mask;
  291. }
  292. /**
  293. * @brief disable auto ack
  294. *
  295. * @details Disable I2C auto generates proper acknowledgements for each byte received
  296. *
  297. * @param [in] ptr I2C base address
  298. */
  299. static inline void i2c_disable_auto_ack(I2C_Type *ptr)
  300. {
  301. ptr->INTEN &= ~I2C_EVENT_BYTE_RECEIVED;
  302. }
  303. /**
  304. * @brief enable auto ack
  305. *
  306. * @details Enable I2C auto generates proper acknowledgements for each byte received
  307. *
  308. * @param [in] ptr I2C base address
  309. */
  310. static inline void i2c_enable_auto_ack(I2C_Type *ptr)
  311. {
  312. ptr->INTEN |= I2C_EVENT_BYTE_RECEIVED;
  313. }
  314. /**
  315. * @brief enable 10 bit address mode
  316. *
  317. * @details enable 10 bit address mode, if not, address is 7 bit mode
  318. *
  319. * @param [in] ptr I2C base address
  320. * @param [in] enable
  321. * @arg true: enable 10 bit address mode
  322. * @arg false: enable 7 bit address mode
  323. */
  324. static inline void i2c_enable_10bit_address_mode(I2C_Type *ptr, bool enable)
  325. {
  326. ptr->SETUP |= I2C_SETUP_ADDRESSING_SET(enable);
  327. }
  328. /**
  329. * @brief I2C master initialization
  330. *
  331. * @details Initialized I2C controller working at master mode
  332. *
  333. * @param [in] ptr I2C base address
  334. * @param [in] src_clk_in_hz I2C controller source clock source frequency in Hz
  335. * @param [in] config i2c_config_t
  336. * @retval hpm_stat_t: status_success if initialization is completed without any error
  337. */
  338. hpm_stat_t i2c_init_master(I2C_Type *ptr,
  339. uint32_t src_clk_in_hz,
  340. i2c_config_t *config);
  341. /**
  342. * @brief I2C master write data to specific address of certain slave device
  343. *
  344. * @details Write to certain I2C device at specific address within that device
  345. * @note the sum of addr_size_in_byte and size_in_byte should not not greater than I2C_SOC_TRANSFER_COUNT_MAX
  346. *
  347. * @param [in] ptr I2C base address
  348. * @param [in] device_address I2C slave address
  349. * @param [in] addr address in that I2C device
  350. * @param [in] addr_size_in_byte I2C address in byte
  351. * @param [in] buf pointer of the data to be sent
  352. * @param [in] size_in_byte size of data to be sent in bytes
  353. * @retval hpm_stat_t: status_success if writing is completed without any error
  354. */
  355. hpm_stat_t i2c_master_address_write(I2C_Type *ptr,
  356. const uint16_t device_address,
  357. uint8_t *addr,
  358. uint32_t addr_size_in_byte,
  359. uint8_t *buf,
  360. const uint32_t size_in_byte);
  361. /**
  362. * @brief I2C master read data from specific address of certain slave device
  363. *
  364. * @details Read fram certain I2C device at specific address within that device
  365. * @note both addr_size_in_byte and size_in_byte should not not greater than I2C_SOC_TRANSFER_COUNT_MAX
  366. *
  367. * @param [in] ptr I2C base address
  368. * @param [in] device_address I2C slave address
  369. * @param [in] addr address in that I2C device
  370. * @param [in] addr_size_in_byte I2C address in byte
  371. * @param [out] buf pointer of the buffer to receive data read from the device
  372. * @param [in] size_in_byte size of data to be read in bytes
  373. * @retval hpm_stat_t: status_success if reading is completed without any error
  374. */
  375. hpm_stat_t i2c_master_address_read(I2C_Type *ptr,
  376. const uint16_t device_address,
  377. uint8_t *addr,
  378. uint32_t addr_size_in_byte,
  379. uint8_t *buf,
  380. const uint32_t size_in_byte);
  381. /**
  382. * @brief I2C master write data to certain slave device
  383. *
  384. * @details Write data to I2C device
  385. * @note size should not not greater than I2C_SOC_TRANSFER_COUNT_MAX
  386. *
  387. * @param [in] ptr I2C base address
  388. * @param [in] device_address I2C slave address
  389. * @param [in] buf pointer of the data to be sent
  390. * @param [in] size size of data to be sent in bytes
  391. * @retval hpm_stat_t: status_success if writing is completed without any error
  392. */
  393. hpm_stat_t i2c_master_write(I2C_Type *ptr,
  394. const uint16_t device_address,
  395. uint8_t *buf,
  396. const uint32_t size);
  397. /**
  398. * @brief I2C master start write data by DMA
  399. *
  400. * @details Write data to I2C device by DMA
  401. * @note size should not not greater than I2C_SOC_TRANSFER_COUNT_MAX
  402. *
  403. * @param [in] i2c_ptr I2C base address
  404. * @param [in] device_address I2C slave address
  405. * @param [in] size size of data to be sent in bytes
  406. * @retval hpm_stat_t status_success if starting transmission without any error
  407. */
  408. hpm_stat_t i2c_master_start_dma_write(I2C_Type *i2c_ptr, const uint16_t device_address, uint32_t size);
  409. /**
  410. * @brief I2C master start read data by DMA
  411. *
  412. * @details Read data to I2C device by DMA
  413. * @note size should not not greater than I2C_SOC_TRANSFER_COUNT_MAX
  414. *
  415. * @param [in] i2c_ptr I2C base address
  416. * @param [in] device_address I2C slave address
  417. * @param [in] size size of data to be read in bytes
  418. * @retval hpm_stat_t status_success if starting transmission without any error
  419. */
  420. hpm_stat_t i2c_master_start_dma_read(I2C_Type *i2c_ptr, const uint16_t device_address, uint32_t size);
  421. /**
  422. * @brief I2C master read data from certain slave device
  423. *
  424. * @details Read data from I2C device
  425. * @note size should not not greater than I2C_SOC_TRANSFER_COUNT_MAX
  426. *
  427. * @param [in] ptr I2C base address
  428. * @param [in] device_address I2C slave address
  429. * @param [out] buf pointer of the buffer to store data read from device
  430. * @param [in] size size of data to be read in bytes
  431. * @retval hpm_stat_t: status_success if reading is completed without any error
  432. */
  433. hpm_stat_t i2c_master_read(I2C_Type *ptr,
  434. const uint16_t device_address,
  435. uint8_t *buf,
  436. const uint32_t size);
  437. /**
  438. * @brief I2C slave initialization
  439. *
  440. * @details Initialize I2C controller working at slave mode
  441. *
  442. * @param [in] ptr I2C base address
  443. * @param [in] src_clk_in_hz I2C controller source clock source frequency in Hz
  444. * @param [in] config I2C configuration structure
  445. * @param [in] slave_address I2C address to be used at slave mode
  446. * @retval hpm_stat_t: status_success if initialization is completed without any error
  447. */
  448. hpm_stat_t i2c_init_slave(I2C_Type *ptr, uint32_t src_clk_in_hz,
  449. i2c_config_t *config, const uint16_t slave_address);
  450. /**
  451. * @brief I2C slave read data
  452. *
  453. * @details Read data at slave mode
  454. * @note size should not not greater than I2C_SOC_TRANSFER_COUNT_MAX
  455. *
  456. * @param [in] ptr I2C base address
  457. * @param [in] buf pointer of the buffer to store data read from device
  458. * @param [in] size size of data to be read in bytes
  459. * @retval hpm_stat_t: status_success if reading is completed without any error
  460. */
  461. hpm_stat_t i2c_slave_read(I2C_Type *ptr, uint8_t *buf, const uint32_t size);
  462. /**
  463. * @brief I2C slave write data
  464. *
  465. * @details Write data at slave mode.
  466. * @note size should not not greater than I2C_SOC_TRANSFER_COUNT_MAX
  467. *
  468. * @param [in] ptr I2C base address
  469. * @param [in] buf pointer of the buffer to store data sent from device
  470. * @param [in] size size of data to be sent in bytes
  471. * @retval hpm_stat_t status_success if writing is completed without any error
  472. */
  473. hpm_stat_t i2c_slave_write(I2C_Type *ptr, uint8_t *buf, const uint32_t size);
  474. /**
  475. * @brief reset I2C
  476. *
  477. * @param [in] ptr I2C base address
  478. */
  479. void i2c_reset(I2C_Type *ptr);
  480. /**
  481. * @brief Enable i2c DMA
  482. *
  483. * @param [in] ptr I2C base address
  484. */
  485. static inline void i2c_dma_enable(I2C_Type *ptr)
  486. {
  487. ptr->SETUP |= I2C_SETUP_DMAEN_MASK;
  488. }
  489. /**
  490. * @brief Disable i2c DMA
  491. *
  492. * @param [in] ptr I2C base address
  493. */
  494. static inline void i2c_dma_disable(I2C_Type *ptr)
  495. {
  496. ptr->SETUP &= ~I2C_SETUP_DMAEN_MASK;
  497. }
  498. /**
  499. * @brief I2C slave dma transfer data
  500. *
  501. * @note The direction of data transmission depends on Master setting
  502. *
  503. * @param [in] ptr I2C base address
  504. * @param [in] size size of data in bytes
  505. * @retval hpm_stat_t status_success if configuring transmission without any error
  506. */
  507. hpm_stat_t i2c_slave_dma_transfer(I2C_Type *ptr, const uint32_t size);
  508. /**
  509. * @brief I2C write byte into FIFO
  510. *
  511. * @param ptr [in] ptr I2C base address
  512. * @param data [in] byte to ne sent
  513. */
  514. static inline void i2c_write_byte(I2C_Type *ptr, uint8_t data)
  515. {
  516. ptr->DATA = I2C_DATA_DATA_SET(data);
  517. }
  518. /**
  519. * @brief I2C read byte into FIFO
  520. *
  521. * @param ptr [in] ptr I2C base address
  522. * @return uint8_t read byte
  523. */
  524. static inline uint8_t i2c_read_byte(I2C_Type *ptr)
  525. {
  526. return (uint8_t)I2C_DATA_DATA_GET(ptr->DATA);
  527. }
  528. /**
  529. * @brief I2C get direction
  530. *
  531. * @note The same value has different meanings in master and slave modes
  532. *
  533. * @param ptr [in] ptr I2C base address
  534. * @return uint8_t direction value
  535. */
  536. static inline uint8_t i2c_get_direction(I2C_Type *ptr)
  537. {
  538. return (uint8_t)I2C_CTRL_DIR_GET(ptr->CTRL);
  539. }
  540. /**
  541. * @brief I2C master configure transfer setting
  542. *
  543. * @param i2c_ptr [in] ptr I2C base address
  544. * @param device_address [in] I2C slave address
  545. * @param size [in] size of data to be transferred in bytes
  546. * @param read [in] true for receive, false for transmit
  547. * @retval hpm_stat_t status_success if configuring transmission without any error
  548. */
  549. hpm_stat_t i2c_master_configure_transfer(I2C_Type *i2c_ptr, const uint16_t device_address, uint32_t size, bool read);
  550. /**
  551. * @brief sequential transmit in master I2C mode an amount of data in blocking
  552. *
  553. * @param i2c_ptr [in] ptr I2C base address
  554. * @param device_address [in] I2C slave address
  555. * @param [in] buf pointer of the buffer to store data sent from device
  556. * @param [in] size size of data to be sent in bytes
  557. * @param [in] opt I2c sequential transfer options
  558. * @retval hpm_stat_t status_success if transmit is completed without any error
  559. */
  560. hpm_stat_t i2c_master_seq_transmit(I2C_Type *ptr, const uint16_t device_address,
  561. uint8_t *buf, const uint32_t size, i2c_seq_transfer_opt_t opt);
  562. /**
  563. * @brief sequential receive in master I2C mode an amount of data in blocking
  564. *
  565. * @param i2c_ptr [in] ptr I2C base address
  566. * @param device_address [in] I2C slave address
  567. * @param [in] buf pointer of the buffer to store data sent from device
  568. * @param [in] size size of data to be sent in bytes
  569. * @param [in] opt I2c sequential transfer options
  570. * @retval hpm_stat_t status_success if receive is completed without any error
  571. */
  572. hpm_stat_t i2c_master_seq_receive(I2C_Type *ptr, const uint16_t device_address,
  573. uint8_t *buf, const uint32_t size, i2c_seq_transfer_opt_t opt);
  574. /**
  575. * @}
  576. */
  577. #ifdef __cplusplus
  578. }
  579. #endif
  580. #endif /* HPM_I2C_DRV_H */