Prusa MINI Firmware overview
stm32f4xx_hal_i2c.h
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  * @file stm32f4xx_hal_i2c.h
4  * @author MCD Application Team
5  * @brief Header file of I2C HAL module.
6  ******************************************************************************
7  * @attention
8  *
9  * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
10  *
11  * Redistribution and use in source and binary forms, with or without modification,
12  * are permitted provided that the following conditions are met:
13  * 1. Redistributions of source code must retain the above copyright notice,
14  * this list of conditions and the following disclaimer.
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  * 3. Neither the name of STMicroelectronics nor the names of its contributors
19  * may be used to endorse or promote products derived from this software
20  * without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  ******************************************************************************
34  */
35 
36 /* Define to prevent recursive inclusion -------------------------------------*/
37 #ifndef __STM32F4xx_HAL_I2C_H
38 #define __STM32F4xx_HAL_I2C_H
39 
40 #ifdef __cplusplus
41  extern "C" {
42 #endif
43 
44 /* Includes ------------------------------------------------------------------*/
45 #include "stm32f4xx_hal_def.h"
46 
47 /** @addtogroup STM32F4xx_HAL_Driver
48  * @{
49  */
50 
51 /** @addtogroup I2C
52  * @{
53  */
54 
55 /* Exported types ------------------------------------------------------------*/
56 /** @defgroup I2C_Exported_Types I2C Exported Types
57  * @{
58  */
59 
60 /**
61  * @brief I2C Configuration Structure definition
62  */
63 typedef struct
64 {
65  uint32_t ClockSpeed; /*!< Specifies the clock frequency.
66  This parameter must be set to a value lower than 400kHz */
67 
68  uint32_t DutyCycle; /*!< Specifies the I2C fast mode duty cycle.
69  This parameter can be a value of @ref I2C_duty_cycle_in_fast_mode */
70 
71  uint32_t OwnAddress1; /*!< Specifies the first device own address.
72  This parameter can be a 7-bit or 10-bit address. */
73 
74  uint32_t AddressingMode; /*!< Specifies if 7-bit or 10-bit addressing mode is selected.
75  This parameter can be a value of @ref I2C_addressing_mode */
76 
77  uint32_t DualAddressMode; /*!< Specifies if dual addressing mode is selected.
78  This parameter can be a value of @ref I2C_dual_addressing_mode */
79 
80  uint32_t OwnAddress2; /*!< Specifies the second device own address if dual addressing mode is selected
81  This parameter can be a 7-bit address. */
82 
83  uint32_t GeneralCallMode; /*!< Specifies if general call mode is selected.
84  This parameter can be a value of @ref I2C_general_call_addressing_mode */
85 
86  uint32_t NoStretchMode; /*!< Specifies if nostretch mode is selected.
87  This parameter can be a value of @ref I2C_nostretch_mode */
88 
90 
91 /**
92  * @brief HAL State structure definition
93  * @note HAL I2C State value coding follow below described bitmap :
94  * b7-b6 Error information
95  * 00 : No Error
96  * 01 : Abort (Abort user request on going)
97  * 10 : Timeout
98  * 11 : Error
99  * b5 IP initilisation status
100  * 0 : Reset (IP not initialized)
101  * 1 : Init done (IP initialized and ready to use. HAL I2C Init function called)
102  * b4 (not used)
103  * x : Should be set to 0
104  * b3
105  * 0 : Ready or Busy (No Listen mode ongoing)
106  * 1 : Listen (IP in Address Listen Mode)
107  * b2 Intrinsic process state
108  * 0 : Ready
109  * 1 : Busy (IP busy with some configuration or internal operations)
110  * b1 Rx state
111  * 0 : Ready (no Rx operation ongoing)
112  * 1 : Busy (Rx operation ongoing)
113  * b0 Tx state
114  * 0 : Ready (no Tx operation ongoing)
115  * 1 : Busy (Tx operation ongoing)
116  */
117 typedef enum
118 {
119  HAL_I2C_STATE_RESET = 0x00U, /*!< Peripheral is not yet Initialized */
120  HAL_I2C_STATE_READY = 0x20U, /*!< Peripheral Initialized and ready for use */
121  HAL_I2C_STATE_BUSY = 0x24U, /*!< An internal process is ongoing */
122  HAL_I2C_STATE_BUSY_TX = 0x21U, /*!< Data Transmission process is ongoing */
123  HAL_I2C_STATE_BUSY_RX = 0x22U, /*!< Data Reception process is ongoing */
124  HAL_I2C_STATE_LISTEN = 0x28U, /*!< Address Listen Mode is ongoing */
125  HAL_I2C_STATE_BUSY_TX_LISTEN = 0x29U, /*!< Address Listen Mode and Data Transmission
126  process is ongoing */
127  HAL_I2C_STATE_BUSY_RX_LISTEN = 0x2AU, /*!< Address Listen Mode and Data Reception
128  process is ongoing */
129  HAL_I2C_STATE_ABORT = 0x60U, /*!< Abort user request ongoing */
130  HAL_I2C_STATE_TIMEOUT = 0xA0U, /*!< Timeout state */
131  HAL_I2C_STATE_ERROR = 0xE0U /*!< Error */
132 
134 
135 /**
136  * @brief HAL Mode structure definition
137  * @note HAL I2C Mode value coding follow below described bitmap :
138  * b7 (not used)
139  * x : Should be set to 0
140  * b6
141  * 0 : None
142  * 1 : Memory (HAL I2C communication is in Memory Mode)
143  * b5
144  * 0 : None
145  * 1 : Slave (HAL I2C communication is in Slave Mode)
146  * b4
147  * 0 : None
148  * 1 : Master (HAL I2C communication is in Master Mode)
149  * b3-b2-b1-b0 (not used)
150  * xxxx : Should be set to 0000
151  */
152 typedef enum
153 {
154  HAL_I2C_MODE_NONE = 0x00U, /*!< No I2C communication on going */
155  HAL_I2C_MODE_MASTER = 0x10U, /*!< I2C communication is in Master Mode */
156  HAL_I2C_MODE_SLAVE = 0x20U, /*!< I2C communication is in Slave Mode */
157  HAL_I2C_MODE_MEM = 0x40U /*!< I2C communication is in Memory Mode */
158 
160 
161 /**
162  * @brief I2C handle Structure definition
163  */
164 typedef struct
165 {
166  I2C_TypeDef *Instance; /*!< I2C registers base address */
167 
168  I2C_InitTypeDef Init; /*!< I2C communication parameters */
169 
170  uint8_t *pBuffPtr; /*!< Pointer to I2C transfer buffer */
171 
172  uint16_t XferSize; /*!< I2C transfer size */
173 
174  __IO uint16_t XferCount; /*!< I2C transfer counter */
175 
176  __IO uint32_t XferOptions; /*!< I2C transfer options */
177 
178  __IO uint32_t PreviousState; /*!< I2C communication Previous state and mode
179  context for internal usage */
180 
181  DMA_HandleTypeDef *hdmatx; /*!< I2C Tx DMA handle parameters */
182 
183  DMA_HandleTypeDef *hdmarx; /*!< I2C Rx DMA handle parameters */
184 
185  HAL_LockTypeDef Lock; /*!< I2C locking object */
186 
187  __IO HAL_I2C_StateTypeDef State; /*!< I2C communication state */
188 
189  __IO HAL_I2C_ModeTypeDef Mode; /*!< I2C communication mode */
190 
191  __IO uint32_t ErrorCode; /*!< I2C Error code */
192 
193  __IO uint32_t Devaddress; /*!< I2C Target device address */
194 
195  __IO uint32_t Memaddress; /*!< I2C Target memory address */
196 
197  __IO uint32_t MemaddSize; /*!< I2C Target memory address size */
198 
199  __IO uint32_t EventCount; /*!< I2C Event counter */
200 
202 
203 /**
204  * @}
205  */
206 
207 /* Exported constants --------------------------------------------------------*/
208 /** @defgroup I2C_Exported_Constants I2C Exported Constants
209  * @{
210  */
211 
212 /** @defgroup I2C_Error_Code I2C Error Code
213  * @brief I2C Error Code
214  * @{
215  */
216 #define HAL_I2C_ERROR_NONE 0x00000000U /*!< No error */
217 #define HAL_I2C_ERROR_BERR 0x00000001U /*!< BERR error */
218 #define HAL_I2C_ERROR_ARLO 0x00000002U /*!< ARLO error */
219 #define HAL_I2C_ERROR_AF 0x00000004U /*!< AF error */
220 #define HAL_I2C_ERROR_OVR 0x00000008U /*!< OVR error */
221 #define HAL_I2C_ERROR_DMA 0x00000010U /*!< DMA transfer error */
222 #define HAL_I2C_ERROR_TIMEOUT 0x00000020U /*!< Timeout Error */
223 /**
224  * @}
225  */
226 
227 /** @defgroup I2C_duty_cycle_in_fast_mode I2C duty cycle in fast mode
228  * @{
229  */
230 #define I2C_DUTYCYCLE_2 0x00000000U
231 #define I2C_DUTYCYCLE_16_9 I2C_CCR_DUTY
232 /**
233  * @}
234  */
235 
236 /** @defgroup I2C_addressing_mode I2C addressing mode
237  * @{
238  */
239 #define I2C_ADDRESSINGMODE_7BIT 0x00004000U
240 #define I2C_ADDRESSINGMODE_10BIT (I2C_OAR1_ADDMODE | 0x00004000U)
241 /**
242  * @}
243  */
244 
245 /** @defgroup I2C_dual_addressing_mode I2C dual addressing mode
246  * @{
247  */
248 #define I2C_DUALADDRESS_DISABLE 0x00000000U
249 #define I2C_DUALADDRESS_ENABLE I2C_OAR2_ENDUAL
250 /**
251  * @}
252  */
253 
254 /** @defgroup I2C_general_call_addressing_mode I2C general call addressing mode
255  * @{
256  */
257 #define I2C_GENERALCALL_DISABLE 0x00000000U
258 #define I2C_GENERALCALL_ENABLE I2C_CR1_ENGC
259 /**
260  * @}
261  */
262 
263 /** @defgroup I2C_nostretch_mode I2C nostretch mode
264  * @{
265  */
266 #define I2C_NOSTRETCH_DISABLE 0x00000000U
267 #define I2C_NOSTRETCH_ENABLE I2C_CR1_NOSTRETCH
268 /**
269  * @}
270  */
271 
272 /** @defgroup I2C_Memory_Address_Size I2C Memory Address Size
273  * @{
274  */
275 #define I2C_MEMADD_SIZE_8BIT 0x00000001U
276 #define I2C_MEMADD_SIZE_16BIT 0x00000010U
277 /**
278  * @}
279  */
280 
281 /** @defgroup I2C_XferDirection_definition I2C XferDirection definition
282  * @{
283  */
284 #define I2C_DIRECTION_RECEIVE 0x00000000U
285 #define I2C_DIRECTION_TRANSMIT 0x00000001U
286 /**
287  * @}
288  */
289 
290 /** @defgroup I2C_XferOptions_definition I2C XferOptions definition
291  * @{
292  */
293 #define I2C_FIRST_FRAME 0x00000001U
294 #define I2C_NEXT_FRAME 0x00000002U
295 #define I2C_FIRST_AND_LAST_FRAME 0x00000004U
296 #define I2C_LAST_FRAME 0x00000008U
297 /**
298  * @}
299  */
300 
301 /** @defgroup I2C_Interrupt_configuration_definition I2C Interrupt configuration definition
302  * @{
303  */
304 #define I2C_IT_BUF I2C_CR2_ITBUFEN
305 #define I2C_IT_EVT I2C_CR2_ITEVTEN
306 #define I2C_IT_ERR I2C_CR2_ITERREN
307 /**
308  * @}
309  */
310 
311 /** @defgroup I2C_Flag_definition I2C Flag definition
312  * @{
313  */
314 #define I2C_FLAG_SMBALERT 0x00018000U
315 #define I2C_FLAG_TIMEOUT 0x00014000U
316 #define I2C_FLAG_PECERR 0x00011000U
317 #define I2C_FLAG_OVR 0x00010800U
318 #define I2C_FLAG_AF 0x00010400U
319 #define I2C_FLAG_ARLO 0x00010200U
320 #define I2C_FLAG_BERR 0x00010100U
321 #define I2C_FLAG_TXE 0x00010080U
322 #define I2C_FLAG_RXNE 0x00010040U
323 #define I2C_FLAG_STOPF 0x00010010U
324 #define I2C_FLAG_ADD10 0x00010008U
325 #define I2C_FLAG_BTF 0x00010004U
326 #define I2C_FLAG_ADDR 0x00010002U
327 #define I2C_FLAG_SB 0x00010001U
328 #define I2C_FLAG_DUALF 0x00100080U
329 #define I2C_FLAG_SMBHOST 0x00100040U
330 #define I2C_FLAG_SMBDEFAULT 0x00100020U
331 #define I2C_FLAG_GENCALL 0x00100010U
332 #define I2C_FLAG_TRA 0x00100004U
333 #define I2C_FLAG_BUSY 0x00100002U
334 #define I2C_FLAG_MSL 0x00100001U
335 /**
336  * @}
337  */
338 
339 /**
340  * @}
341  */
342 
343 /* Exported macro ------------------------------------------------------------*/
344 /** @defgroup I2C_Exported_Macros I2C Exported Macros
345  * @{
346  */
347 
348 /** @brief Reset I2C handle state
349  * @param __HANDLE__ specifies the I2C Handle.
350  * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
351  * @retval None
352  */
353 #define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2C_STATE_RESET)
354 
355 /** @brief Enable or disable the specified I2C interrupts.
356  * @param __HANDLE__ specifies the I2C Handle.
357  * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
358  * @param __INTERRUPT__ specifies the interrupt source to enable or disable.
359  * This parameter can be one of the following values:
360  * @arg I2C_IT_BUF: Buffer interrupt enable
361  * @arg I2C_IT_EVT: Event interrupt enable
362  * @arg I2C_IT_ERR: Error interrupt enable
363  * @retval None
364  */
365 #define __HAL_I2C_ENABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 |= (__INTERRUPT__))
366 #define __HAL_I2C_DISABLE_IT(__HANDLE__, __INTERRUPT__) ((__HANDLE__)->Instance->CR2 &= (~(__INTERRUPT__)))
367 
368 /** @brief Checks if the specified I2C interrupt source is enabled or disabled.
369  * @param __HANDLE__ specifies the I2C Handle.
370  * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
371  * @param __INTERRUPT__ specifies the I2C interrupt source to check.
372  * This parameter can be one of the following values:
373  * @arg I2C_IT_BUF: Buffer interrupt enable
374  * @arg I2C_IT_EVT: Event interrupt enable
375  * @arg I2C_IT_ERR: Error interrupt enable
376  * @retval The new state of __INTERRUPT__ (TRUE or FALSE).
377  */
378 #define __HAL_I2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR2 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
379 
380 /** @brief Checks whether the specified I2C flag is set or not.
381  * @param __HANDLE__ specifies the I2C Handle.
382  * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
383  * @param __FLAG__ specifies the flag to check.
384  * This parameter can be one of the following values:
385  * @arg I2C_FLAG_SMBALERT: SMBus Alert flag
386  * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow error flag
387  * @arg I2C_FLAG_PECERR: PEC error in reception flag
388  * @arg I2C_FLAG_OVR: Overrun/Underrun flag
389  * @arg I2C_FLAG_AF: Acknowledge failure flag
390  * @arg I2C_FLAG_ARLO: Arbitration lost flag
391  * @arg I2C_FLAG_BERR: Bus error flag
392  * @arg I2C_FLAG_TXE: Data register empty flag
393  * @arg I2C_FLAG_RXNE: Data register not empty flag
394  * @arg I2C_FLAG_STOPF: Stop detection flag
395  * @arg I2C_FLAG_ADD10: 10-bit header sent flag
396  * @arg I2C_FLAG_BTF: Byte transfer finished flag
397  * @arg I2C_FLAG_ADDR: Address sent flag
398  * Address matched flag
399  * @arg I2C_FLAG_SB: Start bit flag
400  * @arg I2C_FLAG_DUALF: Dual flag
401  * @arg I2C_FLAG_SMBHOST: SMBus host header
402  * @arg I2C_FLAG_SMBDEFAULT: SMBus default header
403  * @arg I2C_FLAG_GENCALL: General call header flag
404  * @arg I2C_FLAG_TRA: Transmitter/Receiver flag
405  * @arg I2C_FLAG_BUSY: Bus busy flag
406  * @arg I2C_FLAG_MSL: Master/Slave flag
407  * @retval The new state of __FLAG__ (TRUE or FALSE).
408  */
409 #define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) ((((uint8_t)((__FLAG__) >> 16U)) == 0x01U)?((((__HANDLE__)->Instance->SR1) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)): \
410  ((((__HANDLE__)->Instance->SR2) & ((__FLAG__) & I2C_FLAG_MASK)) == ((__FLAG__) & I2C_FLAG_MASK)))
411 
412 /** @brief Clears the I2C pending flags which are cleared by writing 0 in a specific bit.
413  * @param __HANDLE__ specifies the I2C Handle.
414  * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
415  * @param __FLAG__ specifies the flag to clear.
416  * This parameter can be any combination of the following values:
417  * @arg I2C_FLAG_SMBALERT: SMBus Alert flag
418  * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow error flag
419  * @arg I2C_FLAG_PECERR: PEC error in reception flag
420  * @arg I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode)
421  * @arg I2C_FLAG_AF: Acknowledge failure flag
422  * @arg I2C_FLAG_ARLO: Arbitration lost flag (Master mode)
423  * @arg I2C_FLAG_BERR: Bus error flag
424  * @retval None
425  */
426 #define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->SR1 = ~((__FLAG__) & I2C_FLAG_MASK))
427 
428 /** @brief Clears the I2C ADDR pending flag.
429  * @param __HANDLE__ specifies the I2C Handle.
430  * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
431  * @retval None
432  */
433 #define __HAL_I2C_CLEAR_ADDRFLAG(__HANDLE__) \
434  do{ \
435  __IO uint32_t tmpreg = 0x00U; \
436  tmpreg = (__HANDLE__)->Instance->SR1; \
437  tmpreg = (__HANDLE__)->Instance->SR2; \
438  UNUSED(tmpreg); \
439  } while(0)
440 
441 /** @brief Clears the I2C STOPF pending flag.
442  * @param __HANDLE__ specifies the I2C Handle.
443  * This parameter can be I2C where x: 1, 2, or 3 to select the I2C peripheral.
444  * @retval None
445  */
446 #define __HAL_I2C_CLEAR_STOPFLAG(__HANDLE__) \
447  do{ \
448  __IO uint32_t tmpreg = 0x00U; \
449  tmpreg = (__HANDLE__)->Instance->SR1; \
450  (__HANDLE__)->Instance->CR1 |= I2C_CR1_PE; \
451  UNUSED(tmpreg); \
452  } while(0)
453 
454 /** @brief Enable the I2C peripheral.
455  * @param __HANDLE__ specifies the I2C Handle.
456  * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral.
457  * @retval None
458  */
459 #define __HAL_I2C_ENABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 |= I2C_CR1_PE)
460 
461 /** @brief Disable the I2C peripheral.
462  * @param __HANDLE__ specifies the I2C Handle.
463  * This parameter can be I2Cx where x: 1 or 2 to select the I2C peripheral.
464  * @retval None
465  */
466 #define __HAL_I2C_DISABLE(__HANDLE__) ((__HANDLE__)->Instance->CR1 &= ~I2C_CR1_PE)
467 
468 /**
469  * @}
470  */
471 
472 /* Include I2C HAL Extension module */
473 #include "stm32f4xx_hal_i2c_ex.h"
474 
475 /* Exported functions --------------------------------------------------------*/
476 /** @addtogroup I2C_Exported_Functions
477  * @{
478  */
479 
480 /** @addtogroup I2C_Exported_Functions_Group1
481  * @{
482  */
483 /* Initialization/de-initialization functions **********************************/
488 /**
489  * @}
490  */
491 
492 /** @addtogroup I2C_Exported_Functions_Group2
493  * @{
494  */
495 /* I/O operation functions *****************************************************/
496 /******* Blocking mode: Polling */
497 HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
498 HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
499 HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
500 HAL_StatusTypeDef HAL_I2C_Slave_Receive(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
501 HAL_StatusTypeDef HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
502 HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout);
503 HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout);
504 
505 /******* Non-Blocking mode: Interrupt */
506 HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
507 HAL_StatusTypeDef HAL_I2C_Master_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
510 HAL_StatusTypeDef HAL_I2C_Mem_Write_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
511 HAL_StatusTypeDef HAL_I2C_Mem_Read_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
512 
513 HAL_StatusTypeDef HAL_I2C_Master_Sequential_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
514 HAL_StatusTypeDef HAL_I2C_Master_Sequential_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
515 HAL_StatusTypeDef HAL_I2C_Slave_Sequential_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
516 HAL_StatusTypeDef HAL_I2C_Slave_Sequential_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions);
520 
521 /******* Non-Blocking mode: DMA */
522 HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
523 HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
526 HAL_StatusTypeDef HAL_I2C_Mem_Write_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
527 HAL_StatusTypeDef HAL_I2C_Mem_Read_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size);
528 
529 /******* I2C IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
536 void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode);
542 /**
543  * @}
544  */
545 
546 /** @addtogroup I2C_Exported_Functions_Group3
547  * @{
548  */
549 /* Peripheral State, Mode and Errors functions *********************************/
552 uint32_t HAL_I2C_GetError(I2C_HandleTypeDef *hi2c);
553 
554 /**
555  * @}
556  */
557 
558 /**
559  * @}
560  */
561 /* Private types -------------------------------------------------------------*/
562 /* Private variables ---------------------------------------------------------*/
563 /* Private constants ---------------------------------------------------------*/
564 /** @defgroup I2C_Private_Constants I2C Private Constants
565  * @{
566  */
567 #define I2C_FLAG_MASK 0x0000FFFFU
568 /**
569  * @}
570  */
571 
572 /* Private macros ------------------------------------------------------------*/
573 /** @defgroup I2C_Private_Macros I2C Private Macros
574  * @{
575  */
576 
577 #define I2C_FREQRANGE(__PCLK__) ((__PCLK__)/1000000U)
578 #define I2C_RISE_TIME(__FREQRANGE__, __SPEED__) (((__SPEED__) <= 100000U) ? ((__FREQRANGE__) + 1U) : ((((__FREQRANGE__) * 300U) / 1000U) + 1U))
579 #define I2C_SPEED_STANDARD(__PCLK__, __SPEED__) (((((__PCLK__)/((__SPEED__) << 1U)) & I2C_CCR_CCR) < 4U)? 4U:((__PCLK__) / ((__SPEED__) << 1U)))
580 #define I2C_SPEED_FAST(__PCLK__, __SPEED__, __DUTYCYCLE__) (((__DUTYCYCLE__) == I2C_DUTYCYCLE_2)? ((__PCLK__) / ((__SPEED__) * 3U)) : (((__PCLK__) / ((__SPEED__) * 25U)) | I2C_DUTYCYCLE_16_9))
581 #define I2C_SPEED(__PCLK__, __SPEED__, __DUTYCYCLE__) (((__SPEED__) <= 100000U)? (I2C_SPEED_STANDARD((__PCLK__), (__SPEED__))) : \
582  ((I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__)) & I2C_CCR_CCR) == 0U)? 1U : \
583  ((I2C_SPEED_FAST((__PCLK__), (__SPEED__), (__DUTYCYCLE__))) | I2C_CCR_FS))
584 
585 #define I2C_7BIT_ADD_WRITE(__ADDRESS__) ((uint8_t)((__ADDRESS__) & (~I2C_OAR1_ADD0)))
586 #define I2C_7BIT_ADD_READ(__ADDRESS__) ((uint8_t)((__ADDRESS__) | I2C_OAR1_ADD0))
587 
588 #define I2C_10BIT_ADDRESS(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)0x00FF)))
589 #define I2C_10BIT_HEADER_WRITE(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0x0300)) >> 7) | (uint16_t)0x00F0)))
590 #define I2C_10BIT_HEADER_READ(__ADDRESS__) ((uint8_t)((uint16_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0x0300)) >> 7) | (uint16_t)(0x00F1))))
591 
592 #define I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)0xFF00)) >> 8)))
593 #define I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)0x00FF)))
594 
595 /** @defgroup I2C_IS_RTC_Definitions I2C Private macros to check input parameters
596  * @{
597  */
598 #define IS_I2C_DUTY_CYCLE(CYCLE) (((CYCLE) == I2C_DUTYCYCLE_2) || \
599  ((CYCLE) == I2C_DUTYCYCLE_16_9))
600 #define IS_I2C_ADDRESSING_MODE(ADDRESS) (((ADDRESS) == I2C_ADDRESSINGMODE_7BIT) || \
601  ((ADDRESS) == I2C_ADDRESSINGMODE_10BIT))
602 #define IS_I2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == I2C_DUALADDRESS_DISABLE) || \
603  ((ADDRESS) == I2C_DUALADDRESS_ENABLE))
604 #define IS_I2C_GENERAL_CALL(CALL) (((CALL) == I2C_GENERALCALL_DISABLE) || \
605  ((CALL) == I2C_GENERALCALL_ENABLE))
606 #define IS_I2C_NO_STRETCH(STRETCH) (((STRETCH) == I2C_NOSTRETCH_DISABLE) || \
607  ((STRETCH) == I2C_NOSTRETCH_ENABLE))
608 #define IS_I2C_MEMADD_SIZE(SIZE) (((SIZE) == I2C_MEMADD_SIZE_8BIT) || \
609  ((SIZE) == I2C_MEMADD_SIZE_16BIT))
610 #define IS_I2C_CLOCK_SPEED(SPEED) (((SPEED) > 0U) && ((SPEED) <= 400000U))
611 #define IS_I2C_OWN_ADDRESS1(ADDRESS1) (((ADDRESS1) & 0xFFFFFC00U) == 0U)
612 #define IS_I2C_OWN_ADDRESS2(ADDRESS2) (((ADDRESS2) & 0xFFFFFF01U) == 0U)
613 #define IS_I2C_TRANSFER_OPTIONS_REQUEST(REQUEST) (((REQUEST) == I2C_FIRST_FRAME) || \
614  ((REQUEST) == I2C_NEXT_FRAME) || \
615  ((REQUEST) == I2C_FIRST_AND_LAST_FRAME) || \
616  ((REQUEST) == I2C_LAST_FRAME))
617 /**
618  * @}
619  */
620 
621 /**
622  * @}
623  */
624 
625 /* Private functions ---------------------------------------------------------*/
626 /** @defgroup I2C_Private_Functions I2C Private Functions
627  * @{
628  */
629 
630 /**
631  * @}
632  */
633 
634 /**
635  * @}
636  */
637 
638 /**
639  * @}
640  */
641 
642 #ifdef __cplusplus
643 }
644 #endif
645 
646 
647 #endif /* __STM32F4xx_HAL_I2C_H */
648 
649 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
HAL_I2C_Mem_Read_DMA
HAL_StatusTypeDef HAL_I2C_Mem_Read_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size)
I2C_InitTypeDef::OwnAddress2
uint32_t OwnAddress2
Definition: stm32f4xx_hal_i2c.h:80
HAL_I2C_EnableListen_IT
HAL_StatusTypeDef HAL_I2C_EnableListen_IT(I2C_HandleTypeDef *hi2c)
I2C_HandleTypeDef::EventCount
__IO uint32_t EventCount
Definition: stm32f4xx_hal_i2c.h:199
HAL_I2C_STATE_READY
Definition: stm32f4xx_hal_i2c.h:120
HAL_I2C_SlaveTxCpltCallback
void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c)
stm32f4xx_hal_def.h
This file contains HAL common defines, enumeration, macros and structures definitions.
HAL_I2C_MemRxCpltCallback
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c)
I2C_HandleTypeDef::ErrorCode
__IO uint32_t ErrorCode
Definition: stm32f4xx_hal_i2c.h:191
HAL_I2C_MODE_MASTER
Definition: stm32f4xx_hal_i2c.h:155
I2C_HandleTypeDef::Memaddress
__IO uint32_t Memaddress
Definition: stm32f4xx_hal_i2c.h:195
HAL_I2C_IsDeviceReady
HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout)
HAL_I2C_MspInit
void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c)
I2C MSP Initialization This function configures the hardware resources used in this example.
Definition: stm32f4xx_hal_msp.c:190
HAL_I2C_MODE_NONE
Definition: stm32f4xx_hal_i2c.h:154
I2C_HandleTypeDef::XferOptions
__IO uint32_t XferOptions
Definition: stm32f4xx_hal_i2c.h:176
HAL_I2C_MasterTxCpltCallback
void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c)
HAL_I2C_MspDeInit
void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c)
I2C MSP De-Initialization This function freeze the hardware resources used in this example.
Definition: stm32f4xx_hal_msp.c:225
HAL_I2C_ErrorCallback
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c)
I2C_InitTypeDef::DutyCycle
uint32_t DutyCycle
Definition: stm32f4xx_hal_i2c.h:68
HAL_I2C_DisableListen_IT
HAL_StatusTypeDef HAL_I2C_DisableListen_IT(I2C_HandleTypeDef *hi2c)
HAL_I2C_AddrCallback
void HAL_I2C_AddrCallback(I2C_HandleTypeDef *hi2c, uint8_t TransferDirection, uint16_t AddrMatchCode)
HAL_I2C_Master_Sequential_Receive_IT
HAL_StatusTypeDef HAL_I2C_Master_Sequential_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions)
I2C_HandleTypeDef::XferCount
__IO uint16_t XferCount
Definition: stm32f4xx_hal_i2c.h:174
I2C_HandleTypeDef::Devaddress
__IO uint32_t Devaddress
Definition: stm32f4xx_hal_i2c.h:193
HAL_I2C_DeInit
HAL_StatusTypeDef HAL_I2C_DeInit(I2C_HandleTypeDef *hi2c)
I2C_InitTypeDef
I2C Configuration Structure definition.
Definition: stm32f4xx_hal_i2c.h:63
HAL_I2C_GetError
uint32_t HAL_I2C_GetError(I2C_HandleTypeDef *hi2c)
HAL_I2C_STATE_BUSY
Definition: stm32f4xx_hal_i2c.h:121
HAL_StatusTypeDef
HAL_StatusTypeDef
HAL Status structures definition.
Definition: stm32f4xx_hal_def.h:55
HAL_I2C_EV_IRQHandler
void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c)
HAL_I2C_Slave_Receive_IT
HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size)
HAL_I2C_GetState
HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c)
HAL_I2C_Master_Transmit_DMA
HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size)
HAL_I2C_Master_Receive_IT
HAL_StatusTypeDef HAL_I2C_Master_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size)
HAL_I2C_Slave_Transmit_IT
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size)
I2C_InitTypeDef::AddressingMode
uint32_t AddressingMode
Definition: stm32f4xx_hal_i2c.h:74
HAL_I2C_AbortCpltCallback
void HAL_I2C_AbortCpltCallback(I2C_HandleTypeDef *hi2c)
HAL_I2C_STATE_ABORT
Definition: stm32f4xx_hal_i2c.h:129
HAL_I2C_Slave_Sequential_Transmit_IT
HAL_StatusTypeDef HAL_I2C_Slave_Sequential_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions)
HAL_I2C_Mem_Write
HAL_StatusTypeDef HAL_I2C_Mem_Write(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout)
I2C_InitTypeDef::GeneralCallMode
uint32_t GeneralCallMode
Definition: stm32f4xx_hal_i2c.h:83
__DMA_HandleTypeDef
DMA handle Structure definition.
Definition: stm32f4xx_hal_dma.h:155
HAL_I2C_Master_Sequential_Transmit_IT
HAL_StatusTypeDef HAL_I2C_Master_Sequential_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t XferOptions)
I2C_HandleTypeDef::PreviousState
__IO uint32_t PreviousState
Definition: stm32f4xx_hal_i2c.h:178
HAL_I2C_ER_IRQHandler
void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c)
stm32f4xx_hal_i2c_ex.h
Header file of I2C HAL Extension module.
HAL_I2C_SlaveRxCpltCallback
void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c)
I2C_InitTypeDef::OwnAddress1
uint32_t OwnAddress1
Definition: stm32f4xx_hal_i2c.h:71
HAL_I2C_Mem_Read
HAL_StatusTypeDef HAL_I2C_Mem_Read(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size, uint32_t Timeout)
I2C_HandleTypeDef::hdmatx
DMA_HandleTypeDef * hdmatx
Definition: stm32f4xx_hal_i2c.h:181
I2C_HandleTypeDef::Lock
HAL_LockTypeDef Lock
Definition: stm32f4xx_hal_i2c.h:185
I2C_HandleTypeDef::Init
I2C_InitTypeDef Init
Definition: stm32f4xx_hal_i2c.h:168
HAL_I2C_STATE_LISTEN
Definition: stm32f4xx_hal_i2c.h:124
uint8_t
const uint8_t[]
Definition: 404_html.c:3
HAL_I2C_Slave_Transmit_DMA
HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size)
I2C_HandleTypeDef::State
__IO HAL_I2C_StateTypeDef State
Definition: stm32f4xx_hal_i2c.h:187
HAL_I2C_STATE_BUSY_RX
Definition: stm32f4xx_hal_i2c.h:123
HAL_I2C_Master_Transmit
HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout)
HAL_I2C_Slave_Sequential_Receive_IT
HAL_StatusTypeDef HAL_I2C_Slave_Sequential_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t XferOptions)
HAL_I2C_ModeTypeDef
HAL_I2C_ModeTypeDef
HAL Mode structure definition.
Definition: stm32f4xx_hal_i2c.h:152
I2C_HandleTypeDef::hdmarx
DMA_HandleTypeDef * hdmarx
Definition: stm32f4xx_hal_i2c.h:183
HAL_I2C_STATE_BUSY_TX
Definition: stm32f4xx_hal_i2c.h:122
HAL_I2C_Slave_Receive_DMA
HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size)
I2C_HandleTypeDef::MemaddSize
__IO uint32_t MemaddSize
Definition: stm32f4xx_hal_i2c.h:197
HAL_I2C_Master_Abort_IT
HAL_StatusTypeDef HAL_I2C_Master_Abort_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress)
I2C_HandleTypeDef::Instance
I2C_TypeDef * Instance
Definition: stm32f4xx_hal_i2c.h:166
HAL_I2C_Mem_Write_IT
HAL_StatusTypeDef HAL_I2C_Mem_Write_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size)
HAL_I2C_STATE_BUSY_RX_LISTEN
Definition: stm32f4xx_hal_i2c.h:127
HAL_I2C_ListenCpltCallback
void HAL_I2C_ListenCpltCallback(I2C_HandleTypeDef *hi2c)
I2C_HandleTypeDef::pBuffPtr
uint8_t * pBuffPtr
Definition: stm32f4xx_hal_i2c.h:170
I2C_InitTypeDef::ClockSpeed
uint32_t ClockSpeed
Definition: stm32f4xx_hal_i2c.h:65
HAL_I2C_Master_Receive
HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout)
I2C_HandleTypeDef::Mode
__IO HAL_I2C_ModeTypeDef Mode
Definition: stm32f4xx_hal_i2c.h:189
HAL_I2C_MODE_MEM
Definition: stm32f4xx_hal_i2c.h:157
HAL_I2C_MasterRxCpltCallback
void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c)
I2C_InitTypeDef::DualAddressMode
uint32_t DualAddressMode
Definition: stm32f4xx_hal_i2c.h:77
HAL_I2C_Init
HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c)
HAL_I2C_MemTxCpltCallback
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c)
HAL_I2C_STATE_BUSY_TX_LISTEN
Definition: stm32f4xx_hal_i2c.h:125
HAL_I2C_GetMode
HAL_I2C_ModeTypeDef HAL_I2C_GetMode(I2C_HandleTypeDef *hi2c)
HAL_I2C_Master_Transmit_IT
HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size)
HAL_LockTypeDef
HAL_LockTypeDef
HAL Lock structures definition.
Definition: stm32f4xx_hal_def.h:66
HAL_I2C_StateTypeDef
HAL_I2C_StateTypeDef
HAL State structure definition.
Definition: stm32f4xx_hal_i2c.h:117
HAL_I2C_Mem_Read_IT
HAL_StatusTypeDef HAL_I2C_Mem_Read_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size)
HAL_I2C_Master_Receive_DMA
HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size)
HAL_I2C_STATE_TIMEOUT
Definition: stm32f4xx_hal_i2c.h:130
HAL_I2C_STATE_RESET
Definition: stm32f4xx_hal_i2c.h:119
HAL_I2C_Slave_Receive
HAL_StatusTypeDef HAL_I2C_Slave_Receive(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout)
I2C_InitTypeDef::NoStretchMode
uint32_t NoStretchMode
Definition: stm32f4xx_hal_i2c.h:86
HAL_I2C_MODE_SLAVE
Definition: stm32f4xx_hal_i2c.h:156
I2C_HandleTypeDef::XferSize
uint16_t XferSize
Definition: stm32f4xx_hal_i2c.h:172
HAL_I2C_Mem_Write_DMA
HAL_StatusTypeDef HAL_I2C_Mem_Write_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint16_t MemAddress, uint16_t MemAddSize, uint8_t *pData, uint16_t Size)
HAL_I2C_STATE_ERROR
Definition: stm32f4xx_hal_i2c.h:131
I2C_HandleTypeDef
I2C handle Structure definition.
Definition: stm32f4xx_hal_i2c.h:164
HAL_I2C_Slave_Transmit
HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout)