version_2.0

Dependents:   cc3000_ping_demo_try_2

Fork of mbed by mbed official

Committer:
bogdanm
Date:
Mon Apr 07 18:28:36 2014 +0100
Revision:
82:6473597d706e
Release 82 of the mbed library

Main changes:

- support for K64F
- Revisited Nordic code structure
- Test infrastructure improvements
- various bug fixes

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bogdanm 82:6473597d706e 1 /**
bogdanm 82:6473597d706e 2 ******************************************************************************
bogdanm 82:6473597d706e 3 * @file stm32f30x_i2c.h
bogdanm 82:6473597d706e 4 * @author MCD Application Team
bogdanm 82:6473597d706e 5 * @version V1.1.0
bogdanm 82:6473597d706e 6 * @date 27-February-2014
bogdanm 82:6473597d706e 7 * @brief This file contains all the functions prototypes for the I2C firmware
bogdanm 82:6473597d706e 8 * library.
bogdanm 82:6473597d706e 9 ******************************************************************************
bogdanm 82:6473597d706e 10 * @attention
bogdanm 82:6473597d706e 11 *
bogdanm 82:6473597d706e 12 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
bogdanm 82:6473597d706e 13 *
bogdanm 82:6473597d706e 14 * Redistribution and use in source and binary forms, with or without modification,
bogdanm 82:6473597d706e 15 * are permitted provided that the following conditions are met:
bogdanm 82:6473597d706e 16 * 1. Redistributions of source code must retain the above copyright notice,
bogdanm 82:6473597d706e 17 * this list of conditions and the following disclaimer.
bogdanm 82:6473597d706e 18 * 2. Redistributions in binary form must reproduce the above copyright notice,
bogdanm 82:6473597d706e 19 * this list of conditions and the following disclaimer in the documentation
bogdanm 82:6473597d706e 20 * and/or other materials provided with the distribution.
bogdanm 82:6473597d706e 21 * 3. Neither the name of STMicroelectronics nor the names of its contributors
bogdanm 82:6473597d706e 22 * may be used to endorse or promote products derived from this software
bogdanm 82:6473597d706e 23 * without specific prior written permission.
bogdanm 82:6473597d706e 24 *
bogdanm 82:6473597d706e 25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
bogdanm 82:6473597d706e 26 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
bogdanm 82:6473597d706e 27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
bogdanm 82:6473597d706e 28 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
bogdanm 82:6473597d706e 29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
bogdanm 82:6473597d706e 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
bogdanm 82:6473597d706e 31 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
bogdanm 82:6473597d706e 32 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
bogdanm 82:6473597d706e 33 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
bogdanm 82:6473597d706e 34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
bogdanm 82:6473597d706e 35 *
bogdanm 82:6473597d706e 36 ******************************************************************************
bogdanm 82:6473597d706e 37 */
bogdanm 82:6473597d706e 38
bogdanm 82:6473597d706e 39 /* Define to prevent recursive inclusion -------------------------------------*/
bogdanm 82:6473597d706e 40 #ifndef __STM32F30x_I2C_H
bogdanm 82:6473597d706e 41 #define __STM32F30x_I2C_H
bogdanm 82:6473597d706e 42
bogdanm 82:6473597d706e 43 #ifdef __cplusplus
bogdanm 82:6473597d706e 44 extern "C" {
bogdanm 82:6473597d706e 45 #endif
bogdanm 82:6473597d706e 46
bogdanm 82:6473597d706e 47 /* Includes ------------------------------------------------------------------*/
bogdanm 82:6473597d706e 48 #include "stm32f30x.h"
bogdanm 82:6473597d706e 49
bogdanm 82:6473597d706e 50 /** @addtogroup STM32F30x_StdPeriph_Driver
bogdanm 82:6473597d706e 51 * @{
bogdanm 82:6473597d706e 52 */
bogdanm 82:6473597d706e 53
bogdanm 82:6473597d706e 54 /** @addtogroup I2C
bogdanm 82:6473597d706e 55 * @{
bogdanm 82:6473597d706e 56 */
bogdanm 82:6473597d706e 57
bogdanm 82:6473597d706e 58 /* Exported types ------------------------------------------------------------*/
bogdanm 82:6473597d706e 59
bogdanm 82:6473597d706e 60 /**
bogdanm 82:6473597d706e 61 * @brief I2C Init structure definition
bogdanm 82:6473597d706e 62 */
bogdanm 82:6473597d706e 63
bogdanm 82:6473597d706e 64 typedef struct
bogdanm 82:6473597d706e 65 {
bogdanm 82:6473597d706e 66 uint32_t I2C_Timing; /*!< Specifies the I2C_TIMINGR_register value.
bogdanm 82:6473597d706e 67 This parameter calculated by referring to I2C initialization
bogdanm 82:6473597d706e 68 section in Reference manual*/
bogdanm 82:6473597d706e 69
bogdanm 82:6473597d706e 70 uint32_t I2C_AnalogFilter; /*!< Enables or disables analog noise filter.
bogdanm 82:6473597d706e 71 This parameter can be a value of @ref I2C_Analog_Filter */
bogdanm 82:6473597d706e 72
bogdanm 82:6473597d706e 73 uint32_t I2C_DigitalFilter; /*!< Configures the digital noise filter.
bogdanm 82:6473597d706e 74 This parameter can be a number between 0x00 and 0x0F */
bogdanm 82:6473597d706e 75
bogdanm 82:6473597d706e 76 uint32_t I2C_Mode; /*!< Specifies the I2C mode.
bogdanm 82:6473597d706e 77 This parameter can be a value of @ref I2C_mode */
bogdanm 82:6473597d706e 78
bogdanm 82:6473597d706e 79 uint32_t I2C_OwnAddress1; /*!< Specifies the device own address 1.
bogdanm 82:6473597d706e 80 This parameter can be a 7-bit or 10-bit address */
bogdanm 82:6473597d706e 81
bogdanm 82:6473597d706e 82 uint32_t I2C_Ack; /*!< Enables or disables the acknowledgement.
bogdanm 82:6473597d706e 83 This parameter can be a value of @ref I2C_acknowledgement */
bogdanm 82:6473597d706e 84
bogdanm 82:6473597d706e 85 uint32_t I2C_AcknowledgedAddress; /*!< Specifies if 7-bit or 10-bit address is acknowledged.
bogdanm 82:6473597d706e 86 This parameter can be a value of @ref I2C_acknowledged_address */
bogdanm 82:6473597d706e 87 }I2C_InitTypeDef;
bogdanm 82:6473597d706e 88
bogdanm 82:6473597d706e 89 /* Exported constants --------------------------------------------------------*/
bogdanm 82:6473597d706e 90
bogdanm 82:6473597d706e 91
bogdanm 82:6473597d706e 92 /** @defgroup I2C_Exported_Constants
bogdanm 82:6473597d706e 93 * @{
bogdanm 82:6473597d706e 94 */
bogdanm 82:6473597d706e 95
bogdanm 82:6473597d706e 96 #define IS_I2C_ALL_PERIPH(PERIPH) (((PERIPH) == I2C1) || \
bogdanm 82:6473597d706e 97 ((PERIPH) == I2C2))
bogdanm 82:6473597d706e 98
bogdanm 82:6473597d706e 99 /** @defgroup I2C_Analog_Filter
bogdanm 82:6473597d706e 100 * @{
bogdanm 82:6473597d706e 101 */
bogdanm 82:6473597d706e 102
bogdanm 82:6473597d706e 103 #define I2C_AnalogFilter_Enable ((uint32_t)0x00000000)
bogdanm 82:6473597d706e 104 #define I2C_AnalogFilter_Disable I2C_CR1_ANFOFF
bogdanm 82:6473597d706e 105
bogdanm 82:6473597d706e 106 #define IS_I2C_ANALOG_FILTER(FILTER) (((FILTER) == I2C_AnalogFilter_Enable) || \
bogdanm 82:6473597d706e 107 ((FILTER) == I2C_AnalogFilter_Disable))
bogdanm 82:6473597d706e 108 /**
bogdanm 82:6473597d706e 109 * @}
bogdanm 82:6473597d706e 110 */
bogdanm 82:6473597d706e 111
bogdanm 82:6473597d706e 112 /** @defgroup I2C_Digital_Filter
bogdanm 82:6473597d706e 113 * @{
bogdanm 82:6473597d706e 114 */
bogdanm 82:6473597d706e 115
bogdanm 82:6473597d706e 116 #define IS_I2C_DIGITAL_FILTER(FILTER) ((FILTER) <= 0x0000000F)
bogdanm 82:6473597d706e 117 /**
bogdanm 82:6473597d706e 118 * @}
bogdanm 82:6473597d706e 119 */
bogdanm 82:6473597d706e 120
bogdanm 82:6473597d706e 121 /** @defgroup I2C_mode
bogdanm 82:6473597d706e 122 * @{
bogdanm 82:6473597d706e 123 */
bogdanm 82:6473597d706e 124
bogdanm 82:6473597d706e 125 #define I2C_Mode_I2C ((uint32_t)0x00000000)
bogdanm 82:6473597d706e 126 #define I2C_Mode_SMBusDevice I2C_CR1_SMBDEN
bogdanm 82:6473597d706e 127 #define I2C_Mode_SMBusHost I2C_CR1_SMBHEN
bogdanm 82:6473597d706e 128
bogdanm 82:6473597d706e 129 #define IS_I2C_MODE(MODE) (((MODE) == I2C_Mode_I2C) || \
bogdanm 82:6473597d706e 130 ((MODE) == I2C_Mode_SMBusDevice) || \
bogdanm 82:6473597d706e 131 ((MODE) == I2C_Mode_SMBusHost))
bogdanm 82:6473597d706e 132 /**
bogdanm 82:6473597d706e 133 * @}
bogdanm 82:6473597d706e 134 */
bogdanm 82:6473597d706e 135
bogdanm 82:6473597d706e 136 /** @defgroup I2C_acknowledgement
bogdanm 82:6473597d706e 137 * @{
bogdanm 82:6473597d706e 138 */
bogdanm 82:6473597d706e 139
bogdanm 82:6473597d706e 140 #define I2C_Ack_Enable ((uint32_t)0x00000000)
bogdanm 82:6473597d706e 141 #define I2C_Ack_Disable I2C_CR2_NACK
bogdanm 82:6473597d706e 142
bogdanm 82:6473597d706e 143 #define IS_I2C_ACK(ACK) (((ACK) == I2C_Ack_Enable) || \
bogdanm 82:6473597d706e 144 ((ACK) == I2C_Ack_Disable))
bogdanm 82:6473597d706e 145 /**
bogdanm 82:6473597d706e 146 * @}
bogdanm 82:6473597d706e 147 */
bogdanm 82:6473597d706e 148
bogdanm 82:6473597d706e 149 /** @defgroup I2C_acknowledged_address
bogdanm 82:6473597d706e 150 * @{
bogdanm 82:6473597d706e 151 */
bogdanm 82:6473597d706e 152
bogdanm 82:6473597d706e 153 #define I2C_AcknowledgedAddress_7bit ((uint32_t)0x00000000)
bogdanm 82:6473597d706e 154 #define I2C_AcknowledgedAddress_10bit I2C_OAR1_OA1MODE
bogdanm 82:6473597d706e 155
bogdanm 82:6473597d706e 156 #define IS_I2C_ACKNOWLEDGE_ADDRESS(ADDRESS) (((ADDRESS) == I2C_AcknowledgedAddress_7bit) || \
bogdanm 82:6473597d706e 157 ((ADDRESS) == I2C_AcknowledgedAddress_10bit))
bogdanm 82:6473597d706e 158 /**
bogdanm 82:6473597d706e 159 * @}
bogdanm 82:6473597d706e 160 */
bogdanm 82:6473597d706e 161
bogdanm 82:6473597d706e 162 /** @defgroup I2C_own_address1
bogdanm 82:6473597d706e 163 * @{
bogdanm 82:6473597d706e 164 */
bogdanm 82:6473597d706e 165
bogdanm 82:6473597d706e 166 #define IS_I2C_OWN_ADDRESS1(ADDRESS1) ((ADDRESS1) <= (uint32_t)0x000003FF)
bogdanm 82:6473597d706e 167 /**
bogdanm 82:6473597d706e 168 * @}
bogdanm 82:6473597d706e 169 */
bogdanm 82:6473597d706e 170
bogdanm 82:6473597d706e 171 /** @defgroup I2C_transfer_direction
bogdanm 82:6473597d706e 172 * @{
bogdanm 82:6473597d706e 173 */
bogdanm 82:6473597d706e 174
bogdanm 82:6473597d706e 175 #define I2C_Direction_Transmitter ((uint16_t)0x0000)
bogdanm 82:6473597d706e 176 #define I2C_Direction_Receiver ((uint16_t)0x0400)
bogdanm 82:6473597d706e 177
bogdanm 82:6473597d706e 178 #define IS_I2C_DIRECTION(DIRECTION) (((DIRECTION) == I2C_Direction_Transmitter) || \
bogdanm 82:6473597d706e 179 ((DIRECTION) == I2C_Direction_Receiver))
bogdanm 82:6473597d706e 180 /**
bogdanm 82:6473597d706e 181 * @}
bogdanm 82:6473597d706e 182 */
bogdanm 82:6473597d706e 183
bogdanm 82:6473597d706e 184 /** @defgroup I2C_DMA_transfer_requests
bogdanm 82:6473597d706e 185 * @{
bogdanm 82:6473597d706e 186 */
bogdanm 82:6473597d706e 187
bogdanm 82:6473597d706e 188 #define I2C_DMAReq_Tx I2C_CR1_TXDMAEN
bogdanm 82:6473597d706e 189 #define I2C_DMAReq_Rx I2C_CR1_RXDMAEN
bogdanm 82:6473597d706e 190
bogdanm 82:6473597d706e 191 #define IS_I2C_DMA_REQ(REQ) ((((REQ) & (uint32_t)0xFFFF3FFF) == 0x00) && ((REQ) != 0x00))
bogdanm 82:6473597d706e 192 /**
bogdanm 82:6473597d706e 193 * @}
bogdanm 82:6473597d706e 194 */
bogdanm 82:6473597d706e 195
bogdanm 82:6473597d706e 196 /** @defgroup I2C_slave_address
bogdanm 82:6473597d706e 197 * @{
bogdanm 82:6473597d706e 198 */
bogdanm 82:6473597d706e 199
bogdanm 82:6473597d706e 200 #define IS_I2C_SLAVE_ADDRESS(ADDRESS) ((ADDRESS) <= (uint16_t)0x03FF)
bogdanm 82:6473597d706e 201 /**
bogdanm 82:6473597d706e 202 * @}
bogdanm 82:6473597d706e 203 */
bogdanm 82:6473597d706e 204
bogdanm 82:6473597d706e 205
bogdanm 82:6473597d706e 206 /** @defgroup I2C_own_address2
bogdanm 82:6473597d706e 207 * @{
bogdanm 82:6473597d706e 208 */
bogdanm 82:6473597d706e 209
bogdanm 82:6473597d706e 210 #define IS_I2C_OWN_ADDRESS2(ADDRESS2) ((ADDRESS2) <= (uint16_t)0x00FF)
bogdanm 82:6473597d706e 211
bogdanm 82:6473597d706e 212 /**
bogdanm 82:6473597d706e 213 * @}
bogdanm 82:6473597d706e 214 */
bogdanm 82:6473597d706e 215
bogdanm 82:6473597d706e 216 /** @defgroup I2C_own_address2_mask
bogdanm 82:6473597d706e 217 * @{
bogdanm 82:6473597d706e 218 */
bogdanm 82:6473597d706e 219
bogdanm 82:6473597d706e 220 #define I2C_OA2_NoMask ((uint8_t)0x00)
bogdanm 82:6473597d706e 221 #define I2C_OA2_Mask01 ((uint8_t)0x01)
bogdanm 82:6473597d706e 222 #define I2C_OA2_Mask02 ((uint8_t)0x02)
bogdanm 82:6473597d706e 223 #define I2C_OA2_Mask03 ((uint8_t)0x03)
bogdanm 82:6473597d706e 224 #define I2C_OA2_Mask04 ((uint8_t)0x04)
bogdanm 82:6473597d706e 225 #define I2C_OA2_Mask05 ((uint8_t)0x05)
bogdanm 82:6473597d706e 226 #define I2C_OA2_Mask06 ((uint8_t)0x06)
bogdanm 82:6473597d706e 227 #define I2C_OA2_Mask07 ((uint8_t)0x07)
bogdanm 82:6473597d706e 228
bogdanm 82:6473597d706e 229 #define IS_I2C_OWN_ADDRESS2_MASK(MASK) (((MASK) == I2C_OA2_NoMask) || \
bogdanm 82:6473597d706e 230 ((MASK) == I2C_OA2_Mask01) || \
bogdanm 82:6473597d706e 231 ((MASK) == I2C_OA2_Mask02) || \
bogdanm 82:6473597d706e 232 ((MASK) == I2C_OA2_Mask03) || \
bogdanm 82:6473597d706e 233 ((MASK) == I2C_OA2_Mask04) || \
bogdanm 82:6473597d706e 234 ((MASK) == I2C_OA2_Mask05) || \
bogdanm 82:6473597d706e 235 ((MASK) == I2C_OA2_Mask06) || \
bogdanm 82:6473597d706e 236 ((MASK) == I2C_OA2_Mask07))
bogdanm 82:6473597d706e 237
bogdanm 82:6473597d706e 238 /**
bogdanm 82:6473597d706e 239 * @}
bogdanm 82:6473597d706e 240 */
bogdanm 82:6473597d706e 241
bogdanm 82:6473597d706e 242 /** @defgroup I2C_timeout
bogdanm 82:6473597d706e 243 * @{
bogdanm 82:6473597d706e 244 */
bogdanm 82:6473597d706e 245
bogdanm 82:6473597d706e 246 #define IS_I2C_TIMEOUT(TIMEOUT) ((TIMEOUT) <= (uint16_t)0x0FFF)
bogdanm 82:6473597d706e 247
bogdanm 82:6473597d706e 248 /**
bogdanm 82:6473597d706e 249 * @}
bogdanm 82:6473597d706e 250 */
bogdanm 82:6473597d706e 251
bogdanm 82:6473597d706e 252 /** @defgroup I2C_registers
bogdanm 82:6473597d706e 253 * @{
bogdanm 82:6473597d706e 254 */
bogdanm 82:6473597d706e 255
bogdanm 82:6473597d706e 256 #define I2C_Register_CR1 ((uint8_t)0x00)
bogdanm 82:6473597d706e 257 #define I2C_Register_CR2 ((uint8_t)0x04)
bogdanm 82:6473597d706e 258 #define I2C_Register_OAR1 ((uint8_t)0x08)
bogdanm 82:6473597d706e 259 #define I2C_Register_OAR2 ((uint8_t)0x0C)
bogdanm 82:6473597d706e 260 #define I2C_Register_TIMINGR ((uint8_t)0x10)
bogdanm 82:6473597d706e 261 #define I2C_Register_TIMEOUTR ((uint8_t)0x14)
bogdanm 82:6473597d706e 262 #define I2C_Register_ISR ((uint8_t)0x18)
bogdanm 82:6473597d706e 263 #define I2C_Register_ICR ((uint8_t)0x1C)
bogdanm 82:6473597d706e 264 #define I2C_Register_PECR ((uint8_t)0x20)
bogdanm 82:6473597d706e 265 #define I2C_Register_RXDR ((uint8_t)0x24)
bogdanm 82:6473597d706e 266 #define I2C_Register_TXDR ((uint8_t)0x28)
bogdanm 82:6473597d706e 267
bogdanm 82:6473597d706e 268 #define IS_I2C_REGISTER(REGISTER) (((REGISTER) == I2C_Register_CR1) || \
bogdanm 82:6473597d706e 269 ((REGISTER) == I2C_Register_CR2) || \
bogdanm 82:6473597d706e 270 ((REGISTER) == I2C_Register_OAR1) || \
bogdanm 82:6473597d706e 271 ((REGISTER) == I2C_Register_OAR2) || \
bogdanm 82:6473597d706e 272 ((REGISTER) == I2C_Register_TIMINGR) || \
bogdanm 82:6473597d706e 273 ((REGISTER) == I2C_Register_TIMEOUTR) || \
bogdanm 82:6473597d706e 274 ((REGISTER) == I2C_Register_ISR) || \
bogdanm 82:6473597d706e 275 ((REGISTER) == I2C_Register_ICR) || \
bogdanm 82:6473597d706e 276 ((REGISTER) == I2C_Register_PECR) || \
bogdanm 82:6473597d706e 277 ((REGISTER) == I2C_Register_RXDR) || \
bogdanm 82:6473597d706e 278 ((REGISTER) == I2C_Register_TXDR))
bogdanm 82:6473597d706e 279 /**
bogdanm 82:6473597d706e 280 * @}
bogdanm 82:6473597d706e 281 */
bogdanm 82:6473597d706e 282
bogdanm 82:6473597d706e 283 /** @defgroup I2C_interrupts_definition
bogdanm 82:6473597d706e 284 * @{
bogdanm 82:6473597d706e 285 */
bogdanm 82:6473597d706e 286
bogdanm 82:6473597d706e 287 #define I2C_IT_ERRI I2C_CR1_ERRIE
bogdanm 82:6473597d706e 288 #define I2C_IT_TCI I2C_CR1_TCIE
bogdanm 82:6473597d706e 289 #define I2C_IT_STOPI I2C_CR1_STOPIE
bogdanm 82:6473597d706e 290 #define I2C_IT_NACKI I2C_CR1_NACKIE
bogdanm 82:6473597d706e 291 #define I2C_IT_ADDRI I2C_CR1_ADDRIE
bogdanm 82:6473597d706e 292 #define I2C_IT_RXI I2C_CR1_RXIE
bogdanm 82:6473597d706e 293 #define I2C_IT_TXI I2C_CR1_TXIE
bogdanm 82:6473597d706e 294
bogdanm 82:6473597d706e 295 #define IS_I2C_CONFIG_IT(IT) ((((IT) & (uint32_t)0xFFFFFF01) == 0x00) && ((IT) != 0x00))
bogdanm 82:6473597d706e 296
bogdanm 82:6473597d706e 297 /**
bogdanm 82:6473597d706e 298 * @}
bogdanm 82:6473597d706e 299 */
bogdanm 82:6473597d706e 300
bogdanm 82:6473597d706e 301 /** @defgroup I2C_flags_definition
bogdanm 82:6473597d706e 302 * @{
bogdanm 82:6473597d706e 303 */
bogdanm 82:6473597d706e 304
bogdanm 82:6473597d706e 305 #define I2C_FLAG_TXE I2C_ISR_TXE
bogdanm 82:6473597d706e 306 #define I2C_FLAG_TXIS I2C_ISR_TXIS
bogdanm 82:6473597d706e 307 #define I2C_FLAG_RXNE I2C_ISR_RXNE
bogdanm 82:6473597d706e 308 #define I2C_FLAG_ADDR I2C_ISR_ADDR
bogdanm 82:6473597d706e 309 #define I2C_FLAG_NACKF I2C_ISR_NACKF
bogdanm 82:6473597d706e 310 #define I2C_FLAG_STOPF I2C_ISR_STOPF
bogdanm 82:6473597d706e 311 #define I2C_FLAG_TC I2C_ISR_TC
bogdanm 82:6473597d706e 312 #define I2C_FLAG_TCR I2C_ISR_TCR
bogdanm 82:6473597d706e 313 #define I2C_FLAG_BERR I2C_ISR_BERR
bogdanm 82:6473597d706e 314 #define I2C_FLAG_ARLO I2C_ISR_ARLO
bogdanm 82:6473597d706e 315 #define I2C_FLAG_OVR I2C_ISR_OVR
bogdanm 82:6473597d706e 316 #define I2C_FLAG_PECERR I2C_ISR_PECERR
bogdanm 82:6473597d706e 317 #define I2C_FLAG_TIMEOUT I2C_ISR_TIMEOUT
bogdanm 82:6473597d706e 318 #define I2C_FLAG_ALERT I2C_ISR_ALERT
bogdanm 82:6473597d706e 319 #define I2C_FLAG_BUSY I2C_ISR_BUSY
bogdanm 82:6473597d706e 320
bogdanm 82:6473597d706e 321 #define IS_I2C_CLEAR_FLAG(FLAG) ((((FLAG) & (uint32_t)0xFFFF4000) == 0x00) && ((FLAG) != 0x00))
bogdanm 82:6473597d706e 322
bogdanm 82:6473597d706e 323 #define IS_I2C_GET_FLAG(FLAG) (((FLAG) == I2C_FLAG_TXE) || ((FLAG) == I2C_FLAG_TXIS) || \
bogdanm 82:6473597d706e 324 ((FLAG) == I2C_FLAG_RXNE) || ((FLAG) == I2C_FLAG_ADDR) || \
bogdanm 82:6473597d706e 325 ((FLAG) == I2C_FLAG_NACKF) || ((FLAG) == I2C_FLAG_STOPF) || \
bogdanm 82:6473597d706e 326 ((FLAG) == I2C_FLAG_TC) || ((FLAG) == I2C_FLAG_TCR) || \
bogdanm 82:6473597d706e 327 ((FLAG) == I2C_FLAG_BERR) || ((FLAG) == I2C_FLAG_ARLO) || \
bogdanm 82:6473597d706e 328 ((FLAG) == I2C_FLAG_OVR) || ((FLAG) == I2C_FLAG_PECERR) || \
bogdanm 82:6473597d706e 329 ((FLAG) == I2C_FLAG_TIMEOUT) || ((FLAG) == I2C_FLAG_ALERT) || \
bogdanm 82:6473597d706e 330 ((FLAG) == I2C_FLAG_BUSY))
bogdanm 82:6473597d706e 331
bogdanm 82:6473597d706e 332 /**
bogdanm 82:6473597d706e 333 * @}
bogdanm 82:6473597d706e 334 */
bogdanm 82:6473597d706e 335
bogdanm 82:6473597d706e 336
bogdanm 82:6473597d706e 337 /** @defgroup I2C_interrupts_definition
bogdanm 82:6473597d706e 338 * @{
bogdanm 82:6473597d706e 339 */
bogdanm 82:6473597d706e 340
bogdanm 82:6473597d706e 341 #define I2C_IT_TXIS I2C_ISR_TXIS
bogdanm 82:6473597d706e 342 #define I2C_IT_RXNE I2C_ISR_RXNE
bogdanm 82:6473597d706e 343 #define I2C_IT_ADDR I2C_ISR_ADDR
bogdanm 82:6473597d706e 344 #define I2C_IT_NACKF I2C_ISR_NACKF
bogdanm 82:6473597d706e 345 #define I2C_IT_STOPF I2C_ISR_STOPF
bogdanm 82:6473597d706e 346 #define I2C_IT_TC I2C_ISR_TC
bogdanm 82:6473597d706e 347 #define I2C_IT_TCR I2C_ISR_TCR
bogdanm 82:6473597d706e 348 #define I2C_IT_BERR I2C_ISR_BERR
bogdanm 82:6473597d706e 349 #define I2C_IT_ARLO I2C_ISR_ARLO
bogdanm 82:6473597d706e 350 #define I2C_IT_OVR I2C_ISR_OVR
bogdanm 82:6473597d706e 351 #define I2C_IT_PECERR I2C_ISR_PECERR
bogdanm 82:6473597d706e 352 #define I2C_IT_TIMEOUT I2C_ISR_TIMEOUT
bogdanm 82:6473597d706e 353 #define I2C_IT_ALERT I2C_ISR_ALERT
bogdanm 82:6473597d706e 354
bogdanm 82:6473597d706e 355 #define IS_I2C_CLEAR_IT(IT) ((((IT) & (uint32_t)0xFFFFC001) == 0x00) && ((IT) != 0x00))
bogdanm 82:6473597d706e 356
bogdanm 82:6473597d706e 357 #define IS_I2C_GET_IT(IT) (((IT) == I2C_IT_TXIS) || ((IT) == I2C_IT_RXNE) || \
bogdanm 82:6473597d706e 358 ((IT) == I2C_IT_ADDR) || ((IT) == I2C_IT_NACKF) || \
bogdanm 82:6473597d706e 359 ((IT) == I2C_IT_STOPF) || ((IT) == I2C_IT_TC) || \
bogdanm 82:6473597d706e 360 ((IT) == I2C_IT_TCR) || ((IT) == I2C_IT_BERR) || \
bogdanm 82:6473597d706e 361 ((IT) == I2C_IT_ARLO) || ((IT) == I2C_IT_OVR) || \
bogdanm 82:6473597d706e 362 ((IT) == I2C_IT_PECERR) || ((IT) == I2C_IT_TIMEOUT) || \
bogdanm 82:6473597d706e 363 ((IT) == I2C_IT_ALERT))
bogdanm 82:6473597d706e 364
bogdanm 82:6473597d706e 365
bogdanm 82:6473597d706e 366 /**
bogdanm 82:6473597d706e 367 * @}
bogdanm 82:6473597d706e 368 */
bogdanm 82:6473597d706e 369
bogdanm 82:6473597d706e 370 /** @defgroup I2C_ReloadEndMode_definition
bogdanm 82:6473597d706e 371 * @{
bogdanm 82:6473597d706e 372 */
bogdanm 82:6473597d706e 373
bogdanm 82:6473597d706e 374 #define I2C_Reload_Mode I2C_CR2_RELOAD
bogdanm 82:6473597d706e 375 #define I2C_AutoEnd_Mode I2C_CR2_AUTOEND
bogdanm 82:6473597d706e 376 #define I2C_SoftEnd_Mode ((uint32_t)0x00000000)
bogdanm 82:6473597d706e 377
bogdanm 82:6473597d706e 378
bogdanm 82:6473597d706e 379 #define IS_RELOAD_END_MODE(MODE) (((MODE) == I2C_Reload_Mode) || \
bogdanm 82:6473597d706e 380 ((MODE) == I2C_AutoEnd_Mode) || \
bogdanm 82:6473597d706e 381 ((MODE) == I2C_SoftEnd_Mode))
bogdanm 82:6473597d706e 382
bogdanm 82:6473597d706e 383
bogdanm 82:6473597d706e 384 /**
bogdanm 82:6473597d706e 385 * @}
bogdanm 82:6473597d706e 386 */
bogdanm 82:6473597d706e 387
bogdanm 82:6473597d706e 388 /** @defgroup I2C_StartStopMode_definition
bogdanm 82:6473597d706e 389 * @{
bogdanm 82:6473597d706e 390 */
bogdanm 82:6473597d706e 391
bogdanm 82:6473597d706e 392 #define I2C_No_StartStop ((uint32_t)0x00000000)
bogdanm 82:6473597d706e 393 #define I2C_Generate_Stop I2C_CR2_STOP
bogdanm 82:6473597d706e 394 #define I2C_Generate_Start_Read (uint32_t)(I2C_CR2_START | I2C_CR2_RD_WRN)
bogdanm 82:6473597d706e 395 #define I2C_Generate_Start_Write I2C_CR2_START
bogdanm 82:6473597d706e 396
bogdanm 82:6473597d706e 397
bogdanm 82:6473597d706e 398 #define IS_START_STOP_MODE(MODE) (((MODE) == I2C_Generate_Stop) || \
bogdanm 82:6473597d706e 399 ((MODE) == I2C_Generate_Start_Read) || \
bogdanm 82:6473597d706e 400 ((MODE) == I2C_Generate_Start_Write) || \
bogdanm 82:6473597d706e 401 ((MODE) == I2C_No_StartStop))
bogdanm 82:6473597d706e 402
bogdanm 82:6473597d706e 403
bogdanm 82:6473597d706e 404 /**
bogdanm 82:6473597d706e 405 * @}
bogdanm 82:6473597d706e 406 */
bogdanm 82:6473597d706e 407
bogdanm 82:6473597d706e 408 /**
bogdanm 82:6473597d706e 409 * @}
bogdanm 82:6473597d706e 410 */
bogdanm 82:6473597d706e 411
bogdanm 82:6473597d706e 412 /* Exported macro ------------------------------------------------------------*/
bogdanm 82:6473597d706e 413 /* Exported functions ------------------------------------------------------- */
bogdanm 82:6473597d706e 414
bogdanm 82:6473597d706e 415
bogdanm 82:6473597d706e 416 /* Initialization and Configuration functions *********************************/
bogdanm 82:6473597d706e 417 void I2C_DeInit(I2C_TypeDef* I2Cx);
bogdanm 82:6473597d706e 418 void I2C_Init(I2C_TypeDef* I2Cx, I2C_InitTypeDef* I2C_InitStruct);
bogdanm 82:6473597d706e 419 void I2C_StructInit(I2C_InitTypeDef* I2C_InitStruct);
bogdanm 82:6473597d706e 420 void I2C_Cmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 421 void I2C_SoftwareResetCmd(I2C_TypeDef* I2Cx);
bogdanm 82:6473597d706e 422 void I2C_ITConfig(I2C_TypeDef* I2Cx, uint32_t I2C_IT, FunctionalState NewState);
bogdanm 82:6473597d706e 423 void I2C_StretchClockCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 424 void I2C_StopModeCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 425 void I2C_DualAddressCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 426 void I2C_OwnAddress2Config(I2C_TypeDef* I2Cx, uint16_t Address, uint8_t Mask);
bogdanm 82:6473597d706e 427 void I2C_GeneralCallCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 428 void I2C_SlaveByteControlCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 429 void I2C_SlaveAddressConfig(I2C_TypeDef* I2Cx, uint16_t Address);
bogdanm 82:6473597d706e 430 void I2C_10BitAddressingModeCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 431
bogdanm 82:6473597d706e 432 /* Communications handling functions ******************************************/
bogdanm 82:6473597d706e 433 void I2C_AutoEndCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 434 void I2C_ReloadCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 435 void I2C_NumberOfBytesConfig(I2C_TypeDef* I2Cx, uint8_t Number_Bytes);
bogdanm 82:6473597d706e 436 void I2C_MasterRequestConfig(I2C_TypeDef* I2Cx, uint16_t I2C_Direction);
bogdanm 82:6473597d706e 437 void I2C_GenerateSTART(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 438 void I2C_GenerateSTOP(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 439 void I2C_10BitAddressHeaderCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 440 void I2C_AcknowledgeConfig(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 441 uint8_t I2C_GetAddressMatched(I2C_TypeDef* I2Cx);
bogdanm 82:6473597d706e 442 uint16_t I2C_GetTransferDirection(I2C_TypeDef* I2Cx);
bogdanm 82:6473597d706e 443 void I2C_TransferHandling(I2C_TypeDef* I2Cx, uint16_t Address, uint8_t Number_Bytes, uint32_t ReloadEndMode, uint32_t StartStopMode);
bogdanm 82:6473597d706e 444
bogdanm 82:6473597d706e 445 /* SMBUS management functions ************************************************/
bogdanm 82:6473597d706e 446 void I2C_SMBusAlertCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 447 void I2C_ClockTimeoutCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 448 void I2C_ExtendedClockTimeoutCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 449 void I2C_IdleClockTimeoutCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 450 void I2C_TimeoutAConfig(I2C_TypeDef* I2Cx, uint16_t Timeout);
bogdanm 82:6473597d706e 451 void I2C_TimeoutBConfig(I2C_TypeDef* I2Cx, uint16_t Timeout);
bogdanm 82:6473597d706e 452 void I2C_CalculatePEC(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 453 void I2C_PECRequestCmd(I2C_TypeDef* I2Cx, FunctionalState NewState);
bogdanm 82:6473597d706e 454 uint8_t I2C_GetPEC(I2C_TypeDef* I2Cx);
bogdanm 82:6473597d706e 455
bogdanm 82:6473597d706e 456 /* I2C registers management functions *****************************************/
bogdanm 82:6473597d706e 457 uint32_t I2C_ReadRegister(I2C_TypeDef* I2Cx, uint8_t I2C_Register);
bogdanm 82:6473597d706e 458
bogdanm 82:6473597d706e 459 /* Data transfers management functions ****************************************/
bogdanm 82:6473597d706e 460 void I2C_SendData(I2C_TypeDef* I2Cx, uint8_t Data);
bogdanm 82:6473597d706e 461 uint8_t I2C_ReceiveData(I2C_TypeDef* I2Cx);
bogdanm 82:6473597d706e 462
bogdanm 82:6473597d706e 463 /* DMA transfers management functions *****************************************/
bogdanm 82:6473597d706e 464 void I2C_DMACmd(I2C_TypeDef* I2Cx, uint32_t I2C_DMAReq, FunctionalState NewState);
bogdanm 82:6473597d706e 465
bogdanm 82:6473597d706e 466 /* Interrupts and flags management functions **********************************/
bogdanm 82:6473597d706e 467 FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG);
bogdanm 82:6473597d706e 468 void I2C_ClearFlag(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG);
bogdanm 82:6473597d706e 469 ITStatus I2C_GetITStatus(I2C_TypeDef* I2Cx, uint32_t I2C_IT);
bogdanm 82:6473597d706e 470 void I2C_ClearITPendingBit(I2C_TypeDef* I2Cx, uint32_t I2C_IT);
bogdanm 82:6473597d706e 471
bogdanm 82:6473597d706e 472
bogdanm 82:6473597d706e 473 #ifdef __cplusplus
bogdanm 82:6473597d706e 474 }
bogdanm 82:6473597d706e 475 #endif
bogdanm 82:6473597d706e 476
bogdanm 82:6473597d706e 477 #endif /*__STM32F30x_I2C_H */
bogdanm 82:6473597d706e 478
bogdanm 82:6473597d706e 479 /**
bogdanm 82:6473597d706e 480 * @}
bogdanm 82:6473597d706e 481 */
bogdanm 82:6473597d706e 482
bogdanm 82:6473597d706e 483 /**
bogdanm 82:6473597d706e 484 * @}
bogdanm 82:6473597d706e 485 */
bogdanm 82:6473597d706e 486
bogdanm 82:6473597d706e 487 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/