mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_F103RB/stm32f10x_i2c.c@52:a51c77007319, 2013-12-02 (annotated)
- Committer:
- mbed_official
- Date:
- Mon Dec 02 11:30:05 2013 +0000
- Revision:
- 52:a51c77007319
- Child:
- 70:c1fbde68b492
Synchronized with git revision 49df530ae72ce97ccc773d1f2c13b38e868e6abd
Full URL: https://github.com/mbedmicro/mbed/commit/49df530ae72ce97ccc773d1f2c13b38e868e6abd/
Add STMicroelectronics NUCLEO_F103RB target
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 52:a51c77007319 | 1 | /** |
mbed_official | 52:a51c77007319 | 2 | ****************************************************************************** |
mbed_official | 52:a51c77007319 | 3 | * @file stm32f10x_i2c.c |
mbed_official | 52:a51c77007319 | 4 | * @author MCD Application Team |
mbed_official | 52:a51c77007319 | 5 | * @version V3.5.0 |
mbed_official | 52:a51c77007319 | 6 | * @date 11-March-2011 |
mbed_official | 52:a51c77007319 | 7 | * @brief This file provides all the I2C firmware functions. |
mbed_official | 52:a51c77007319 | 8 | ****************************************************************************** |
mbed_official | 52:a51c77007319 | 9 | * @attention |
mbed_official | 52:a51c77007319 | 10 | * |
mbed_official | 52:a51c77007319 | 11 | * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS |
mbed_official | 52:a51c77007319 | 12 | * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE |
mbed_official | 52:a51c77007319 | 13 | * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY |
mbed_official | 52:a51c77007319 | 14 | * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING |
mbed_official | 52:a51c77007319 | 15 | * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE |
mbed_official | 52:a51c77007319 | 16 | * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS. |
mbed_official | 52:a51c77007319 | 17 | * |
mbed_official | 52:a51c77007319 | 18 | * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2> |
mbed_official | 52:a51c77007319 | 19 | ****************************************************************************** |
mbed_official | 52:a51c77007319 | 20 | */ |
mbed_official | 52:a51c77007319 | 21 | |
mbed_official | 52:a51c77007319 | 22 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 52:a51c77007319 | 23 | #include "stm32f10x_i2c.h" |
mbed_official | 52:a51c77007319 | 24 | #include "stm32f10x_rcc.h" |
mbed_official | 52:a51c77007319 | 25 | |
mbed_official | 52:a51c77007319 | 26 | |
mbed_official | 52:a51c77007319 | 27 | /** @addtogroup STM32F10x_StdPeriph_Driver |
mbed_official | 52:a51c77007319 | 28 | * @{ |
mbed_official | 52:a51c77007319 | 29 | */ |
mbed_official | 52:a51c77007319 | 30 | |
mbed_official | 52:a51c77007319 | 31 | /** @defgroup I2C |
mbed_official | 52:a51c77007319 | 32 | * @brief I2C driver modules |
mbed_official | 52:a51c77007319 | 33 | * @{ |
mbed_official | 52:a51c77007319 | 34 | */ |
mbed_official | 52:a51c77007319 | 35 | |
mbed_official | 52:a51c77007319 | 36 | /** @defgroup I2C_Private_TypesDefinitions |
mbed_official | 52:a51c77007319 | 37 | * @{ |
mbed_official | 52:a51c77007319 | 38 | */ |
mbed_official | 52:a51c77007319 | 39 | |
mbed_official | 52:a51c77007319 | 40 | /** |
mbed_official | 52:a51c77007319 | 41 | * @} |
mbed_official | 52:a51c77007319 | 42 | */ |
mbed_official | 52:a51c77007319 | 43 | |
mbed_official | 52:a51c77007319 | 44 | /** @defgroup I2C_Private_Defines |
mbed_official | 52:a51c77007319 | 45 | * @{ |
mbed_official | 52:a51c77007319 | 46 | */ |
mbed_official | 52:a51c77007319 | 47 | |
mbed_official | 52:a51c77007319 | 48 | /* I2C SPE mask */ |
mbed_official | 52:a51c77007319 | 49 | #define CR1_PE_Set ((uint16_t)0x0001) |
mbed_official | 52:a51c77007319 | 50 | #define CR1_PE_Reset ((uint16_t)0xFFFE) |
mbed_official | 52:a51c77007319 | 51 | |
mbed_official | 52:a51c77007319 | 52 | /* I2C START mask */ |
mbed_official | 52:a51c77007319 | 53 | #define CR1_START_Set ((uint16_t)0x0100) |
mbed_official | 52:a51c77007319 | 54 | #define CR1_START_Reset ((uint16_t)0xFEFF) |
mbed_official | 52:a51c77007319 | 55 | |
mbed_official | 52:a51c77007319 | 56 | /* I2C STOP mask */ |
mbed_official | 52:a51c77007319 | 57 | #define CR1_STOP_Set ((uint16_t)0x0200) |
mbed_official | 52:a51c77007319 | 58 | #define CR1_STOP_Reset ((uint16_t)0xFDFF) |
mbed_official | 52:a51c77007319 | 59 | |
mbed_official | 52:a51c77007319 | 60 | /* I2C ACK mask */ |
mbed_official | 52:a51c77007319 | 61 | #define CR1_ACK_Set ((uint16_t)0x0400) |
mbed_official | 52:a51c77007319 | 62 | #define CR1_ACK_Reset ((uint16_t)0xFBFF) |
mbed_official | 52:a51c77007319 | 63 | |
mbed_official | 52:a51c77007319 | 64 | /* I2C ENGC mask */ |
mbed_official | 52:a51c77007319 | 65 | #define CR1_ENGC_Set ((uint16_t)0x0040) |
mbed_official | 52:a51c77007319 | 66 | #define CR1_ENGC_Reset ((uint16_t)0xFFBF) |
mbed_official | 52:a51c77007319 | 67 | |
mbed_official | 52:a51c77007319 | 68 | /* I2C SWRST mask */ |
mbed_official | 52:a51c77007319 | 69 | #define CR1_SWRST_Set ((uint16_t)0x8000) |
mbed_official | 52:a51c77007319 | 70 | #define CR1_SWRST_Reset ((uint16_t)0x7FFF) |
mbed_official | 52:a51c77007319 | 71 | |
mbed_official | 52:a51c77007319 | 72 | /* I2C PEC mask */ |
mbed_official | 52:a51c77007319 | 73 | #define CR1_PEC_Set ((uint16_t)0x1000) |
mbed_official | 52:a51c77007319 | 74 | #define CR1_PEC_Reset ((uint16_t)0xEFFF) |
mbed_official | 52:a51c77007319 | 75 | |
mbed_official | 52:a51c77007319 | 76 | /* I2C ENPEC mask */ |
mbed_official | 52:a51c77007319 | 77 | #define CR1_ENPEC_Set ((uint16_t)0x0020) |
mbed_official | 52:a51c77007319 | 78 | #define CR1_ENPEC_Reset ((uint16_t)0xFFDF) |
mbed_official | 52:a51c77007319 | 79 | |
mbed_official | 52:a51c77007319 | 80 | /* I2C ENARP mask */ |
mbed_official | 52:a51c77007319 | 81 | #define CR1_ENARP_Set ((uint16_t)0x0010) |
mbed_official | 52:a51c77007319 | 82 | #define CR1_ENARP_Reset ((uint16_t)0xFFEF) |
mbed_official | 52:a51c77007319 | 83 | |
mbed_official | 52:a51c77007319 | 84 | /* I2C NOSTRETCH mask */ |
mbed_official | 52:a51c77007319 | 85 | #define CR1_NOSTRETCH_Set ((uint16_t)0x0080) |
mbed_official | 52:a51c77007319 | 86 | #define CR1_NOSTRETCH_Reset ((uint16_t)0xFF7F) |
mbed_official | 52:a51c77007319 | 87 | |
mbed_official | 52:a51c77007319 | 88 | /* I2C registers Masks */ |
mbed_official | 52:a51c77007319 | 89 | #define CR1_CLEAR_Mask ((uint16_t)0xFBF5) |
mbed_official | 52:a51c77007319 | 90 | |
mbed_official | 52:a51c77007319 | 91 | /* I2C DMAEN mask */ |
mbed_official | 52:a51c77007319 | 92 | #define CR2_DMAEN_Set ((uint16_t)0x0800) |
mbed_official | 52:a51c77007319 | 93 | #define CR2_DMAEN_Reset ((uint16_t)0xF7FF) |
mbed_official | 52:a51c77007319 | 94 | |
mbed_official | 52:a51c77007319 | 95 | /* I2C LAST mask */ |
mbed_official | 52:a51c77007319 | 96 | #define CR2_LAST_Set ((uint16_t)0x1000) |
mbed_official | 52:a51c77007319 | 97 | #define CR2_LAST_Reset ((uint16_t)0xEFFF) |
mbed_official | 52:a51c77007319 | 98 | |
mbed_official | 52:a51c77007319 | 99 | /* I2C FREQ mask */ |
mbed_official | 52:a51c77007319 | 100 | #define CR2_FREQ_Reset ((uint16_t)0xFFC0) |
mbed_official | 52:a51c77007319 | 101 | |
mbed_official | 52:a51c77007319 | 102 | /* I2C ADD0 mask */ |
mbed_official | 52:a51c77007319 | 103 | #define OAR1_ADD0_Set ((uint16_t)0x0001) |
mbed_official | 52:a51c77007319 | 104 | #define OAR1_ADD0_Reset ((uint16_t)0xFFFE) |
mbed_official | 52:a51c77007319 | 105 | |
mbed_official | 52:a51c77007319 | 106 | /* I2C ENDUAL mask */ |
mbed_official | 52:a51c77007319 | 107 | #define OAR2_ENDUAL_Set ((uint16_t)0x0001) |
mbed_official | 52:a51c77007319 | 108 | #define OAR2_ENDUAL_Reset ((uint16_t)0xFFFE) |
mbed_official | 52:a51c77007319 | 109 | |
mbed_official | 52:a51c77007319 | 110 | /* I2C ADD2 mask */ |
mbed_official | 52:a51c77007319 | 111 | #define OAR2_ADD2_Reset ((uint16_t)0xFF01) |
mbed_official | 52:a51c77007319 | 112 | |
mbed_official | 52:a51c77007319 | 113 | /* I2C F/S mask */ |
mbed_official | 52:a51c77007319 | 114 | #define CCR_FS_Set ((uint16_t)0x8000) |
mbed_official | 52:a51c77007319 | 115 | |
mbed_official | 52:a51c77007319 | 116 | /* I2C CCR mask */ |
mbed_official | 52:a51c77007319 | 117 | #define CCR_CCR_Set ((uint16_t)0x0FFF) |
mbed_official | 52:a51c77007319 | 118 | |
mbed_official | 52:a51c77007319 | 119 | /* I2C FLAG mask */ |
mbed_official | 52:a51c77007319 | 120 | #define FLAG_Mask ((uint32_t)0x00FFFFFF) |
mbed_official | 52:a51c77007319 | 121 | |
mbed_official | 52:a51c77007319 | 122 | /* I2C Interrupt Enable mask */ |
mbed_official | 52:a51c77007319 | 123 | #define ITEN_Mask ((uint32_t)0x07000000) |
mbed_official | 52:a51c77007319 | 124 | |
mbed_official | 52:a51c77007319 | 125 | /** |
mbed_official | 52:a51c77007319 | 126 | * @} |
mbed_official | 52:a51c77007319 | 127 | */ |
mbed_official | 52:a51c77007319 | 128 | |
mbed_official | 52:a51c77007319 | 129 | /** @defgroup I2C_Private_Macros |
mbed_official | 52:a51c77007319 | 130 | * @{ |
mbed_official | 52:a51c77007319 | 131 | */ |
mbed_official | 52:a51c77007319 | 132 | |
mbed_official | 52:a51c77007319 | 133 | /** |
mbed_official | 52:a51c77007319 | 134 | * @} |
mbed_official | 52:a51c77007319 | 135 | */ |
mbed_official | 52:a51c77007319 | 136 | |
mbed_official | 52:a51c77007319 | 137 | /** @defgroup I2C_Private_Variables |
mbed_official | 52:a51c77007319 | 138 | * @{ |
mbed_official | 52:a51c77007319 | 139 | */ |
mbed_official | 52:a51c77007319 | 140 | |
mbed_official | 52:a51c77007319 | 141 | /** |
mbed_official | 52:a51c77007319 | 142 | * @} |
mbed_official | 52:a51c77007319 | 143 | */ |
mbed_official | 52:a51c77007319 | 144 | |
mbed_official | 52:a51c77007319 | 145 | /** @defgroup I2C_Private_FunctionPrototypes |
mbed_official | 52:a51c77007319 | 146 | * @{ |
mbed_official | 52:a51c77007319 | 147 | */ |
mbed_official | 52:a51c77007319 | 148 | |
mbed_official | 52:a51c77007319 | 149 | /** |
mbed_official | 52:a51c77007319 | 150 | * @} |
mbed_official | 52:a51c77007319 | 151 | */ |
mbed_official | 52:a51c77007319 | 152 | |
mbed_official | 52:a51c77007319 | 153 | /** @defgroup I2C_Private_Functions |
mbed_official | 52:a51c77007319 | 154 | * @{ |
mbed_official | 52:a51c77007319 | 155 | */ |
mbed_official | 52:a51c77007319 | 156 | |
mbed_official | 52:a51c77007319 | 157 | /** |
mbed_official | 52:a51c77007319 | 158 | * @brief Deinitializes the I2Cx peripheral registers to their default reset values. |
mbed_official | 52:a51c77007319 | 159 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 160 | * @retval None |
mbed_official | 52:a51c77007319 | 161 | */ |
mbed_official | 52:a51c77007319 | 162 | void I2C_DeInit(I2C_TypeDef* I2Cx) |
mbed_official | 52:a51c77007319 | 163 | { |
mbed_official | 52:a51c77007319 | 164 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 165 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 166 | |
mbed_official | 52:a51c77007319 | 167 | if (I2Cx == I2C1) |
mbed_official | 52:a51c77007319 | 168 | { |
mbed_official | 52:a51c77007319 | 169 | /* Enable I2C1 reset state */ |
mbed_official | 52:a51c77007319 | 170 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE); |
mbed_official | 52:a51c77007319 | 171 | /* Release I2C1 from reset state */ |
mbed_official | 52:a51c77007319 | 172 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE); |
mbed_official | 52:a51c77007319 | 173 | } |
mbed_official | 52:a51c77007319 | 174 | else |
mbed_official | 52:a51c77007319 | 175 | { |
mbed_official | 52:a51c77007319 | 176 | /* Enable I2C2 reset state */ |
mbed_official | 52:a51c77007319 | 177 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, ENABLE); |
mbed_official | 52:a51c77007319 | 178 | /* Release I2C2 from reset state */ |
mbed_official | 52:a51c77007319 | 179 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, DISABLE); |
mbed_official | 52:a51c77007319 | 180 | } |
mbed_official | 52:a51c77007319 | 181 | } |
mbed_official | 52:a51c77007319 | 182 | |
mbed_official | 52:a51c77007319 | 183 | /** |
mbed_official | 52:a51c77007319 | 184 | * @brief Initializes the I2Cx peripheral according to the specified |
mbed_official | 52:a51c77007319 | 185 | * parameters in the I2C_InitStruct. |
mbed_official | 52:a51c77007319 | 186 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 187 | * @param I2C_InitStruct: pointer to a I2C_InitTypeDef structure that |
mbed_official | 52:a51c77007319 | 188 | * contains the configuration information for the specified I2C peripheral. |
mbed_official | 52:a51c77007319 | 189 | * @retval None |
mbed_official | 52:a51c77007319 | 190 | */ |
mbed_official | 52:a51c77007319 | 191 | void I2C_Init(I2C_TypeDef* I2Cx, I2C_InitTypeDef* I2C_InitStruct) |
mbed_official | 52:a51c77007319 | 192 | { |
mbed_official | 52:a51c77007319 | 193 | uint16_t tmpreg = 0, freqrange = 0; |
mbed_official | 52:a51c77007319 | 194 | uint16_t result = 0x04; |
mbed_official | 52:a51c77007319 | 195 | uint32_t pclk1 = 8000000; |
mbed_official | 52:a51c77007319 | 196 | RCC_ClocksTypeDef rcc_clocks; |
mbed_official | 52:a51c77007319 | 197 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 198 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 199 | assert_param(IS_I2C_CLOCK_SPEED(I2C_InitStruct->I2C_ClockSpeed)); |
mbed_official | 52:a51c77007319 | 200 | assert_param(IS_I2C_MODE(I2C_InitStruct->I2C_Mode)); |
mbed_official | 52:a51c77007319 | 201 | assert_param(IS_I2C_DUTY_CYCLE(I2C_InitStruct->I2C_DutyCycle)); |
mbed_official | 52:a51c77007319 | 202 | assert_param(IS_I2C_OWN_ADDRESS1(I2C_InitStruct->I2C_OwnAddress1)); |
mbed_official | 52:a51c77007319 | 203 | assert_param(IS_I2C_ACK_STATE(I2C_InitStruct->I2C_Ack)); |
mbed_official | 52:a51c77007319 | 204 | assert_param(IS_I2C_ACKNOWLEDGE_ADDRESS(I2C_InitStruct->I2C_AcknowledgedAddress)); |
mbed_official | 52:a51c77007319 | 205 | |
mbed_official | 52:a51c77007319 | 206 | /*---------------------------- I2Cx CR2 Configuration ------------------------*/ |
mbed_official | 52:a51c77007319 | 207 | /* Get the I2Cx CR2 value */ |
mbed_official | 52:a51c77007319 | 208 | tmpreg = I2Cx->CR2; |
mbed_official | 52:a51c77007319 | 209 | /* Clear frequency FREQ[5:0] bits */ |
mbed_official | 52:a51c77007319 | 210 | tmpreg &= CR2_FREQ_Reset; |
mbed_official | 52:a51c77007319 | 211 | /* Get pclk1 frequency value */ |
mbed_official | 52:a51c77007319 | 212 | RCC_GetClocksFreq(&rcc_clocks); |
mbed_official | 52:a51c77007319 | 213 | pclk1 = rcc_clocks.PCLK1_Frequency; |
mbed_official | 52:a51c77007319 | 214 | /* Set frequency bits depending on pclk1 value */ |
mbed_official | 52:a51c77007319 | 215 | freqrange = (uint16_t)(pclk1 / 1000000); |
mbed_official | 52:a51c77007319 | 216 | tmpreg |= freqrange; |
mbed_official | 52:a51c77007319 | 217 | /* Write to I2Cx CR2 */ |
mbed_official | 52:a51c77007319 | 218 | I2Cx->CR2 = tmpreg; |
mbed_official | 52:a51c77007319 | 219 | |
mbed_official | 52:a51c77007319 | 220 | /*---------------------------- I2Cx CCR Configuration ------------------------*/ |
mbed_official | 52:a51c77007319 | 221 | /* Disable the selected I2C peripheral to configure TRISE */ |
mbed_official | 52:a51c77007319 | 222 | I2Cx->CR1 &= CR1_PE_Reset; |
mbed_official | 52:a51c77007319 | 223 | /* Reset tmpreg value */ |
mbed_official | 52:a51c77007319 | 224 | /* Clear F/S, DUTY and CCR[11:0] bits */ |
mbed_official | 52:a51c77007319 | 225 | tmpreg = 0; |
mbed_official | 52:a51c77007319 | 226 | |
mbed_official | 52:a51c77007319 | 227 | /* Configure speed in standard mode */ |
mbed_official | 52:a51c77007319 | 228 | if (I2C_InitStruct->I2C_ClockSpeed <= 100000) |
mbed_official | 52:a51c77007319 | 229 | { |
mbed_official | 52:a51c77007319 | 230 | /* Standard mode speed calculate */ |
mbed_official | 52:a51c77007319 | 231 | result = (uint16_t)(pclk1 / (I2C_InitStruct->I2C_ClockSpeed << 1)); |
mbed_official | 52:a51c77007319 | 232 | /* Test if CCR value is under 0x4*/ |
mbed_official | 52:a51c77007319 | 233 | if (result < 0x04) |
mbed_official | 52:a51c77007319 | 234 | { |
mbed_official | 52:a51c77007319 | 235 | /* Set minimum allowed value */ |
mbed_official | 52:a51c77007319 | 236 | result = 0x04; |
mbed_official | 52:a51c77007319 | 237 | } |
mbed_official | 52:a51c77007319 | 238 | /* Set speed value for standard mode */ |
mbed_official | 52:a51c77007319 | 239 | tmpreg |= result; |
mbed_official | 52:a51c77007319 | 240 | /* Set Maximum Rise Time for standard mode */ |
mbed_official | 52:a51c77007319 | 241 | I2Cx->TRISE = freqrange + 1; |
mbed_official | 52:a51c77007319 | 242 | } |
mbed_official | 52:a51c77007319 | 243 | /* Configure speed in fast mode */ |
mbed_official | 52:a51c77007319 | 244 | else /*(I2C_InitStruct->I2C_ClockSpeed <= 400000)*/ |
mbed_official | 52:a51c77007319 | 245 | { |
mbed_official | 52:a51c77007319 | 246 | if (I2C_InitStruct->I2C_DutyCycle == I2C_DutyCycle_2) |
mbed_official | 52:a51c77007319 | 247 | { |
mbed_official | 52:a51c77007319 | 248 | /* Fast mode speed calculate: Tlow/Thigh = 2 */ |
mbed_official | 52:a51c77007319 | 249 | result = (uint16_t)(pclk1 / (I2C_InitStruct->I2C_ClockSpeed * 3)); |
mbed_official | 52:a51c77007319 | 250 | } |
mbed_official | 52:a51c77007319 | 251 | else /*I2C_InitStruct->I2C_DutyCycle == I2C_DutyCycle_16_9*/ |
mbed_official | 52:a51c77007319 | 252 | { |
mbed_official | 52:a51c77007319 | 253 | /* Fast mode speed calculate: Tlow/Thigh = 16/9 */ |
mbed_official | 52:a51c77007319 | 254 | result = (uint16_t)(pclk1 / (I2C_InitStruct->I2C_ClockSpeed * 25)); |
mbed_official | 52:a51c77007319 | 255 | /* Set DUTY bit */ |
mbed_official | 52:a51c77007319 | 256 | result |= I2C_DutyCycle_16_9; |
mbed_official | 52:a51c77007319 | 257 | } |
mbed_official | 52:a51c77007319 | 258 | |
mbed_official | 52:a51c77007319 | 259 | /* Test if CCR value is under 0x1*/ |
mbed_official | 52:a51c77007319 | 260 | if ((result & CCR_CCR_Set) == 0) |
mbed_official | 52:a51c77007319 | 261 | { |
mbed_official | 52:a51c77007319 | 262 | /* Set minimum allowed value */ |
mbed_official | 52:a51c77007319 | 263 | result |= (uint16_t)0x0001; |
mbed_official | 52:a51c77007319 | 264 | } |
mbed_official | 52:a51c77007319 | 265 | /* Set speed value and set F/S bit for fast mode */ |
mbed_official | 52:a51c77007319 | 266 | tmpreg |= (uint16_t)(result | CCR_FS_Set); |
mbed_official | 52:a51c77007319 | 267 | /* Set Maximum Rise Time for fast mode */ |
mbed_official | 52:a51c77007319 | 268 | I2Cx->TRISE = (uint16_t)(((freqrange * (uint16_t)300) / (uint16_t)1000) + (uint16_t)1); |
mbed_official | 52:a51c77007319 | 269 | } |
mbed_official | 52:a51c77007319 | 270 | |
mbed_official | 52:a51c77007319 | 271 | /* Write to I2Cx CCR */ |
mbed_official | 52:a51c77007319 | 272 | I2Cx->CCR = tmpreg; |
mbed_official | 52:a51c77007319 | 273 | /* Enable the selected I2C peripheral */ |
mbed_official | 52:a51c77007319 | 274 | I2Cx->CR1 |= CR1_PE_Set; |
mbed_official | 52:a51c77007319 | 275 | |
mbed_official | 52:a51c77007319 | 276 | /*---------------------------- I2Cx CR1 Configuration ------------------------*/ |
mbed_official | 52:a51c77007319 | 277 | /* Get the I2Cx CR1 value */ |
mbed_official | 52:a51c77007319 | 278 | tmpreg = I2Cx->CR1; |
mbed_official | 52:a51c77007319 | 279 | /* Clear ACK, SMBTYPE and SMBUS bits */ |
mbed_official | 52:a51c77007319 | 280 | tmpreg &= CR1_CLEAR_Mask; |
mbed_official | 52:a51c77007319 | 281 | /* Configure I2Cx: mode and acknowledgement */ |
mbed_official | 52:a51c77007319 | 282 | /* Set SMBTYPE and SMBUS bits according to I2C_Mode value */ |
mbed_official | 52:a51c77007319 | 283 | /* Set ACK bit according to I2C_Ack value */ |
mbed_official | 52:a51c77007319 | 284 | tmpreg |= (uint16_t)((uint32_t)I2C_InitStruct->I2C_Mode | I2C_InitStruct->I2C_Ack); |
mbed_official | 52:a51c77007319 | 285 | /* Write to I2Cx CR1 */ |
mbed_official | 52:a51c77007319 | 286 | I2Cx->CR1 = tmpreg; |
mbed_official | 52:a51c77007319 | 287 | |
mbed_official | 52:a51c77007319 | 288 | /*---------------------------- I2Cx OAR1 Configuration -----------------------*/ |
mbed_official | 52:a51c77007319 | 289 | /* Set I2Cx Own Address1 and acknowledged address */ |
mbed_official | 52:a51c77007319 | 290 | I2Cx->OAR1 = (I2C_InitStruct->I2C_AcknowledgedAddress | I2C_InitStruct->I2C_OwnAddress1); |
mbed_official | 52:a51c77007319 | 291 | } |
mbed_official | 52:a51c77007319 | 292 | |
mbed_official | 52:a51c77007319 | 293 | /** |
mbed_official | 52:a51c77007319 | 294 | * @brief Fills each I2C_InitStruct member with its default value. |
mbed_official | 52:a51c77007319 | 295 | * @param I2C_InitStruct: pointer to an I2C_InitTypeDef structure which will be initialized. |
mbed_official | 52:a51c77007319 | 296 | * @retval None |
mbed_official | 52:a51c77007319 | 297 | */ |
mbed_official | 52:a51c77007319 | 298 | void I2C_StructInit(I2C_InitTypeDef* I2C_InitStruct) |
mbed_official | 52:a51c77007319 | 299 | { |
mbed_official | 52:a51c77007319 | 300 | /*---------------- Reset I2C init structure parameters values ----------------*/ |
mbed_official | 52:a51c77007319 | 301 | /* initialize the I2C_ClockSpeed member */ |
mbed_official | 52:a51c77007319 | 302 | I2C_InitStruct->I2C_ClockSpeed = 5000; |
mbed_official | 52:a51c77007319 | 303 | /* Initialize the I2C_Mode member */ |
mbed_official | 52:a51c77007319 | 304 | I2C_InitStruct->I2C_Mode = I2C_Mode_I2C; |
mbed_official | 52:a51c77007319 | 305 | /* Initialize the I2C_DutyCycle member */ |
mbed_official | 52:a51c77007319 | 306 | I2C_InitStruct->I2C_DutyCycle = I2C_DutyCycle_2; |
mbed_official | 52:a51c77007319 | 307 | /* Initialize the I2C_OwnAddress1 member */ |
mbed_official | 52:a51c77007319 | 308 | I2C_InitStruct->I2C_OwnAddress1 = 0; |
mbed_official | 52:a51c77007319 | 309 | /* Initialize the I2C_Ack member */ |
mbed_official | 52:a51c77007319 | 310 | I2C_InitStruct->I2C_Ack = I2C_Ack_Disable; |
mbed_official | 52:a51c77007319 | 311 | /* Initialize the I2C_AcknowledgedAddress member */ |
mbed_official | 52:a51c77007319 | 312 | I2C_InitStruct->I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; |
mbed_official | 52:a51c77007319 | 313 | } |
mbed_official | 52:a51c77007319 | 314 | |
mbed_official | 52:a51c77007319 | 315 | /** |
mbed_official | 52:a51c77007319 | 316 | * @brief Enables or disables the specified I2C peripheral. |
mbed_official | 52:a51c77007319 | 317 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 318 | * @param NewState: new state of the I2Cx peripheral. |
mbed_official | 52:a51c77007319 | 319 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 52:a51c77007319 | 320 | * @retval None |
mbed_official | 52:a51c77007319 | 321 | */ |
mbed_official | 52:a51c77007319 | 322 | void I2C_Cmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 52:a51c77007319 | 323 | { |
mbed_official | 52:a51c77007319 | 324 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 325 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 326 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 52:a51c77007319 | 327 | if (NewState != DISABLE) |
mbed_official | 52:a51c77007319 | 328 | { |
mbed_official | 52:a51c77007319 | 329 | /* Enable the selected I2C peripheral */ |
mbed_official | 52:a51c77007319 | 330 | I2Cx->CR1 |= CR1_PE_Set; |
mbed_official | 52:a51c77007319 | 331 | } |
mbed_official | 52:a51c77007319 | 332 | else |
mbed_official | 52:a51c77007319 | 333 | { |
mbed_official | 52:a51c77007319 | 334 | /* Disable the selected I2C peripheral */ |
mbed_official | 52:a51c77007319 | 335 | I2Cx->CR1 &= CR1_PE_Reset; |
mbed_official | 52:a51c77007319 | 336 | } |
mbed_official | 52:a51c77007319 | 337 | } |
mbed_official | 52:a51c77007319 | 338 | |
mbed_official | 52:a51c77007319 | 339 | /** |
mbed_official | 52:a51c77007319 | 340 | * @brief Enables or disables the specified I2C DMA requests. |
mbed_official | 52:a51c77007319 | 341 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 342 | * @param NewState: new state of the I2C DMA transfer. |
mbed_official | 52:a51c77007319 | 343 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 52:a51c77007319 | 344 | * @retval None |
mbed_official | 52:a51c77007319 | 345 | */ |
mbed_official | 52:a51c77007319 | 346 | void I2C_DMACmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 52:a51c77007319 | 347 | { |
mbed_official | 52:a51c77007319 | 348 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 349 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 350 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 52:a51c77007319 | 351 | if (NewState != DISABLE) |
mbed_official | 52:a51c77007319 | 352 | { |
mbed_official | 52:a51c77007319 | 353 | /* Enable the selected I2C DMA requests */ |
mbed_official | 52:a51c77007319 | 354 | I2Cx->CR2 |= CR2_DMAEN_Set; |
mbed_official | 52:a51c77007319 | 355 | } |
mbed_official | 52:a51c77007319 | 356 | else |
mbed_official | 52:a51c77007319 | 357 | { |
mbed_official | 52:a51c77007319 | 358 | /* Disable the selected I2C DMA requests */ |
mbed_official | 52:a51c77007319 | 359 | I2Cx->CR2 &= CR2_DMAEN_Reset; |
mbed_official | 52:a51c77007319 | 360 | } |
mbed_official | 52:a51c77007319 | 361 | } |
mbed_official | 52:a51c77007319 | 362 | |
mbed_official | 52:a51c77007319 | 363 | /** |
mbed_official | 52:a51c77007319 | 364 | * @brief Specifies if the next DMA transfer will be the last one. |
mbed_official | 52:a51c77007319 | 365 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 366 | * @param NewState: new state of the I2C DMA last transfer. |
mbed_official | 52:a51c77007319 | 367 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 52:a51c77007319 | 368 | * @retval None |
mbed_official | 52:a51c77007319 | 369 | */ |
mbed_official | 52:a51c77007319 | 370 | void I2C_DMALastTransferCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 52:a51c77007319 | 371 | { |
mbed_official | 52:a51c77007319 | 372 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 373 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 374 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 52:a51c77007319 | 375 | if (NewState != DISABLE) |
mbed_official | 52:a51c77007319 | 376 | { |
mbed_official | 52:a51c77007319 | 377 | /* Next DMA transfer is the last transfer */ |
mbed_official | 52:a51c77007319 | 378 | I2Cx->CR2 |= CR2_LAST_Set; |
mbed_official | 52:a51c77007319 | 379 | } |
mbed_official | 52:a51c77007319 | 380 | else |
mbed_official | 52:a51c77007319 | 381 | { |
mbed_official | 52:a51c77007319 | 382 | /* Next DMA transfer is not the last transfer */ |
mbed_official | 52:a51c77007319 | 383 | I2Cx->CR2 &= CR2_LAST_Reset; |
mbed_official | 52:a51c77007319 | 384 | } |
mbed_official | 52:a51c77007319 | 385 | } |
mbed_official | 52:a51c77007319 | 386 | |
mbed_official | 52:a51c77007319 | 387 | /** |
mbed_official | 52:a51c77007319 | 388 | * @brief Generates I2Cx communication START condition. |
mbed_official | 52:a51c77007319 | 389 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 390 | * @param NewState: new state of the I2C START condition generation. |
mbed_official | 52:a51c77007319 | 391 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 52:a51c77007319 | 392 | * @retval None. |
mbed_official | 52:a51c77007319 | 393 | */ |
mbed_official | 52:a51c77007319 | 394 | void I2C_GenerateSTART(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 52:a51c77007319 | 395 | { |
mbed_official | 52:a51c77007319 | 396 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 397 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 398 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 52:a51c77007319 | 399 | if (NewState != DISABLE) |
mbed_official | 52:a51c77007319 | 400 | { |
mbed_official | 52:a51c77007319 | 401 | /* Generate a START condition */ |
mbed_official | 52:a51c77007319 | 402 | I2Cx->CR1 |= CR1_START_Set; |
mbed_official | 52:a51c77007319 | 403 | } |
mbed_official | 52:a51c77007319 | 404 | else |
mbed_official | 52:a51c77007319 | 405 | { |
mbed_official | 52:a51c77007319 | 406 | /* Disable the START condition generation */ |
mbed_official | 52:a51c77007319 | 407 | I2Cx->CR1 &= CR1_START_Reset; |
mbed_official | 52:a51c77007319 | 408 | } |
mbed_official | 52:a51c77007319 | 409 | } |
mbed_official | 52:a51c77007319 | 410 | |
mbed_official | 52:a51c77007319 | 411 | /** |
mbed_official | 52:a51c77007319 | 412 | * @brief Generates I2Cx communication STOP condition. |
mbed_official | 52:a51c77007319 | 413 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 414 | * @param NewState: new state of the I2C STOP condition generation. |
mbed_official | 52:a51c77007319 | 415 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 52:a51c77007319 | 416 | * @retval None. |
mbed_official | 52:a51c77007319 | 417 | */ |
mbed_official | 52:a51c77007319 | 418 | void I2C_GenerateSTOP(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 52:a51c77007319 | 419 | { |
mbed_official | 52:a51c77007319 | 420 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 421 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 422 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 52:a51c77007319 | 423 | if (NewState != DISABLE) |
mbed_official | 52:a51c77007319 | 424 | { |
mbed_official | 52:a51c77007319 | 425 | /* Generate a STOP condition */ |
mbed_official | 52:a51c77007319 | 426 | I2Cx->CR1 |= CR1_STOP_Set; |
mbed_official | 52:a51c77007319 | 427 | } |
mbed_official | 52:a51c77007319 | 428 | else |
mbed_official | 52:a51c77007319 | 429 | { |
mbed_official | 52:a51c77007319 | 430 | /* Disable the STOP condition generation */ |
mbed_official | 52:a51c77007319 | 431 | I2Cx->CR1 &= CR1_STOP_Reset; |
mbed_official | 52:a51c77007319 | 432 | } |
mbed_official | 52:a51c77007319 | 433 | } |
mbed_official | 52:a51c77007319 | 434 | |
mbed_official | 52:a51c77007319 | 435 | /** |
mbed_official | 52:a51c77007319 | 436 | * @brief Enables or disables the specified I2C acknowledge feature. |
mbed_official | 52:a51c77007319 | 437 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 438 | * @param NewState: new state of the I2C Acknowledgement. |
mbed_official | 52:a51c77007319 | 439 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 52:a51c77007319 | 440 | * @retval None. |
mbed_official | 52:a51c77007319 | 441 | */ |
mbed_official | 52:a51c77007319 | 442 | void I2C_AcknowledgeConfig(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 52:a51c77007319 | 443 | { |
mbed_official | 52:a51c77007319 | 444 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 445 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 446 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 52:a51c77007319 | 447 | if (NewState != DISABLE) |
mbed_official | 52:a51c77007319 | 448 | { |
mbed_official | 52:a51c77007319 | 449 | /* Enable the acknowledgement */ |
mbed_official | 52:a51c77007319 | 450 | I2Cx->CR1 |= CR1_ACK_Set; |
mbed_official | 52:a51c77007319 | 451 | } |
mbed_official | 52:a51c77007319 | 452 | else |
mbed_official | 52:a51c77007319 | 453 | { |
mbed_official | 52:a51c77007319 | 454 | /* Disable the acknowledgement */ |
mbed_official | 52:a51c77007319 | 455 | I2Cx->CR1 &= CR1_ACK_Reset; |
mbed_official | 52:a51c77007319 | 456 | } |
mbed_official | 52:a51c77007319 | 457 | } |
mbed_official | 52:a51c77007319 | 458 | |
mbed_official | 52:a51c77007319 | 459 | /** |
mbed_official | 52:a51c77007319 | 460 | * @brief Configures the specified I2C own address2. |
mbed_official | 52:a51c77007319 | 461 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 462 | * @param Address: specifies the 7bit I2C own address2. |
mbed_official | 52:a51c77007319 | 463 | * @retval None. |
mbed_official | 52:a51c77007319 | 464 | */ |
mbed_official | 52:a51c77007319 | 465 | void I2C_OwnAddress2Config(I2C_TypeDef* I2Cx, uint8_t Address) |
mbed_official | 52:a51c77007319 | 466 | { |
mbed_official | 52:a51c77007319 | 467 | uint16_t tmpreg = 0; |
mbed_official | 52:a51c77007319 | 468 | |
mbed_official | 52:a51c77007319 | 469 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 470 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 471 | |
mbed_official | 52:a51c77007319 | 472 | /* Get the old register value */ |
mbed_official | 52:a51c77007319 | 473 | tmpreg = I2Cx->OAR2; |
mbed_official | 52:a51c77007319 | 474 | |
mbed_official | 52:a51c77007319 | 475 | /* Reset I2Cx Own address2 bit [7:1] */ |
mbed_official | 52:a51c77007319 | 476 | tmpreg &= OAR2_ADD2_Reset; |
mbed_official | 52:a51c77007319 | 477 | |
mbed_official | 52:a51c77007319 | 478 | /* Set I2Cx Own address2 */ |
mbed_official | 52:a51c77007319 | 479 | tmpreg |= (uint16_t)((uint16_t)Address & (uint16_t)0x00FE); |
mbed_official | 52:a51c77007319 | 480 | |
mbed_official | 52:a51c77007319 | 481 | /* Store the new register value */ |
mbed_official | 52:a51c77007319 | 482 | I2Cx->OAR2 = tmpreg; |
mbed_official | 52:a51c77007319 | 483 | } |
mbed_official | 52:a51c77007319 | 484 | |
mbed_official | 52:a51c77007319 | 485 | /** |
mbed_official | 52:a51c77007319 | 486 | * @brief Enables or disables the specified I2C dual addressing mode. |
mbed_official | 52:a51c77007319 | 487 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 488 | * @param NewState: new state of the I2C dual addressing mode. |
mbed_official | 52:a51c77007319 | 489 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 52:a51c77007319 | 490 | * @retval None |
mbed_official | 52:a51c77007319 | 491 | */ |
mbed_official | 52:a51c77007319 | 492 | void I2C_DualAddressCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 52:a51c77007319 | 493 | { |
mbed_official | 52:a51c77007319 | 494 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 495 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 496 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 52:a51c77007319 | 497 | if (NewState != DISABLE) |
mbed_official | 52:a51c77007319 | 498 | { |
mbed_official | 52:a51c77007319 | 499 | /* Enable dual addressing mode */ |
mbed_official | 52:a51c77007319 | 500 | I2Cx->OAR2 |= OAR2_ENDUAL_Set; |
mbed_official | 52:a51c77007319 | 501 | } |
mbed_official | 52:a51c77007319 | 502 | else |
mbed_official | 52:a51c77007319 | 503 | { |
mbed_official | 52:a51c77007319 | 504 | /* Disable dual addressing mode */ |
mbed_official | 52:a51c77007319 | 505 | I2Cx->OAR2 &= OAR2_ENDUAL_Reset; |
mbed_official | 52:a51c77007319 | 506 | } |
mbed_official | 52:a51c77007319 | 507 | } |
mbed_official | 52:a51c77007319 | 508 | |
mbed_official | 52:a51c77007319 | 509 | /** |
mbed_official | 52:a51c77007319 | 510 | * @brief Enables or disables the specified I2C general call feature. |
mbed_official | 52:a51c77007319 | 511 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 512 | * @param NewState: new state of the I2C General call. |
mbed_official | 52:a51c77007319 | 513 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 52:a51c77007319 | 514 | * @retval None |
mbed_official | 52:a51c77007319 | 515 | */ |
mbed_official | 52:a51c77007319 | 516 | void I2C_GeneralCallCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 52:a51c77007319 | 517 | { |
mbed_official | 52:a51c77007319 | 518 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 519 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 520 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 52:a51c77007319 | 521 | if (NewState != DISABLE) |
mbed_official | 52:a51c77007319 | 522 | { |
mbed_official | 52:a51c77007319 | 523 | /* Enable generall call */ |
mbed_official | 52:a51c77007319 | 524 | I2Cx->CR1 |= CR1_ENGC_Set; |
mbed_official | 52:a51c77007319 | 525 | } |
mbed_official | 52:a51c77007319 | 526 | else |
mbed_official | 52:a51c77007319 | 527 | { |
mbed_official | 52:a51c77007319 | 528 | /* Disable generall call */ |
mbed_official | 52:a51c77007319 | 529 | I2Cx->CR1 &= CR1_ENGC_Reset; |
mbed_official | 52:a51c77007319 | 530 | } |
mbed_official | 52:a51c77007319 | 531 | } |
mbed_official | 52:a51c77007319 | 532 | |
mbed_official | 52:a51c77007319 | 533 | /** |
mbed_official | 52:a51c77007319 | 534 | * @brief Enables or disables the specified I2C interrupts. |
mbed_official | 52:a51c77007319 | 535 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 536 | * @param I2C_IT: specifies the I2C interrupts sources to be enabled or disabled. |
mbed_official | 52:a51c77007319 | 537 | * This parameter can be any combination of the following values: |
mbed_official | 52:a51c77007319 | 538 | * @arg I2C_IT_BUF: Buffer interrupt mask |
mbed_official | 52:a51c77007319 | 539 | * @arg I2C_IT_EVT: Event interrupt mask |
mbed_official | 52:a51c77007319 | 540 | * @arg I2C_IT_ERR: Error interrupt mask |
mbed_official | 52:a51c77007319 | 541 | * @param NewState: new state of the specified I2C interrupts. |
mbed_official | 52:a51c77007319 | 542 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 52:a51c77007319 | 543 | * @retval None |
mbed_official | 52:a51c77007319 | 544 | */ |
mbed_official | 52:a51c77007319 | 545 | void I2C_ITConfig(I2C_TypeDef* I2Cx, uint16_t I2C_IT, FunctionalState NewState) |
mbed_official | 52:a51c77007319 | 546 | { |
mbed_official | 52:a51c77007319 | 547 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 548 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 549 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 52:a51c77007319 | 550 | assert_param(IS_I2C_CONFIG_IT(I2C_IT)); |
mbed_official | 52:a51c77007319 | 551 | |
mbed_official | 52:a51c77007319 | 552 | if (NewState != DISABLE) |
mbed_official | 52:a51c77007319 | 553 | { |
mbed_official | 52:a51c77007319 | 554 | /* Enable the selected I2C interrupts */ |
mbed_official | 52:a51c77007319 | 555 | I2Cx->CR2 |= I2C_IT; |
mbed_official | 52:a51c77007319 | 556 | } |
mbed_official | 52:a51c77007319 | 557 | else |
mbed_official | 52:a51c77007319 | 558 | { |
mbed_official | 52:a51c77007319 | 559 | /* Disable the selected I2C interrupts */ |
mbed_official | 52:a51c77007319 | 560 | I2Cx->CR2 &= (uint16_t)~I2C_IT; |
mbed_official | 52:a51c77007319 | 561 | } |
mbed_official | 52:a51c77007319 | 562 | } |
mbed_official | 52:a51c77007319 | 563 | |
mbed_official | 52:a51c77007319 | 564 | /** |
mbed_official | 52:a51c77007319 | 565 | * @brief Sends a data byte through the I2Cx peripheral. |
mbed_official | 52:a51c77007319 | 566 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 567 | * @param Data: Byte to be transmitted.. |
mbed_official | 52:a51c77007319 | 568 | * @retval None |
mbed_official | 52:a51c77007319 | 569 | */ |
mbed_official | 52:a51c77007319 | 570 | void I2C_SendData(I2C_TypeDef* I2Cx, uint8_t Data) |
mbed_official | 52:a51c77007319 | 571 | { |
mbed_official | 52:a51c77007319 | 572 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 573 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 574 | /* Write in the DR register the data to be sent */ |
mbed_official | 52:a51c77007319 | 575 | I2Cx->DR = Data; |
mbed_official | 52:a51c77007319 | 576 | } |
mbed_official | 52:a51c77007319 | 577 | |
mbed_official | 52:a51c77007319 | 578 | /** |
mbed_official | 52:a51c77007319 | 579 | * @brief Returns the most recent received data by the I2Cx peripheral. |
mbed_official | 52:a51c77007319 | 580 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 581 | * @retval The value of the received data. |
mbed_official | 52:a51c77007319 | 582 | */ |
mbed_official | 52:a51c77007319 | 583 | uint8_t I2C_ReceiveData(I2C_TypeDef* I2Cx) |
mbed_official | 52:a51c77007319 | 584 | { |
mbed_official | 52:a51c77007319 | 585 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 586 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 587 | /* Return the data in the DR register */ |
mbed_official | 52:a51c77007319 | 588 | return (uint8_t)I2Cx->DR; |
mbed_official | 52:a51c77007319 | 589 | } |
mbed_official | 52:a51c77007319 | 590 | |
mbed_official | 52:a51c77007319 | 591 | /** |
mbed_official | 52:a51c77007319 | 592 | * @brief Transmits the address byte to select the slave device. |
mbed_official | 52:a51c77007319 | 593 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 594 | * @param Address: specifies the slave address which will be transmitted |
mbed_official | 52:a51c77007319 | 595 | * @param I2C_Direction: specifies whether the I2C device will be a |
mbed_official | 52:a51c77007319 | 596 | * Transmitter or a Receiver. This parameter can be one of the following values |
mbed_official | 52:a51c77007319 | 597 | * @arg I2C_Direction_Transmitter: Transmitter mode |
mbed_official | 52:a51c77007319 | 598 | * @arg I2C_Direction_Receiver: Receiver mode |
mbed_official | 52:a51c77007319 | 599 | * @retval None. |
mbed_official | 52:a51c77007319 | 600 | */ |
mbed_official | 52:a51c77007319 | 601 | void I2C_Send7bitAddress(I2C_TypeDef* I2Cx, uint8_t Address, uint8_t I2C_Direction) |
mbed_official | 52:a51c77007319 | 602 | { |
mbed_official | 52:a51c77007319 | 603 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 604 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 605 | assert_param(IS_I2C_DIRECTION(I2C_Direction)); |
mbed_official | 52:a51c77007319 | 606 | /* Test on the direction to set/reset the read/write bit */ |
mbed_official | 52:a51c77007319 | 607 | if (I2C_Direction != I2C_Direction_Transmitter) |
mbed_official | 52:a51c77007319 | 608 | { |
mbed_official | 52:a51c77007319 | 609 | /* Set the address bit0 for read */ |
mbed_official | 52:a51c77007319 | 610 | Address |= OAR1_ADD0_Set; |
mbed_official | 52:a51c77007319 | 611 | } |
mbed_official | 52:a51c77007319 | 612 | else |
mbed_official | 52:a51c77007319 | 613 | { |
mbed_official | 52:a51c77007319 | 614 | /* Reset the address bit0 for write */ |
mbed_official | 52:a51c77007319 | 615 | Address &= OAR1_ADD0_Reset; |
mbed_official | 52:a51c77007319 | 616 | } |
mbed_official | 52:a51c77007319 | 617 | /* Send the address */ |
mbed_official | 52:a51c77007319 | 618 | I2Cx->DR = Address; |
mbed_official | 52:a51c77007319 | 619 | } |
mbed_official | 52:a51c77007319 | 620 | |
mbed_official | 52:a51c77007319 | 621 | /** |
mbed_official | 52:a51c77007319 | 622 | * @brief Reads the specified I2C register and returns its value. |
mbed_official | 52:a51c77007319 | 623 | * @param I2C_Register: specifies the register to read. |
mbed_official | 52:a51c77007319 | 624 | * This parameter can be one of the following values: |
mbed_official | 52:a51c77007319 | 625 | * @arg I2C_Register_CR1: CR1 register. |
mbed_official | 52:a51c77007319 | 626 | * @arg I2C_Register_CR2: CR2 register. |
mbed_official | 52:a51c77007319 | 627 | * @arg I2C_Register_OAR1: OAR1 register. |
mbed_official | 52:a51c77007319 | 628 | * @arg I2C_Register_OAR2: OAR2 register. |
mbed_official | 52:a51c77007319 | 629 | * @arg I2C_Register_DR: DR register. |
mbed_official | 52:a51c77007319 | 630 | * @arg I2C_Register_SR1: SR1 register. |
mbed_official | 52:a51c77007319 | 631 | * @arg I2C_Register_SR2: SR2 register. |
mbed_official | 52:a51c77007319 | 632 | * @arg I2C_Register_CCR: CCR register. |
mbed_official | 52:a51c77007319 | 633 | * @arg I2C_Register_TRISE: TRISE register. |
mbed_official | 52:a51c77007319 | 634 | * @retval The value of the read register. |
mbed_official | 52:a51c77007319 | 635 | */ |
mbed_official | 52:a51c77007319 | 636 | uint16_t I2C_ReadRegister(I2C_TypeDef* I2Cx, uint8_t I2C_Register) |
mbed_official | 52:a51c77007319 | 637 | { |
mbed_official | 52:a51c77007319 | 638 | __IO uint32_t tmp = 0; |
mbed_official | 52:a51c77007319 | 639 | |
mbed_official | 52:a51c77007319 | 640 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 641 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 642 | assert_param(IS_I2C_REGISTER(I2C_Register)); |
mbed_official | 52:a51c77007319 | 643 | |
mbed_official | 52:a51c77007319 | 644 | tmp = (uint32_t) I2Cx; |
mbed_official | 52:a51c77007319 | 645 | tmp += I2C_Register; |
mbed_official | 52:a51c77007319 | 646 | |
mbed_official | 52:a51c77007319 | 647 | /* Return the selected register value */ |
mbed_official | 52:a51c77007319 | 648 | return (*(__IO uint16_t *) tmp); |
mbed_official | 52:a51c77007319 | 649 | } |
mbed_official | 52:a51c77007319 | 650 | |
mbed_official | 52:a51c77007319 | 651 | /** |
mbed_official | 52:a51c77007319 | 652 | * @brief Enables or disables the specified I2C software reset. |
mbed_official | 52:a51c77007319 | 653 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 654 | * @param NewState: new state of the I2C software reset. |
mbed_official | 52:a51c77007319 | 655 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 52:a51c77007319 | 656 | * @retval None |
mbed_official | 52:a51c77007319 | 657 | */ |
mbed_official | 52:a51c77007319 | 658 | void I2C_SoftwareResetCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 52:a51c77007319 | 659 | { |
mbed_official | 52:a51c77007319 | 660 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 661 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 662 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 52:a51c77007319 | 663 | if (NewState != DISABLE) |
mbed_official | 52:a51c77007319 | 664 | { |
mbed_official | 52:a51c77007319 | 665 | /* Peripheral under reset */ |
mbed_official | 52:a51c77007319 | 666 | I2Cx->CR1 |= CR1_SWRST_Set; |
mbed_official | 52:a51c77007319 | 667 | } |
mbed_official | 52:a51c77007319 | 668 | else |
mbed_official | 52:a51c77007319 | 669 | { |
mbed_official | 52:a51c77007319 | 670 | /* Peripheral not under reset */ |
mbed_official | 52:a51c77007319 | 671 | I2Cx->CR1 &= CR1_SWRST_Reset; |
mbed_official | 52:a51c77007319 | 672 | } |
mbed_official | 52:a51c77007319 | 673 | } |
mbed_official | 52:a51c77007319 | 674 | |
mbed_official | 52:a51c77007319 | 675 | /** |
mbed_official | 52:a51c77007319 | 676 | * @brief Selects the specified I2C NACK position in master receiver mode. |
mbed_official | 52:a51c77007319 | 677 | * This function is useful in I2C Master Receiver mode when the number |
mbed_official | 52:a51c77007319 | 678 | * of data to be received is equal to 2. In this case, this function |
mbed_official | 52:a51c77007319 | 679 | * should be called (with parameter I2C_NACKPosition_Next) before data |
mbed_official | 52:a51c77007319 | 680 | * reception starts,as described in the 2-byte reception procedure |
mbed_official | 52:a51c77007319 | 681 | * recommended in Reference Manual in Section: Master receiver. |
mbed_official | 52:a51c77007319 | 682 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 683 | * @param I2C_NACKPosition: specifies the NACK position. |
mbed_official | 52:a51c77007319 | 684 | * This parameter can be one of the following values: |
mbed_official | 52:a51c77007319 | 685 | * @arg I2C_NACKPosition_Next: indicates that the next byte will be the last |
mbed_official | 52:a51c77007319 | 686 | * received byte. |
mbed_official | 52:a51c77007319 | 687 | * @arg I2C_NACKPosition_Current: indicates that current byte is the last |
mbed_official | 52:a51c77007319 | 688 | * received byte. |
mbed_official | 52:a51c77007319 | 689 | * |
mbed_official | 52:a51c77007319 | 690 | * @note This function configures the same bit (POS) as I2C_PECPositionConfig() |
mbed_official | 52:a51c77007319 | 691 | * but is intended to be used in I2C mode while I2C_PECPositionConfig() |
mbed_official | 52:a51c77007319 | 692 | * is intended to used in SMBUS mode. |
mbed_official | 52:a51c77007319 | 693 | * |
mbed_official | 52:a51c77007319 | 694 | * @retval None |
mbed_official | 52:a51c77007319 | 695 | */ |
mbed_official | 52:a51c77007319 | 696 | void I2C_NACKPositionConfig(I2C_TypeDef* I2Cx, uint16_t I2C_NACKPosition) |
mbed_official | 52:a51c77007319 | 697 | { |
mbed_official | 52:a51c77007319 | 698 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 699 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 700 | assert_param(IS_I2C_NACK_POSITION(I2C_NACKPosition)); |
mbed_official | 52:a51c77007319 | 701 | |
mbed_official | 52:a51c77007319 | 702 | /* Check the input parameter */ |
mbed_official | 52:a51c77007319 | 703 | if (I2C_NACKPosition == I2C_NACKPosition_Next) |
mbed_official | 52:a51c77007319 | 704 | { |
mbed_official | 52:a51c77007319 | 705 | /* Next byte in shift register is the last received byte */ |
mbed_official | 52:a51c77007319 | 706 | I2Cx->CR1 |= I2C_NACKPosition_Next; |
mbed_official | 52:a51c77007319 | 707 | } |
mbed_official | 52:a51c77007319 | 708 | else |
mbed_official | 52:a51c77007319 | 709 | { |
mbed_official | 52:a51c77007319 | 710 | /* Current byte in shift register is the last received byte */ |
mbed_official | 52:a51c77007319 | 711 | I2Cx->CR1 &= I2C_NACKPosition_Current; |
mbed_official | 52:a51c77007319 | 712 | } |
mbed_official | 52:a51c77007319 | 713 | } |
mbed_official | 52:a51c77007319 | 714 | |
mbed_official | 52:a51c77007319 | 715 | /** |
mbed_official | 52:a51c77007319 | 716 | * @brief Drives the SMBusAlert pin high or low for the specified I2C. |
mbed_official | 52:a51c77007319 | 717 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 718 | * @param I2C_SMBusAlert: specifies SMBAlert pin level. |
mbed_official | 52:a51c77007319 | 719 | * This parameter can be one of the following values: |
mbed_official | 52:a51c77007319 | 720 | * @arg I2C_SMBusAlert_Low: SMBAlert pin driven low |
mbed_official | 52:a51c77007319 | 721 | * @arg I2C_SMBusAlert_High: SMBAlert pin driven high |
mbed_official | 52:a51c77007319 | 722 | * @retval None |
mbed_official | 52:a51c77007319 | 723 | */ |
mbed_official | 52:a51c77007319 | 724 | void I2C_SMBusAlertConfig(I2C_TypeDef* I2Cx, uint16_t I2C_SMBusAlert) |
mbed_official | 52:a51c77007319 | 725 | { |
mbed_official | 52:a51c77007319 | 726 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 727 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 728 | assert_param(IS_I2C_SMBUS_ALERT(I2C_SMBusAlert)); |
mbed_official | 52:a51c77007319 | 729 | if (I2C_SMBusAlert == I2C_SMBusAlert_Low) |
mbed_official | 52:a51c77007319 | 730 | { |
mbed_official | 52:a51c77007319 | 731 | /* Drive the SMBusAlert pin Low */ |
mbed_official | 52:a51c77007319 | 732 | I2Cx->CR1 |= I2C_SMBusAlert_Low; |
mbed_official | 52:a51c77007319 | 733 | } |
mbed_official | 52:a51c77007319 | 734 | else |
mbed_official | 52:a51c77007319 | 735 | { |
mbed_official | 52:a51c77007319 | 736 | /* Drive the SMBusAlert pin High */ |
mbed_official | 52:a51c77007319 | 737 | I2Cx->CR1 &= I2C_SMBusAlert_High; |
mbed_official | 52:a51c77007319 | 738 | } |
mbed_official | 52:a51c77007319 | 739 | } |
mbed_official | 52:a51c77007319 | 740 | |
mbed_official | 52:a51c77007319 | 741 | /** |
mbed_official | 52:a51c77007319 | 742 | * @brief Enables or disables the specified I2C PEC transfer. |
mbed_official | 52:a51c77007319 | 743 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 744 | * @param NewState: new state of the I2C PEC transmission. |
mbed_official | 52:a51c77007319 | 745 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 52:a51c77007319 | 746 | * @retval None |
mbed_official | 52:a51c77007319 | 747 | */ |
mbed_official | 52:a51c77007319 | 748 | void I2C_TransmitPEC(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 52:a51c77007319 | 749 | { |
mbed_official | 52:a51c77007319 | 750 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 751 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 752 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 52:a51c77007319 | 753 | if (NewState != DISABLE) |
mbed_official | 52:a51c77007319 | 754 | { |
mbed_official | 52:a51c77007319 | 755 | /* Enable the selected I2C PEC transmission */ |
mbed_official | 52:a51c77007319 | 756 | I2Cx->CR1 |= CR1_PEC_Set; |
mbed_official | 52:a51c77007319 | 757 | } |
mbed_official | 52:a51c77007319 | 758 | else |
mbed_official | 52:a51c77007319 | 759 | { |
mbed_official | 52:a51c77007319 | 760 | /* Disable the selected I2C PEC transmission */ |
mbed_official | 52:a51c77007319 | 761 | I2Cx->CR1 &= CR1_PEC_Reset; |
mbed_official | 52:a51c77007319 | 762 | } |
mbed_official | 52:a51c77007319 | 763 | } |
mbed_official | 52:a51c77007319 | 764 | |
mbed_official | 52:a51c77007319 | 765 | /** |
mbed_official | 52:a51c77007319 | 766 | * @brief Selects the specified I2C PEC position. |
mbed_official | 52:a51c77007319 | 767 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 768 | * @param I2C_PECPosition: specifies the PEC position. |
mbed_official | 52:a51c77007319 | 769 | * This parameter can be one of the following values: |
mbed_official | 52:a51c77007319 | 770 | * @arg I2C_PECPosition_Next: indicates that the next byte is PEC |
mbed_official | 52:a51c77007319 | 771 | * @arg I2C_PECPosition_Current: indicates that current byte is PEC |
mbed_official | 52:a51c77007319 | 772 | * |
mbed_official | 52:a51c77007319 | 773 | * @note This function configures the same bit (POS) as I2C_NACKPositionConfig() |
mbed_official | 52:a51c77007319 | 774 | * but is intended to be used in SMBUS mode while I2C_NACKPositionConfig() |
mbed_official | 52:a51c77007319 | 775 | * is intended to used in I2C mode. |
mbed_official | 52:a51c77007319 | 776 | * |
mbed_official | 52:a51c77007319 | 777 | * @retval None |
mbed_official | 52:a51c77007319 | 778 | */ |
mbed_official | 52:a51c77007319 | 779 | void I2C_PECPositionConfig(I2C_TypeDef* I2Cx, uint16_t I2C_PECPosition) |
mbed_official | 52:a51c77007319 | 780 | { |
mbed_official | 52:a51c77007319 | 781 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 782 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 783 | assert_param(IS_I2C_PEC_POSITION(I2C_PECPosition)); |
mbed_official | 52:a51c77007319 | 784 | if (I2C_PECPosition == I2C_PECPosition_Next) |
mbed_official | 52:a51c77007319 | 785 | { |
mbed_official | 52:a51c77007319 | 786 | /* Next byte in shift register is PEC */ |
mbed_official | 52:a51c77007319 | 787 | I2Cx->CR1 |= I2C_PECPosition_Next; |
mbed_official | 52:a51c77007319 | 788 | } |
mbed_official | 52:a51c77007319 | 789 | else |
mbed_official | 52:a51c77007319 | 790 | { |
mbed_official | 52:a51c77007319 | 791 | /* Current byte in shift register is PEC */ |
mbed_official | 52:a51c77007319 | 792 | I2Cx->CR1 &= I2C_PECPosition_Current; |
mbed_official | 52:a51c77007319 | 793 | } |
mbed_official | 52:a51c77007319 | 794 | } |
mbed_official | 52:a51c77007319 | 795 | |
mbed_official | 52:a51c77007319 | 796 | /** |
mbed_official | 52:a51c77007319 | 797 | * @brief Enables or disables the PEC value calculation of the transferred bytes. |
mbed_official | 52:a51c77007319 | 798 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 799 | * @param NewState: new state of the I2Cx PEC value calculation. |
mbed_official | 52:a51c77007319 | 800 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 52:a51c77007319 | 801 | * @retval None |
mbed_official | 52:a51c77007319 | 802 | */ |
mbed_official | 52:a51c77007319 | 803 | void I2C_CalculatePEC(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 52:a51c77007319 | 804 | { |
mbed_official | 52:a51c77007319 | 805 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 806 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 807 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 52:a51c77007319 | 808 | if (NewState != DISABLE) |
mbed_official | 52:a51c77007319 | 809 | { |
mbed_official | 52:a51c77007319 | 810 | /* Enable the selected I2C PEC calculation */ |
mbed_official | 52:a51c77007319 | 811 | I2Cx->CR1 |= CR1_ENPEC_Set; |
mbed_official | 52:a51c77007319 | 812 | } |
mbed_official | 52:a51c77007319 | 813 | else |
mbed_official | 52:a51c77007319 | 814 | { |
mbed_official | 52:a51c77007319 | 815 | /* Disable the selected I2C PEC calculation */ |
mbed_official | 52:a51c77007319 | 816 | I2Cx->CR1 &= CR1_ENPEC_Reset; |
mbed_official | 52:a51c77007319 | 817 | } |
mbed_official | 52:a51c77007319 | 818 | } |
mbed_official | 52:a51c77007319 | 819 | |
mbed_official | 52:a51c77007319 | 820 | /** |
mbed_official | 52:a51c77007319 | 821 | * @brief Returns the PEC value for the specified I2C. |
mbed_official | 52:a51c77007319 | 822 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 823 | * @retval The PEC value. |
mbed_official | 52:a51c77007319 | 824 | */ |
mbed_official | 52:a51c77007319 | 825 | uint8_t I2C_GetPEC(I2C_TypeDef* I2Cx) |
mbed_official | 52:a51c77007319 | 826 | { |
mbed_official | 52:a51c77007319 | 827 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 828 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 829 | /* Return the selected I2C PEC value */ |
mbed_official | 52:a51c77007319 | 830 | return ((I2Cx->SR2) >> 8); |
mbed_official | 52:a51c77007319 | 831 | } |
mbed_official | 52:a51c77007319 | 832 | |
mbed_official | 52:a51c77007319 | 833 | /** |
mbed_official | 52:a51c77007319 | 834 | * @brief Enables or disables the specified I2C ARP. |
mbed_official | 52:a51c77007319 | 835 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 836 | * @param NewState: new state of the I2Cx ARP. |
mbed_official | 52:a51c77007319 | 837 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 52:a51c77007319 | 838 | * @retval None |
mbed_official | 52:a51c77007319 | 839 | */ |
mbed_official | 52:a51c77007319 | 840 | void I2C_ARPCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 52:a51c77007319 | 841 | { |
mbed_official | 52:a51c77007319 | 842 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 843 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 844 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 52:a51c77007319 | 845 | if (NewState != DISABLE) |
mbed_official | 52:a51c77007319 | 846 | { |
mbed_official | 52:a51c77007319 | 847 | /* Enable the selected I2C ARP */ |
mbed_official | 52:a51c77007319 | 848 | I2Cx->CR1 |= CR1_ENARP_Set; |
mbed_official | 52:a51c77007319 | 849 | } |
mbed_official | 52:a51c77007319 | 850 | else |
mbed_official | 52:a51c77007319 | 851 | { |
mbed_official | 52:a51c77007319 | 852 | /* Disable the selected I2C ARP */ |
mbed_official | 52:a51c77007319 | 853 | I2Cx->CR1 &= CR1_ENARP_Reset; |
mbed_official | 52:a51c77007319 | 854 | } |
mbed_official | 52:a51c77007319 | 855 | } |
mbed_official | 52:a51c77007319 | 856 | |
mbed_official | 52:a51c77007319 | 857 | /** |
mbed_official | 52:a51c77007319 | 858 | * @brief Enables or disables the specified I2C Clock stretching. |
mbed_official | 52:a51c77007319 | 859 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 860 | * @param NewState: new state of the I2Cx Clock stretching. |
mbed_official | 52:a51c77007319 | 861 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 52:a51c77007319 | 862 | * @retval None |
mbed_official | 52:a51c77007319 | 863 | */ |
mbed_official | 52:a51c77007319 | 864 | void I2C_StretchClockCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 52:a51c77007319 | 865 | { |
mbed_official | 52:a51c77007319 | 866 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 867 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 868 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 52:a51c77007319 | 869 | if (NewState == DISABLE) |
mbed_official | 52:a51c77007319 | 870 | { |
mbed_official | 52:a51c77007319 | 871 | /* Enable the selected I2C Clock stretching */ |
mbed_official | 52:a51c77007319 | 872 | I2Cx->CR1 |= CR1_NOSTRETCH_Set; |
mbed_official | 52:a51c77007319 | 873 | } |
mbed_official | 52:a51c77007319 | 874 | else |
mbed_official | 52:a51c77007319 | 875 | { |
mbed_official | 52:a51c77007319 | 876 | /* Disable the selected I2C Clock stretching */ |
mbed_official | 52:a51c77007319 | 877 | I2Cx->CR1 &= CR1_NOSTRETCH_Reset; |
mbed_official | 52:a51c77007319 | 878 | } |
mbed_official | 52:a51c77007319 | 879 | } |
mbed_official | 52:a51c77007319 | 880 | |
mbed_official | 52:a51c77007319 | 881 | /** |
mbed_official | 52:a51c77007319 | 882 | * @brief Selects the specified I2C fast mode duty cycle. |
mbed_official | 52:a51c77007319 | 883 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 884 | * @param I2C_DutyCycle: specifies the fast mode duty cycle. |
mbed_official | 52:a51c77007319 | 885 | * This parameter can be one of the following values: |
mbed_official | 52:a51c77007319 | 886 | * @arg I2C_DutyCycle_2: I2C fast mode Tlow/Thigh = 2 |
mbed_official | 52:a51c77007319 | 887 | * @arg I2C_DutyCycle_16_9: I2C fast mode Tlow/Thigh = 16/9 |
mbed_official | 52:a51c77007319 | 888 | * @retval None |
mbed_official | 52:a51c77007319 | 889 | */ |
mbed_official | 52:a51c77007319 | 890 | void I2C_FastModeDutyCycleConfig(I2C_TypeDef* I2Cx, uint16_t I2C_DutyCycle) |
mbed_official | 52:a51c77007319 | 891 | { |
mbed_official | 52:a51c77007319 | 892 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 893 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 894 | assert_param(IS_I2C_DUTY_CYCLE(I2C_DutyCycle)); |
mbed_official | 52:a51c77007319 | 895 | if (I2C_DutyCycle != I2C_DutyCycle_16_9) |
mbed_official | 52:a51c77007319 | 896 | { |
mbed_official | 52:a51c77007319 | 897 | /* I2C fast mode Tlow/Thigh=2 */ |
mbed_official | 52:a51c77007319 | 898 | I2Cx->CCR &= I2C_DutyCycle_2; |
mbed_official | 52:a51c77007319 | 899 | } |
mbed_official | 52:a51c77007319 | 900 | else |
mbed_official | 52:a51c77007319 | 901 | { |
mbed_official | 52:a51c77007319 | 902 | /* I2C fast mode Tlow/Thigh=16/9 */ |
mbed_official | 52:a51c77007319 | 903 | I2Cx->CCR |= I2C_DutyCycle_16_9; |
mbed_official | 52:a51c77007319 | 904 | } |
mbed_official | 52:a51c77007319 | 905 | } |
mbed_official | 52:a51c77007319 | 906 | |
mbed_official | 52:a51c77007319 | 907 | |
mbed_official | 52:a51c77007319 | 908 | |
mbed_official | 52:a51c77007319 | 909 | /** |
mbed_official | 52:a51c77007319 | 910 | * @brief |
mbed_official | 52:a51c77007319 | 911 | **************************************************************************************** |
mbed_official | 52:a51c77007319 | 912 | * |
mbed_official | 52:a51c77007319 | 913 | * I2C State Monitoring Functions |
mbed_official | 52:a51c77007319 | 914 | * |
mbed_official | 52:a51c77007319 | 915 | **************************************************************************************** |
mbed_official | 52:a51c77007319 | 916 | * This I2C driver provides three different ways for I2C state monitoring |
mbed_official | 52:a51c77007319 | 917 | * depending on the application requirements and constraints: |
mbed_official | 52:a51c77007319 | 918 | * |
mbed_official | 52:a51c77007319 | 919 | * |
mbed_official | 52:a51c77007319 | 920 | * 1) Basic state monitoring: |
mbed_official | 52:a51c77007319 | 921 | * Using I2C_CheckEvent() function: |
mbed_official | 52:a51c77007319 | 922 | * It compares the status registers (SR1 and SR2) content to a given event |
mbed_official | 52:a51c77007319 | 923 | * (can be the combination of one or more flags). |
mbed_official | 52:a51c77007319 | 924 | * It returns SUCCESS if the current status includes the given flags |
mbed_official | 52:a51c77007319 | 925 | * and returns ERROR if one or more flags are missing in the current status. |
mbed_official | 52:a51c77007319 | 926 | * - When to use: |
mbed_official | 52:a51c77007319 | 927 | * - This function is suitable for most applications as well as for startup |
mbed_official | 52:a51c77007319 | 928 | * activity since the events are fully described in the product reference manual |
mbed_official | 52:a51c77007319 | 929 | * (RM0008). |
mbed_official | 52:a51c77007319 | 930 | * - It is also suitable for users who need to define their own events. |
mbed_official | 52:a51c77007319 | 931 | * - Limitations: |
mbed_official | 52:a51c77007319 | 932 | * - If an error occurs (ie. error flags are set besides to the monitored flags), |
mbed_official | 52:a51c77007319 | 933 | * the I2C_CheckEvent() function may return SUCCESS despite the communication |
mbed_official | 52:a51c77007319 | 934 | * hold or corrupted real state. |
mbed_official | 52:a51c77007319 | 935 | * In this case, it is advised to use error interrupts to monitor the error |
mbed_official | 52:a51c77007319 | 936 | * events and handle them in the interrupt IRQ handler. |
mbed_official | 52:a51c77007319 | 937 | * |
mbed_official | 52:a51c77007319 | 938 | * @note |
mbed_official | 52:a51c77007319 | 939 | * For error management, it is advised to use the following functions: |
mbed_official | 52:a51c77007319 | 940 | * - I2C_ITConfig() to configure and enable the error interrupts (I2C_IT_ERR). |
mbed_official | 52:a51c77007319 | 941 | * - I2Cx_ER_IRQHandler() which is called when the error interrupt occurs. |
mbed_official | 52:a51c77007319 | 942 | * Where x is the peripheral instance (I2C1, I2C2 ...) |
mbed_official | 52:a51c77007319 | 943 | * - I2C_GetFlagStatus() or I2C_GetITStatus() to be called into I2Cx_ER_IRQHandler() |
mbed_official | 52:a51c77007319 | 944 | * in order to determine which error occured. |
mbed_official | 52:a51c77007319 | 945 | * - I2C_ClearFlag() or I2C_ClearITPendingBit() and/or I2C_SoftwareResetCmd() |
mbed_official | 52:a51c77007319 | 946 | * and/or I2C_GenerateStop() in order to clear the error flag and source, |
mbed_official | 52:a51c77007319 | 947 | * and return to correct communication status. |
mbed_official | 52:a51c77007319 | 948 | * |
mbed_official | 52:a51c77007319 | 949 | * |
mbed_official | 52:a51c77007319 | 950 | * 2) Advanced state monitoring: |
mbed_official | 52:a51c77007319 | 951 | * Using the function I2C_GetLastEvent() which returns the image of both status |
mbed_official | 52:a51c77007319 | 952 | * registers in a single word (uint32_t) (Status Register 2 value is shifted left |
mbed_official | 52:a51c77007319 | 953 | * by 16 bits and concatenated to Status Register 1). |
mbed_official | 52:a51c77007319 | 954 | * - When to use: |
mbed_official | 52:a51c77007319 | 955 | * - This function is suitable for the same applications above but it allows to |
mbed_official | 52:a51c77007319 | 956 | * overcome the mentioned limitation of I2C_GetFlagStatus() function. |
mbed_official | 52:a51c77007319 | 957 | * The returned value could be compared to events already defined in the |
mbed_official | 52:a51c77007319 | 958 | * library (stm32f10x_i2c.h) or to custom values defined by user. |
mbed_official | 52:a51c77007319 | 959 | * - This function is suitable when multiple flags are monitored at the same time. |
mbed_official | 52:a51c77007319 | 960 | * - At the opposite of I2C_CheckEvent() function, this function allows user to |
mbed_official | 52:a51c77007319 | 961 | * choose when an event is accepted (when all events flags are set and no |
mbed_official | 52:a51c77007319 | 962 | * other flags are set or just when the needed flags are set like |
mbed_official | 52:a51c77007319 | 963 | * I2C_CheckEvent() function). |
mbed_official | 52:a51c77007319 | 964 | * - Limitations: |
mbed_official | 52:a51c77007319 | 965 | * - User may need to define his own events. |
mbed_official | 52:a51c77007319 | 966 | * - Same remark concerning the error management is applicable for this |
mbed_official | 52:a51c77007319 | 967 | * function if user decides to check only regular communication flags (and |
mbed_official | 52:a51c77007319 | 968 | * ignores error flags). |
mbed_official | 52:a51c77007319 | 969 | * |
mbed_official | 52:a51c77007319 | 970 | * |
mbed_official | 52:a51c77007319 | 971 | * 3) Flag-based state monitoring: |
mbed_official | 52:a51c77007319 | 972 | * Using the function I2C_GetFlagStatus() which simply returns the status of |
mbed_official | 52:a51c77007319 | 973 | * one single flag (ie. I2C_FLAG_RXNE ...). |
mbed_official | 52:a51c77007319 | 974 | * - When to use: |
mbed_official | 52:a51c77007319 | 975 | * - This function could be used for specific applications or in debug phase. |
mbed_official | 52:a51c77007319 | 976 | * - It is suitable when only one flag checking is needed (most I2C events |
mbed_official | 52:a51c77007319 | 977 | * are monitored through multiple flags). |
mbed_official | 52:a51c77007319 | 978 | * - Limitations: |
mbed_official | 52:a51c77007319 | 979 | * - When calling this function, the Status register is accessed. Some flags are |
mbed_official | 52:a51c77007319 | 980 | * cleared when the status register is accessed. So checking the status |
mbed_official | 52:a51c77007319 | 981 | * of one Flag, may clear other ones. |
mbed_official | 52:a51c77007319 | 982 | * - Function may need to be called twice or more in order to monitor one |
mbed_official | 52:a51c77007319 | 983 | * single event. |
mbed_official | 52:a51c77007319 | 984 | * |
mbed_official | 52:a51c77007319 | 985 | * For detailed description of Events, please refer to section I2C_Events in |
mbed_official | 52:a51c77007319 | 986 | * stm32f10x_i2c.h file. |
mbed_official | 52:a51c77007319 | 987 | * |
mbed_official | 52:a51c77007319 | 988 | */ |
mbed_official | 52:a51c77007319 | 989 | |
mbed_official | 52:a51c77007319 | 990 | /** |
mbed_official | 52:a51c77007319 | 991 | * |
mbed_official | 52:a51c77007319 | 992 | * 1) Basic state monitoring |
mbed_official | 52:a51c77007319 | 993 | ******************************************************************************* |
mbed_official | 52:a51c77007319 | 994 | */ |
mbed_official | 52:a51c77007319 | 995 | |
mbed_official | 52:a51c77007319 | 996 | /** |
mbed_official | 52:a51c77007319 | 997 | * @brief Checks whether the last I2Cx Event is equal to the one passed |
mbed_official | 52:a51c77007319 | 998 | * as parameter. |
mbed_official | 52:a51c77007319 | 999 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 1000 | * @param I2C_EVENT: specifies the event to be checked. |
mbed_official | 52:a51c77007319 | 1001 | * This parameter can be one of the following values: |
mbed_official | 52:a51c77007319 | 1002 | * @arg I2C_EVENT_SLAVE_TRANSMITTER_ADDRESS_MATCHED : EV1 |
mbed_official | 52:a51c77007319 | 1003 | * @arg I2C_EVENT_SLAVE_RECEIVER_ADDRESS_MATCHED : EV1 |
mbed_official | 52:a51c77007319 | 1004 | * @arg I2C_EVENT_SLAVE_TRANSMITTER_SECONDADDRESS_MATCHED : EV1 |
mbed_official | 52:a51c77007319 | 1005 | * @arg I2C_EVENT_SLAVE_RECEIVER_SECONDADDRESS_MATCHED : EV1 |
mbed_official | 52:a51c77007319 | 1006 | * @arg I2C_EVENT_SLAVE_GENERALCALLADDRESS_MATCHED : EV1 |
mbed_official | 52:a51c77007319 | 1007 | * @arg I2C_EVENT_SLAVE_BYTE_RECEIVED : EV2 |
mbed_official | 52:a51c77007319 | 1008 | * @arg (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_DUALF) : EV2 |
mbed_official | 52:a51c77007319 | 1009 | * @arg (I2C_EVENT_SLAVE_BYTE_RECEIVED | I2C_FLAG_GENCALL) : EV2 |
mbed_official | 52:a51c77007319 | 1010 | * @arg I2C_EVENT_SLAVE_BYTE_TRANSMITTED : EV3 |
mbed_official | 52:a51c77007319 | 1011 | * @arg (I2C_EVENT_SLAVE_BYTE_TRANSMITTED | I2C_FLAG_DUALF) : EV3 |
mbed_official | 52:a51c77007319 | 1012 | * @arg (I2C_EVENT_SLAVE_BYTE_TRANSMITTED | I2C_FLAG_GENCALL) : EV3 |
mbed_official | 52:a51c77007319 | 1013 | * @arg I2C_EVENT_SLAVE_ACK_FAILURE : EV3_2 |
mbed_official | 52:a51c77007319 | 1014 | * @arg I2C_EVENT_SLAVE_STOP_DETECTED : EV4 |
mbed_official | 52:a51c77007319 | 1015 | * @arg I2C_EVENT_MASTER_MODE_SELECT : EV5 |
mbed_official | 52:a51c77007319 | 1016 | * @arg I2C_EVENT_MASTER_TRANSMITTER_MODE_SELECTED : EV6 |
mbed_official | 52:a51c77007319 | 1017 | * @arg I2C_EVENT_MASTER_RECEIVER_MODE_SELECTED : EV6 |
mbed_official | 52:a51c77007319 | 1018 | * @arg I2C_EVENT_MASTER_BYTE_RECEIVED : EV7 |
mbed_official | 52:a51c77007319 | 1019 | * @arg I2C_EVENT_MASTER_BYTE_TRANSMITTING : EV8 |
mbed_official | 52:a51c77007319 | 1020 | * @arg I2C_EVENT_MASTER_BYTE_TRANSMITTED : EV8_2 |
mbed_official | 52:a51c77007319 | 1021 | * @arg I2C_EVENT_MASTER_MODE_ADDRESS10 : EV9 |
mbed_official | 52:a51c77007319 | 1022 | * |
mbed_official | 52:a51c77007319 | 1023 | * @note: For detailed description of Events, please refer to section |
mbed_official | 52:a51c77007319 | 1024 | * I2C_Events in stm32f10x_i2c.h file. |
mbed_official | 52:a51c77007319 | 1025 | * |
mbed_official | 52:a51c77007319 | 1026 | * @retval An ErrorStatus enumeration value: |
mbed_official | 52:a51c77007319 | 1027 | * - SUCCESS: Last event is equal to the I2C_EVENT |
mbed_official | 52:a51c77007319 | 1028 | * - ERROR: Last event is different from the I2C_EVENT |
mbed_official | 52:a51c77007319 | 1029 | */ |
mbed_official | 52:a51c77007319 | 1030 | ErrorStatus I2C_CheckEvent(I2C_TypeDef* I2Cx, uint32_t I2C_EVENT) |
mbed_official | 52:a51c77007319 | 1031 | { |
mbed_official | 52:a51c77007319 | 1032 | uint32_t lastevent = 0; |
mbed_official | 52:a51c77007319 | 1033 | uint32_t flag1 = 0, flag2 = 0; |
mbed_official | 52:a51c77007319 | 1034 | ErrorStatus status = ERROR; |
mbed_official | 52:a51c77007319 | 1035 | |
mbed_official | 52:a51c77007319 | 1036 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 1037 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 1038 | assert_param(IS_I2C_EVENT(I2C_EVENT)); |
mbed_official | 52:a51c77007319 | 1039 | |
mbed_official | 52:a51c77007319 | 1040 | /* Read the I2Cx status register */ |
mbed_official | 52:a51c77007319 | 1041 | flag1 = I2Cx->SR1; |
mbed_official | 52:a51c77007319 | 1042 | flag2 = I2Cx->SR2; |
mbed_official | 52:a51c77007319 | 1043 | flag2 = flag2 << 16; |
mbed_official | 52:a51c77007319 | 1044 | |
mbed_official | 52:a51c77007319 | 1045 | /* Get the last event value from I2C status register */ |
mbed_official | 52:a51c77007319 | 1046 | lastevent = (flag1 | flag2) & FLAG_Mask; |
mbed_official | 52:a51c77007319 | 1047 | |
mbed_official | 52:a51c77007319 | 1048 | /* Check whether the last event contains the I2C_EVENT */ |
mbed_official | 52:a51c77007319 | 1049 | if ((lastevent & I2C_EVENT) == I2C_EVENT) |
mbed_official | 52:a51c77007319 | 1050 | { |
mbed_official | 52:a51c77007319 | 1051 | /* SUCCESS: last event is equal to I2C_EVENT */ |
mbed_official | 52:a51c77007319 | 1052 | status = SUCCESS; |
mbed_official | 52:a51c77007319 | 1053 | } |
mbed_official | 52:a51c77007319 | 1054 | else |
mbed_official | 52:a51c77007319 | 1055 | { |
mbed_official | 52:a51c77007319 | 1056 | /* ERROR: last event is different from I2C_EVENT */ |
mbed_official | 52:a51c77007319 | 1057 | status = ERROR; |
mbed_official | 52:a51c77007319 | 1058 | } |
mbed_official | 52:a51c77007319 | 1059 | /* Return status */ |
mbed_official | 52:a51c77007319 | 1060 | return status; |
mbed_official | 52:a51c77007319 | 1061 | } |
mbed_official | 52:a51c77007319 | 1062 | |
mbed_official | 52:a51c77007319 | 1063 | /** |
mbed_official | 52:a51c77007319 | 1064 | * |
mbed_official | 52:a51c77007319 | 1065 | * 2) Advanced state monitoring |
mbed_official | 52:a51c77007319 | 1066 | ******************************************************************************* |
mbed_official | 52:a51c77007319 | 1067 | */ |
mbed_official | 52:a51c77007319 | 1068 | |
mbed_official | 52:a51c77007319 | 1069 | /** |
mbed_official | 52:a51c77007319 | 1070 | * @brief Returns the last I2Cx Event. |
mbed_official | 52:a51c77007319 | 1071 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 1072 | * |
mbed_official | 52:a51c77007319 | 1073 | * @note: For detailed description of Events, please refer to section |
mbed_official | 52:a51c77007319 | 1074 | * I2C_Events in stm32f10x_i2c.h file. |
mbed_official | 52:a51c77007319 | 1075 | * |
mbed_official | 52:a51c77007319 | 1076 | * @retval The last event |
mbed_official | 52:a51c77007319 | 1077 | */ |
mbed_official | 52:a51c77007319 | 1078 | uint32_t I2C_GetLastEvent(I2C_TypeDef* I2Cx) |
mbed_official | 52:a51c77007319 | 1079 | { |
mbed_official | 52:a51c77007319 | 1080 | uint32_t lastevent = 0; |
mbed_official | 52:a51c77007319 | 1081 | uint32_t flag1 = 0, flag2 = 0; |
mbed_official | 52:a51c77007319 | 1082 | |
mbed_official | 52:a51c77007319 | 1083 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 1084 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 1085 | |
mbed_official | 52:a51c77007319 | 1086 | /* Read the I2Cx status register */ |
mbed_official | 52:a51c77007319 | 1087 | flag1 = I2Cx->SR1; |
mbed_official | 52:a51c77007319 | 1088 | flag2 = I2Cx->SR2; |
mbed_official | 52:a51c77007319 | 1089 | flag2 = flag2 << 16; |
mbed_official | 52:a51c77007319 | 1090 | |
mbed_official | 52:a51c77007319 | 1091 | /* Get the last event value from I2C status register */ |
mbed_official | 52:a51c77007319 | 1092 | lastevent = (flag1 | flag2) & FLAG_Mask; |
mbed_official | 52:a51c77007319 | 1093 | |
mbed_official | 52:a51c77007319 | 1094 | /* Return status */ |
mbed_official | 52:a51c77007319 | 1095 | return lastevent; |
mbed_official | 52:a51c77007319 | 1096 | } |
mbed_official | 52:a51c77007319 | 1097 | |
mbed_official | 52:a51c77007319 | 1098 | /** |
mbed_official | 52:a51c77007319 | 1099 | * |
mbed_official | 52:a51c77007319 | 1100 | * 3) Flag-based state monitoring |
mbed_official | 52:a51c77007319 | 1101 | ******************************************************************************* |
mbed_official | 52:a51c77007319 | 1102 | */ |
mbed_official | 52:a51c77007319 | 1103 | |
mbed_official | 52:a51c77007319 | 1104 | /** |
mbed_official | 52:a51c77007319 | 1105 | * @brief Checks whether the specified I2C flag is set or not. |
mbed_official | 52:a51c77007319 | 1106 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 1107 | * @param I2C_FLAG: specifies the flag to check. |
mbed_official | 52:a51c77007319 | 1108 | * This parameter can be one of the following values: |
mbed_official | 52:a51c77007319 | 1109 | * @arg I2C_FLAG_DUALF: Dual flag (Slave mode) |
mbed_official | 52:a51c77007319 | 1110 | * @arg I2C_FLAG_SMBHOST: SMBus host header (Slave mode) |
mbed_official | 52:a51c77007319 | 1111 | * @arg I2C_FLAG_SMBDEFAULT: SMBus default header (Slave mode) |
mbed_official | 52:a51c77007319 | 1112 | * @arg I2C_FLAG_GENCALL: General call header flag (Slave mode) |
mbed_official | 52:a51c77007319 | 1113 | * @arg I2C_FLAG_TRA: Transmitter/Receiver flag |
mbed_official | 52:a51c77007319 | 1114 | * @arg I2C_FLAG_BUSY: Bus busy flag |
mbed_official | 52:a51c77007319 | 1115 | * @arg I2C_FLAG_MSL: Master/Slave flag |
mbed_official | 52:a51c77007319 | 1116 | * @arg I2C_FLAG_SMBALERT: SMBus Alert flag |
mbed_official | 52:a51c77007319 | 1117 | * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow error flag |
mbed_official | 52:a51c77007319 | 1118 | * @arg I2C_FLAG_PECERR: PEC error in reception flag |
mbed_official | 52:a51c77007319 | 1119 | * @arg I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode) |
mbed_official | 52:a51c77007319 | 1120 | * @arg I2C_FLAG_AF: Acknowledge failure flag |
mbed_official | 52:a51c77007319 | 1121 | * @arg I2C_FLAG_ARLO: Arbitration lost flag (Master mode) |
mbed_official | 52:a51c77007319 | 1122 | * @arg I2C_FLAG_BERR: Bus error flag |
mbed_official | 52:a51c77007319 | 1123 | * @arg I2C_FLAG_TXE: Data register empty flag (Transmitter) |
mbed_official | 52:a51c77007319 | 1124 | * @arg I2C_FLAG_RXNE: Data register not empty (Receiver) flag |
mbed_official | 52:a51c77007319 | 1125 | * @arg I2C_FLAG_STOPF: Stop detection flag (Slave mode) |
mbed_official | 52:a51c77007319 | 1126 | * @arg I2C_FLAG_ADD10: 10-bit header sent flag (Master mode) |
mbed_official | 52:a51c77007319 | 1127 | * @arg I2C_FLAG_BTF: Byte transfer finished flag |
mbed_official | 52:a51c77007319 | 1128 | * @arg I2C_FLAG_ADDR: Address sent flag (Master mode) "ADSL" |
mbed_official | 52:a51c77007319 | 1129 | * Address matched flag (Slave mode)"ENDA" |
mbed_official | 52:a51c77007319 | 1130 | * @arg I2C_FLAG_SB: Start bit flag (Master mode) |
mbed_official | 52:a51c77007319 | 1131 | * @retval The new state of I2C_FLAG (SET or RESET). |
mbed_official | 52:a51c77007319 | 1132 | */ |
mbed_official | 52:a51c77007319 | 1133 | FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG) |
mbed_official | 52:a51c77007319 | 1134 | { |
mbed_official | 52:a51c77007319 | 1135 | FlagStatus bitstatus = RESET; |
mbed_official | 52:a51c77007319 | 1136 | __IO uint32_t i2creg = 0, i2cxbase = 0; |
mbed_official | 52:a51c77007319 | 1137 | |
mbed_official | 52:a51c77007319 | 1138 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 1139 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 1140 | assert_param(IS_I2C_GET_FLAG(I2C_FLAG)); |
mbed_official | 52:a51c77007319 | 1141 | |
mbed_official | 52:a51c77007319 | 1142 | /* Get the I2Cx peripheral base address */ |
mbed_official | 52:a51c77007319 | 1143 | i2cxbase = (uint32_t)I2Cx; |
mbed_official | 52:a51c77007319 | 1144 | |
mbed_official | 52:a51c77007319 | 1145 | /* Read flag register index */ |
mbed_official | 52:a51c77007319 | 1146 | i2creg = I2C_FLAG >> 28; |
mbed_official | 52:a51c77007319 | 1147 | |
mbed_official | 52:a51c77007319 | 1148 | /* Get bit[23:0] of the flag */ |
mbed_official | 52:a51c77007319 | 1149 | I2C_FLAG &= FLAG_Mask; |
mbed_official | 52:a51c77007319 | 1150 | |
mbed_official | 52:a51c77007319 | 1151 | if(i2creg != 0) |
mbed_official | 52:a51c77007319 | 1152 | { |
mbed_official | 52:a51c77007319 | 1153 | /* Get the I2Cx SR1 register address */ |
mbed_official | 52:a51c77007319 | 1154 | i2cxbase += 0x14; |
mbed_official | 52:a51c77007319 | 1155 | } |
mbed_official | 52:a51c77007319 | 1156 | else |
mbed_official | 52:a51c77007319 | 1157 | { |
mbed_official | 52:a51c77007319 | 1158 | /* Flag in I2Cx SR2 Register */ |
mbed_official | 52:a51c77007319 | 1159 | I2C_FLAG = (uint32_t)(I2C_FLAG >> 16); |
mbed_official | 52:a51c77007319 | 1160 | /* Get the I2Cx SR2 register address */ |
mbed_official | 52:a51c77007319 | 1161 | i2cxbase += 0x18; |
mbed_official | 52:a51c77007319 | 1162 | } |
mbed_official | 52:a51c77007319 | 1163 | |
mbed_official | 52:a51c77007319 | 1164 | if(((*(__IO uint32_t *)i2cxbase) & I2C_FLAG) != (uint32_t)RESET) |
mbed_official | 52:a51c77007319 | 1165 | { |
mbed_official | 52:a51c77007319 | 1166 | /* I2C_FLAG is set */ |
mbed_official | 52:a51c77007319 | 1167 | bitstatus = SET; |
mbed_official | 52:a51c77007319 | 1168 | } |
mbed_official | 52:a51c77007319 | 1169 | else |
mbed_official | 52:a51c77007319 | 1170 | { |
mbed_official | 52:a51c77007319 | 1171 | /* I2C_FLAG is reset */ |
mbed_official | 52:a51c77007319 | 1172 | bitstatus = RESET; |
mbed_official | 52:a51c77007319 | 1173 | } |
mbed_official | 52:a51c77007319 | 1174 | |
mbed_official | 52:a51c77007319 | 1175 | /* Return the I2C_FLAG status */ |
mbed_official | 52:a51c77007319 | 1176 | return bitstatus; |
mbed_official | 52:a51c77007319 | 1177 | } |
mbed_official | 52:a51c77007319 | 1178 | |
mbed_official | 52:a51c77007319 | 1179 | |
mbed_official | 52:a51c77007319 | 1180 | |
mbed_official | 52:a51c77007319 | 1181 | /** |
mbed_official | 52:a51c77007319 | 1182 | * @brief Clears the I2Cx's pending flags. |
mbed_official | 52:a51c77007319 | 1183 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 1184 | * @param I2C_FLAG: specifies the flag to clear. |
mbed_official | 52:a51c77007319 | 1185 | * This parameter can be any combination of the following values: |
mbed_official | 52:a51c77007319 | 1186 | * @arg I2C_FLAG_SMBALERT: SMBus Alert flag |
mbed_official | 52:a51c77007319 | 1187 | * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow error flag |
mbed_official | 52:a51c77007319 | 1188 | * @arg I2C_FLAG_PECERR: PEC error in reception flag |
mbed_official | 52:a51c77007319 | 1189 | * @arg I2C_FLAG_OVR: Overrun/Underrun flag (Slave mode) |
mbed_official | 52:a51c77007319 | 1190 | * @arg I2C_FLAG_AF: Acknowledge failure flag |
mbed_official | 52:a51c77007319 | 1191 | * @arg I2C_FLAG_ARLO: Arbitration lost flag (Master mode) |
mbed_official | 52:a51c77007319 | 1192 | * @arg I2C_FLAG_BERR: Bus error flag |
mbed_official | 52:a51c77007319 | 1193 | * |
mbed_official | 52:a51c77007319 | 1194 | * @note |
mbed_official | 52:a51c77007319 | 1195 | * - STOPF (STOP detection) is cleared by software sequence: a read operation |
mbed_official | 52:a51c77007319 | 1196 | * to I2C_SR1 register (I2C_GetFlagStatus()) followed by a write operation |
mbed_official | 52:a51c77007319 | 1197 | * to I2C_CR1 register (I2C_Cmd() to re-enable the I2C peripheral). |
mbed_official | 52:a51c77007319 | 1198 | * - ADD10 (10-bit header sent) is cleared by software sequence: a read |
mbed_official | 52:a51c77007319 | 1199 | * operation to I2C_SR1 (I2C_GetFlagStatus()) followed by writing the |
mbed_official | 52:a51c77007319 | 1200 | * second byte of the address in DR register. |
mbed_official | 52:a51c77007319 | 1201 | * - BTF (Byte Transfer Finished) is cleared by software sequence: a read |
mbed_official | 52:a51c77007319 | 1202 | * operation to I2C_SR1 register (I2C_GetFlagStatus()) followed by a |
mbed_official | 52:a51c77007319 | 1203 | * read/write to I2C_DR register (I2C_SendData()). |
mbed_official | 52:a51c77007319 | 1204 | * - ADDR (Address sent) is cleared by software sequence: a read operation to |
mbed_official | 52:a51c77007319 | 1205 | * I2C_SR1 register (I2C_GetFlagStatus()) followed by a read operation to |
mbed_official | 52:a51c77007319 | 1206 | * I2C_SR2 register ((void)(I2Cx->SR2)). |
mbed_official | 52:a51c77007319 | 1207 | * - SB (Start Bit) is cleared software sequence: a read operation to I2C_SR1 |
mbed_official | 52:a51c77007319 | 1208 | * register (I2C_GetFlagStatus()) followed by a write operation to I2C_DR |
mbed_official | 52:a51c77007319 | 1209 | * register (I2C_SendData()). |
mbed_official | 52:a51c77007319 | 1210 | * @retval None |
mbed_official | 52:a51c77007319 | 1211 | */ |
mbed_official | 52:a51c77007319 | 1212 | void I2C_ClearFlag(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG) |
mbed_official | 52:a51c77007319 | 1213 | { |
mbed_official | 52:a51c77007319 | 1214 | uint32_t flagpos = 0; |
mbed_official | 52:a51c77007319 | 1215 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 1216 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 1217 | assert_param(IS_I2C_CLEAR_FLAG(I2C_FLAG)); |
mbed_official | 52:a51c77007319 | 1218 | /* Get the I2C flag position */ |
mbed_official | 52:a51c77007319 | 1219 | flagpos = I2C_FLAG & FLAG_Mask; |
mbed_official | 52:a51c77007319 | 1220 | /* Clear the selected I2C flag */ |
mbed_official | 52:a51c77007319 | 1221 | I2Cx->SR1 = (uint16_t)~flagpos; |
mbed_official | 52:a51c77007319 | 1222 | } |
mbed_official | 52:a51c77007319 | 1223 | |
mbed_official | 52:a51c77007319 | 1224 | /** |
mbed_official | 52:a51c77007319 | 1225 | * @brief Checks whether the specified I2C interrupt has occurred or not. |
mbed_official | 52:a51c77007319 | 1226 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 1227 | * @param I2C_IT: specifies the interrupt source to check. |
mbed_official | 52:a51c77007319 | 1228 | * This parameter can be one of the following values: |
mbed_official | 52:a51c77007319 | 1229 | * @arg I2C_IT_SMBALERT: SMBus Alert flag |
mbed_official | 52:a51c77007319 | 1230 | * @arg I2C_IT_TIMEOUT: Timeout or Tlow error flag |
mbed_official | 52:a51c77007319 | 1231 | * @arg I2C_IT_PECERR: PEC error in reception flag |
mbed_official | 52:a51c77007319 | 1232 | * @arg I2C_IT_OVR: Overrun/Underrun flag (Slave mode) |
mbed_official | 52:a51c77007319 | 1233 | * @arg I2C_IT_AF: Acknowledge failure flag |
mbed_official | 52:a51c77007319 | 1234 | * @arg I2C_IT_ARLO: Arbitration lost flag (Master mode) |
mbed_official | 52:a51c77007319 | 1235 | * @arg I2C_IT_BERR: Bus error flag |
mbed_official | 52:a51c77007319 | 1236 | * @arg I2C_IT_TXE: Data register empty flag (Transmitter) |
mbed_official | 52:a51c77007319 | 1237 | * @arg I2C_IT_RXNE: Data register not empty (Receiver) flag |
mbed_official | 52:a51c77007319 | 1238 | * @arg I2C_IT_STOPF: Stop detection flag (Slave mode) |
mbed_official | 52:a51c77007319 | 1239 | * @arg I2C_IT_ADD10: 10-bit header sent flag (Master mode) |
mbed_official | 52:a51c77007319 | 1240 | * @arg I2C_IT_BTF: Byte transfer finished flag |
mbed_official | 52:a51c77007319 | 1241 | * @arg I2C_IT_ADDR: Address sent flag (Master mode) "ADSL" |
mbed_official | 52:a51c77007319 | 1242 | * Address matched flag (Slave mode)"ENDAD" |
mbed_official | 52:a51c77007319 | 1243 | * @arg I2C_IT_SB: Start bit flag (Master mode) |
mbed_official | 52:a51c77007319 | 1244 | * @retval The new state of I2C_IT (SET or RESET). |
mbed_official | 52:a51c77007319 | 1245 | */ |
mbed_official | 52:a51c77007319 | 1246 | ITStatus I2C_GetITStatus(I2C_TypeDef* I2Cx, uint32_t I2C_IT) |
mbed_official | 52:a51c77007319 | 1247 | { |
mbed_official | 52:a51c77007319 | 1248 | ITStatus bitstatus = RESET; |
mbed_official | 52:a51c77007319 | 1249 | uint32_t enablestatus = 0; |
mbed_official | 52:a51c77007319 | 1250 | |
mbed_official | 52:a51c77007319 | 1251 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 1252 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 1253 | assert_param(IS_I2C_GET_IT(I2C_IT)); |
mbed_official | 52:a51c77007319 | 1254 | |
mbed_official | 52:a51c77007319 | 1255 | /* Check if the interrupt source is enabled or not */ |
mbed_official | 52:a51c77007319 | 1256 | enablestatus = (uint32_t)(((I2C_IT & ITEN_Mask) >> 16) & (I2Cx->CR2)) ; |
mbed_official | 52:a51c77007319 | 1257 | |
mbed_official | 52:a51c77007319 | 1258 | /* Get bit[23:0] of the flag */ |
mbed_official | 52:a51c77007319 | 1259 | I2C_IT &= FLAG_Mask; |
mbed_official | 52:a51c77007319 | 1260 | |
mbed_official | 52:a51c77007319 | 1261 | /* Check the status of the specified I2C flag */ |
mbed_official | 52:a51c77007319 | 1262 | if (((I2Cx->SR1 & I2C_IT) != (uint32_t)RESET) && enablestatus) |
mbed_official | 52:a51c77007319 | 1263 | { |
mbed_official | 52:a51c77007319 | 1264 | /* I2C_IT is set */ |
mbed_official | 52:a51c77007319 | 1265 | bitstatus = SET; |
mbed_official | 52:a51c77007319 | 1266 | } |
mbed_official | 52:a51c77007319 | 1267 | else |
mbed_official | 52:a51c77007319 | 1268 | { |
mbed_official | 52:a51c77007319 | 1269 | /* I2C_IT is reset */ |
mbed_official | 52:a51c77007319 | 1270 | bitstatus = RESET; |
mbed_official | 52:a51c77007319 | 1271 | } |
mbed_official | 52:a51c77007319 | 1272 | /* Return the I2C_IT status */ |
mbed_official | 52:a51c77007319 | 1273 | return bitstatus; |
mbed_official | 52:a51c77007319 | 1274 | } |
mbed_official | 52:a51c77007319 | 1275 | |
mbed_official | 52:a51c77007319 | 1276 | /** |
mbed_official | 52:a51c77007319 | 1277 | * @brief Clears the I2Cxs interrupt pending bits. |
mbed_official | 52:a51c77007319 | 1278 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 52:a51c77007319 | 1279 | * @param I2C_IT: specifies the interrupt pending bit to clear. |
mbed_official | 52:a51c77007319 | 1280 | * This parameter can be any combination of the following values: |
mbed_official | 52:a51c77007319 | 1281 | * @arg I2C_IT_SMBALERT: SMBus Alert interrupt |
mbed_official | 52:a51c77007319 | 1282 | * @arg I2C_IT_TIMEOUT: Timeout or Tlow error interrupt |
mbed_official | 52:a51c77007319 | 1283 | * @arg I2C_IT_PECERR: PEC error in reception interrupt |
mbed_official | 52:a51c77007319 | 1284 | * @arg I2C_IT_OVR: Overrun/Underrun interrupt (Slave mode) |
mbed_official | 52:a51c77007319 | 1285 | * @arg I2C_IT_AF: Acknowledge failure interrupt |
mbed_official | 52:a51c77007319 | 1286 | * @arg I2C_IT_ARLO: Arbitration lost interrupt (Master mode) |
mbed_official | 52:a51c77007319 | 1287 | * @arg I2C_IT_BERR: Bus error interrupt |
mbed_official | 52:a51c77007319 | 1288 | * |
mbed_official | 52:a51c77007319 | 1289 | * @note |
mbed_official | 52:a51c77007319 | 1290 | * - STOPF (STOP detection) is cleared by software sequence: a read operation |
mbed_official | 52:a51c77007319 | 1291 | * to I2C_SR1 register (I2C_GetITStatus()) followed by a write operation to |
mbed_official | 52:a51c77007319 | 1292 | * I2C_CR1 register (I2C_Cmd() to re-enable the I2C peripheral). |
mbed_official | 52:a51c77007319 | 1293 | * - ADD10 (10-bit header sent) is cleared by software sequence: a read |
mbed_official | 52:a51c77007319 | 1294 | * operation to I2C_SR1 (I2C_GetITStatus()) followed by writing the second |
mbed_official | 52:a51c77007319 | 1295 | * byte of the address in I2C_DR register. |
mbed_official | 52:a51c77007319 | 1296 | * - BTF (Byte Transfer Finished) is cleared by software sequence: a read |
mbed_official | 52:a51c77007319 | 1297 | * operation to I2C_SR1 register (I2C_GetITStatus()) followed by a |
mbed_official | 52:a51c77007319 | 1298 | * read/write to I2C_DR register (I2C_SendData()). |
mbed_official | 52:a51c77007319 | 1299 | * - ADDR (Address sent) is cleared by software sequence: a read operation to |
mbed_official | 52:a51c77007319 | 1300 | * I2C_SR1 register (I2C_GetITStatus()) followed by a read operation to |
mbed_official | 52:a51c77007319 | 1301 | * I2C_SR2 register ((void)(I2Cx->SR2)). |
mbed_official | 52:a51c77007319 | 1302 | * - SB (Start Bit) is cleared by software sequence: a read operation to |
mbed_official | 52:a51c77007319 | 1303 | * I2C_SR1 register (I2C_GetITStatus()) followed by a write operation to |
mbed_official | 52:a51c77007319 | 1304 | * I2C_DR register (I2C_SendData()). |
mbed_official | 52:a51c77007319 | 1305 | * @retval None |
mbed_official | 52:a51c77007319 | 1306 | */ |
mbed_official | 52:a51c77007319 | 1307 | void I2C_ClearITPendingBit(I2C_TypeDef* I2Cx, uint32_t I2C_IT) |
mbed_official | 52:a51c77007319 | 1308 | { |
mbed_official | 52:a51c77007319 | 1309 | uint32_t flagpos = 0; |
mbed_official | 52:a51c77007319 | 1310 | /* Check the parameters */ |
mbed_official | 52:a51c77007319 | 1311 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 52:a51c77007319 | 1312 | assert_param(IS_I2C_CLEAR_IT(I2C_IT)); |
mbed_official | 52:a51c77007319 | 1313 | /* Get the I2C flag position */ |
mbed_official | 52:a51c77007319 | 1314 | flagpos = I2C_IT & FLAG_Mask; |
mbed_official | 52:a51c77007319 | 1315 | /* Clear the selected I2C flag */ |
mbed_official | 52:a51c77007319 | 1316 | I2Cx->SR1 = (uint16_t)~flagpos; |
mbed_official | 52:a51c77007319 | 1317 | } |
mbed_official | 52:a51c77007319 | 1318 | |
mbed_official | 52:a51c77007319 | 1319 | /** |
mbed_official | 52:a51c77007319 | 1320 | * @} |
mbed_official | 52:a51c77007319 | 1321 | */ |
mbed_official | 52:a51c77007319 | 1322 | |
mbed_official | 52:a51c77007319 | 1323 | /** |
mbed_official | 52:a51c77007319 | 1324 | * @} |
mbed_official | 52:a51c77007319 | 1325 | */ |
mbed_official | 52:a51c77007319 | 1326 | |
mbed_official | 52:a51c77007319 | 1327 | /** |
mbed_official | 52:a51c77007319 | 1328 | * @} |
mbed_official | 52:a51c77007319 | 1329 | */ |
mbed_official | 52:a51c77007319 | 1330 | |
mbed_official | 52:a51c77007319 | 1331 | /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/ |