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