nu_i2c.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. /****************************************************************************//**
  2. * @file nu_i2c.h
  3. * @version V1.00
  4. * @brief M031 series I2C driver header file
  5. *
  6. * SPDX-License-Identifier: Apache-2.0
  7. * @copyright (C) 2018 Nuvoton Technology Corp. All rights reserved.
  8. *****************************************************************************/
  9. #ifndef __NU_I2C_H__
  10. #define __NU_I2C_H__
  11. #ifdef __cplusplus
  12. extern "C"
  13. {
  14. #endif
  15. /** @addtogroup Standard_Driver Standard Driver
  16. @{
  17. */
  18. /** @addtogroup I2C_Driver I2C Driver
  19. @{
  20. */
  21. /** @addtogroup I2C_EXPORTED_CONSTANTS I2C Exported Constants
  22. @{
  23. */
  24. /*---------------------------------------------------------------------------------------------------------*/
  25. /* I2C_CTL constant definitions. */
  26. /*---------------------------------------------------------------------------------------------------------*/
  27. #define I2C_CTL_STA_SI 0x28UL /*!< I2C_CTL setting for I2C control bits. It would set STA and SI bits \hideinitializer */
  28. #define I2C_CTL_STA_SI_AA 0x2CUL /*!< I2C_CTL setting for I2C control bits. It would set STA, SI and AA bits \hideinitializer */
  29. #define I2C_CTL_STO_SI 0x18UL /*!< I2C_CTL setting for I2C control bits. It would set STO and SI bits \hideinitializer */
  30. #define I2C_CTL_STO_SI_AA 0x1CUL /*!< I2C_CTL setting for I2C control bits. It would set STO, SI and AA bits \hideinitializer */
  31. #define I2C_CTL_SI 0x08UL /*!< I2C_CTL setting for I2C control bits. It would set SI bit \hideinitializer */
  32. #define I2C_CTL_SI_AA 0x0CUL /*!< I2C_CTL setting for I2C control bits. It would set SI and AA bits \hideinitializer */
  33. #define I2C_CTL_STA 0x20UL /*!< I2C_CTL setting for I2C control bits. It would set STA bit \hideinitializer */
  34. #define I2C_CTL_STO 0x10UL /*!< I2C_CTL setting for I2C control bits. It would set STO bit \hideinitializer */
  35. #define I2C_CTL_AA 0x04UL /*!< I2C_CTL setting for I2C control bits. It would set AA bit \hideinitializer */
  36. /*---------------------------------------------------------------------------------------------------------*/
  37. /* I2C GCMode constant definitions. */
  38. /*---------------------------------------------------------------------------------------------------------*/
  39. #define I2C_GCMODE_ENABLE 1 /*!< Enable I2C GC Mode \hideinitializer */
  40. #define I2C_GCMODE_DISABLE 0 /*!< Disable I2C GC Mode \hideinitializer */
  41. /*---------------------------------------------------------------------------------------------------------*/
  42. /* I2C SMBUS constant definitions. */
  43. /*---------------------------------------------------------------------------------------------------------*/
  44. #define I2C_SMBH_ENABLE 1 /*!< Enable SMBus Host Mode enable \hideinitializer */
  45. #define I2C_SMBD_ENABLE 0 /*!< Enable SMBus Device Mode enable \hideinitializer */
  46. #define I2C_PECTX_ENABLE 1 /*!< Enable SMBus Packet Error Check Transmit function \hideinitializer */
  47. #define I2C_PECTX_DISABLE 0 /*!< Disable SMBus Packet Error Check Transmit function \hideinitializer */
  48. /*@}*/ /* end of group I2C_EXPORTED_CONSTANTS */
  49. /** @addtogroup I2C_EXPORTED_FUNCTIONS I2C Exported Functions
  50. @{
  51. */
  52. /**
  53. * @brief The macro is used to set I2C bus condition at One Time
  54. *
  55. * @param[in] i2c Specify I2C port
  56. * @param[in] u8Ctrl A byte writes to I2C control register
  57. *
  58. * @return None
  59. *
  60. * @details Set I2C_CTL register to control I2C bus conditions of START, STOP, SI, ACK.
  61. * \hideinitializer
  62. */
  63. #define I2C_SET_CONTROL_REG(i2c, u8Ctrl) ((i2c)->CTL0 = ((i2c)->CTL0 & ~0x3C) | (u8Ctrl))
  64. /**
  65. * @brief The macro is used to set START condition of I2C Bus
  66. *
  67. * @param[in] i2c Specify I2C port
  68. *
  69. * @return None
  70. *
  71. * @details Set the I2C bus START condition in I2C_CTL register.
  72. * \hideinitializer
  73. */
  74. #define I2C_START(i2c) ((i2c)->CTL0 = ((i2c)->CTL0 | I2C_CTL0_SI_Msk) | I2C_CTL0_STA_Msk)
  75. /**
  76. * @brief The macro is used to wait I2C bus status get ready
  77. *
  78. * @param[in] i2c Specify I2C port
  79. *
  80. * @return None
  81. *
  82. * @details When a new status is presented of I2C bus, the SI flag will be set in I2C_CTL register.
  83. * \hideinitializer
  84. */
  85. #define I2C_WAIT_READY(i2c) while(!((i2c)->CTL0 & I2C_CTL0_SI_Msk))
  86. /**
  87. * @brief The macro is used to Read I2C Bus Data Register
  88. *
  89. * @param[in] i2c Specify I2C port
  90. *
  91. * @return A byte of I2C data register
  92. *
  93. * @details I2C controller read data from bus and save it in I2C_DAT register.
  94. * \hideinitializer
  95. */
  96. #define I2C_GET_DATA(i2c) ((i2c)->DAT)
  97. /**
  98. * @brief Write a Data to I2C Data Register
  99. *
  100. * @param[in] i2c Specify I2C port
  101. * @param[in] u8Data A byte that writes to data register
  102. *
  103. * @return None
  104. *
  105. * @details When write a data to I2C_DAT register, the I2C controller will shift it to I2C bus.
  106. * \hideinitializer
  107. */
  108. #define I2C_SET_DATA(i2c, u8Data) ((i2c)->DAT = (u8Data))
  109. /**
  110. * @brief Get I2C Bus status code
  111. *
  112. * @param[in] i2c Specify I2C port
  113. *
  114. * @return I2C status code
  115. *
  116. * @details To get this status code to monitor I2C bus event.
  117. * \hideinitializer
  118. */
  119. #define I2C_GET_STATUS(i2c) ((i2c)->STATUS0)
  120. /**
  121. * @brief Get Time-out flag from I2C Bus
  122. *
  123. * @param[in] i2c Specify I2C port
  124. *
  125. * @retval 0 I2C Bus time-out is not happened
  126. * @retval 1 I2C Bus time-out is happened
  127. *
  128. * @details When I2C bus occurs time-out event, the time-out flag will be set.
  129. * \hideinitializer
  130. */
  131. #define I2C_GET_TIMEOUT_FLAG(i2c) ( ((i2c)->TOCTL & I2C_TOCTL_TOIF_Msk) == I2C_TOCTL_TOIF_Msk ? 1:0 )
  132. /**
  133. * @brief To get wake-up flag from I2C Bus
  134. *
  135. * @param[in] i2c Specify I2C port
  136. *
  137. * @retval 0 Chip is not woken-up from power-down mode
  138. * @retval 1 Chip is woken-up from power-down mode
  139. *
  140. * @details I2C bus occurs wake-up event, wake-up flag will be set.
  141. * \hideinitializer
  142. */
  143. #define I2C_GET_WAKEUP_FLAG(i2c) ( ((i2c)->WKSTS & I2C_WKSTS_WKIF_Msk) == I2C_WKSTS_WKIF_Msk ? 1:0 )
  144. /**
  145. * @brief To clear wake-up flag
  146. *
  147. * @param[in] i2c Specify I2C port
  148. *
  149. * @return None
  150. *
  151. * @details If wake-up flag is set, use this macro to clear it.
  152. * \hideinitializer
  153. */
  154. #define I2C_CLEAR_WAKEUP_FLAG(i2c) ((i2c)->WKSTS = I2C_WKSTS_WKIF_Msk)
  155. /**
  156. * @brief To get wake-up address frame ACK done flag from I2C Bus
  157. *
  158. * @param[in] i2c Specify I2C port
  159. *
  160. * @retval 0 The ACK bit cycle of address match frame is not done
  161. * @retval 1 The ACK bit cycle of address match frame is done in power-down
  162. *
  163. * @details I2C bus occurs wake-up event and address frame ACK is done, this flag will be set.
  164. * \hideinitializer
  165. */
  166. #define I2C_GET_WAKEUP_DONE(i2c) ( ((i2c)->WKSTS & I2C_WKSTS_WKAKDONE_Msk) == I2C_WKSTS_WKAKDONE_Msk ? 1 : 0)
  167. /**
  168. * @brief To clear address frame ACK done flag
  169. *
  170. * @param[in] i2c Specify I2C port
  171. *
  172. * @return None
  173. *
  174. * @details If wake-up done is set, use this macro to clear it.
  175. * \hideinitializer
  176. */
  177. #define I2C_CLEAR_WAKEUP_DONE(i2c) ((i2c)->WKSTS = I2C_WKSTS_WKAKDONE_Msk)
  178. /**
  179. * @brief To get read/write status bit in address wakeup frame
  180. *
  181. * @param[in] i2c Specify I2C port
  182. *
  183. * @retval 0 Write command be record on the address match wakeup frame
  184. * @retval 1 Read command be record on the address match wakeup frame.
  185. *
  186. * @details I2C bus occurs wake-up event and address frame is received, this bit will record read/write status.
  187. * \hideinitializer
  188. */
  189. #define I2C_GET_WAKEUP_WR_STATUS(i2c) ( ((i2c)->WKSTS & I2C_WKSTS_WRSTSWK_Msk) == I2C_WKSTS_WRSTSWK_Msk ? 1 : 0)
  190. /**
  191. * @brief To get SMBus Status
  192. *
  193. * @param[in] i2c Specify I2C port
  194. *
  195. * @return SMBus status
  196. *
  197. * @details To get the Bus Management status of I2C_BUSSTS register
  198. * \hideinitializer
  199. *
  200. */
  201. #define I2C_SMBUS_GET_STATUS(i2c) ((i2c)->BUSSTS)
  202. /**
  203. * @brief Get SMBus CRC value
  204. *
  205. * @param[in] i2c Specify I2C port
  206. *
  207. * @return Packet error check byte value
  208. *
  209. * @details The CRC check value after a transmission or a reception by count by using CRC8
  210. * \hideinitializer
  211. */
  212. #define I2C_SMBUS_GET_PEC_VALUE(i2c) ((i2c)->PKTCRC)
  213. /**
  214. * @brief Set SMBus Bytes number of Transmission or reception
  215. *
  216. * @param[in] i2c Specify I2C port
  217. * @param[in] u32PktSize Transmit / Receive bytes
  218. *
  219. * @return None
  220. *
  221. * @details The transmission or receive byte number in one transaction when PECEN is set. The maximum is 255 bytes.
  222. * \hideinitializer
  223. */
  224. #define I2C_SMBUS_SET_PACKET_BYTE_COUNT(i2c, u32PktSize) ((i2c)->PKTSIZE = (u32PktSize))
  225. /**
  226. * @brief Enable SMBus Alert function
  227. *
  228. * @param[in] i2c Specify I2C port
  229. *
  230. * @return None
  231. *
  232. * @details Device Mode(BMHEN=0): If ALERTEN(I2C_BUSCTL[4]) is set, the Alert pin will pull lo, and reply ACK when get ARP from host
  233. * Host Mode(BMHEN=1): If ALERTEN(I2C_BUSCTL[4]) is set, the Alert pin is supported to receive alert state(Lo trigger)
  234. * \hideinitializer
  235. */
  236. #define I2C_SMBUS_ENABLE_ALERT(i2c) ((i2c)->BUSCTL |= I2C_BUSCTL_ALERTEN_Msk)
  237. /**
  238. * @brief Disable SMBus Alert pin function
  239. *
  240. * @param[in] i2c Specify I2C port
  241. *
  242. * @return None
  243. *
  244. * @details Device Mode(BMHEN=0): If ALERTEN(I2C_BUSCTL[4]) is clear, the Alert pin will pull hi, and reply NACK when get ARP from host
  245. * Host Mode(BMHEN=1): If ALERTEN(I2C_BUSCTL[4]) is clear, the Alert pin is not supported to receive alert state(Lo trigger)
  246. * \hideinitializer
  247. */
  248. #define I2C_SMBUS_DISABLE_ALERT(i2c) ((i2c)->BUSCTL &= ~I2C_BUSCTL_ALERTEN_Msk)
  249. /**
  250. * @brief Set SMBus SUSCON pin is output mode
  251. *
  252. * @param[in] i2c Specify I2C port
  253. *
  254. * @return None
  255. *
  256. * @details This function to set SUSCON(I2C_BUSCTL[6]) pin is output mode.
  257. *
  258. * \hideinitializer
  259. */
  260. #define I2C_SMBUS_SET_SUSCON_OUT(i2c) ((i2c)->BUSCTL |= I2C_BUSCTL_SCTLOEN_Msk)
  261. /**
  262. * @brief Set SMBus SUSCON pin is input mode
  263. *
  264. * @param[in] i2c Specify I2C port
  265. *
  266. * @return None
  267. *
  268. * @details This function to set SUSCON(I2C_BUSCTL[6]) pin is input mode.
  269. *
  270. * \hideinitializer
  271. */
  272. #define I2C_SMBUS_SET_SUSCON_IN(i2c) ((i2c)->BUSCTL &= ~I2C_BUSCTL_SCTLOEN_Msk)
  273. /**
  274. * @brief Set SMBus SUSCON pin output high state
  275. *
  276. * @param[in] i2c Specify I2C port
  277. *
  278. * @return None
  279. *
  280. * @details This function to set SUSCON(I2C_BUSCTL[6]) pin is output hi state.
  281. * \hideinitializer
  282. */
  283. #define I2C_SMBUS_SET_SUSCON_HIGH(i2c) ((i2c)->BUSCTL |= I2C_BUSCTL_SCTLOSTS_Msk)
  284. /**
  285. * @brief Set SMBus SUSCON pin output low state
  286. *
  287. * @param[in] i2c Specify I2C port
  288. *
  289. * @return None
  290. *
  291. * @details This function to set SUSCON(I2C_BUSCTL[6]) pin is output lo state.
  292. * \hideinitializer
  293. */
  294. #define I2C_SMBUS_SET_SUSCON_LOW(i2c) ((i2c)->BUSCTL &= ~I2C_BUSCTL_SCTLOSTS_Msk)
  295. /**
  296. * @brief Enable SMBus Acknowledge control by manual
  297. *
  298. * @param[in] i2c Specify I2C port
  299. *
  300. * @return None
  301. *
  302. * @details The 9th bit can response the ACK or NACK according the received data by user. When the byte is received, SCLK line stretching to low between the 8th and 9th SCLK pulse.
  303. * \hideinitializer
  304. */
  305. #define I2C_SMBUS_ACK_MANUAL(i2c) ((i2c)->BUSCTL |= I2C_BUSCTL_ACKMEN_Msk)
  306. /**
  307. * @brief Disable SMBus Acknowledge control by manual
  308. *
  309. * @param[in] i2c Specify I2C port
  310. *
  311. * @return None
  312. *
  313. * @details Disable acknowledge response control by user.
  314. * \hideinitializer
  315. */
  316. #define I2C_SMBUS_ACK_AUTO(i2c) ((i2c)->BUSCTL &= ~I2C_BUSCTL_ACKMEN_Msk)
  317. /**
  318. * @brief Enable SMBus Acknowledge manual interrupt
  319. *
  320. * @param[in] i2c Specify I2C port
  321. *
  322. * @return None
  323. *
  324. * @details This function is used to enable SMBUS acknowledge manual interrupt on the 9th clock cycle when SMBUS=1 and ACKMEN=1
  325. * \hideinitializer
  326. */
  327. #define I2C_SMBUS_9THBIT_INT_ENABLE(i2c) ((i2c)->BUSCTL |= I2C_BUSCTL_ACKM9SI_Msk)
  328. /**
  329. * @brief Disable SMBus Acknowledge manual interrupt
  330. *
  331. * @param[in] i2c Specify I2C port
  332. *
  333. * @return None
  334. *
  335. * @details This function is used to disable SMBUS acknowledge manual interrupt on the 9th clock cycle when SMBUS=1 and ACKMEN=1
  336. * \hideinitializer
  337. */
  338. #define I2C_SMBUS_9THBIT_INT_DISABLE(i2c) ((i2c)->BUSCTL &= ~I2C_BUSCTL_ACKM9SI_Msk)
  339. /**
  340. * @brief Enable SMBus PEC clear at REPEAT START
  341. *
  342. * @param[in] i2c Specify I2C port
  343. *
  344. * @return None
  345. *
  346. * @details This function is used to enable the condition of REAEAT START can clear the PEC calculation.
  347. * \hideinitializer
  348. */
  349. #define I2C_SMBUS_RST_PEC_AT_START_ENABLE(i2c) ((i2c)->BUSCTL |= I2C_BUSCTL_PECCLR_Msk)
  350. /**
  351. * @brief Disable SMBus PEC clear at Repeat START
  352. *
  353. * @param[in] i2c Specify I2C port
  354. *
  355. * @return None
  356. *
  357. * @details This function is used to disable the condition of Repeat START can clear the PEC calculation.
  358. * \hideinitializer
  359. */
  360. #define I2C_SMBUS_RST_PEC_AT_START_DISABLE(i2c) ((i2c)->BUSCTL &= ~I2C_BUSCTL_PECCLR_Msk)
  361. /**
  362. * @brief Enable RX PDMA function.
  363. * @param[in] i2c The pointer of the specified I2C module.
  364. * @return None.
  365. * @details Set RXPDMAEN bit of I2C_CTL1 register to enable RX PDMA transfer function.
  366. * \hideinitializer
  367. */
  368. #define I2C_ENABLE_RX_PDMA(i2c) ((i2c)->CTL1 |= I2C_CTL1_RXPDMAEN_Msk)
  369. /**
  370. * @brief Enable TX PDMA function.
  371. * @param[in] i2c The pointer of the specified I2C module.
  372. * @return None.
  373. * @details Set TXPDMAEN bit of I2C_CTL1 register to enable TX PDMA transfer function.
  374. * \hideinitializer
  375. */
  376. #define I2C_ENABLE_TX_PDMA(i2c) ((i2c)->CTL1 |= I2C_CTL1_TXPDMAEN_Msk)
  377. /**
  378. * @brief Disable RX PDMA transfer.
  379. * @param[in] i2c The pointer of the specified I2C module.
  380. * @return None.
  381. * @details Clear RXPDMAEN bit of I2C_CTL1 register to disable RX PDMA transfer function.
  382. * \hideinitializer
  383. */
  384. #define I2C_DISABLE_RX_PDMA(i2c) ((i2c)->CTL1 &= ~I2C_CTL1_RXPDMAEN_Msk)
  385. /**
  386. * @brief Disable TX PDMA transfer.
  387. * @param[in] i2c The pointer of the specified I2C module.
  388. * @return None.
  389. * @details Clear TXPDMAEN bit of I2C_CTL1 register to disable TX PDMA transfer function.
  390. * \hideinitializer
  391. */
  392. #define I2C_DISABLE_TX_PDMA(i2c) ((i2c)->CTL1 &= ~I2C_CTL1_TXPDMAEN_Msk)
  393. /**
  394. * @brief Enable PDMA stretch function.
  395. * @param[in] i2c The pointer of the specified I2C module.
  396. * @return None.
  397. * @details Enable this function is to stretch bus by hardware after PDMA transfer is done if SI is not cleared.
  398. * \hideinitializer
  399. */
  400. #define I2C_ENABLE_PDMA_STRETCH(i2c) ((i2c)->CTL1 |= I2C_CTL1_PDMASTR_Msk)
  401. /**
  402. * @brief Disable PDMA stretch function.
  403. * @param[in] i2c The pointer of the specified I2C module.
  404. * @return None.
  405. * @details I2C will send STOP after PDMA transfers done automatically.
  406. * \hideinitializer
  407. */
  408. #define I2C_DISABLE_PDMA_STRETCH(i2c) ((i2c)->CTL1 &= ~I2C_CTL1_PDMASTR_Msk)
  409. /**
  410. * @brief Reset PDMA function.
  411. * @param[in] i2c The pointer of the specified I2C module.
  412. * @return None.
  413. * @details I2C PDMA engine will be reset after this function is called.
  414. * \hideinitializer
  415. */
  416. #define I2C_DISABLE_RST_PDMA(i2c) ((i2c)->CTL1 |= I2C_CTL1_PDMARST_Msk)
  417. /*---------------------------------------------------------------------------------------------------------*/
  418. /* inline functions */
  419. /*---------------------------------------------------------------------------------------------------------*/
  420. /* Declare these inline functions here to avoid MISRA C 2004 rule 8.1 error */
  421. __STATIC_INLINE void I2C_STOP(I2C_T *i2c);
  422. /**
  423. * @brief The macro is used to set STOP condition of I2C Bus
  424. *
  425. * @param[in] i2c Specify I2C port
  426. *
  427. * @return None
  428. *
  429. * @details Set the I2C bus STOP condition in I2C_CTL register.
  430. */
  431. __STATIC_INLINE void I2C_STOP(I2C_T *i2c)
  432. {
  433. (i2c)->CTL0 |= (I2C_CTL0_SI_Msk | I2C_CTL0_STO_Msk);
  434. while(i2c->CTL0 & I2C_CTL0_STO_Msk)
  435. {
  436. }
  437. }
  438. void I2C_ClearTimeoutFlag(I2C_T *i2c);
  439. void I2C_Close(I2C_T *i2c);
  440. void I2C_Trigger(I2C_T *i2c, uint8_t u8Start, uint8_t u8Stop, uint8_t u8Si, uint8_t u8Ack);
  441. void I2C_DisableInt(I2C_T *i2c);
  442. void I2C_EnableInt(I2C_T *i2c);
  443. uint32_t I2C_GetBusClockFreq(I2C_T *i2c);
  444. uint32_t I2C_GetIntFlag(I2C_T *i2c);
  445. uint32_t I2C_GetStatus(I2C_T *i2c);
  446. uint32_t I2C_Open(I2C_T *i2c, uint32_t u32BusClock);
  447. uint8_t I2C_GetData(I2C_T *i2c);
  448. void I2C_SetSlaveAddr(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddr, uint8_t u8GCMode);
  449. void I2C_SetSlaveAddrMask(I2C_T *i2c, uint8_t u8SlaveNo, uint8_t u8SlaveAddrMask);
  450. uint32_t I2C_SetBusClockFreq(I2C_T *i2c, uint32_t u32BusClock);
  451. void I2C_EnableTimeout(I2C_T *i2c, uint8_t u8LongTimeout);
  452. void I2C_DisableTimeout(I2C_T *i2c);
  453. void I2C_EnableWakeup(I2C_T *i2c);
  454. void I2C_DisableWakeup(I2C_T *i2c);
  455. void I2C_SetData(I2C_T *i2c, uint8_t u8Data);
  456. uint8_t I2C_WriteByte(I2C_T *i2c, uint8_t u8SlaveAddr, uint8_t data);
  457. uint32_t I2C_WriteMultiBytes(I2C_T *i2c, uint8_t u8SlaveAddr, uint8_t data[], uint32_t u32wLen);
  458. uint8_t I2C_WriteByteOneReg(I2C_T *i2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr, uint8_t data);
  459. uint32_t I2C_WriteMultiBytesOneReg(I2C_T *i2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr, uint8_t data[], uint32_t u32wLen);
  460. uint8_t I2C_WriteByteTwoRegs(I2C_T *i2c, uint8_t u8SlaveAddr, uint16_t u16DataAddr, uint8_t data);
  461. uint32_t I2C_WriteMultiBytesTwoRegs(I2C_T *i2c, uint8_t u8SlaveAddr, uint16_t u16DataAddr, uint8_t data[], uint32_t u32wLen);
  462. uint8_t I2C_ReadByte(I2C_T *i2c, uint8_t u8SlaveAddr);
  463. uint32_t I2C_ReadMultiBytes(I2C_T *i2c, uint8_t u8SlaveAddr, uint8_t rdata[], uint32_t u32rLen);
  464. uint8_t I2C_ReadByteOneReg(I2C_T *i2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr);
  465. uint32_t I2C_ReadMultiBytesOneReg(I2C_T *i2c, uint8_t u8SlaveAddr, uint8_t u8DataAddr, uint8_t rdata[], uint32_t u32rLen);
  466. uint8_t I2C_ReadByteTwoRegs(I2C_T *i2c, uint8_t u8SlaveAddr, uint16_t u16DataAddr);
  467. uint32_t I2C_ReadMultiBytesTwoRegs(I2C_T *i2c, uint8_t u8SlaveAddr, uint16_t u16DataAddr, uint8_t rdata[], uint32_t u32rLen);
  468. uint32_t I2C_SMBusGetStatus(I2C_T *i2c);
  469. void I2C_SMBusClearInterruptFlag(I2C_T *i2c, uint8_t u8SMBusIntFlag);
  470. void I2C_SMBusSetPacketByteCount(I2C_T *i2c, uint32_t u32PktSize);
  471. void I2C_SMBusOpen(I2C_T *i2c, uint8_t u8HostDevice);
  472. void I2C_SMBusClose(I2C_T *i2c);
  473. void I2C_SMBusPECTxEnable(I2C_T *i2c, uint8_t u8PECTxEn);
  474. uint8_t I2C_SMBusGetPECValue(I2C_T *i2c);
  475. void I2C_SMBusIdleTimeout(I2C_T *i2c, uint32_t us, uint32_t u32Hclk);
  476. void I2C_SMBusTimeout(I2C_T *i2c, uint32_t ms, uint32_t u32Pclk);
  477. void I2C_SMBusClockLoTimeout(I2C_T *i2c, uint32_t ms, uint32_t u32Pclk);
  478. /*@}*/ /* end of group I2C_EXPORTED_FUNCTIONS */
  479. /*@}*/ /* end of group I2C_Driver */
  480. /*@}*/ /* end of group Standard_Driver */
  481. #ifdef __cplusplus
  482. }
  483. #endif
  484. #endif
  485. /*** (C) COPYRIGHT 2018 Nuvoton Technology Corp. ***/