]> git.donarmstrong.com Git - qmk_firmware.git/blob - tool/mbed/mbed-sdk/libraries/mbed/targets/cmsis/TARGET_STM/TARGET_STM32F3/stm32f3xx_hal_i2c.h
Squashed 'tmk_core/' changes from 7967731..b9e0ea0
[qmk_firmware.git] / tool / mbed / mbed-sdk / libraries / mbed / targets / cmsis / TARGET_STM / TARGET_STM32F3 / stm32f3xx_hal_i2c.h
1 /**
2   ******************************************************************************
3   * @file    stm32f3xx_hal_i2c.h
4   * @author  MCD Application Team
5   * @version V1.1.0
6   * @date    12-Sept-2014
7   * @brief   Header file of I2C HAL module.
8   ******************************************************************************
9   * @attention
10   *
11   * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
12   *
13   * Redistribution and use in source and binary forms, with or without modification,
14   * are permitted provided that the following conditions are met:
15   *   1. Redistributions of source code must retain the above copyright notice,
16   *      this list of conditions and the following disclaimer.
17   *   2. Redistributions in binary form must reproduce the above copyright notice,
18   *      this list of conditions and the following disclaimer in the documentation
19   *      and/or other materials provided with the distribution.
20   *   3. Neither the name of STMicroelectronics nor the names of its contributors
21   *      may be used to endorse or promote products derived from this software
22   *      without 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 ARE
27   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34   *
35   ******************************************************************************
36   */ 
37
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F3xx_HAL_I2C_H
40 #define __STM32F3xx_HAL_I2C_H
41
42 #ifdef __cplusplus
43  extern "C" {
44 #endif
45
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f3xx_hal_def.h"  
48
49 /** @addtogroup STM32F3xx_HAL_Driver
50   * @{
51   */
52
53 /** @addtogroup I2C
54   * @{
55   */ 
56
57 /* Exported types ------------------------------------------------------------*/ 
58 /** @defgroup I2C_Exported_Types I2C Exported Types
59   * @{
60   */
61
62 /** @defgroup I2C_Configuration_Structure_definition I2C Configuration Structure definition
63   * @brief  I2C Configuration Structure definition  
64   * @{
65   */
66 typedef struct
67 {
68   uint32_t Timing;              /*!< Specifies the I2C_TIMINGR_register value.
69                                   This parameter calculated by referring to I2C initialization 
70                                          section in Reference manual */
71
72   uint32_t OwnAddress1;         /*!< Specifies the first device own address.
73                                   This parameter can be a 7-bit or 10-bit address. */
74
75   uint32_t AddressingMode;      /*!< Specifies if 7-bit or 10-bit addressing mode is selected.
76                                   This parameter can be a value of @ref I2C_addressing_mode */
77
78   uint32_t DualAddressMode;     /*!< Specifies if dual addressing mode is selected.
79                                   This parameter can be a value of @ref I2C_dual_addressing_mode */
80
81   uint32_t OwnAddress2;         /*!< Specifies the second device own address if dual addressing mode is selected
82                                   This parameter can be a 7-bit address. */
83
84   uint32_t OwnAddress2Masks;    /*!< Specifies the acknoledge mask address second device own address if dual addressing mode is selected
85                                   This parameter can be a value of @ref I2C_own_address2_masks. */
86
87   uint32_t GeneralCallMode;     /*!< Specifies if general call mode is selected.
88                                   This parameter can be a value of @ref I2C_general_call_addressing_mode. */
89
90   uint32_t NoStretchMode;       /*!< Specifies if nostretch mode is selected.
91                                   This parameter can be a value of @ref I2C_nostretch_mode */
92
93 }I2C_InitTypeDef;
94
95 /** 
96   * @}
97   */
98
99 /** @defgroup HAL_state_structure_definition HAL state structure definition
100   * @brief  HAL State structure definition  
101   * @{
102   */ 
103
104 typedef enum
105 {
106   HAL_I2C_STATE_RESET           = 0x00,  /*!< I2C not yet initialized or disabled         */
107   HAL_I2C_STATE_READY           = 0x01,  /*!< I2C initialized and ready for use           */
108   HAL_I2C_STATE_BUSY            = 0x02,  /*!< I2C internal process is ongoing             */
109   HAL_I2C_STATE_MASTER_BUSY_TX  = 0x12,  /*!< Master Data Transmission process is ongoing */ 
110   HAL_I2C_STATE_MASTER_BUSY_RX  = 0x22,  /*!< Master Data Reception process is ongoing    */
111   HAL_I2C_STATE_SLAVE_BUSY_TX   = 0x32,  /*!< Slave Data Transmission process is ongoing  */ 
112   HAL_I2C_STATE_SLAVE_BUSY_RX   = 0x42,  /*!< Slave Data Reception process is ongoing     */
113   HAL_I2C_STATE_MEM_BUSY_TX     = 0x52,  /*!< Memory Data Transmission process is ongoing */ 
114   HAL_I2C_STATE_MEM_BUSY_RX     = 0x62,  /*!< Memory Data Reception process is ongoing    */  
115   HAL_I2C_STATE_TIMEOUT         = 0x03,  /*!< Timeout state                               */  
116   HAL_I2C_STATE_ERROR           = 0x04   /*!< Reception process is ongoing                */      
117                                                                         
118 }HAL_I2C_StateTypeDef;
119
120 /** 
121   * @}
122   */
123
124 /** @defgroup I2C_Error_Code_structure_definition I2C Error Code structure definition
125   * @brief  I2C Error Code structure definition  
126   * @{
127   */ 
128
129 typedef enum
130 {
131   HAL_I2C_ERROR_NONE      = 0x00,    /*!< No error              */
132   HAL_I2C_ERROR_BERR      = 0x01,    /*!< BERR error            */
133   HAL_I2C_ERROR_ARLO      = 0x02,    /*!< ARLO error            */   
134   HAL_I2C_ERROR_AF        = 0x04,    /*!< AF error             */
135   HAL_I2C_ERROR_OVR       = 0x08,    /*!< OVR error             */
136   HAL_I2C_ERROR_DMA       = 0x10,    /*!< DMA transfer error    */
137   HAL_I2C_ERROR_TIMEOUT   = 0x20,    /*!< Timeout error         */
138   HAL_I2C_ERROR_SIZE      = 0x40     /*!< Size Management error */
139 }HAL_I2C_ErrorTypeDef;
140
141 /** 
142   * @}
143   */
144
145 /** @defgroup I2C_handle_Structure_definition I2C handle Structure definition 
146   * @brief  I2C handle Structure definition  
147   * @{
148   */
149
150 typedef struct
151 {
152   I2C_TypeDef                *Instance;  /*!< I2C registers base address     */
153
154   I2C_InitTypeDef            Init;       /*!< I2C communication parameters   */
155
156   uint8_t                    *pBuffPtr;  /*!< Pointer to I2C transfer buffer */
157
158   uint16_t                   XferSize;   /*!< I2C transfer size              */
159
160   __IO uint16_t              XferCount;  /*!< I2C transfer counter           */
161
162   DMA_HandleTypeDef          *hdmatx;    /*!< I2C Tx DMA handle parameters   */
163
164   DMA_HandleTypeDef          *hdmarx;    /*!< I2C Rx DMA handle parameters   */
165
166   HAL_LockTypeDef            Lock;       /*!< I2C locking object             */
167
168   __IO HAL_I2C_StateTypeDef  State;      /*!< I2C communication state        */
169
170   __IO HAL_I2C_ErrorTypeDef  ErrorCode;  /* I2C Error code                   */
171
172 }I2C_HandleTypeDef;
173 /**
174   * @}
175   */
176
177 /**
178   * @}
179   */  
180 /* Exported constants --------------------------------------------------------*/
181
182 /** @defgroup I2C_Exported_Constants I2C Exported Constants
183   * @{
184   */
185
186 /** @defgroup I2C_addressing_mode I2C addressing mode
187   * @{
188   */
189 #define I2C_ADDRESSINGMODE_7BIT          ((uint32_t)0x00000001) 
190 #define I2C_ADDRESSINGMODE_10BIT         ((uint32_t)0x00000002)
191
192 #define IS_I2C_ADDRESSING_MODE(MODE) (((MODE) == I2C_ADDRESSINGMODE_7BIT)                                        || \
193                                          ((MODE) == I2C_ADDRESSINGMODE_10BIT))
194 /**
195   * @}
196   */
197
198 /** @defgroup I2C_dual_addressing_mode I2C dual addressing mode
199   * @{
200   */
201
202 #define I2C_DUALADDRESS_DISABLED        ((uint32_t)0x00000000)
203 #define I2C_DUALADDRESS_ENABLED         I2C_OAR2_OA2EN
204
205 #define IS_I2C_DUAL_ADDRESS(ADDRESS) (((ADDRESS) == I2C_DUALADDRESS_DISABLED) || \
206                                       ((ADDRESS) == I2C_DUALADDRESS_ENABLED))
207 /**
208   * @}
209   */
210
211 /** @defgroup I2C_own_address2_masks I2C own address2 masks
212   * @{
213   */
214
215 #define I2C_OA2_NOMASK                  ((uint8_t)0x00)
216 #define I2C_OA2_MASK01                  ((uint8_t)0x01)
217 #define I2C_OA2_MASK02                  ((uint8_t)0x02)
218 #define I2C_OA2_MASK03                  ((uint8_t)0x03)
219 #define I2C_OA2_MASK04                  ((uint8_t)0x04)
220 #define I2C_OA2_MASK05                  ((uint8_t)0x05)
221 #define I2C_OA2_MASK06                  ((uint8_t)0x06)
222 #define I2C_OA2_MASK07                  ((uint8_t)0x07)
223
224 #define IS_I2C_OWN_ADDRESS2_MASK(MASK)  (((MASK) == I2C_OA2_NOMASK) || \
225                                          ((MASK) == I2C_OA2_MASK01) || \
226                                          ((MASK) == I2C_OA2_MASK02) || \
227                                          ((MASK) == I2C_OA2_MASK03) || \
228                                          ((MASK) == I2C_OA2_MASK04) || \
229                                          ((MASK) == I2C_OA2_MASK05) || \
230                                          ((MASK) == I2C_OA2_MASK06) || \
231                                          ((MASK) == I2C_OA2_MASK07))  
232 /**
233   * @}
234   */
235
236 /** @defgroup I2C_general_call_addressing_mode I2C general call addressing mode
237   * @{
238   */
239 #define I2C_GENERALCALL_DISABLED        ((uint32_t)0x00000000)
240 #define I2C_GENERALCALL_ENABLED         I2C_CR1_GCEN
241
242 #define IS_I2C_GENERAL_CALL(CALL) (((CALL) == I2C_GENERALCALL_DISABLED) || \
243                                    ((CALL) == I2C_GENERALCALL_ENABLED))
244 /**
245   * @}
246   */
247
248 /** @defgroup I2C_nostretch_mode I2C nostretch mode
249   * @{
250   */
251 #define I2C_NOSTRETCH_DISABLED          ((uint32_t)0x00000000)
252 #define I2C_NOSTRETCH_ENABLED           I2C_CR1_NOSTRETCH
253
254 #define IS_I2C_NO_STRETCH(STRETCH) (((STRETCH) == I2C_NOSTRETCH_DISABLED) || \
255                                     ((STRETCH) == I2C_NOSTRETCH_ENABLED))
256 /**
257   * @}
258   */
259
260 /** @defgroup I2C_Memory_Address_Size I2C Memory Address Size
261   * @{
262   */
263 #define I2C_MEMADD_SIZE_8BIT            ((uint32_t)0x00000001)
264 #define I2C_MEMADD_SIZE_16BIT           ((uint32_t)0x00000002)
265
266 #define IS_I2C_MEMADD_SIZE(SIZE) (((SIZE) == I2C_MEMADD_SIZE_8BIT) || \
267                                   ((SIZE) == I2C_MEMADD_SIZE_16BIT))
268 /**
269   * @}
270   */  
271   
272 /** @defgroup I2C_ReloadEndMode_definition I2C ReloadEndMode definition
273   * @{
274   */
275
276 #define  I2C_RELOAD_MODE                I2C_CR2_RELOAD
277 #define  I2C_AUTOEND_MODE               I2C_CR2_AUTOEND
278 #define  I2C_SOFTEND_MODE               ((uint32_t)0x00000000)
279
280 #define IS_TRANSFER_MODE(MODE)        (((MODE) == I2C_RELOAD_MODE)  || \
281                                        ((MODE) == I2C_AUTOEND_MODE) || \
282                                        ((MODE) == I2C_SOFTEND_MODE))
283 /**
284   * @}
285   */
286
287 /** @defgroup I2C_StartStopMode_definition I2C StartStopMode definition
288   * @{
289   */
290
291 #define  I2C_NO_STARTSTOP                 ((uint32_t)0x00000000)
292 #define  I2C_GENERATE_STOP                I2C_CR2_STOP
293 #define  I2C_GENERATE_START_READ          (uint32_t)(I2C_CR2_START | I2C_CR2_RD_WRN)
294 #define  I2C_GENERATE_START_WRITE         I2C_CR2_START
295                               
296 #define IS_TRANSFER_REQUEST(REQUEST)    (((REQUEST) == I2C_GENERATE_STOP)        || \
297                                          ((REQUEST) == I2C_GENERATE_START_READ)  || \
298                                          ((REQUEST) == I2C_GENERATE_START_WRITE) || \
299                                          ((REQUEST) == I2C_NO_STARTSTOP))
300                                
301 /**
302   * @}
303   */
304
305 /** @defgroup I2C_Interrupt_configuration_definition I2C Interrupt configuration definition
306   * @brief I2C Interrupt definition
307   *        Elements values convention: 0xXXXXXXXX
308   *           - XXXXXXXX  : Interrupt control mask
309   * @{
310   */
311 #define I2C_IT_ERRI                       I2C_CR1_ERRIE
312 #define I2C_IT_TCI                        I2C_CR1_TCIE
313 #define I2C_IT_STOPI                      I2C_CR1_STOPIE
314 #define I2C_IT_NACKI                      I2C_CR1_NACKIE
315 #define I2C_IT_ADDRI                      I2C_CR1_ADDRIE
316 #define I2C_IT_RXI                        I2C_CR1_RXIE
317 #define I2C_IT_TXI                        I2C_CR1_TXIE
318
319 /**
320   * @}
321   */
322
323
324 /** @defgroup I2C_Flag_definition I2C Flag definition
325   * @{
326   */ 
327
328 #define I2C_FLAG_TXE                      I2C_ISR_TXE
329 #define I2C_FLAG_TXIS                     I2C_ISR_TXIS
330 #define I2C_FLAG_RXNE                     I2C_ISR_RXNE
331 #define I2C_FLAG_ADDR                     I2C_ISR_ADDR
332 #define I2C_FLAG_AF                       I2C_ISR_NACKF
333 #define I2C_FLAG_STOPF                    I2C_ISR_STOPF
334 #define I2C_FLAG_TC                       I2C_ISR_TC
335 #define I2C_FLAG_TCR                      I2C_ISR_TCR
336 #define I2C_FLAG_BERR                     I2C_ISR_BERR
337 #define I2C_FLAG_ARLO                     I2C_ISR_ARLO
338 #define I2C_FLAG_OVR                      I2C_ISR_OVR
339 #define I2C_FLAG_PECERR                   I2C_ISR_PECERR
340 #define I2C_FLAG_TIMEOUT                  I2C_ISR_TIMEOUT
341 #define I2C_FLAG_ALERT                    I2C_ISR_ALERT
342 #define I2C_FLAG_BUSY                     I2C_ISR_BUSY
343 #define I2C_FLAG_DIR                      I2C_ISR_DIR
344 /**
345   * @}
346   */
347
348 /**
349   * @}
350   */ 
351   
352 /* Exported macros -----------------------------------------------------------*/
353
354 /** @defgroup I2C_Exported_Macros I2C Exported Macros
355   * @{
356   */
357
358 /** @brief  Reset I2C handle state
359   * @param  __HANDLE__: I2C handle.
360   * @retval None
361   */
362 #define __HAL_I2C_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_I2C_STATE_RESET)
363
364 /** @brief  Enables or disables the specified I2C interrupts.
365   * @param  __HANDLE__: specifies the I2C Handle.
366   *         This parameter can be I2Cx where x: 1, 2, or 3 to select the I2C peripheral.
367   * @param  __INTERRUPT__: specifies the interrupt source to enable or disable.
368   *         This parameter can be one of the following values:
369   *            @arg I2C_IT_ERRI: Errors interrupt enable
370   *            @arg I2C_IT_TCI: Transfer complete interrupt enable
371   *            @arg I2C_IT_STOPI: STOP detection interrupt enable
372   *            @arg I2C_IT_NACKI: NACK received interrupt enable
373   *            @arg I2C_IT_ADDRI: Address match interrupt enable
374   *            @arg I2C_IT_RXI: RX interrupt enable
375   *            @arg I2C_IT_TXI: TX interrupt enable
376   *   
377   * @retval None
378   */
379   
380 #define __HAL_I2C_ENABLE_IT(__HANDLE__, __INTERRUPT__)   ((__HANDLE__)->Instance->CR1 |= (__INTERRUPT__))
381 #define __HAL_I2C_DISABLE_IT(__HANDLE__, __INTERRUPT__)  ((__HANDLE__)->Instance->CR1 &= (~(__INTERRUPT__)))
382  
383 /** @brief  Checks if the specified I2C interrupt source is enabled or disabled.
384   * @param  __HANDLE__: specifies the I2C Handle.
385   *         This parameter can be I2Cx where x: 1, 2, or 3 to select the I2C peripheral.
386   * @param  __INTERRUPT__: specifies the I2C interrupt source to check.
387   *         This parameter can be one of the following values:
388   *            @arg I2C_IT_ERRI: Errors interrupt enable
389   *            @arg I2C_IT_TCI: Transfer complete interrupt enable
390   *            @arg I2C_IT_STOPI: STOP detection interrupt enable
391   *            @arg I2C_IT_NACKI: NACK received interrupt enable
392   *            @arg I2C_IT_ADDRI: Address match interrupt enable
393   *            @arg I2C_IT_RXI: RX interrupt enable
394   *            @arg I2C_IT_TXI: TX interrupt enable
395   *   
396   * @retval The new state of __IT__ (TRUE or FALSE).
397   */
398 #define __HAL_I2C_GET_IT_SOURCE(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->CR1 & (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
399
400 /** @brief  Checks whether the specified I2C flag is set or not.
401   * @param  __HANDLE__: specifies the I2C Handle.
402   *         This parameter can be I2Cx where x: 1, 2, or 3 to select the I2C peripheral.
403   * @param  __FLAG__: specifies the flag to check.
404   *         This parameter can be one of the following values:
405   *            @arg I2C_FLAG_TXE: Transmit data register empty
406   *            @arg I2C_FLAG_TXIS: Transmit interrupt status
407   *            @arg I2C_FLAG_RXNE: Receive data register not empty
408   *            @arg I2C_FLAG_ADDR: Address matched (slave mode)
409   *            @arg I2C_FLAG_AF: Acknowledge failure received flag
410   *            @arg I2C_FLAG_STOPF: STOP detection flag
411   *            @arg I2C_FLAG_TC: Transfer complete (master mode)
412   *            @arg I2C_FLAG_TCR: Transfer complete reload
413   *            @arg I2C_FLAG_BERR: Bus error
414   *            @arg I2C_FLAG_ARLO: Arbitration lost
415   *            @arg I2C_FLAG_OVR: Overrun/Underrun            
416   *            @arg I2C_FLAG_PECERR: PEC error in reception
417   *            @arg I2C_FLAG_TIMEOUT: Timeout or Tlow detection flag 
418   *            @arg I2C_FLAG_ALERT: SMBus alert
419   *            @arg I2C_FLAG_BUSY: Bus busy
420   *            @arg I2C_FLAG_DIR: Transfer direction (slave mode)
421   *   
422   * @retval The new state of __FLAG__ (TRUE or FALSE).
423   */
424 #define __HAL_I2C_GET_FLAG(__HANDLE__, __FLAG__) ((((__HANDLE__)->Instance->ISR) & (__FLAG__)) == (__FLAG__))
425
426 /** @brief  Clears the I2C pending flags which are cleared by writing 1 in a specific bit.
427   * @param  __HANDLE__: specifies the I2C Handle.
428   *         This parameter can be I2Cx where x: 1, 2, or 3 to select the I2C peripheral.
429   * @param  __FLAG__: specifies the flag to clear.
430   *          This parameter can be any combination of the following values:
431   *            @arg I2C_FLAG_ADDR: Address matched (slave mode)
432   *            @arg I2C_FLAG_AF: Acknowledge failure flag
433   *            @arg I2C_FLAG_STOPF: STOP detection flag
434   *            @arg I2C_FLAG_BERR: Bus error
435   *            @arg I2C_FLAG_ARLO: Arbitration lost
436   *            @arg I2C_FLAG_OVR: Overrun/Underrun            
437   *            @arg I2C_FLAG_PECERR: PEC error in reception
438   *            @arg I2C_FLAG_TIMEOUT: Timeout or Tlow detection flag 
439   *            @arg I2C_FLAG_ALERT: SMBus alert
440   *   
441   * @retval None
442   */
443 #define __HAL_I2C_CLEAR_FLAG(__HANDLE__, __FLAG__) ((__HANDLE__)->Instance->ICR = (__FLAG__))
444  
445
446 #define __HAL_I2C_ENABLE(__HANDLE__)                            ((__HANDLE__)->Instance->CR1 |=  I2C_CR1_PE)
447 #define __HAL_I2C_DISABLE(__HANDLE__)                           ((__HANDLE__)->Instance->CR1 &=  ~I2C_CR1_PE)
448
449 #define __HAL_I2C_RESET_CR2(__HANDLE__)                         ((__HANDLE__)->Instance->CR2 &= (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_HEAD10R | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_RD_WRN)))
450
451 #define __HAL_I2C_MEM_ADD_MSB(__ADDRESS__)                       ((uint8_t)((uint16_t)(((uint16_t)((__ADDRESS__) & (uint16_t)(0xFF00))) >> 8)))
452 #define __HAL_I2C_MEM_ADD_LSB(__ADDRESS__)                       ((uint8_t)((uint16_t)((__ADDRESS__) & (uint16_t)(0x00FF))))
453
454 #define __HAL_I2C_GENERATE_START(__ADDMODE__,__ADDRESS__)       (((__ADDMODE__) == I2C_ADDRESSINGMODE_7BIT) ? (uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | (I2C_CR2_START) | (I2C_CR2_AUTOEND)) & (~I2C_CR2_RD_WRN)) : \
455                                                                   (uint32_t)((((uint32_t)(__ADDRESS__) & (I2C_CR2_SADD)) | (I2C_CR2_ADD10) | (I2C_CR2_START)) & (~I2C_CR2_RD_WRN)))
456
457 #define IS_I2C_OWN_ADDRESS1(ADDRESS1)   ((ADDRESS1) <= (uint32_t)0x000003FF)
458 #define IS_I2C_OWN_ADDRESS2(ADDRESS2)   ((ADDRESS2) <= (uint16_t)0x00FF)
459 /**
460   * @}
461   */ 
462
463 /* Include I2C HAL Extended module */
464 #include "stm32f3xx_hal_i2c_ex.h"
465
466 /* Exported functions --------------------------------------------------------*/
467 /** @addtogroup I2C_Exported_Functions
468   * @{
469   */
470
471 /** @addtogroup I2C_Exported_Functions_Group1 Initialization and de-initialization functions
472   * @{
473   */
474   
475 /* Initialization/de-initialization functions  **********************************/
476 HAL_StatusTypeDef HAL_I2C_Init(I2C_HandleTypeDef *hi2c);
477 HAL_StatusTypeDef HAL_I2C_DeInit (I2C_HandleTypeDef *hi2c);
478 void HAL_I2C_MspInit(I2C_HandleTypeDef *hi2c);
479 void HAL_I2C_MspDeInit(I2C_HandleTypeDef *hi2c);
480
481 /**
482   * @}
483   */ 
484
485 /** @addtogroup I2C_Exported_Functions_Group2 Input and Output operation functions
486   * @{
487   */
488    
489 /* IO operation functions  *****************************************************/
490
491 /** @addtogroup Blocking_mode_Polling Blocking mode Polling
492  * @{
493  */
494
495  /******* Blocking mode: Polling */
496 HAL_StatusTypeDef HAL_I2C_Master_Transmit(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
497 HAL_StatusTypeDef HAL_I2C_Master_Receive(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size, uint32_t Timeout);
498 HAL_StatusTypeDef HAL_I2C_Slave_Transmit(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
499 HAL_StatusTypeDef HAL_I2C_Slave_Receive(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size, uint32_t Timeout);
500 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);
501 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);
502 HAL_StatusTypeDef HAL_I2C_IsDeviceReady(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint32_t Trials, uint32_t Timeout);
503
504 /**
505   * @}
506   */ 
507
508 /** @addtogroup Non_Blocking_mode_Interrupt Non Blocking mode Interrupt
509  * @{
510  */
511    
512  /******* Non-Blocking mode: Interrupt */
513 HAL_StatusTypeDef HAL_I2C_Master_Transmit_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
514 HAL_StatusTypeDef HAL_I2C_Master_Receive_IT(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
515 HAL_StatusTypeDef HAL_I2C_Slave_Transmit_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
516 HAL_StatusTypeDef HAL_I2C_Slave_Receive_IT(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
517 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);
518 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);
519
520 /**
521   * @}
522   */ 
523
524 /** @addtogroup Non_Blocking_mode_DMA Non Blocking mode DMA
525  * @{
526  */  
527  /******* Non-Blocking mode: DMA */
528 HAL_StatusTypeDef HAL_I2C_Master_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
529 HAL_StatusTypeDef HAL_I2C_Master_Receive_DMA(I2C_HandleTypeDef *hi2c, uint16_t DevAddress, uint8_t *pData, uint16_t Size);
530 HAL_StatusTypeDef HAL_I2C_Slave_Transmit_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
531 HAL_StatusTypeDef HAL_I2C_Slave_Receive_DMA(I2C_HandleTypeDef *hi2c, uint8_t *pData, uint16_t Size);
532 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);
533 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);
534 /**
535   * @}
536   */ 
537
538 /** @addtogroup IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
539  * @{
540  */   
541  /******* I2C IRQHandler and Callbacks used in non blocking modes (Interrupt and DMA) */
542 void HAL_I2C_EV_IRQHandler(I2C_HandleTypeDef *hi2c);
543 void HAL_I2C_ER_IRQHandler(I2C_HandleTypeDef *hi2c);
544 void HAL_I2C_MasterTxCpltCallback(I2C_HandleTypeDef *hi2c);
545 void HAL_I2C_MasterRxCpltCallback(I2C_HandleTypeDef *hi2c);
546 void HAL_I2C_SlaveTxCpltCallback(I2C_HandleTypeDef *hi2c);
547 void HAL_I2C_SlaveRxCpltCallback(I2C_HandleTypeDef *hi2c);
548 void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *hi2c);
549 void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *hi2c);
550 void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c);
551
552 /**
553   * @}
554   */ 
555
556 /**
557   * @}
558   */ 
559   
560 /** @addtogroup I2C_Exported_Functions_Group3 Peripheral State and Errors functions
561   * @{
562   */
563   
564 /* Peripheral State and Errors functions  **************************************/
565 HAL_I2C_StateTypeDef HAL_I2C_GetState(I2C_HandleTypeDef *hi2c);
566 uint32_t             HAL_I2C_GetError(I2C_HandleTypeDef *hi2c);
567
568 /**
569   * @}
570   */ 
571
572 /**
573   * @}
574   */ 
575   
576 /**
577   * @}
578   */ 
579
580 /**
581   * @}
582   */ 
583   
584 #ifdef __cplusplus
585 }
586 #endif
587
588
589 #endif /* __STM32F3xx_HAL_I2C_H */
590
591 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/