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