mbed library with additional peripherals for ST F401 board

Fork of mbed-src by mbed official

This mbed LIB has additional peripherals for ST F401 board

  • UART2 : PA_3 rx, PA_2 tx
  • UART3 : PC_7 rx, PC_6 tx
  • I2C2 : PB_3 SDA, PB_10 SCL
  • I2C3 : PB_4 SDA, PA_8 SCL
Committer:
mbed_official
Date:
Wed Feb 26 09:45:12 2014 +0000
Revision:
106:ced8cbb51063
Parent:
76:aeb1df146756
Synchronized with git revision 4222735eff5868389433f0e9271976b39c8115cd

Full URL: https://github.com/mbedmicro/mbed/commit/4222735eff5868389433f0e9271976b39c8115cd/

[NUCLEO_xxx] Update STM32CubeF4 driver V1.0.0 + update license

Who changed what in which revision?

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