mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Wed Mar 19 10:15:22 2014 +0000
Revision:
125:23cc3068a9e4
Synchronized with git revision ace35dfba3748c7cdc102eb38ec6b9e1067c3252

Full URL: https://github.com/mbedmicro/mbed/commit/ace35dfba3748c7cdc102eb38ec6b9e1067c3252/

[NUCLEO_F302R8] Add cmsis and hal files + change F401RE clock to 84MHz

Who changed what in which revision?

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