gr55xx_hal_i2c.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file gr55xx_hal_i2c.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of I2C HAL library.
7  *
8  ****************************************************************************************
9  * @attention
10  #####Copyright (c) 2019 GOODIX
11  All rights reserved.
12 
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  * Neither the name of GOODIX nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23 
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  ****************************************************************************************
36  */
37 
38 /** @addtogroup PERIPHERAL Peripheral Driver
39  * @{
40  */
41 
42 /** @addtogroup HAL_DRIVER HAL Driver
43  * @{
44  */
45 
46 /** @defgroup HAL_I2C I2C
47  * @brief I2C HAL module driver.
48  * @{
49  */
50 
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_I2C_H__
53 #define __GR55xx_HAL_I2C_H__
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_i2c.h"
61 #include "gr55xx_hal_def.h"
62 
63 /* Exported types ------------------------------------------------------------*/
64 /** @addtogroup HAL_I2C_ENUMERATIONS Enumerations
65  * @{
66  */
67 
68 /** @defgroup HAL_I2C_state HAL I2C state
69  * @{
70  */
71 
72 /**
73  * @brief HAL I2C State Enumerations definition
74  * @note HAL I2C State value coding follow below described bitmap :\n
75  * @verbatim
76  b7-b6 Error information
77  00 : No Error
78  01 : Abort (Abort user request on going)
79  10 : Timeout
80  11 : Error
81  b5 IP initilisation status
82  0 : Reset (IP not initialized)
83  1 : init done (IP initialized and ready to use. HAL I2C init function called)
84  b4 (not used)
85  x : Should be set to 0
86  b3
87  0 : Ready or Busy (No Listen mode ongoing)
88  1 : Listen (IP in Address Listen Mode)
89  b2 Intrinsic process state
90  0 : Ready
91  1 : Busy (IP busy with some configuration or internal operations)
92  b1 Rx state
93  0 : Ready (no Rx operation ongoing)
94  1 : Busy (Rx operation ongoing)
95  b0 Tx state
96  0 : Ready (no Tx operation ongoing)
97  1 : Busy (Tx operation ongoing)
98  * @endverbatim
99  */
100 typedef enum
101 {
102  HAL_I2C_STATE_RESET = 0x00U, /**< Peripheral is not yet Initialized */
103  HAL_I2C_STATE_READY = 0x20U, /**< Peripheral Initialized and ready for use */
104  HAL_I2C_STATE_BUSY = 0x24U, /**< An internal process is ongoing */
105  HAL_I2C_STATE_BUSY_TX = 0x21U, /**< Data Transmission process is ongoing */
106  HAL_I2C_STATE_BUSY_RX = 0x22U, /**< Data Reception process is ongoing */
107  HAL_I2C_STATE_LISTEN = 0x28U, /**< Address Listen Mode is ongoing */
108  HAL_I2C_STATE_BUSY_TX_LISTEN = 0x29U, /**< Address Listen Mode and Data Transmission
109  process is ongoing */
110  HAL_I2C_STATE_BUSY_RX_LISTEN = 0x2AU, /**< Address Listen Mode and Data Reception
111  process is ongoing */
112  HAL_I2C_STATE_ABORT = 0x60U, /**< Abort user request ongoing */
113  HAL_I2C_STATE_TIMEOUT = 0xA0U, /**< Timeout state */
114  HAL_I2C_STATE_ERROR = 0xE0U /**< Error */
115 
117 /** @} */
118 
119 /** @defgroup HAL_I2C_mode HAL I2C mode
120  * @{
121  */
122 
123 /**
124  * @brief HAL I2C Mode Enumerations definition
125  * @note HAL I2C Mode value coding follow below described bitmap :\n
126  * @verbatim
127  b7 (not used)
128  x : Should be set to 0
129  b6
130  0 : None
131  1 : Memory (HAL I2C communication is in Memory Mode)
132  b5
133  0 : None
134  1 : Slave (HAL I2C communication is in Slave Mode)
135  b4
136  0 : None
137  1 : Master (HAL I2C communication is in Master Mode)
138  b3-b2-b1-b0 (not used)
139  xxxx : Should be set to 0000
140  * @endverbatim
141  */
142 typedef enum
143 {
144  HAL_I2C_MODE_NONE = 0x00U, /**< No I2C communication on going */
145  HAL_I2C_MODE_MASTER = 0x10U, /**< I2C communication is in Master Mode */
146  HAL_I2C_MODE_SLAVE = 0x20U, /**< I2C communication is in Slave Mode */
147  HAL_I2C_MODE_MEM = 0x40U /**< I2C communication is in Memory Mode */
148 
150 /** @} */
151 
152 /** @} */
153 
154 
155 /** @addtogroup HAL_I2C_STRUCTURES Structures
156  * @{
157  */
158 
159 /** @defgroup I2C_Configuration I2C Configuration
160  * @{
161  */
162 
163 /**
164  * @brief I2C Configuration Structure definition
165  */
166 typedef struct _i2c_init
167 {
168  uint32_t speed; /**< Specifies the I2C transfer speed.
169  This parameter can be a value of @ref I2C_Speed */
170 
171  uint32_t own_address; /**< Specifies the device own address.
172  This parameter can be a 7-bit or 10-bit address. */
173 
174  uint32_t addressing_mode; /**< Specifies if 7-bit or 10-bit addressing mode is selected.
175  This parameter can be a value of @ref I2C_Addressing_Mode */
176 
177  uint32_t general_call_mode; /**< Specifies if general call mode is selected.
178  This parameter can be a value of @ref I2C_General_Call_Addressing_Mode */
179 
181 /** @} */
182 
183 /** @defgroup I2C_handle I2C handle
184  * @{
185  */
186 
187 /**
188  * @brief I2C handle Structure definition
189  */
190 typedef struct _i2c_handle
191 {
192  i2c_regs_t *p_instance; /**< I2C registers base address */
193 
194  i2c_init_t init; /**< I2C communication parameters */
195 
196  uint8_t *p_buffer; /**< Pointer to I2C transfer buffer */
197 
198  uint16_t xfer_size; /**< I2C transfer size */
199 
200  __IO uint16_t xfer_count; /**< I2C transfer counter */
201 
202  __IO uint16_t master_ack_count; /**< I2C master acknowledge counter in master receive progress */
203 
204  __IO uint32_t xfer_options; /**< I2C sequantial transfer options, this parameter can
205  be a value of @ref I2C_XferOptions */
206 
207  __IO uint32_t previous_state; /**< I2C communication Previous state */
208 
209  hal_status_t(*xfer_isr)(struct _i2c_handle *p_i2c, uint32_t it_source, uint32_t abort_sources);
210  /**< I2C transfer IRQ handler function pointer */
211 
212  dma_handle_t *p_dmatx; /**< I2C Tx DMA handle parameters */
213 
214  dma_handle_t *p_dmarx; /**< I2C Rx DMA handle parameters */
215 
216  hal_lock_t lock; /**< I2C locking object */
217 
218  __IO hal_i2c_state_t state; /**< I2C communication state */
219 
220  __IO hal_i2c_mode_t mode; /**< I2C communication mode */
221 
222  __IO uint32_t error_code; /**< I2C Error code */
223 
224  uint32_t retention[19]; /**< I2C important register information. */
226 /** @} */
227 
228 /** @} */
229 
230 /** @addtogroup HAL_I2C_CALLBACK_STRUCTURES Callback Structures
231  * @{
232  */
233 
234 /** @defgroup HAL_I2C_Callback Callback
235  * @{
236  */
237 
238 /**
239  * @brief HAL_I2C Callback function definition
240  */
241 
242 typedef struct _hal_i2c_callback
243 {
244  void (*i2c_msp_init)(i2c_handle_t *p_i2c); /**< I2C init MSP callback */
245  void (*i2c_msp_deinit)(i2c_handle_t *p_i2c); /**< I2C de-init MSP callback */
246  void (*i2c_master_tx_cplt_callback)(i2c_handle_t *p_i2c); /**< I2C master tx transfer completed callbac */
247  void (*i2c_master_rx_cplt_callback)(i2c_handle_t *p_i2c); /**< I2C master rx transfer completed callback */
248  void (*i2c_slave_tx_cplt_callback)(i2c_handle_t *p_i2c); /**< I2C slave tx transfer completed callback */
249  void (*i2c_slave_rx_cplt_callback)(i2c_handle_t *p_i2c); /**< I2C slave rx transfer completed callback */
250  void (*i2c_listen_cplt_callback)(i2c_handle_t *p_i2c); /**< I2C listen Complete callback */
251  void (*i2c_mem_tx_cplt_callback)(i2c_handle_t *p_i2c); /**< I2C mem tx transfer completed callback */
252  void (*i2c_mem_rx_cplt_callback)(i2c_handle_t *p_i2c); /**< I2C mem rx transfer completed callback */
253  void (*i2c_error_callback)(i2c_handle_t *p_i2c); /**< I2C error callback */
254  void (*i2c_abort_cplt_callback)(i2c_handle_t *p_i2c); /**< I2C abort completed callback */
256 
257 /** @} */
258 
259 /** @} */
260 
261 /** @defgroup HAL_I2C_MACRO Defines
262  * @{
263  */
264 
265 /* Exported constants --------------------------------------------------------*/
266 /** @defgroup I2C_Exported_Constants I2C Exported Constants
267  * @{
268  */
269 
270 /** @defgroup I2C_Error_Code_definition I2C Error Code definition
271  * @{
272  */
273 #define HAL_I2C_ERROR_NONE (0x00000000U) /**< No error */
274 #define HAL_I2C_ERROR_ARB_LOST (0x00000002U) /**< Arbitration lost error */
275 #define HAL_I2C_ERROR_NOACK (0x00000004U) /**< No acknowledge error */
276 #define HAL_I2C_ERROR_OVER (0x00000008U) /**< RX_OVER error */
277 #define HAL_I2C_ERROR_DMA (0x00000010U) /**< DMA transfer error */
278 #define HAL_I2C_ERROR_TIMEOUT (0x00000020U) /**< Timeout error */
279 /** @} */
280 
281 /** @defgroup I2C_Speed I2C Transfer Speed
282  * @{
283  */
284 #define I2C_SPEED_100K LL_I2C_SPEED_100K /**< Standard speed. */
285 #define I2C_SPEED_400K LL_I2C_SPEED_400K /**< Fast speed. */
286 #define I2C_SPEED_1000K LL_I2C_SPEED_1000K /**< Fast Plus speed. */
287 #define I2C_SPEED_2000K LL_I2C_SPEED_2000K /**< High speed. */
288 /** @} */
289 
290 /** @defgroup I2C_Addressing_Mode I2C Addressing Mode
291  * @{
292  */
293 #define I2C_ADDRESSINGMODE_7BIT (0x00000001U) /**< 7-bit addressing mode. */
294 #define I2C_ADDRESSINGMODE_10BIT (0x00000002U) /**< 10-bit addressing mode. */
295 /** @} */
296 
297 /** @defgroup I2C_General_Call_Addressing_Mode I2C General Call Addressing Mode
298  * @{
299  */
300 #define I2C_GENERALCALL_DISABLE (0x00000000U) /**< General call mode disable. */
301 #define I2C_GENERALCALL_ENABLE (0x00000001U) /**< General call mode enable. */
302 /** @} */
303 
304 /** @defgroup I2C_Memory_Address_Size I2C Memory Address Size
305  * @{
306  */
307 #define I2C_MEMADD_SIZE_8BIT (0x00000001U) /**< 8-bit memory address. */
308 #define I2C_MEMADD_SIZE_16BIT (0x00000002U) /**< 16-bit memory address. */
309 /** @} */
310 
311 /** @defgroup I2C_XferOptions I2C Sequential Transfer Options
312  * @{
313  */
314 #define I2C_FIRST_FRAME (0x00000000U) /**< First transfer frame. */
315 #define I2C_FIRST_AND_NEXT_FRAME (0x00000001U) /**< First and next transfer frames. */
316 #define I2C_NEXT_FRAME (0x00000002U) /**< Next transfer frame. */
317 #define I2C_FIRST_AND_LAST_FRAME (0x00000003U) /**< First and last transfer frames. */
318 #define I2C_LAST_FRAME (0x00000004U) /**< Last transfer frame. */
319 /** @} */
320 
321 /** @defgroup I2C_Timing_type I2C Timing type
322  * @{
323  */
324 #define I2C_TIMING_SS_SCL_LOW (0x00000000U) /**< Standard speed(0, 100K] SCL low time. */
325 #define I2C_TIMING_SS_SCL_HIGH (0x00000001U) /**< Standard speed(0, 100K] SCL high time. */
326 #define I2C_TIMING_FS_SCL_LOW (0x00000002U) /**< Fast and fast puls speed(100K, 1000K] SCL low time. */
327 #define I2C_TIMING_FS_SCL_HIGH (0x00000003U) /**< Fast and fast puls speed(100K, 1000K] SCL high time. */
328 #define I2C_TIMING_HS_SCL_LOW (0x00000004U) /**< High speed(1000K, 3400K] SCL low time. */
329 #define I2C_TIMING_HS_SCL_HIGH (0x00000005U) /**< High speed(1000K, 3400K] SCL high time. */
330 #define I2C_TIMING_FS_SPK (0x00000006U) /**< Fast and fast puls speed(100K, 1000K] spike suppression time. */
331 #define I2C_TIMING_HS_SPK (0x00000007U) /**< High speed(1000K, 3400K] spike suppression time. */
332 #define I2C_TIMING_SDA_TX_HOLD (0x00000008U) /**< SDA hold time when TX. (Hold time: Time of master and slave exchange SDA control) */
333 #define I2C_TIMING_SDA_RX_HOLD (0x00000009U) /**< SDA hold time when RX. (Hold time: Time of master and slave exchange SDA control) */
334 /** @} */
335 
336 /**
337  * @brief I2C InitStruct default configuartion
338  */
339 #define I2C_DEFAULT_CONFIG \
340 { \
341  .speed = I2C_SPEED_400K, \
342  .own_address = 0x55U, \
343  .addressing_mode = I2C_ADDRESSINGMODE_7BIT, \
344  .general_call_mode = I2C_GENERALCALL_DISABLE, \
345 }
346 
347 /** @} */
348 
349 /* Exported macros -----------------------------------------------------------*/
350 /** @defgroup I2C_Exported_Macros I2C Exported Macros
351  * @{
352  */
353 
354 /** @brief Reset I2C handle state.
355  * @param __HANDLE__ Specifies the I2C Handle.
356  * @retval None
357  */
358 #define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_I2C_STATE_RESET)
359 /** @} */
360 
361 /* Private macros ------------------------------------------------------------*/
362 /** @defgroup I2C_Private_Macro I2C Private Macros
363  * @{
364  */
365 
366 /**
367  * @brief Check if the I2C speed is valid.
368  * @param __SPEED__ I2C transfer speed.
369  * @retval SET (__SPEED__ is valid) or RESET (__SPEED__ is invalid)
370  */
371 #define IS_I2C_SPEED(__SPEED__) (((__SPEED__) == I2C_SPEED_100K) || \
372  ((__SPEED__) == I2C_SPEED_400K) || \
373  ((__SPEED__) == I2C_SPEED_1000K) || \
374  ((__SPEED__) == I2C_SPEED_2000K))
375 
376 /**
377  * @brief Check if the I2C addressing mode is valid.
378  * @param __MODE__ I2C addressing mode.
379  * @retval SET (__MODE__ is valid) or RESET (__MODE__ is invalid)
380  */
381 #define IS_I2C_ADDRESSING_MODE(__MODE__) (((__MODE__) == I2C_ADDRESSINGMODE_7BIT) || \
382  ((__MODE__) == I2C_ADDRESSINGMODE_10BIT))
383 
384 /**
385  * @brief Check if the I2C general call mode is valid.
386  * @param __CALL__ I2C general call mode.
387  * @retval SET (__CALL__ is valid) or RESET (__CALL__ is invalid)
388  */
389 #define IS_I2C_GENERAL_CALL(__CALL__) (((__CALL__) == I2C_GENERALCALL_DISABLE) || \
390  ((__CALL__) == I2C_GENERALCALL_ENABLE))
391 
392 /**
393  * @brief Check if the I2C memory address size is valid.
394  * @param __SIZE__ I2C memory address size.
395  * @retval SET (__SIZE__ is valid) or RESET (__SIZE__ is invalid)
396  */
397 #define IS_I2C_MEMADD_SIZE(__SIZE__) (((__SIZE__) == I2C_MEMADD_SIZE_8BIT) || \
398  ((__SIZE__) == I2C_MEMADD_SIZE_16BIT))
399 
400 /**
401  * @brief Check if the I2C transfer request command is valid.
402  * @param __REQUEST__ I2C transfer request command.
403  * @retval SET (__REQUEST__ is valid) or RESET (__REQUEST__ is invalid)
404  */
405 #define IS_TRANSFER_REQUEST(__REQUEST__) (((__REQUEST__) == I2C_CMD_SLV_NONE) || \
406  ((__REQUEST__) == I2C_CMD_MST_WRITE) || \
407  ((__REQUEST__) == I2C_CMD_MST_READ) || \
408  ((__REQUEST__) == I2C_CMD_MST_GEN_STOP) || \
409  ((__REQUEST__) == I2C_CMD_MST_GEN_RESTART))
410 
411 /**
412  * @brief Check if the I2C transfer options request is valid.
413  * @param __REQUEST__ I2C transfer options request.
414  * @retval SET (__REQUEST__ is valid) or RESET (__REQUEST__ is invalid)
415  */
416 #define IS_I2C_TRANSFER_OPTIONS_REQUEST(__REQUEST__) (((__REQUEST__) == I2C_FIRST_FRAME) || \
417  ((__REQUEST__) == I2C_FIRST_AND_NEXT_FRAME) || \
418  ((__REQUEST__) == I2C_NEXT_FRAME) || \
419  ((__REQUEST__) == I2C_FIRST_AND_LAST_FRAME) || \
420  ((__REQUEST__) == I2C_LAST_FRAME))
421 
422 /**
423  * @brief Check if the I2C slave address is valid.
424  * @param __ADDRESS__ I2C slave address.
425  * @retval SET (__ADDRESS__ is valid) or RESET (__ADDRESS__ is invalid)
426  */
427 #define IS_I2C_SLV_ADDRESS(__ADDRESS__) ((__ADDRESS__) < 0x03FFU)
428 
429 /**
430  * @brief Check if the I2C own address is valid.
431  * @param __ADDRESS__ I2C own address.
432  * @retval SET (__ADDRESS__ is valid) or RESET (__ADDRESS__ is invalid)
433  */
434 #define IS_I2C_OWN_ADDRESS(__ADDRESS__) ((((__ADDRESS__) > 0x0007U) && ((__ADDRESS__) < 0x0078U)) || \
435  (((__ADDRESS__) > 0x007FU) && ((__ADDRESS__) < 0x03FFU)))
436 
437 /**
438  * @brief Get the Most Significant 8 Bits of memory address.
439  * @param __ADDRESS__ Memory address.
440  * @retval SET (__ADDRESS__ is valid) or RESET (__ADDRESS__ is invalid)
441  */
442 #define I2C_MEM_ADD_MSB(__ADDRESS__) ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0xFF00U))) >> 8U)))
443 
444 /**
445  * @brief Get the Least Significant 8 Bits of memory address.
446  * @param __ADDRESS__ Memory address.
447  * @retval SET (__ADDRESS__ is valid) or RESET (__ADDRESS__ is invalid)
448  */
449 #define I2C_MEM_ADD_LSB(__ADDRESS__) ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FFU))))
450 
451 /** @} */
452 
453 /** @} */
454 
455 /* Exported functions --------------------------------------------------------*/
456 /** @addtogroup HAL_I2C_DRIVER_FUNCTIONS Functions
457  * @{
458  */
459 
460 /** @addtogroup I2C_Exported_Functions_Group1 Initialization and de-initialization functions
461  * @brief Initialization and de-initialization functions
462  * @verbatim
463  ===============================================================================
464  ##### Initialization and de-initialization functions #####
465  ===============================================================================
466  [..] This subsection provides a set of functions allowing to initialize and
467  de-initialize the I2Cx peripheral:
468 
469  (+) User must Implement hal_i2c_msp_init() function in which he configures
470  all related peripherals resources (CLOCK, GPIO, DMA, IT and NVIC ).
471 
472  (+) Call the function hal_i2c_init() to configure the selected device with
473  the selected configuration:
474  (++) Speed
475  (++) Own Address
476  (++) Addressing mode (Master, Slave)
477  (++) General call mode
478 
479  (+) Call the function hal_i2c_deinit() to restore the default configuration
480  of the selected I2Cx peripheral.
481 
482 @endverbatim
483  * @{
484  */
485 
486 /**
487  ****************************************************************************************
488  * @brief Initializes the I2C according to the specified parameters
489  * in the i2c_init_t and initialize the associated handle.
490  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration
491  * information for the specified I2C.
492  * @retval ::HAL_OK: Operation is OK.
493  * @retval ::HAL_ERROR: Parameter error or operation not supported.
494  * @retval ::HAL_BUSY: Driver is busy.
495  * @retval ::HAL_TIMEOUT: Timeout occurred.
496  ****************************************************************************************
497  */
499 
500 /**
501  ****************************************************************************************
502  * @brief De-initialize the I2C peripheral.
503  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
504  * @retval ::HAL_OK: Operation is OK.
505  * @retval ::HAL_ERROR: Parameter error or operation not supported.
506  * @retval ::HAL_BUSY: Driver is busy.
507  * @retval ::HAL_TIMEOUT: Timeout occurred.
508  ****************************************************************************************
509  */
511 
512 /**
513  ****************************************************************************************
514  * @brief Initialize the I2C MSP.
515  * @note This function should not be modified. When the callback is needed,
516  * the hal_i2c_msp_init could be implemented in the user file.
517  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
518  ****************************************************************************************
519  */
521 
522 /**
523  ****************************************************************************************
524  * @brief De-initialize the I2C MSP.
525  * @note This function should not be modified. When the callback is needed,
526  * the hal_i2c_msp_deinit could be implemented in the user file.
527  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
528  ****************************************************************************************
529  */
531 
532 /** @} */
533 
534 /** @addtogroup I2C_Exported_Functions_Group2 IO operation functions
535  * @brief Data transfers functions
536  *
537 @verbatim
538  ===============================================================================
539  ##### IO operation functions #####
540  ===============================================================================
541  [..]
542  This subsection provides a set of functions allowing to manage the I2C data
543  transfers.
544 
545  (#) There are two modes of transfer:
546  (++) Blocking mode: The communication is performed in the polling mode.
547  The status of all data processing is returned by the same function
548  after finishing transfer.
549  (++) No-Blocking mode: The communication is performed using Interrupts
550  or DMA. These functions return the status of the transfer startup.
551  The end of the data processing will be indicated through the
552  dedicated I2C IRQ when using Interrupt mode or the DMA IRQ when
553  using DMA mode.
554 
555  (#) Blocking mode functions are :
556  (++) hal_i2c_master_transmit()
557  (++) hal_i2c_master_receive()
558  (++) hal_i2c_slave_transmit()
559  (++) hal_i2c_slave_receive()
560  (++) hal_i2c_mem_write()
561  (++) hal_i2c_mem_read()
562  (++) hal_i2c_is_device_ready()
563 
564  (#) No-Blocking mode functions with Interrupt are :
565  (++) hal_i2c_master_transmit_it()
566  (++) hal_i2c_master_receive_it()
567  (++) hal_i2c_slave_transmit_it()
568  (++) hal_i2c_slave_receive_it()
569  (++) hal_i2c_mem_write_it()
570  (++) hal_i2c_mem_read_it()
571 
572  (#) No-Blocking mode functions with DMA are :
573  (++) hal_i2c_master_transmit_dma()
574  (++) hal_i2c_master_recevice_dma()
575  (++) hal_i2c_slave_transmit_dma()
576  (++) hal_i2c_slave_receive_dma()
577  (++) hal_i2c_mem_write_dma()
578  (++) hal_i2c_mem_read_dma()
579 
580  (#) A set of Transfer Complete Callbacks are provided in non Blocking mode:
581  (++) hal_i2c_mem_tx_cplt_callback()
582  (++) hal_i2c_mem_rx_cplt_callback()
583  (++) hal_i2c_master_tx_cplt_callback()
584  (++) hal_i2c_master_rx_cplt_callback()
585  (++) hal_i2c_slave_tx_cplt_callback()
586  (++) hal_i2c_slave_rx_cplt_callback()()
587  (++) hal_i2c_error_callback()
588 
589 @endverbatim
590  * @{
591  */
592 
593 /******* Blocking mode: Polling */
594 
595 /**
596  ****************************************************************************************
597  * @brief Transmits in master mode an amount of data in blocking mode.
598  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
599  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
600  * @param[in] p_data: Pointer to data buffer
601  * @param[in] size: Amount of data to be sent
602  * @param[in] timeout: Timeout duration
603  * @retval ::HAL_OK: Operation is OK.
604  * @retval ::HAL_ERROR: Parameter error or operation not supported.
605  * @retval ::HAL_BUSY: Driver is busy.
606  * @retval ::HAL_TIMEOUT: Timeout occurred.
607  ****************************************************************************************
608  */
609 hal_status_t hal_i2c_master_transmit(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size, uint32_t timeout);
610 
611 /**
612  ****************************************************************************************
613  * @brief Receives in master mode an amount of data in blocking mode.
614  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
615  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
616  * @param[in] p_data: Pointer to data buffer
617  * @param[in] size: Amount of data to be sent
618  * @param[in] timeout: Timeout duration
619  * @retval ::HAL_OK: Operation is OK.
620  * @retval ::HAL_ERROR: Parameter error or operation not supported.
621  * @retval ::HAL_BUSY: Driver is busy.
622  * @retval ::HAL_TIMEOUT: Timeout occurred.
623  * @note This function will return HAL_OK even if the length of data sent by slave is
624  * less than the expected Size.
625  ****************************************************************************************
626  */
627 hal_status_t hal_i2c_master_receive(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size, uint32_t timeout);
628 
629 /**
630  ****************************************************************************************
631  * @brief Transmits in slave mode an amount of data in blocking mode.
632  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
633  * @param[in] p_data: Pointer to data buffer
634  * @param[in] size: Amount of data to be sent
635  * @param[in] timeout: Timeout duration
636  * @retval ::HAL_OK: Operation is OK.
637  * @retval ::HAL_ERROR: Parameter error or operation not supported.
638  * @retval ::HAL_BUSY: Driver is busy.
639  * @retval ::HAL_TIMEOUT: Timeout occurred.
640  ****************************************************************************************
641  */
642 hal_status_t hal_i2c_slave_transmit(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size, uint32_t timeout);
643 
644 /**
645  ****************************************************************************************
646  * @brief Receive in slave mode an amount of data in blocking mode
647  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
648  * @param[in] p_data: Pointer to data buffer
649  * @param[in] size: Amount of data to be sent
650  * @param[in] timeout: Timeout duration
651  * @retval ::HAL_OK: Operation is OK.
652  * @retval ::HAL_ERROR: Parameter error or operation not supported.
653  * @retval ::HAL_BUSY: Driver is busy.
654  * @retval ::HAL_TIMEOUT: Timeout occurred.
655  ****************************************************************************************
656  */
657 hal_status_t hal_i2c_slave_receive(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size, uint32_t timeout);
658 
659 /**
660  ****************************************************************************************
661  * @brief Write an amount of data in blocking mode to a specific memory address
662  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
663  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
664  * @param[in] mem_address: Internal memory address
665  * @param[in] mem_addr_size: Size of internal memory address
666  * @param[in] p_data: Pointer to data buffer
667  * @param[in] size: Amount of data to be sent
668  * @param[in] timeout: Timeout duration
669  * @retval ::HAL_OK: Operation is OK.
670  * @retval ::HAL_ERROR: Parameter error or operation not supported.
671  * @retval ::HAL_BUSY: Driver is busy.
672  * @retval ::HAL_TIMEOUT: Timeout occurred.
673  ****************************************************************************************
674  */
675 hal_status_t hal_i2c_mem_write(i2c_handle_t *p_i2c, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size, uint32_t timeout);
676 
677 /**
678  ****************************************************************************************
679  * @brief Read an amount of data in blocking mode from a specific memory address
680  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
681  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
682  * @param[in] mem_address: Internal memory address
683  * @param[in] mem_addr_size: Size of internal memory address
684  * @param[in] p_data: Pointer to data buffer
685  * @param[in] size: Amount of data to be sent
686  * @param[in] timeout: Timeout duration
687  * @retval ::HAL_OK: Operation is OK.
688  * @retval ::HAL_ERROR: Parameter error or operation not supported.
689  * @retval ::HAL_BUSY: Driver is busy.
690  * @retval ::HAL_TIMEOUT: Timeout occurred.
691  ****************************************************************************************
692  */
693 hal_status_t hal_i2c_mem_read(i2c_handle_t *p_i2c, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size, uint32_t timeout);
694 
695 /******* Non-Blocking mode: Interrupt */
696 
697 /**
698  ****************************************************************************************
699  * @brief Transmit in master mode an amount of data in non-blocking mode with Interrupt
700  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
701  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
702  * @param[in] p_data: Pointer to data buffer
703  * @param[in] size: Amount of data to be sent
704  * @retval ::HAL_OK: Operation is OK.
705  * @retval ::HAL_ERROR: Parameter error or operation not supported.
706  * @retval ::HAL_BUSY: Driver is busy.
707  * @retval ::HAL_TIMEOUT: Timeout occurred.
708  ****************************************************************************************
709  */
710 hal_status_t hal_i2c_master_transmit_it(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size);
711 
712 /**
713  ****************************************************************************************
714  * @brief Receive in master mode an amount of data in non-blocking mode with Interrupt
715  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
716  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
717  * @param[in] p_data: Pointer to data buffer
718  * @param[in] size: Amount of data to be sent
719  * @retval ::HAL_OK: Operation is OK.
720  * @retval ::HAL_ERROR: Parameter error or operation not supported.
721  * @retval ::HAL_BUSY: Driver is busy.
722  * @retval ::HAL_TIMEOUT: Timeout occurred.
723  ****************************************************************************************
724  */
725 hal_status_t hal_i2c_master_receive_it(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size);
726 
727 /**
728  ****************************************************************************************
729  * @brief Transmit in slave mode an amount of data in non-blocking mode with Interrupt
730  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
731  * @param[in] p_data: Pointer to data buffer
732  * @param[in] size: Amount of data to be sent
733  * @retval ::HAL_OK: Operation is OK.
734  * @retval ::HAL_ERROR: Parameter error or operation not supported.
735  * @retval ::HAL_BUSY: Driver is busy.
736  * @retval ::HAL_TIMEOUT: Timeout occurred.
737  ****************************************************************************************
738  */
739 hal_status_t hal_i2c_slave_transmit_it(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size);
740 
741 /**
742  ****************************************************************************************
743  * @brief Receive in slave mode an amount of data in non-blocking mode with Interrupt
744  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
745  * @param[in] p_data: Pointer to data buffer
746  * @param[in] size: Amount of data to be sent
747  * @retval ::HAL_OK: Operation is OK.
748  * @retval ::HAL_ERROR: Parameter error or operation not supported.
749  * @retval ::HAL_BUSY: Driver is busy.
750  * @retval ::HAL_TIMEOUT: Timeout occurred.
751  ****************************************************************************************
752  */
753 hal_status_t hal_i2c_slave_receive_it(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size);
754 
755 /**
756  ****************************************************************************************
757  * @brief Write an amount of data in non-blocking mode with Interrupt to a specific memory address
758  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
759  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
760  * @param[in] mem_address: Internal memory address
761  * @param[in] mem_addr_size: Size of internal memory address
762  * @param[in] p_data: Pointer to data buffer
763  * @param[in] size: Amount of data to be sent
764  * @retval ::HAL_OK: Operation is OK.
765  * @retval ::HAL_ERROR: Parameter error or operation not supported.
766  * @retval ::HAL_BUSY: Driver is busy.
767  * @retval ::HAL_TIMEOUT: Timeout occurred.
768  ****************************************************************************************
769  */
770 hal_status_t hal_i2c_mem_write_it(i2c_handle_t *p_i2c, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size);
771 
772 /**
773  ****************************************************************************************
774  * @brief Read an amount of data in non-blocking mode with Interrupt from a specific memory address
775  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
776  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
777  * @param[in] mem_address: Internal memory address
778  * @param[in] mem_addr_size: Size of internal memory address
779  * @param[in] p_data: Pointer to data buffer
780  * @param[in] size: Amount of data to be sent
781  * @retval ::HAL_OK: Operation is OK.
782  * @retval ::HAL_ERROR: Parameter error or operation not supported.
783  * @retval ::HAL_BUSY: Driver is busy.
784  * @retval ::HAL_TIMEOUT: Timeout occurred.
785  ****************************************************************************************
786  */
787 hal_status_t hal_i2c_mem_read_it(i2c_handle_t *p_i2c, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size);
788 
789 /**
790  ****************************************************************************************
791  * @brief Sequentially transmit in master I2C mode an amount of data in non-blocking mode with Interrupt.
792  * @note This interface allows to manage repeated start condition when a direction changes during transfer
793  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
794  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
795  * @param[in] p_data: Pointer to data buffer
796  * @param[in] size: Amount of data to be sent
797  * @param[in] xfer_options: Options of Transfer, value of @ref I2C_XferOptions
798  * @retval ::HAL_OK: Operation is OK.
799  * @retval ::HAL_ERROR: Parameter error or operation not supported.
800  * @retval ::HAL_BUSY: Driver is busy.
801  * @retval ::HAL_TIMEOUT: Timeout occurred.
802  ****************************************************************************************
803  */
804 hal_status_t hal_i2c_master_sequential_transmit_it(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size, uint32_t xfer_options);
805 
806 /**
807  ****************************************************************************************
808  * @brief Sequentially receive in master I2C mode an amount of data in non-blocking mode with Interrupt
809  * @note This interface allows to manage repeated start condition when a direction changes during transfer
810  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
811  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
812  * @param[in] p_data: Pointer to data buffer
813  * @param[in] size: Amount of data to be sent
814  * @param[in] xfer_options: Options of Transfer, value of @ref I2C_XferOptions
815  * @retval ::HAL_OK: Operation is OK.
816  * @retval ::HAL_ERROR: Parameter error or operation not supported.
817  * @retval ::HAL_BUSY: Driver is busy.
818  * @retval ::HAL_TIMEOUT: Timeout occurred.
819  ****************************************************************************************
820  */
821 hal_status_t hal_i2c_master_sequential_receive_it(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size, uint32_t xfer_options);
822 
823 /**
824  ****************************************************************************************
825  * @brief Sequential transmit in slave/device I2C mode an amount of data in non-blocking mode with Interrupt
826  * @note This interface allow to manage repeated start condition when a direction change during transfer
827  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
828  * @param[in] p_data: Pointer to data buffer
829  * @param[in] size: Amount of data to be sent
830  * @param[in] xfer_options: Options of Transfer, value of @ref I2C_XferOptions
831  * @retval ::HAL_OK: Operation is OK.
832  * @retval ::HAL_ERROR: Parameter error or operation not supported.
833  * @retval ::HAL_BUSY: Driver is busy.
834  * @retval ::HAL_TIMEOUT: Timeout occurred.
835  ****************************************************************************************
836  */
837 hal_status_t hal_i2c_slave_sequential_transmit_it(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size, uint32_t xfer_options);
838 
839 /**
840  ****************************************************************************************
841  * @brief Sequential receive in slave/device I2C mode an amount of data in non-blocking mode with Interrupt
842  * @note This interface allow to manage repeated start condition when a direction change during transfer
843  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
844  * @param[in] p_data: Pointer to data buffer
845  * @param[in] size: Amount of data to be sent
846  * @param[in] xfer_options: Options of Transfer, value of @ref I2C_XferOptions
847  * @retval ::HAL_OK: Operation is OK.
848  * @retval ::HAL_ERROR: Parameter error or operation not supported.
849  * @retval ::HAL_BUSY: Driver is busy.
850  * @retval ::HAL_TIMEOUT: Timeout occurred.
851  ****************************************************************************************
852  */
853 hal_status_t hal_i2c_slave_sequential_receive_it(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size, uint32_t xfer_options);
854 
855 /**
856  ****************************************************************************************
857  * @brief Enable the Master Read Request listen mode with Interrupt.
858  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
859  * @retval ::HAL_OK: Operation is OK.
860  * @retval ::HAL_ERROR: Parameter error or operation not supported.
861  * @retval ::HAL_BUSY: Driver is busy.
862  * @retval ::HAL_TIMEOUT: Timeout occurred.
863  ****************************************************************************************
864  */
866 
867 /**
868  ****************************************************************************************
869  * @brief Disable the Master Read Request listen mode with Interrupt.
870  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
871  * @retval ::HAL_OK: Operation is OK.
872  * @retval ::HAL_ERROR: Parameter error or operation not supported.
873  * @retval ::HAL_BUSY: Driver is busy.
874  * @retval ::HAL_TIMEOUT: Timeout occurred.
875  ****************************************************************************************
876  */
878 
879 /**
880  ****************************************************************************************
881  * @brief Abort a master I2C IT or DMA process communication with Interrupt.
882  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
883  * @retval ::HAL_OK: Operation is OK.
884  * @retval ::HAL_ERROR: Parameter error or operation not supported.
885  * @retval ::HAL_BUSY: Driver is busy.
886  * @retval ::HAL_TIMEOUT: Timeout occurred.
887  ****************************************************************************************
888  */
890 
891 /******* Non-Blocking mode: DMA */
892 
893 /**
894  ****************************************************************************************
895  * @brief Transmit in master mode an amount of data in non-blocking mode with DMA
896  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
897  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface.
898  * @param[in] p_data: Pointer to data buffer
899  * @param[in] size: Amount of data to be sent, ranging between 0 and 4095.
900  * @retval ::HAL_OK: Operation is OK.
901  * @retval ::HAL_ERROR: Parameter error or operation not supported.
902  * @retval ::HAL_BUSY: Driver is busy.
903  * @retval ::HAL_TIMEOUT: Timeout occurred.
904  ****************************************************************************************
905  */
906 hal_status_t hal_i2c_master_transmit_dma(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size);
907 
908 /**
909  ****************************************************************************************
910  * @brief Receive in master mode an amount of data in non-blocking mode with DMA
911  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
912  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface.
913  * @param[in] p_data: Pointer to data buffer
914  * @param[in] size: Amount of data to be sent, ranging between 0 and 4095.
915  * @retval ::HAL_OK: Operation is OK.
916  * @retval ::HAL_ERROR: Parameter error or operation not supported.
917  * @retval ::HAL_BUSY: Driver is busy.
918  * @retval ::HAL_TIMEOUT: Timeout occurred.
919  ****************************************************************************************
920  */
921 hal_status_t hal_i2c_master_receive_dma(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size);
922 
923 /**
924  ****************************************************************************************
925  * @brief Transmit in slave mode an amount of data in non-blocking mode with DMA
926  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
927  * @param[in] p_data: Pointer to data buffer
928  * @param[in] size: Amount of data to be sent, ranging between 0 and 4095.
929  * @retval ::HAL_OK: Operation is OK.
930  * @retval ::HAL_ERROR: Parameter error or operation not supported.
931  * @retval ::HAL_BUSY: Driver is busy.
932  * @retval ::HAL_TIMEOUT: Timeout occurred.
933  ****************************************************************************************
934  */
935 hal_status_t hal_i2c_slave_transmit_dma(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size);
936 
937 /**
938  ****************************************************************************************
939  * @brief Receive in slave mode an amount of data in non-blocking mode with DMA
940  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
941  * @param[in] p_data: Pointer to data buffer
942  * @param[in] size: Amount of data to be sent, ranging between 0 and 4095.
943  * @retval ::HAL_OK: Operation is OK.
944  * @retval ::HAL_ERROR: Parameter error or operation not supported.
945  * @retval ::HAL_BUSY: Driver is busy.
946  * @retval ::HAL_TIMEOUT: Timeout occurred.
947  ****************************************************************************************
948  */
949 hal_status_t hal_i2c_slave_receive_dma(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size);
950 
951 /**
952  ****************************************************************************************
953  * @brief Write an amount of data in non-blocking mode with DMA to a specific memory address
954  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
955  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
956  * @param[in] mem_address: Internal memory address
957  * @param[in] mem_addr_size: Size of internal memory address
958  * @param[in] p_data: Pointer to data buffer
959  * @param[in] size: Amount of data to be sent, ranging between 0 and 4095.
960  * @retval ::HAL_OK: Operation is OK.
961  * @retval ::HAL_ERROR: Parameter error or operation not supported.
962  * @retval ::HAL_BUSY: Driver is busy.
963  * @retval ::HAL_TIMEOUT: Timeout occurred.
964  ****************************************************************************************
965  */
966 hal_status_t hal_i2c_mem_write_dma(i2c_handle_t *p_i2c, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size);
967 
968 /**
969  ****************************************************************************************
970  * @brief Reads an amount of data in non-blocking mode with DMA from a specific memory address.
971  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
972  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
973  * @param[in] mem_address: Internal memory address
974  * @param[in] mem_addr_size: Size of internal memory address
975  * @param[in] p_data: Pointer to data buffer
976  * @param[in] size: Amount of data to be sent, ranging between 0 and 4095.
977  * @retval ::HAL_OK: Operation is OK.
978  * @retval ::HAL_ERROR: Parameter error or operation not supported.
979  * @retval ::HAL_BUSY: Driver is busy.
980  * @retval ::HAL_TIMEOUT: Timeout occurred.
981  ****************************************************************************************
982  */
983 hal_status_t hal_i2c_mem_read_dma(i2c_handle_t *p_i2c, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size);
984 
985 /** @} */
986 
987 /** @addtogroup I2C_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
988  * @brief IRQ Handler and Callbacks functions
989  * @{
990  */
991 
992 /**
993  ****************************************************************************************
994  * @brief This function handles I2C event interrupt request.
995  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
996  ****************************************************************************************
997  */
999 
1000 /**
1001  ****************************************************************************************
1002  * @brief Master Tx Transfer completed callback.
1003  * @note This function should not be modified. When the callback is needed,
1004  * the hal_i2c_master_tx_cplt_callback can be implemented in the user file
1005  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
1006  ****************************************************************************************
1007  */
1009 
1010 /**
1011  ****************************************************************************************
1012  * @brief Master Rx Transfer completed callback.
1013  * @note This function should not be modified. When the callback is needed,
1014  * the hal_i2c_master_rx_cplt_callback can be implemented in the user file
1015  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
1016  ****************************************************************************************
1017  */
1019 
1020 /**
1021  ****************************************************************************************
1022  * @brief Slave Tx Transfer completed callback.
1023  * @note This function should not be modified. When the callback is needed,
1024  * the hal_i2c_slave_tx_cplt_callback can be implemented in the user file
1025  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
1026  ****************************************************************************************
1027  */
1029 
1030 /**
1031  ****************************************************************************************
1032  * @brief Slave Rx Transfer completed callback.
1033  * @note This function should not be modified. When the callback is needed,
1034  * the hal_i2c_slave_rx_cplt_callback can be implemented in the user file
1035  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
1036  ****************************************************************************************
1037  */
1039 
1040 /**
1041  ****************************************************************************************
1042  * @brief Memory Tx Transfer completed callback.
1043  * @note This function should not be modified. When the callback is needed,
1044  * the hal_i2c_mem_tx_cplt_callback can be implemented in the user file
1045  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
1046  ****************************************************************************************
1047  */
1049 
1050 /**
1051  ****************************************************************************************
1052  * @brief Memory Rx Transfer completed callback.
1053  * @note This function should not be modified. When the callback is needed,
1054  * the hal_i2c_mem_rx_cplt_callback can be implemented in the user file
1055  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
1056  ****************************************************************************************
1057  */
1059 
1060 /**
1061  ****************************************************************************************
1062  * @brief Listen Complete callback.
1063  * @note This function should not be modified. When the callback is needed,
1064  * the hal_i2c_listen_cplt_callback can be implemented in the user file
1065  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
1066  ****************************************************************************************
1067  */
1069 
1070 /**
1071  ****************************************************************************************
1072  * @brief I2C error callback.
1073  * @note This function should not be modified. When the callback is needed,
1074  * the hal_i2c_error_callback can be implemented in the user file
1075  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
1076  ****************************************************************************************
1077  */
1079 
1080 /**
1081  ****************************************************************************************
1082  * @brief I2C abort callback.
1083  * @note This function should not be modified. When the callback is needed,
1084  * the hal_i2c_abort_cplt_callback can be implemented in the user file
1085  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
1086  ****************************************************************************************
1087  */
1089 
1090 /** @} */
1091 
1092 /** @addtogroup I2C_Exported_Functions_Group3 Peripheral State, Mode and Error functions
1093  * @brief Peripheral State, Mode and Error functions
1094  *
1095 @verbatim
1096  ===============================================================================
1097  ##### Peripheral State, Mode and Error functions #####
1098  ===============================================================================
1099  [..]
1100  This subsection permit to get in run-time the status of the peripheral
1101  and the data flow.
1102 
1103 @endverbatim
1104  * @{
1105  */
1106 
1107 /**
1108  ****************************************************************************************
1109  * @brief Return the I2C handle state.
1110  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
1111  * @retval ::HAL_I2C_STATE_RESET: Peripheral is not yet Initialized.
1112  * @retval ::HAL_I2C_STATE_READY: Peripheral Initialized and ready for use.
1113  * @retval ::HAL_I2C_STATE_BUSY: An internal process is ongoing.
1114  * @retval ::HAL_I2C_STATE_BUSY_TX: Data Transmission process is ongoing.
1115  * @retval ::HAL_I2C_STATE_BUSY_RX: Data Reception process is ongoing.
1116  * @retval ::HAL_I2C_STATE_LISTEN: Address Listen Mode is ongoing.
1117  * @retval ::HAL_I2C_STATE_BUSY_TX_LISTEN: Address Listen Mode and Data Transmission process is ongoing.
1118  * @retval ::HAL_I2C_STATE_BUSY_RX_LISTEN: Address Listen Mode and Data Reception process is ongoing.
1119  * @retval ::HAL_I2C_STATE_ABORT: Abort user request ongoing.
1120  * @retval ::HAL_I2C_STATE_TIMEOUT: Timeout state.
1121  * @retval ::HAL_I2C_STATE_ERROR: Error.
1122  ****************************************************************************************
1123  */
1125 
1126 /**
1127  ****************************************************************************************
1128  * @brief Returns the I2C Master, Slave, Memory or no mode.
1129  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
1130  * @retval ::HAL_I2C_MODE_NONE: No I2C communication on going.
1131  * @retval ::HAL_I2C_MODE_MASTER: I2C communication is in Master Mode.
1132  * @retval ::HAL_I2C_MODE_SLAVE: I2C communication is in Slave Mode.
1133  * @retval ::HAL_I2C_MODE_MEM: I2C communication is in Memory Mode.
1134  ****************************************************************************************
1135  */
1137 
1138 /**
1139  ****************************************************************************************
1140  * @brief Return the I2C error code.
1141  * @param[in] p_i2c: Pointer to an I2C handle which contains the configuration information for the specified I2C.
1142  * @return I2C Error Code
1143  ****************************************************************************************
1144  */
1146 
1147 /**
1148  ****************************************************************************************
1149  * @brief Suspend some registers related to I2C configuration before sleep.
1150  * @param[in] p_i2c: Pointer to a I2C handle which contains the configuration
1151  * information for the specified I2C module.
1152  * @retval ::HAL_OK: Operation is OK.
1153  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1154  * @retval ::HAL_BUSY: Driver is busy.
1155  * @retval ::HAL_TIMEOUT: Timeout occurred.
1156  ****************************************************************************************
1157  */
1159 
1160 /**
1161  ****************************************************************************************
1162  * @brief Restore some registers related to I2C configuration after sleep.
1163  * This function must be used in conjunction with the hal_i2c_suspend_reg().
1164  * @param[in] p_i2c: Pointer to a I2C handle which contains the configuration
1165  * information for the specified I2C module.
1166  * @retval ::HAL_OK: Operation is OK.
1167  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1168  * @retval ::HAL_BUSY: Driver is busy.
1169  * @retval ::HAL_TIMEOUT: Timeout occurred.
1170  ****************************************************************************************
1171  */
1173 
1174 /**
1175  ****************************************************************************************
1176  * @brief Adjust I2C timing value to adapt to real load.
1177  * @param[in] p_i2c: Pointer to a I2C handle which contains the configuration
1178  * information for the specified I2C module.
1179  * @param[in] timing_type: Timing type. See I2C_Timing_tpye.
1180  * @param[in] delta: timing change value(uinit: I2C work clock cycles).
1181  * @retval ::HAL_OK: Operation is OK.
1182  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1183  * @retval ::HAL_BUSY: Driver is busy.
1184  ****************************************************************************************
1185  */
1186 hal_status_t hal_i2c_timing_adjust(i2c_handle_t *p_i2c, uint32_t timing_type, int32_t delta);
1187 
1188 /**
1189  ****************************************************************************************
1190  * @brief Get the I2C timing value.
1191  * @param[in] p_i2c: Pointer to a I2C handle which contains the configuration
1192  * information for the specified I2C module.
1193  * @param[in] timing_type: Timing type. See I2C_Timing_tpye.
1194  * @param[in] p_timing_value: Pointer of I2C timing value(uinit: I2C work clock cycles).
1195  * @retval ::HAL_OK: Operation is OK.
1196  * @retval ::HAL_ERROR: Parameter error.
1197  ****************************************************************************************
1198  */
1199 hal_status_t hal_i2c_timing_get(i2c_handle_t *p_i2c, uint32_t timing_type, uint32_t *p_timing_value);
1200 
1201 /**
1202  ****************************************************************************************
1203  * @brief I2C MASTER transmit and receive data with only one bit. For Microsoft HID Over I2C protocol.
1204  * @param[in] p_i2c: Pointer to a I2C handle which contains the configuration
1205  * @param[in] dev_address: Target device address: The device 7 bits address value in datasheet must be shifted at right before call interface
1206  * @param[in] p_tdata: Pointer to transmit data buffer
1207  * @param[in] tsize: Amount of data to be sent
1208  * @param[in] p_rdata: Pointer to receive data buffer
1209  * @param[in] rsize: Amount of data to be received
1210  * @param[in] timeout: Timeout duration
1211  * @retval ::HAL_OK: Operation is OK.
1212  * @retval ::HAL_ERROR: Parameter error.
1213  ****************************************************************************************
1214  */
1215 hal_status_t hal_i2c_master_transmit_receive(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_tdata, uint16_t tsize, uint8_t *p_rdata, uint16_t rsize, uint32_t timeout);
1216 
1217 /**
1218  ****************************************************************************************
1219  * @brief I2C SLAVE receive and transmit data with only one bit. Add for hal_i2c_master_transmit_receive.
1220  * @param[in] p_i2c: Pointer to a I2C handle which contains the configuration
1221  * @param[in] p_tdata: Pointer to transmit data buffer
1222  * @param[in] tsize: Amount of data to be sent
1223  * @param[in] p_rdata: Pointer to receive data buffer
1224  * @param[in] rsize: Amount of data to be received
1225  * @param[in] timeout: Timeout duration
1226  * @retval ::HAL_OK: Operation is OK.
1227  * @retval ::HAL_ERROR: Parameter error.
1228  ****************************************************************************************
1229  */
1230 hal_status_t hal_i2c_slave_receive_transmit(i2c_handle_t *p_i2c, uint8_t *p_tdata, uint16_t tsize, uint8_t *p_rdata, uint16_t rsize, uint32_t timeout);
1231 /** @} */
1232 
1233 /** @} */
1234 
1235 #ifdef __cplusplus
1236 }
1237 #endif
1238 
1239 #endif /* __GR55xx_HAL_I2C_H__ */
1240 
1241 /** @} */
1242 
1243 /** @} */
1244 
1245 /** @} */
_hal_i2c_callback::i2c_mem_tx_cplt_callback
void(* i2c_mem_tx_cplt_callback)(i2c_handle_t *p_i2c)
I2C mem tx transfer completed callback
Definition: gr55xx_hal_i2c.h:251
hal_i2c_slave_sequential_receive_it
hal_status_t hal_i2c_slave_sequential_receive_it(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size, uint32_t xfer_options)
Sequential receive in slave/device I2C mode an amount of data in non-blocking mode with Interrupt.
_hal_i2c_callback::i2c_msp_init
void(* i2c_msp_init)(i2c_handle_t *p_i2c)
I2C init MSP callback
Definition: gr55xx_hal_i2c.h:244
_hal_i2c_callback::i2c_slave_tx_cplt_callback
void(* i2c_slave_tx_cplt_callback)(i2c_handle_t *p_i2c)
I2C slave tx transfer completed callback
Definition: gr55xx_hal_i2c.h:248
_i2c_handle::retention
uint32_t retention[19]
I2C important register information.
Definition: gr55xx_hal_i2c.h:224
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
hal_i2c_mem_read_it
hal_status_t hal_i2c_mem_read_it(i2c_handle_t *p_i2c, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size)
Read an amount of data in non-blocking mode with Interrupt from a specific memory address.
hal_i2c_master_transmit_receive
hal_status_t hal_i2c_master_transmit_receive(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_tdata, uint16_t tsize, uint8_t *p_rdata, uint16_t rsize, uint32_t timeout)
I2C MASTER transmit and receive data with only one bit.
gr55xx_ll_i2c.h
Header file containing functions prototypes of I2C LL library.
hal_i2c_deinit
hal_status_t hal_i2c_deinit(i2c_handle_t *p_i2c)
De-initialize the I2C peripheral.
hal_i2c_listen_cplt_callback
void hal_i2c_listen_cplt_callback(i2c_handle_t *p_i2c)
Listen Complete callback.
hal_i2c_master_sequential_receive_it
hal_status_t hal_i2c_master_sequential_receive_it(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size, uint32_t xfer_options)
Sequentially receive in master I2C mode an amount of data in non-blocking mode with Interrupt.
HAL_I2C_MODE_SLAVE
@ HAL_I2C_MODE_SLAVE
I2C communication is in Slave Mode
Definition: gr55xx_hal_i2c.h:146
hal_i2c_get_error
uint32_t hal_i2c_get_error(i2c_handle_t *p_i2c)
Return the I2C error code.
hal_i2c_master_receive_dma
hal_status_t hal_i2c_master_receive_dma(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size)
Receive in master mode an amount of data in non-blocking mode with DMA.
HAL_I2C_MODE_MEM
@ HAL_I2C_MODE_MEM
I2C communication is in Memory Mode
Definition: gr55xx_hal_i2c.h:147
HAL_I2C_STATE_READY
@ HAL_I2C_STATE_READY
Peripheral Initialized and ready for use
Definition: gr55xx_hal_i2c.h:103
hal_i2c_init
hal_status_t hal_i2c_init(i2c_handle_t *p_i2c)
Initializes the I2C according to the specified parameters in the i2c_init_t and initialize the associ...
_i2c_handle::xfer_size
uint16_t xfer_size
I2C transfer size
Definition: gr55xx_hal_i2c.h:198
_i2c_handle::init
i2c_init_t init
I2C communication parameters
Definition: gr55xx_hal_i2c.h:194
_i2c_handle::xfer_isr
hal_status_t(* xfer_isr)(struct _i2c_handle *p_i2c, uint32_t it_source, uint32_t abort_sources)
I2C transfer IRQ handler function pointer
Definition: gr55xx_hal_i2c.h:209
hal_i2c_slave_receive_it
hal_status_t hal_i2c_slave_receive_it(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size)
Receive in slave mode an amount of data in non-blocking mode with Interrupt.
hal_i2c_master_receive
hal_status_t hal_i2c_master_receive(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size, uint32_t timeout)
Receives in master mode an amount of data in blocking mode.
HAL_I2C_STATE_RESET
@ HAL_I2C_STATE_RESET
Peripheral is not yet Initialized
Definition: gr55xx_hal_i2c.h:102
hal_i2c_master_tx_cplt_callback
void hal_i2c_master_tx_cplt_callback(i2c_handle_t *p_i2c)
Master Tx Transfer completed callback.
_i2c_init::own_address
uint32_t own_address
Specifies the device own address.
Definition: gr55xx_hal_i2c.h:171
_i2c_handle::p_dmarx
dma_handle_t * p_dmarx
I2C Rx DMA handle parameters
Definition: gr55xx_hal_i2c.h:214
_i2c_init
I2C Configuration Structure definition.
Definition: gr55xx_hal_i2c.h:167
HAL_I2C_STATE_BUSY_TX_LISTEN
@ HAL_I2C_STATE_BUSY_TX_LISTEN
Address Listen Mode and Data Transmission process is ongoing
Definition: gr55xx_hal_i2c.h:108
hal_i2c_callback_t
struct _hal_i2c_callback hal_i2c_callback_t
HAL_I2C Callback function definition.
HAL_I2C_STATE_BUSY_RX_LISTEN
@ HAL_I2C_STATE_BUSY_RX_LISTEN
Address Listen Mode and Data Reception process is ongoing
Definition: gr55xx_hal_i2c.h:110
_hal_i2c_callback::i2c_mem_rx_cplt_callback
void(* i2c_mem_rx_cplt_callback)(i2c_handle_t *p_i2c)
I2C mem rx transfer completed callback
Definition: gr55xx_hal_i2c.h:252
hal_i2c_slave_receive_dma
hal_status_t hal_i2c_slave_receive_dma(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size)
Receive in slave mode an amount of data in non-blocking mode with DMA.
_i2c_handle
I2C handle Structure definition.
Definition: gr55xx_hal_i2c.h:191
_i2c_handle::previous_state
__IO uint32_t previous_state
I2C communication Previous state
Definition: gr55xx_hal_i2c.h:207
hal_i2c_mem_write_it
hal_status_t hal_i2c_mem_write_it(i2c_handle_t *p_i2c, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size)
Write an amount of data in non-blocking mode with Interrupt to a specific memory address.
hal_i2c_master_sequential_transmit_it
hal_status_t hal_i2c_master_sequential_transmit_it(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size, uint32_t xfer_options)
Sequentially transmit in master I2C mode an amount of data in non-blocking mode with Interrupt.
_hal_i2c_callback
HAL_I2C Callback function definition.
Definition: gr55xx_hal_i2c.h:243
_hal_i2c_callback::i2c_listen_cplt_callback
void(* i2c_listen_cplt_callback)(i2c_handle_t *p_i2c)
I2C listen Complete callback
Definition: gr55xx_hal_i2c.h:250
hal_i2c_master_transmit_it
hal_status_t hal_i2c_master_transmit_it(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size)
Transmit in master mode an amount of data in non-blocking mode with Interrupt.
_hal_i2c_callback::i2c_error_callback
void(* i2c_error_callback)(i2c_handle_t *p_i2c)
I2C error callback
Definition: gr55xx_hal_i2c.h:253
hal_i2c_slave_receive_transmit
hal_status_t hal_i2c_slave_receive_transmit(i2c_handle_t *p_i2c, uint8_t *p_tdata, uint16_t tsize, uint8_t *p_rdata, uint16_t rsize, uint32_t timeout)
I2C SLAVE receive and transmit data with only one bit.
hal_i2c_slave_transmit_dma
hal_status_t hal_i2c_slave_transmit_dma(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size)
Transmit in slave mode an amount of data in non-blocking mode with DMA.
hal_i2c_timing_get
hal_status_t hal_i2c_timing_get(i2c_handle_t *p_i2c, uint32_t timing_type, uint32_t *p_timing_value)
Get the I2C timing value.
i2c_init_t
struct _i2c_init i2c_init_t
I2C Configuration Structure definition.
_hal_i2c_callback::i2c_abort_cplt_callback
void(* i2c_abort_cplt_callback)(i2c_handle_t *p_i2c)
I2C abort completed callback
Definition: gr55xx_hal_i2c.h:254
i2c_handle_t
struct _i2c_handle i2c_handle_t
I2C handle Structure definition.
hal_i2c_master_transmit_dma
hal_status_t hal_i2c_master_transmit_dma(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size)
Transmit in master mode an amount of data in non-blocking mode with DMA.
_hal_i2c_callback::i2c_slave_rx_cplt_callback
void(* i2c_slave_rx_cplt_callback)(i2c_handle_t *p_i2c)
I2C slave rx transfer completed callback
Definition: gr55xx_hal_i2c.h:249
_hal_i2c_callback::i2c_msp_deinit
void(* i2c_msp_deinit)(i2c_handle_t *p_i2c)
I2C de-init MSP callback
Definition: gr55xx_hal_i2c.h:245
HAL_I2C_MODE_MASTER
@ HAL_I2C_MODE_MASTER
I2C communication is in Master Mode
Definition: gr55xx_hal_i2c.h:145
_i2c_handle::error_code
__IO uint32_t error_code
I2C Error code
Definition: gr55xx_hal_i2c.h:222
hal_i2c_mem_read_dma
hal_status_t hal_i2c_mem_read_dma(i2c_handle_t *p_i2c, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size)
Reads an amount of data in non-blocking mode with DMA from a specific memory address.
hal_i2c_slave_rx_cplt_callback
void hal_i2c_slave_rx_cplt_callback(i2c_handle_t *p_i2c)
Slave Rx Transfer completed callback.
_i2c_handle::p_dmatx
dma_handle_t * p_dmatx
I2C Tx DMA handle parameters
Definition: gr55xx_hal_i2c.h:212
HAL_I2C_STATE_BUSY_RX
@ HAL_I2C_STATE_BUSY_RX
Data Reception process is ongoing
Definition: gr55xx_hal_i2c.h:106
hal_i2c_slave_sequential_transmit_it
hal_status_t hal_i2c_slave_sequential_transmit_it(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size, uint32_t xfer_options)
Sequential transmit in slave/device I2C mode an amount of data in non-blocking mode with Interrupt.
_i2c_handle::mode
__IO hal_i2c_mode_t mode
I2C communication mode
Definition: gr55xx_hal_i2c.h:220
HAL_I2C_STATE_BUSY_TX
@ HAL_I2C_STATE_BUSY_TX
Data Transmission process is ongoing
Definition: gr55xx_hal_i2c.h:105
hal_i2c_state_t
hal_i2c_state_t
HAL I2C State Enumerations definition.
Definition: gr55xx_hal_i2c.h:101
_i2c_handle::state
__IO hal_i2c_state_t state
I2C communication state
Definition: gr55xx_hal_i2c.h:218
_i2c_init::general_call_mode
uint32_t general_call_mode
Specifies if general call mode is selected.
Definition: gr55xx_hal_i2c.h:177
hal_i2c_mem_rx_cplt_callback
void hal_i2c_mem_rx_cplt_callback(i2c_handle_t *p_i2c)
Memory Rx Transfer completed callback.
hal_i2c_suspend_reg
hal_status_t hal_i2c_suspend_reg(i2c_handle_t *p_i2c)
Suspend some registers related to I2C configuration before sleep.
hal_i2c_slave_transmit
hal_status_t hal_i2c_slave_transmit(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size, uint32_t timeout)
Transmits in slave mode an amount of data in blocking mode.
hal_i2c_master_rx_cplt_callback
void hal_i2c_master_rx_cplt_callback(i2c_handle_t *p_i2c)
Master Rx Transfer completed callback.
hal_i2c_slave_receive
hal_status_t hal_i2c_slave_receive(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size, uint32_t timeout)
Receive in slave mode an amount of data in blocking mode.
HAL_I2C_STATE_TIMEOUT
@ HAL_I2C_STATE_TIMEOUT
Timeout state
Definition: gr55xx_hal_i2c.h:113
hal_i2c_slave_transmit_it
hal_status_t hal_i2c_slave_transmit_it(i2c_handle_t *p_i2c, uint8_t *p_data, uint16_t size)
Transmit in slave mode an amount of data in non-blocking mode with Interrupt.
hal_i2c_irq_handler
void hal_i2c_irq_handler(i2c_handle_t *p_i2c)
This function handles I2C event interrupt request.
_hal_i2c_callback::i2c_master_rx_cplt_callback
void(* i2c_master_rx_cplt_callback)(i2c_handle_t *p_i2c)
I2C master rx transfer completed callback
Definition: gr55xx_hal_i2c.h:247
_hal_i2c_callback::i2c_master_tx_cplt_callback
void(* i2c_master_tx_cplt_callback)(i2c_handle_t *p_i2c)
I2C master tx transfer completed callbac
Definition: gr55xx_hal_i2c.h:246
hal_i2c_mode_t
hal_i2c_mode_t
HAL I2C Mode Enumerations definition.
Definition: gr55xx_hal_i2c.h:143
hal_i2c_master_abort_it
hal_status_t hal_i2c_master_abort_it(i2c_handle_t *p_i2c)
Abort a master I2C IT or DMA process communication with Interrupt.
hal_i2c_timing_adjust
hal_status_t hal_i2c_timing_adjust(i2c_handle_t *p_i2c, uint32_t timing_type, int32_t delta)
Adjust I2C timing value to adapt to real load.
_i2c_init::speed
uint32_t speed
Specifies the I2C transfer speed.
Definition: gr55xx_hal_i2c.h:168
hal_i2c_mem_write_dma
hal_status_t hal_i2c_mem_write_dma(i2c_handle_t *p_i2c, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size)
Write an amount of data in non-blocking mode with DMA to a specific memory address.
_i2c_init::addressing_mode
uint32_t addressing_mode
Specifies if 7-bit or 10-bit addressing mode is selected.
Definition: gr55xx_hal_i2c.h:174
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
hal_i2c_mem_write
hal_status_t hal_i2c_mem_write(i2c_handle_t *p_i2c, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size, uint32_t timeout)
Write an amount of data in blocking mode to a specific memory address.
hal_i2c_mem_read
hal_status_t hal_i2c_mem_read(i2c_handle_t *p_i2c, uint16_t dev_address, uint16_t mem_address, uint16_t mem_addr_size, uint8_t *p_data, uint16_t size, uint32_t timeout)
Read an amount of data in blocking mode from a specific memory address.
hal_i2c_mem_tx_cplt_callback
void hal_i2c_mem_tx_cplt_callback(i2c_handle_t *p_i2c)
Memory Tx Transfer completed callback.
HAL_I2C_STATE_ABORT
@ HAL_I2C_STATE_ABORT
Abort user request ongoing
Definition: gr55xx_hal_i2c.h:112
hal_i2c_master_transmit
hal_status_t hal_i2c_master_transmit(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size, uint32_t timeout)
Transmits in master mode an amount of data in blocking mode.
hal_i2c_msp_init
void hal_i2c_msp_init(i2c_handle_t *p_i2c)
Initialize the I2C MSP.
hal_i2c_get_mode
hal_i2c_mode_t hal_i2c_get_mode(i2c_handle_t *p_i2c)
Returns the I2C Master, Slave, Memory or no mode.
hal_i2c_error_callback
void hal_i2c_error_callback(i2c_handle_t *p_i2c)
I2C error callback.
hal_i2c_master_receive_it
hal_status_t hal_i2c_master_receive_it(i2c_handle_t *p_i2c, uint16_t dev_address, uint8_t *p_data, uint16_t size)
Receive in master mode an amount of data in non-blocking mode with Interrupt.
hal_i2c_get_state
hal_i2c_state_t hal_i2c_get_state(i2c_handle_t *p_i2c)
Return the I2C handle state.
hal_i2c_disable_listen_it
hal_status_t hal_i2c_disable_listen_it(i2c_handle_t *p_i2c)
Disable the Master Read Request listen mode with Interrupt.
HAL_I2C_STATE_ERROR
@ HAL_I2C_STATE_ERROR
Error
Definition: gr55xx_hal_i2c.h:114
hal_i2c_resume_reg
hal_status_t hal_i2c_resume_reg(i2c_handle_t *p_i2c)
Restore some registers related to I2C configuration after sleep.
hal_i2c_enable_listen_it
hal_status_t hal_i2c_enable_listen_it(i2c_handle_t *p_i2c)
Enable the Master Read Request listen mode with Interrupt.
_i2c_handle::p_instance
i2c_regs_t * p_instance
I2C registers base address
Definition: gr55xx_hal_i2c.h:192
hal_i2c_abort_cplt_callback
void hal_i2c_abort_cplt_callback(i2c_handle_t *p_i2c)
I2C abort callback.
_i2c_handle::xfer_options
__IO uint32_t xfer_options
I2C sequantial transfer options, this parameter can be a value of I2C Sequential Transfer Options
Definition: gr55xx_hal_i2c.h:204
hal_i2c_slave_tx_cplt_callback
void hal_i2c_slave_tx_cplt_callback(i2c_handle_t *p_i2c)
Slave Tx Transfer completed callback.
_i2c_handle::master_ack_count
__IO uint16_t master_ack_count
I2C master acknowledge counter in master receive progress.
Definition: gr55xx_hal_i2c.h:202
hal_i2c_msp_deinit
void hal_i2c_msp_deinit(i2c_handle_t *p_i2c)
De-initialize the I2C MSP.
_i2c_handle::p_buffer
uint8_t * p_buffer
Pointer to I2C transfer buffer
Definition: gr55xx_hal_i2c.h:196
HAL_I2C_STATE_LISTEN
@ HAL_I2C_STATE_LISTEN
Address Listen Mode is ongoing
Definition: gr55xx_hal_i2c.h:107
_dma_handle
DMA handle Structure definition.
Definition: gr55xx_hal_dma.h:179
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
HAL_I2C_MODE_NONE
@ HAL_I2C_MODE_NONE
No I2C communication on going
Definition: gr55xx_hal_i2c.h:144
_i2c_handle::lock
hal_lock_t lock
I2C locking object
Definition: gr55xx_hal_i2c.h:216
_i2c_handle::xfer_count
__IO uint16_t xfer_count
I2C transfer counter
Definition: gr55xx_hal_i2c.h:200
HAL_I2C_STATE_BUSY
@ HAL_I2C_STATE_BUSY
An internal process is ongoing
Definition: gr55xx_hal_i2c.h:104