mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_STM32F3XX/stm32f30x_i2c.c@637:ed69428d4850, 2015-12-22 (annotated)
- Committer:
- jaerts
- Date:
- Tue Dec 22 13:22:16 2015 +0000
- Revision:
- 637:ed69428d4850
- Parent:
- 155:8435094ec241
Add very shady LPC1768 CAN Filter implementation
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 155:8435094ec241 | 1 | /** |
mbed_official | 155:8435094ec241 | 2 | ****************************************************************************** |
mbed_official | 155:8435094ec241 | 3 | * @file stm32f30x_i2c.c |
mbed_official | 155:8435094ec241 | 4 | * @author MCD Application Team |
mbed_official | 155:8435094ec241 | 5 | * @version V1.1.0 |
mbed_official | 155:8435094ec241 | 6 | * @date 27-February-2014 |
mbed_official | 155:8435094ec241 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 155:8435094ec241 | 8 | * functionalities of the Inter-Integrated circuit (I2C): |
mbed_official | 155:8435094ec241 | 9 | * + Initialization and Configuration |
mbed_official | 155:8435094ec241 | 10 | * + Communications handling |
mbed_official | 155:8435094ec241 | 11 | * + SMBUS management |
mbed_official | 155:8435094ec241 | 12 | * + I2C registers management |
mbed_official | 155:8435094ec241 | 13 | * + Data transfers management |
mbed_official | 155:8435094ec241 | 14 | * + DMA transfers management |
mbed_official | 155:8435094ec241 | 15 | * + Interrupts and flags management |
mbed_official | 155:8435094ec241 | 16 | * |
mbed_official | 155:8435094ec241 | 17 | * @verbatim |
mbed_official | 155:8435094ec241 | 18 | ============================================================================ |
mbed_official | 155:8435094ec241 | 19 | ##### How to use this driver ##### |
mbed_official | 155:8435094ec241 | 20 | ============================================================================ |
mbed_official | 155:8435094ec241 | 21 | [..] |
mbed_official | 155:8435094ec241 | 22 | (#) Enable peripheral clock using RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2Cx, ENABLE) |
mbed_official | 155:8435094ec241 | 23 | function for I2C1 or I2C2. |
mbed_official | 155:8435094ec241 | 24 | (#) Enable SDA, SCL and SMBA (when used) GPIO clocks using |
mbed_official | 155:8435094ec241 | 25 | RCC_AHBPeriphClockCmd() function. |
mbed_official | 155:8435094ec241 | 26 | (#) Peripherals alternate function: |
mbed_official | 155:8435094ec241 | 27 | (++) Connect the pin to the desired peripherals' Alternate |
mbed_official | 155:8435094ec241 | 28 | Function (AF) using GPIO_PinAFConfig() function. |
mbed_official | 155:8435094ec241 | 29 | (++) Configure the desired pin in alternate function by: |
mbed_official | 155:8435094ec241 | 30 | GPIO_InitStruct->GPIO_Mode = GPIO_Mode_AF |
mbed_official | 155:8435094ec241 | 31 | (++) Select the type, OpenDrain and speed via |
mbed_official | 155:8435094ec241 | 32 | GPIO_PuPd, GPIO_OType and GPIO_Speed members |
mbed_official | 155:8435094ec241 | 33 | (++) Call GPIO_Init() function. |
mbed_official | 155:8435094ec241 | 34 | (#) Program the Mode, Timing , Own address, Ack and Acknowledged Address |
mbed_official | 155:8435094ec241 | 35 | using the I2C_Init() function. |
mbed_official | 155:8435094ec241 | 36 | (#) Optionally you can enable/configure the following parameters without |
mbed_official | 155:8435094ec241 | 37 | re-initialization (i.e there is no need to call again I2C_Init() function): |
mbed_official | 155:8435094ec241 | 38 | (++) Enable the acknowledge feature using I2C_AcknowledgeConfig() function. |
mbed_official | 155:8435094ec241 | 39 | (++) Enable the dual addressing mode using I2C_DualAddressCmd() function. |
mbed_official | 155:8435094ec241 | 40 | (++) Enable the general call using the I2C_GeneralCallCmd() function. |
mbed_official | 155:8435094ec241 | 41 | (++) Enable the clock stretching using I2C_StretchClockCmd() function. |
mbed_official | 155:8435094ec241 | 42 | (++) Enable the PEC Calculation using I2C_CalculatePEC() function. |
mbed_official | 155:8435094ec241 | 43 | (++) For SMBus Mode: |
mbed_official | 155:8435094ec241 | 44 | (+++) Enable the SMBusAlert pin using I2C_SMBusAlertCmd() function. |
mbed_official | 155:8435094ec241 | 45 | (#) Enable the NVIC and the corresponding interrupt using the function |
mbed_official | 155:8435094ec241 | 46 | I2C_ITConfig() if you need to use interrupt mode. |
mbed_official | 155:8435094ec241 | 47 | (#) When using the DMA mode |
mbed_official | 155:8435094ec241 | 48 | (++) Configure the DMA using DMA_Init() function. |
mbed_official | 155:8435094ec241 | 49 | (++) Active the needed channel Request using I2C_DMACmd() function. |
mbed_official | 155:8435094ec241 | 50 | (#) Enable the I2C using the I2C_Cmd() function. |
mbed_official | 155:8435094ec241 | 51 | (#) Enable the DMA using the DMA_Cmd() function when using DMA mode in the |
mbed_official | 155:8435094ec241 | 52 | transfers. |
mbed_official | 155:8435094ec241 | 53 | [..] |
mbed_official | 155:8435094ec241 | 54 | (@) When using I2C in Fast Mode Plus, SCL and SDA pin 20mA current drive capability |
mbed_official | 155:8435094ec241 | 55 | must be enabled by setting the driving capability control bit in SYSCFG. |
mbed_official | 155:8435094ec241 | 56 | |
mbed_official | 155:8435094ec241 | 57 | @endverbatim |
mbed_official | 155:8435094ec241 | 58 | ****************************************************************************** |
mbed_official | 155:8435094ec241 | 59 | * @attention |
mbed_official | 155:8435094ec241 | 60 | * |
mbed_official | 155:8435094ec241 | 61 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 155:8435094ec241 | 62 | * |
mbed_official | 155:8435094ec241 | 63 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 155:8435094ec241 | 64 | * are permitted provided that the following conditions are met: |
mbed_official | 155:8435094ec241 | 65 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 155:8435094ec241 | 66 | * this list of conditions and the following disclaimer. |
mbed_official | 155:8435094ec241 | 67 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 155:8435094ec241 | 68 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 155:8435094ec241 | 69 | * and/or other materials provided with the distribution. |
mbed_official | 155:8435094ec241 | 70 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 155:8435094ec241 | 71 | * may be used to endorse or promote products derived from this software |
mbed_official | 155:8435094ec241 | 72 | * without specific prior written permission. |
mbed_official | 155:8435094ec241 | 73 | * |
mbed_official | 155:8435094ec241 | 74 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 155:8435094ec241 | 75 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 155:8435094ec241 | 76 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 155:8435094ec241 | 77 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 155:8435094ec241 | 78 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 155:8435094ec241 | 79 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 155:8435094ec241 | 80 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 155:8435094ec241 | 81 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 155:8435094ec241 | 82 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 155:8435094ec241 | 83 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 155:8435094ec241 | 84 | * |
mbed_official | 155:8435094ec241 | 85 | ****************************************************************************** |
mbed_official | 155:8435094ec241 | 86 | */ |
mbed_official | 155:8435094ec241 | 87 | |
mbed_official | 155:8435094ec241 | 88 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 89 | #include "stm32f30x_i2c.h" |
mbed_official | 155:8435094ec241 | 90 | #include "stm32f30x_rcc.h" |
mbed_official | 155:8435094ec241 | 91 | |
mbed_official | 155:8435094ec241 | 92 | /** @addtogroup STM32F30x_StdPeriph_Driver |
mbed_official | 155:8435094ec241 | 93 | * @{ |
mbed_official | 155:8435094ec241 | 94 | */ |
mbed_official | 155:8435094ec241 | 95 | |
mbed_official | 155:8435094ec241 | 96 | /** @defgroup I2C |
mbed_official | 155:8435094ec241 | 97 | * @brief I2C driver modules |
mbed_official | 155:8435094ec241 | 98 | * @{ |
mbed_official | 155:8435094ec241 | 99 | */ |
mbed_official | 155:8435094ec241 | 100 | |
mbed_official | 155:8435094ec241 | 101 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 102 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 103 | |
mbed_official | 155:8435094ec241 | 104 | #define CR1_CLEAR_MASK ((uint32_t)0x00CFE0FF) /*<! I2C CR1 clear register Mask */ |
mbed_official | 155:8435094ec241 | 105 | #define CR2_CLEAR_MASK ((uint32_t)0x07FF7FFF) /*<! I2C CR2 clear register Mask */ |
mbed_official | 155:8435094ec241 | 106 | #define TIMING_CLEAR_MASK ((uint32_t)0xF0FFFFFF) /*<! I2C TIMING clear register Mask */ |
mbed_official | 155:8435094ec241 | 107 | #define ERROR_IT_MASK ((uint32_t)0x00003F00) /*<! I2C Error interrupt register Mask */ |
mbed_official | 155:8435094ec241 | 108 | #define TC_IT_MASK ((uint32_t)0x000000C0) /*<! I2C TC interrupt register Mask */ |
mbed_official | 155:8435094ec241 | 109 | |
mbed_official | 155:8435094ec241 | 110 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 111 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 112 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 113 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 155:8435094ec241 | 114 | |
mbed_official | 155:8435094ec241 | 115 | /** @defgroup I2C_Private_Functions |
mbed_official | 155:8435094ec241 | 116 | * @{ |
mbed_official | 155:8435094ec241 | 117 | */ |
mbed_official | 155:8435094ec241 | 118 | |
mbed_official | 155:8435094ec241 | 119 | |
mbed_official | 155:8435094ec241 | 120 | /** @defgroup I2C_Group1 Initialization and Configuration functions |
mbed_official | 155:8435094ec241 | 121 | * @brief Initialization and Configuration functions |
mbed_official | 155:8435094ec241 | 122 | * |
mbed_official | 155:8435094ec241 | 123 | @verbatim |
mbed_official | 155:8435094ec241 | 124 | =============================================================================== |
mbed_official | 155:8435094ec241 | 125 | ##### Initialization and Configuration functions ##### |
mbed_official | 155:8435094ec241 | 126 | =============================================================================== |
mbed_official | 155:8435094ec241 | 127 | [..] This section provides a set of functions allowing to initialize the I2C Mode, |
mbed_official | 155:8435094ec241 | 128 | I2C Timing, I2C filters, I2C Addressing mode, I2C OwnAddress1. |
mbed_official | 155:8435094ec241 | 129 | |
mbed_official | 155:8435094ec241 | 130 | [..] The I2C_Init() function follows the I2C configuration procedures (these procedures |
mbed_official | 155:8435094ec241 | 131 | are available in reference manual). |
mbed_official | 155:8435094ec241 | 132 | |
mbed_official | 155:8435094ec241 | 133 | [..] When the Software Reset is performed using I2C_SoftwareResetCmd() function, the internal |
mbed_official | 155:8435094ec241 | 134 | states machines are reset and communication control bits, as well as status bits come |
mbed_official | 155:8435094ec241 | 135 | back to their reset value. |
mbed_official | 155:8435094ec241 | 136 | |
mbed_official | 155:8435094ec241 | 137 | [..] Before enabling Stop mode using I2C_StopModeCmd() I2C Clock source must be set to |
mbed_official | 155:8435094ec241 | 138 | HSI and Digital filters must be disabled. |
mbed_official | 155:8435094ec241 | 139 | |
mbed_official | 155:8435094ec241 | 140 | [..] Before enabling Own Address 2 via I2C_DualAddressCmd() function, OA2 and mask should be |
mbed_official | 155:8435094ec241 | 141 | configured using I2C_OwnAddress2Config() function. |
mbed_official | 155:8435094ec241 | 142 | |
mbed_official | 155:8435094ec241 | 143 | [..] I2C_SlaveByteControlCmd() enable Slave byte control that allow user to get control of |
mbed_official | 155:8435094ec241 | 144 | each byte in slave mode when NBYTES is set to 0x01. |
mbed_official | 155:8435094ec241 | 145 | |
mbed_official | 155:8435094ec241 | 146 | @endverbatim |
mbed_official | 155:8435094ec241 | 147 | * @{ |
mbed_official | 155:8435094ec241 | 148 | */ |
mbed_official | 155:8435094ec241 | 149 | |
mbed_official | 155:8435094ec241 | 150 | /** |
mbed_official | 155:8435094ec241 | 151 | * @brief Deinitializes the I2Cx peripheral registers to their default reset values. |
mbed_official | 155:8435094ec241 | 152 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 153 | * @retval None |
mbed_official | 155:8435094ec241 | 154 | */ |
mbed_official | 155:8435094ec241 | 155 | void I2C_DeInit(I2C_TypeDef* I2Cx) |
mbed_official | 155:8435094ec241 | 156 | { |
mbed_official | 155:8435094ec241 | 157 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 158 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 159 | |
mbed_official | 155:8435094ec241 | 160 | if (I2Cx == I2C1) |
mbed_official | 155:8435094ec241 | 161 | { |
mbed_official | 155:8435094ec241 | 162 | /* Enable I2C1 reset state */ |
mbed_official | 155:8435094ec241 | 163 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, ENABLE); |
mbed_official | 155:8435094ec241 | 164 | /* Release I2C1 from reset state */ |
mbed_official | 155:8435094ec241 | 165 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C1, DISABLE); |
mbed_official | 155:8435094ec241 | 166 | } |
mbed_official | 155:8435094ec241 | 167 | else |
mbed_official | 155:8435094ec241 | 168 | { |
mbed_official | 155:8435094ec241 | 169 | /* Enable I2C2 reset state */ |
mbed_official | 155:8435094ec241 | 170 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, ENABLE); |
mbed_official | 155:8435094ec241 | 171 | /* Release I2C2 from reset state */ |
mbed_official | 155:8435094ec241 | 172 | RCC_APB1PeriphResetCmd(RCC_APB1Periph_I2C2, DISABLE); |
mbed_official | 155:8435094ec241 | 173 | } |
mbed_official | 155:8435094ec241 | 174 | } |
mbed_official | 155:8435094ec241 | 175 | |
mbed_official | 155:8435094ec241 | 176 | /** |
mbed_official | 155:8435094ec241 | 177 | * @brief Initializes the I2Cx peripheral according to the specified |
mbed_official | 155:8435094ec241 | 178 | * parameters in the I2C_InitStruct. |
mbed_official | 155:8435094ec241 | 179 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 180 | * @param I2C_InitStruct: pointer to a I2C_InitTypeDef structure that |
mbed_official | 155:8435094ec241 | 181 | * contains the configuration information for the specified I2C peripheral. |
mbed_official | 155:8435094ec241 | 182 | * @retval None |
mbed_official | 155:8435094ec241 | 183 | */ |
mbed_official | 155:8435094ec241 | 184 | void I2C_Init(I2C_TypeDef* I2Cx, I2C_InitTypeDef* I2C_InitStruct) |
mbed_official | 155:8435094ec241 | 185 | { |
mbed_official | 155:8435094ec241 | 186 | uint32_t tmpreg = 0; |
mbed_official | 155:8435094ec241 | 187 | |
mbed_official | 155:8435094ec241 | 188 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 189 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 190 | assert_param(IS_I2C_ANALOG_FILTER(I2C_InitStruct->I2C_AnalogFilter)); |
mbed_official | 155:8435094ec241 | 191 | assert_param(IS_I2C_DIGITAL_FILTER(I2C_InitStruct->I2C_DigitalFilter)); |
mbed_official | 155:8435094ec241 | 192 | assert_param(IS_I2C_MODE(I2C_InitStruct->I2C_Mode)); |
mbed_official | 155:8435094ec241 | 193 | assert_param(IS_I2C_OWN_ADDRESS1(I2C_InitStruct->I2C_OwnAddress1)); |
mbed_official | 155:8435094ec241 | 194 | assert_param(IS_I2C_ACK(I2C_InitStruct->I2C_Ack)); |
mbed_official | 155:8435094ec241 | 195 | assert_param(IS_I2C_ACKNOWLEDGE_ADDRESS(I2C_InitStruct->I2C_AcknowledgedAddress)); |
mbed_official | 155:8435094ec241 | 196 | |
mbed_official | 155:8435094ec241 | 197 | /* Disable I2Cx Peripheral */ |
mbed_official | 155:8435094ec241 | 198 | I2Cx->CR1 &= (uint32_t)~((uint32_t)I2C_CR1_PE); |
mbed_official | 155:8435094ec241 | 199 | |
mbed_official | 155:8435094ec241 | 200 | /*---------------------------- I2Cx FILTERS Configuration ------------------*/ |
mbed_official | 155:8435094ec241 | 201 | /* Get the I2Cx CR1 value */ |
mbed_official | 155:8435094ec241 | 202 | tmpreg = I2Cx->CR1; |
mbed_official | 155:8435094ec241 | 203 | /* Clear I2Cx CR1 register */ |
mbed_official | 155:8435094ec241 | 204 | tmpreg &= CR1_CLEAR_MASK; |
mbed_official | 155:8435094ec241 | 205 | /* Configure I2Cx: analog and digital filter */ |
mbed_official | 155:8435094ec241 | 206 | /* Set ANFOFF bit according to I2C_AnalogFilter value */ |
mbed_official | 155:8435094ec241 | 207 | /* Set DFN bits according to I2C_DigitalFilter value */ |
mbed_official | 155:8435094ec241 | 208 | tmpreg |= (uint32_t)I2C_InitStruct->I2C_AnalogFilter |(I2C_InitStruct->I2C_DigitalFilter << 8); |
mbed_official | 155:8435094ec241 | 209 | |
mbed_official | 155:8435094ec241 | 210 | /* Write to I2Cx CR1 */ |
mbed_official | 155:8435094ec241 | 211 | I2Cx->CR1 = tmpreg; |
mbed_official | 155:8435094ec241 | 212 | |
mbed_official | 155:8435094ec241 | 213 | /*---------------------------- I2Cx TIMING Configuration -------------------*/ |
mbed_official | 155:8435094ec241 | 214 | /* Configure I2Cx: Timing */ |
mbed_official | 155:8435094ec241 | 215 | /* Set TIMINGR bits according to I2C_Timing */ |
mbed_official | 155:8435094ec241 | 216 | /* Write to I2Cx TIMING */ |
mbed_official | 155:8435094ec241 | 217 | I2Cx->TIMINGR = I2C_InitStruct->I2C_Timing & TIMING_CLEAR_MASK; |
mbed_official | 155:8435094ec241 | 218 | |
mbed_official | 155:8435094ec241 | 219 | /* Enable I2Cx Peripheral */ |
mbed_official | 155:8435094ec241 | 220 | I2Cx->CR1 |= I2C_CR1_PE; |
mbed_official | 155:8435094ec241 | 221 | |
mbed_official | 155:8435094ec241 | 222 | /*---------------------------- I2Cx OAR1 Configuration ---------------------*/ |
mbed_official | 155:8435094ec241 | 223 | /* Clear tmpreg local variable */ |
mbed_official | 155:8435094ec241 | 224 | tmpreg = 0; |
mbed_official | 155:8435094ec241 | 225 | /* Clear OAR1 register */ |
mbed_official | 155:8435094ec241 | 226 | I2Cx->OAR1 = (uint32_t)tmpreg; |
mbed_official | 155:8435094ec241 | 227 | /* Clear OAR2 register */ |
mbed_official | 155:8435094ec241 | 228 | I2Cx->OAR2 = (uint32_t)tmpreg; |
mbed_official | 155:8435094ec241 | 229 | /* Configure I2Cx: Own Address1 and acknowledged address */ |
mbed_official | 155:8435094ec241 | 230 | /* Set OA1MODE bit according to I2C_AcknowledgedAddress value */ |
mbed_official | 155:8435094ec241 | 231 | /* Set OA1 bits according to I2C_OwnAddress1 value */ |
mbed_official | 155:8435094ec241 | 232 | tmpreg = (uint32_t)((uint32_t)I2C_InitStruct->I2C_AcknowledgedAddress | \ |
mbed_official | 155:8435094ec241 | 233 | (uint32_t)I2C_InitStruct->I2C_OwnAddress1); |
mbed_official | 155:8435094ec241 | 234 | /* Write to I2Cx OAR1 */ |
mbed_official | 155:8435094ec241 | 235 | I2Cx->OAR1 = tmpreg; |
mbed_official | 155:8435094ec241 | 236 | /* Enable Own Address1 acknowledgement */ |
mbed_official | 155:8435094ec241 | 237 | I2Cx->OAR1 |= I2C_OAR1_OA1EN; |
mbed_official | 155:8435094ec241 | 238 | |
mbed_official | 155:8435094ec241 | 239 | /*---------------------------- I2Cx MODE Configuration ---------------------*/ |
mbed_official | 155:8435094ec241 | 240 | /* Configure I2Cx: mode */ |
mbed_official | 155:8435094ec241 | 241 | /* Set SMBDEN and SMBHEN bits according to I2C_Mode value */ |
mbed_official | 155:8435094ec241 | 242 | tmpreg = I2C_InitStruct->I2C_Mode; |
mbed_official | 155:8435094ec241 | 243 | /* Write to I2Cx CR1 */ |
mbed_official | 155:8435094ec241 | 244 | I2Cx->CR1 |= tmpreg; |
mbed_official | 155:8435094ec241 | 245 | |
mbed_official | 155:8435094ec241 | 246 | /*---------------------------- I2Cx ACK Configuration ----------------------*/ |
mbed_official | 155:8435094ec241 | 247 | /* Get the I2Cx CR2 value */ |
mbed_official | 155:8435094ec241 | 248 | tmpreg = I2Cx->CR2; |
mbed_official | 155:8435094ec241 | 249 | /* Clear I2Cx CR2 register */ |
mbed_official | 155:8435094ec241 | 250 | tmpreg &= CR2_CLEAR_MASK; |
mbed_official | 155:8435094ec241 | 251 | /* Configure I2Cx: acknowledgement */ |
mbed_official | 155:8435094ec241 | 252 | /* Set NACK bit according to I2C_Ack value */ |
mbed_official | 155:8435094ec241 | 253 | tmpreg |= I2C_InitStruct->I2C_Ack; |
mbed_official | 155:8435094ec241 | 254 | /* Write to I2Cx CR2 */ |
mbed_official | 155:8435094ec241 | 255 | I2Cx->CR2 = tmpreg; |
mbed_official | 155:8435094ec241 | 256 | } |
mbed_official | 155:8435094ec241 | 257 | |
mbed_official | 155:8435094ec241 | 258 | /** |
mbed_official | 155:8435094ec241 | 259 | * @brief Fills each I2C_InitStruct member with its default value. |
mbed_official | 155:8435094ec241 | 260 | * @param I2C_InitStruct: pointer to an I2C_InitTypeDef structure which will be initialized. |
mbed_official | 155:8435094ec241 | 261 | * @retval None |
mbed_official | 155:8435094ec241 | 262 | */ |
mbed_official | 155:8435094ec241 | 263 | void I2C_StructInit(I2C_InitTypeDef* I2C_InitStruct) |
mbed_official | 155:8435094ec241 | 264 | { |
mbed_official | 155:8435094ec241 | 265 | /*---------------- Reset I2C init structure parameters values --------------*/ |
mbed_official | 155:8435094ec241 | 266 | /* Initialize the I2C_Timing member */ |
mbed_official | 155:8435094ec241 | 267 | I2C_InitStruct->I2C_Timing = 0; |
mbed_official | 155:8435094ec241 | 268 | /* Initialize the I2C_AnalogFilter member */ |
mbed_official | 155:8435094ec241 | 269 | I2C_InitStruct->I2C_AnalogFilter = I2C_AnalogFilter_Enable; |
mbed_official | 155:8435094ec241 | 270 | /* Initialize the I2C_DigitalFilter member */ |
mbed_official | 155:8435094ec241 | 271 | I2C_InitStruct->I2C_DigitalFilter = 0; |
mbed_official | 155:8435094ec241 | 272 | /* Initialize the I2C_Mode member */ |
mbed_official | 155:8435094ec241 | 273 | I2C_InitStruct->I2C_Mode = I2C_Mode_I2C; |
mbed_official | 155:8435094ec241 | 274 | /* Initialize the I2C_OwnAddress1 member */ |
mbed_official | 155:8435094ec241 | 275 | I2C_InitStruct->I2C_OwnAddress1 = 0; |
mbed_official | 155:8435094ec241 | 276 | /* Initialize the I2C_Ack member */ |
mbed_official | 155:8435094ec241 | 277 | I2C_InitStruct->I2C_Ack = I2C_Ack_Disable; |
mbed_official | 155:8435094ec241 | 278 | /* Initialize the I2C_AcknowledgedAddress member */ |
mbed_official | 155:8435094ec241 | 279 | I2C_InitStruct->I2C_AcknowledgedAddress = I2C_AcknowledgedAddress_7bit; |
mbed_official | 155:8435094ec241 | 280 | } |
mbed_official | 155:8435094ec241 | 281 | |
mbed_official | 155:8435094ec241 | 282 | /** |
mbed_official | 155:8435094ec241 | 283 | * @brief Enables or disables the specified I2C peripheral. |
mbed_official | 155:8435094ec241 | 284 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 285 | * @param NewState: new state of the I2Cx peripheral. |
mbed_official | 155:8435094ec241 | 286 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 287 | * @retval None |
mbed_official | 155:8435094ec241 | 288 | */ |
mbed_official | 155:8435094ec241 | 289 | void I2C_Cmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 290 | { |
mbed_official | 155:8435094ec241 | 291 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 292 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 293 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 294 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 295 | { |
mbed_official | 155:8435094ec241 | 296 | /* Enable the selected I2C peripheral */ |
mbed_official | 155:8435094ec241 | 297 | I2Cx->CR1 |= I2C_CR1_PE; |
mbed_official | 155:8435094ec241 | 298 | } |
mbed_official | 155:8435094ec241 | 299 | else |
mbed_official | 155:8435094ec241 | 300 | { |
mbed_official | 155:8435094ec241 | 301 | /* Disable the selected I2C peripheral */ |
mbed_official | 155:8435094ec241 | 302 | I2Cx->CR1 &= (uint32_t)~((uint32_t)I2C_CR1_PE); |
mbed_official | 155:8435094ec241 | 303 | } |
mbed_official | 155:8435094ec241 | 304 | } |
mbed_official | 155:8435094ec241 | 305 | |
mbed_official | 155:8435094ec241 | 306 | |
mbed_official | 155:8435094ec241 | 307 | /** |
mbed_official | 155:8435094ec241 | 308 | * @brief Enables or disables the specified I2C software reset. |
mbed_official | 155:8435094ec241 | 309 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 310 | * @retval None |
mbed_official | 155:8435094ec241 | 311 | */ |
mbed_official | 155:8435094ec241 | 312 | void I2C_SoftwareResetCmd(I2C_TypeDef* I2Cx) |
mbed_official | 155:8435094ec241 | 313 | { |
mbed_official | 155:8435094ec241 | 314 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 315 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 316 | |
mbed_official | 155:8435094ec241 | 317 | /* Disable peripheral */ |
mbed_official | 155:8435094ec241 | 318 | I2Cx->CR1 &= (uint32_t)~((uint32_t)I2C_CR1_PE); |
mbed_official | 155:8435094ec241 | 319 | |
mbed_official | 155:8435094ec241 | 320 | /* Perform a dummy read to delay the disable of peripheral for minimum |
mbed_official | 155:8435094ec241 | 321 | 3 APB clock cycles to perform the software reset functionality */ |
mbed_official | 155:8435094ec241 | 322 | *(__IO uint32_t *)(uint32_t)I2Cx; |
mbed_official | 155:8435094ec241 | 323 | |
mbed_official | 155:8435094ec241 | 324 | /* Enable peripheral */ |
mbed_official | 155:8435094ec241 | 325 | I2Cx->CR1 |= I2C_CR1_PE; |
mbed_official | 155:8435094ec241 | 326 | } |
mbed_official | 155:8435094ec241 | 327 | |
mbed_official | 155:8435094ec241 | 328 | /** |
mbed_official | 155:8435094ec241 | 329 | * @brief Enables or disables the specified I2C interrupts. |
mbed_official | 155:8435094ec241 | 330 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 331 | * @param I2C_IT: specifies the I2C interrupts sources to be enabled or disabled. |
mbed_official | 155:8435094ec241 | 332 | * This parameter can be any combination of the following values: |
mbed_official | 155:8435094ec241 | 333 | * @arg I2C_IT_ERRI: Error interrupt mask |
mbed_official | 155:8435094ec241 | 334 | * @arg I2C_IT_TCI: Transfer Complete interrupt mask |
mbed_official | 155:8435094ec241 | 335 | * @arg I2C_IT_STOPI: Stop Detection interrupt mask |
mbed_official | 155:8435094ec241 | 336 | * @arg I2C_IT_NACKI: Not Acknowledge received interrupt mask |
mbed_official | 155:8435094ec241 | 337 | * @arg I2C_IT_ADDRI: Address Match interrupt mask |
mbed_official | 155:8435094ec241 | 338 | * @arg I2C_IT_RXI: RX interrupt mask |
mbed_official | 155:8435094ec241 | 339 | * @arg I2C_IT_TXI: TX interrupt mask |
mbed_official | 155:8435094ec241 | 340 | * @param NewState: new state of the specified I2C interrupts. |
mbed_official | 155:8435094ec241 | 341 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 342 | * @retval None |
mbed_official | 155:8435094ec241 | 343 | */ |
mbed_official | 155:8435094ec241 | 344 | void I2C_ITConfig(I2C_TypeDef* I2Cx, uint32_t I2C_IT, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 345 | { |
mbed_official | 155:8435094ec241 | 346 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 347 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 348 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 349 | assert_param(IS_I2C_CONFIG_IT(I2C_IT)); |
mbed_official | 155:8435094ec241 | 350 | |
mbed_official | 155:8435094ec241 | 351 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 352 | { |
mbed_official | 155:8435094ec241 | 353 | /* Enable the selected I2C interrupts */ |
mbed_official | 155:8435094ec241 | 354 | I2Cx->CR1 |= I2C_IT; |
mbed_official | 155:8435094ec241 | 355 | } |
mbed_official | 155:8435094ec241 | 356 | else |
mbed_official | 155:8435094ec241 | 357 | { |
mbed_official | 155:8435094ec241 | 358 | /* Disable the selected I2C interrupts */ |
mbed_official | 155:8435094ec241 | 359 | I2Cx->CR1 &= (uint32_t)~((uint32_t)I2C_IT); |
mbed_official | 155:8435094ec241 | 360 | } |
mbed_official | 155:8435094ec241 | 361 | } |
mbed_official | 155:8435094ec241 | 362 | |
mbed_official | 155:8435094ec241 | 363 | /** |
mbed_official | 155:8435094ec241 | 364 | * @brief Enables or disables the I2C Clock stretching. |
mbed_official | 155:8435094ec241 | 365 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 366 | * @param NewState: new state of the I2Cx Clock stretching. |
mbed_official | 155:8435094ec241 | 367 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 368 | * @retval None |
mbed_official | 155:8435094ec241 | 369 | */ |
mbed_official | 155:8435094ec241 | 370 | void I2C_StretchClockCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 371 | { |
mbed_official | 155:8435094ec241 | 372 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 373 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 374 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 375 | |
mbed_official | 155:8435094ec241 | 376 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 377 | { |
mbed_official | 155:8435094ec241 | 378 | /* Enable clock stretching */ |
mbed_official | 155:8435094ec241 | 379 | I2Cx->CR1 &= (uint32_t)~((uint32_t)I2C_CR1_NOSTRETCH); |
mbed_official | 155:8435094ec241 | 380 | } |
mbed_official | 155:8435094ec241 | 381 | else |
mbed_official | 155:8435094ec241 | 382 | { |
mbed_official | 155:8435094ec241 | 383 | /* Disable clock stretching */ |
mbed_official | 155:8435094ec241 | 384 | I2Cx->CR1 |= I2C_CR1_NOSTRETCH; |
mbed_official | 155:8435094ec241 | 385 | } |
mbed_official | 155:8435094ec241 | 386 | } |
mbed_official | 155:8435094ec241 | 387 | |
mbed_official | 155:8435094ec241 | 388 | /** |
mbed_official | 155:8435094ec241 | 389 | * @brief Enables or disables I2C wakeup from stop mode. |
mbed_official | 155:8435094ec241 | 390 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 391 | * @param NewState: new state of the I2Cx stop mode. |
mbed_official | 155:8435094ec241 | 392 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 393 | * @retval None |
mbed_official | 155:8435094ec241 | 394 | */ |
mbed_official | 155:8435094ec241 | 395 | void I2C_StopModeCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 396 | { |
mbed_official | 155:8435094ec241 | 397 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 398 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 399 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 400 | |
mbed_official | 155:8435094ec241 | 401 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 402 | { |
mbed_official | 155:8435094ec241 | 403 | /* Enable wakeup from stop mode */ |
mbed_official | 155:8435094ec241 | 404 | I2Cx->CR1 |= I2C_CR1_WUPEN; |
mbed_official | 155:8435094ec241 | 405 | } |
mbed_official | 155:8435094ec241 | 406 | else |
mbed_official | 155:8435094ec241 | 407 | { |
mbed_official | 155:8435094ec241 | 408 | /* Disable wakeup from stop mode */ |
mbed_official | 155:8435094ec241 | 409 | I2Cx->CR1 &= (uint32_t)~((uint32_t)I2C_CR1_WUPEN); |
mbed_official | 155:8435094ec241 | 410 | } |
mbed_official | 155:8435094ec241 | 411 | } |
mbed_official | 155:8435094ec241 | 412 | |
mbed_official | 155:8435094ec241 | 413 | /** |
mbed_official | 155:8435094ec241 | 414 | * @brief Enables or disables the I2C own address 2. |
mbed_official | 155:8435094ec241 | 415 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 416 | * @param NewState: new state of the I2C own address 2. |
mbed_official | 155:8435094ec241 | 417 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 418 | * @retval None |
mbed_official | 155:8435094ec241 | 419 | */ |
mbed_official | 155:8435094ec241 | 420 | void I2C_DualAddressCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 421 | { |
mbed_official | 155:8435094ec241 | 422 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 423 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 424 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 425 | |
mbed_official | 155:8435094ec241 | 426 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 427 | { |
mbed_official | 155:8435094ec241 | 428 | /* Enable own address 2 */ |
mbed_official | 155:8435094ec241 | 429 | I2Cx->OAR2 |= I2C_OAR2_OA2EN; |
mbed_official | 155:8435094ec241 | 430 | } |
mbed_official | 155:8435094ec241 | 431 | else |
mbed_official | 155:8435094ec241 | 432 | { |
mbed_official | 155:8435094ec241 | 433 | /* Disable own address 2 */ |
mbed_official | 155:8435094ec241 | 434 | I2Cx->OAR2 &= (uint32_t)~((uint32_t)I2C_OAR2_OA2EN); |
mbed_official | 155:8435094ec241 | 435 | } |
mbed_official | 155:8435094ec241 | 436 | } |
mbed_official | 155:8435094ec241 | 437 | |
mbed_official | 155:8435094ec241 | 438 | /** |
mbed_official | 155:8435094ec241 | 439 | * @brief Configures the I2C slave own address 2 and mask. |
mbed_official | 155:8435094ec241 | 440 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 441 | * @param Address: specifies the slave address to be programmed. |
mbed_official | 155:8435094ec241 | 442 | * @param Mask: specifies own address 2 mask to be programmed. |
mbed_official | 155:8435094ec241 | 443 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 444 | * @arg I2C_OA2_NoMask: no mask. |
mbed_official | 155:8435094ec241 | 445 | * @arg I2C_OA2_Mask01: OA2[1] is masked and don't care. |
mbed_official | 155:8435094ec241 | 446 | * @arg I2C_OA2_Mask02: OA2[2:1] are masked and don't care. |
mbed_official | 155:8435094ec241 | 447 | * @arg I2C_OA2_Mask03: OA2[3:1] are masked and don't care. |
mbed_official | 155:8435094ec241 | 448 | * @arg I2C_OA2_Mask04: OA2[4:1] are masked and don't care. |
mbed_official | 155:8435094ec241 | 449 | * @arg I2C_OA2_Mask05: OA2[5:1] are masked and don't care. |
mbed_official | 155:8435094ec241 | 450 | * @arg I2C_OA2_Mask06: OA2[6:1] are masked and don't care. |
mbed_official | 155:8435094ec241 | 451 | * @arg I2C_OA2_Mask07: OA2[7:1] are masked and don't care. |
mbed_official | 155:8435094ec241 | 452 | * @retval None |
mbed_official | 155:8435094ec241 | 453 | */ |
mbed_official | 155:8435094ec241 | 454 | void I2C_OwnAddress2Config(I2C_TypeDef* I2Cx, uint16_t Address, uint8_t Mask) |
mbed_official | 155:8435094ec241 | 455 | { |
mbed_official | 155:8435094ec241 | 456 | uint32_t tmpreg = 0; |
mbed_official | 155:8435094ec241 | 457 | |
mbed_official | 155:8435094ec241 | 458 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 459 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 460 | assert_param(IS_I2C_OWN_ADDRESS2(Address)); |
mbed_official | 155:8435094ec241 | 461 | assert_param(IS_I2C_OWN_ADDRESS2_MASK(Mask)); |
mbed_official | 155:8435094ec241 | 462 | |
mbed_official | 155:8435094ec241 | 463 | /* Get the old register value */ |
mbed_official | 155:8435094ec241 | 464 | tmpreg = I2Cx->OAR2; |
mbed_official | 155:8435094ec241 | 465 | |
mbed_official | 155:8435094ec241 | 466 | /* Reset I2Cx OA2 bit [7:1] and OA2MSK bit [1:0] */ |
mbed_official | 155:8435094ec241 | 467 | tmpreg &= (uint32_t)~((uint32_t)(I2C_OAR2_OA2 | I2C_OAR2_OA2MSK)); |
mbed_official | 155:8435094ec241 | 468 | |
mbed_official | 155:8435094ec241 | 469 | /* Set I2Cx SADD */ |
mbed_official | 155:8435094ec241 | 470 | tmpreg |= (uint32_t)(((uint32_t)Address & I2C_OAR2_OA2) | \ |
mbed_official | 155:8435094ec241 | 471 | (((uint32_t)Mask << 8) & I2C_OAR2_OA2MSK)) ; |
mbed_official | 155:8435094ec241 | 472 | |
mbed_official | 155:8435094ec241 | 473 | /* Store the new register value */ |
mbed_official | 155:8435094ec241 | 474 | I2Cx->OAR2 = tmpreg; |
mbed_official | 155:8435094ec241 | 475 | } |
mbed_official | 155:8435094ec241 | 476 | |
mbed_official | 155:8435094ec241 | 477 | /** |
mbed_official | 155:8435094ec241 | 478 | * @brief Enables or disables the I2C general call mode. |
mbed_official | 155:8435094ec241 | 479 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 480 | * @param NewState: new state of the I2C general call mode. |
mbed_official | 155:8435094ec241 | 481 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 482 | * @retval None |
mbed_official | 155:8435094ec241 | 483 | */ |
mbed_official | 155:8435094ec241 | 484 | void I2C_GeneralCallCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 485 | { |
mbed_official | 155:8435094ec241 | 486 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 487 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 488 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 489 | |
mbed_official | 155:8435094ec241 | 490 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 491 | { |
mbed_official | 155:8435094ec241 | 492 | /* Enable general call mode */ |
mbed_official | 155:8435094ec241 | 493 | I2Cx->CR1 |= I2C_CR1_GCEN; |
mbed_official | 155:8435094ec241 | 494 | } |
mbed_official | 155:8435094ec241 | 495 | else |
mbed_official | 155:8435094ec241 | 496 | { |
mbed_official | 155:8435094ec241 | 497 | /* Disable general call mode */ |
mbed_official | 155:8435094ec241 | 498 | I2Cx->CR1 &= (uint32_t)~((uint32_t)I2C_CR1_GCEN); |
mbed_official | 155:8435094ec241 | 499 | } |
mbed_official | 155:8435094ec241 | 500 | } |
mbed_official | 155:8435094ec241 | 501 | |
mbed_official | 155:8435094ec241 | 502 | /** |
mbed_official | 155:8435094ec241 | 503 | * @brief Enables or disables the I2C slave byte control. |
mbed_official | 155:8435094ec241 | 504 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 505 | * @param NewState: new state of the I2C slave byte control. |
mbed_official | 155:8435094ec241 | 506 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 507 | * @retval None |
mbed_official | 155:8435094ec241 | 508 | */ |
mbed_official | 155:8435094ec241 | 509 | void I2C_SlaveByteControlCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 510 | { |
mbed_official | 155:8435094ec241 | 511 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 512 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 513 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 514 | |
mbed_official | 155:8435094ec241 | 515 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 516 | { |
mbed_official | 155:8435094ec241 | 517 | /* Enable slave byte control */ |
mbed_official | 155:8435094ec241 | 518 | I2Cx->CR1 |= I2C_CR1_SBC; |
mbed_official | 155:8435094ec241 | 519 | } |
mbed_official | 155:8435094ec241 | 520 | else |
mbed_official | 155:8435094ec241 | 521 | { |
mbed_official | 155:8435094ec241 | 522 | /* Disable slave byte control */ |
mbed_official | 155:8435094ec241 | 523 | I2Cx->CR1 &= (uint32_t)~((uint32_t)I2C_CR1_SBC); |
mbed_official | 155:8435094ec241 | 524 | } |
mbed_official | 155:8435094ec241 | 525 | } |
mbed_official | 155:8435094ec241 | 526 | |
mbed_official | 155:8435094ec241 | 527 | /** |
mbed_official | 155:8435094ec241 | 528 | * @brief Configures the slave address to be transmitted after start generation. |
mbed_official | 155:8435094ec241 | 529 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 530 | * @param Address: specifies the slave address to be programmed. |
mbed_official | 155:8435094ec241 | 531 | * @note This function should be called before generating start condition. |
mbed_official | 155:8435094ec241 | 532 | * @retval None |
mbed_official | 155:8435094ec241 | 533 | */ |
mbed_official | 155:8435094ec241 | 534 | void I2C_SlaveAddressConfig(I2C_TypeDef* I2Cx, uint16_t Address) |
mbed_official | 155:8435094ec241 | 535 | { |
mbed_official | 155:8435094ec241 | 536 | uint32_t tmpreg = 0; |
mbed_official | 155:8435094ec241 | 537 | |
mbed_official | 155:8435094ec241 | 538 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 539 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 540 | assert_param(IS_I2C_SLAVE_ADDRESS(Address)); |
mbed_official | 155:8435094ec241 | 541 | |
mbed_official | 155:8435094ec241 | 542 | /* Get the old register value */ |
mbed_official | 155:8435094ec241 | 543 | tmpreg = I2Cx->CR2; |
mbed_official | 155:8435094ec241 | 544 | |
mbed_official | 155:8435094ec241 | 545 | /* Reset I2Cx SADD bit [9:0] */ |
mbed_official | 155:8435094ec241 | 546 | tmpreg &= (uint32_t)~((uint32_t)I2C_CR2_SADD); |
mbed_official | 155:8435094ec241 | 547 | |
mbed_official | 155:8435094ec241 | 548 | /* Set I2Cx SADD */ |
mbed_official | 155:8435094ec241 | 549 | tmpreg |= (uint32_t)((uint32_t)Address & I2C_CR2_SADD); |
mbed_official | 155:8435094ec241 | 550 | |
mbed_official | 155:8435094ec241 | 551 | /* Store the new register value */ |
mbed_official | 155:8435094ec241 | 552 | I2Cx->CR2 = tmpreg; |
mbed_official | 155:8435094ec241 | 553 | } |
mbed_official | 155:8435094ec241 | 554 | |
mbed_official | 155:8435094ec241 | 555 | /** |
mbed_official | 155:8435094ec241 | 556 | * @brief Enables or disables the I2C 10-bit addressing mode for the master. |
mbed_official | 155:8435094ec241 | 557 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 558 | * @param NewState: new state of the I2C 10-bit addressing mode. |
mbed_official | 155:8435094ec241 | 559 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 560 | * @note This function should be called before generating start condition. |
mbed_official | 155:8435094ec241 | 561 | * @retval None |
mbed_official | 155:8435094ec241 | 562 | */ |
mbed_official | 155:8435094ec241 | 563 | void I2C_10BitAddressingModeCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 564 | { |
mbed_official | 155:8435094ec241 | 565 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 566 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 567 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 568 | |
mbed_official | 155:8435094ec241 | 569 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 570 | { |
mbed_official | 155:8435094ec241 | 571 | /* Enable 10-bit addressing mode */ |
mbed_official | 155:8435094ec241 | 572 | I2Cx->CR2 |= I2C_CR2_ADD10; |
mbed_official | 155:8435094ec241 | 573 | } |
mbed_official | 155:8435094ec241 | 574 | else |
mbed_official | 155:8435094ec241 | 575 | { |
mbed_official | 155:8435094ec241 | 576 | /* Disable 10-bit addressing mode */ |
mbed_official | 155:8435094ec241 | 577 | I2Cx->CR2 &= (uint32_t)~((uint32_t)I2C_CR2_ADD10); |
mbed_official | 155:8435094ec241 | 578 | } |
mbed_official | 155:8435094ec241 | 579 | } |
mbed_official | 155:8435094ec241 | 580 | |
mbed_official | 155:8435094ec241 | 581 | /** |
mbed_official | 155:8435094ec241 | 582 | * @} |
mbed_official | 155:8435094ec241 | 583 | */ |
mbed_official | 155:8435094ec241 | 584 | |
mbed_official | 155:8435094ec241 | 585 | |
mbed_official | 155:8435094ec241 | 586 | /** @defgroup I2C_Group2 Communications handling functions |
mbed_official | 155:8435094ec241 | 587 | * @brief Communications handling functions |
mbed_official | 155:8435094ec241 | 588 | * |
mbed_official | 155:8435094ec241 | 589 | @verbatim |
mbed_official | 155:8435094ec241 | 590 | =============================================================================== |
mbed_official | 155:8435094ec241 | 591 | ##### Communications handling functions ##### |
mbed_official | 155:8435094ec241 | 592 | =============================================================================== |
mbed_official | 155:8435094ec241 | 593 | [..] This section provides a set of functions that handles I2C communication. |
mbed_official | 155:8435094ec241 | 594 | |
mbed_official | 155:8435094ec241 | 595 | [..] Automatic End mode is enabled using I2C_AutoEndCmd() function. When Reload |
mbed_official | 155:8435094ec241 | 596 | mode is enabled via I2C_ReloadCmd() AutoEnd bit has no effect. |
mbed_official | 155:8435094ec241 | 597 | |
mbed_official | 155:8435094ec241 | 598 | [..] I2C_NumberOfBytesConfig() function set the number of bytes to be transferred, |
mbed_official | 155:8435094ec241 | 599 | this configuration should be done before generating start condition in master |
mbed_official | 155:8435094ec241 | 600 | mode. |
mbed_official | 155:8435094ec241 | 601 | |
mbed_official | 155:8435094ec241 | 602 | [..] When switching from master write operation to read operation in 10Bit addressing |
mbed_official | 155:8435094ec241 | 603 | mode, master can only sends the 1st 7 bits of the 10 bit address, followed by |
mbed_official | 155:8435094ec241 | 604 | Read direction by enabling HEADR bit using I2C_10BitAddressHeader() function. |
mbed_official | 155:8435094ec241 | 605 | |
mbed_official | 155:8435094ec241 | 606 | [..] In master mode, when transferring more than 255 bytes Reload mode should be used |
mbed_official | 155:8435094ec241 | 607 | to handle communication. In the first phase of transfer, Nbytes should be set to |
mbed_official | 155:8435094ec241 | 608 | 255. After transferring these bytes TCR flag is set and I2C_TransferHandling() |
mbed_official | 155:8435094ec241 | 609 | function should be called to handle remaining communication. |
mbed_official | 155:8435094ec241 | 610 | |
mbed_official | 155:8435094ec241 | 611 | [..] In master mode, when software end mode is selected when all data is transferred |
mbed_official | 155:8435094ec241 | 612 | TC flag is set I2C_TransferHandling() function should be called to generate STOP |
mbed_official | 155:8435094ec241 | 613 | or generate ReStart. |
mbed_official | 155:8435094ec241 | 614 | |
mbed_official | 155:8435094ec241 | 615 | @endverbatim |
mbed_official | 155:8435094ec241 | 616 | * @{ |
mbed_official | 155:8435094ec241 | 617 | */ |
mbed_official | 155:8435094ec241 | 618 | |
mbed_official | 155:8435094ec241 | 619 | /** |
mbed_official | 155:8435094ec241 | 620 | * @brief Enables or disables the I2C automatic end mode (stop condition is |
mbed_official | 155:8435094ec241 | 621 | * automatically sent when nbytes data are transferred). |
mbed_official | 155:8435094ec241 | 622 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 623 | * @param NewState: new state of the I2C automatic end mode. |
mbed_official | 155:8435094ec241 | 624 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 625 | * @note This function has effect if Reload mode is disabled. |
mbed_official | 155:8435094ec241 | 626 | * @retval None |
mbed_official | 155:8435094ec241 | 627 | */ |
mbed_official | 155:8435094ec241 | 628 | void I2C_AutoEndCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 629 | { |
mbed_official | 155:8435094ec241 | 630 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 631 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 632 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 633 | |
mbed_official | 155:8435094ec241 | 634 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 635 | { |
mbed_official | 155:8435094ec241 | 636 | /* Enable Auto end mode */ |
mbed_official | 155:8435094ec241 | 637 | I2Cx->CR2 |= I2C_CR2_AUTOEND; |
mbed_official | 155:8435094ec241 | 638 | } |
mbed_official | 155:8435094ec241 | 639 | else |
mbed_official | 155:8435094ec241 | 640 | { |
mbed_official | 155:8435094ec241 | 641 | /* Disable Auto end mode */ |
mbed_official | 155:8435094ec241 | 642 | I2Cx->CR2 &= (uint32_t)~((uint32_t)I2C_CR2_AUTOEND); |
mbed_official | 155:8435094ec241 | 643 | } |
mbed_official | 155:8435094ec241 | 644 | } |
mbed_official | 155:8435094ec241 | 645 | |
mbed_official | 155:8435094ec241 | 646 | /** |
mbed_official | 155:8435094ec241 | 647 | * @brief Enables or disables the I2C nbytes reload mode. |
mbed_official | 155:8435094ec241 | 648 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 649 | * @param NewState: new state of the nbytes reload mode. |
mbed_official | 155:8435094ec241 | 650 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 651 | * @retval None |
mbed_official | 155:8435094ec241 | 652 | */ |
mbed_official | 155:8435094ec241 | 653 | void I2C_ReloadCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 654 | { |
mbed_official | 155:8435094ec241 | 655 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 656 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 657 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 658 | |
mbed_official | 155:8435094ec241 | 659 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 660 | { |
mbed_official | 155:8435094ec241 | 661 | /* Enable Auto Reload mode */ |
mbed_official | 155:8435094ec241 | 662 | I2Cx->CR2 |= I2C_CR2_RELOAD; |
mbed_official | 155:8435094ec241 | 663 | } |
mbed_official | 155:8435094ec241 | 664 | else |
mbed_official | 155:8435094ec241 | 665 | { |
mbed_official | 155:8435094ec241 | 666 | /* Disable Auto Reload mode */ |
mbed_official | 155:8435094ec241 | 667 | I2Cx->CR2 &= (uint32_t)~((uint32_t)I2C_CR2_RELOAD); |
mbed_official | 155:8435094ec241 | 668 | } |
mbed_official | 155:8435094ec241 | 669 | } |
mbed_official | 155:8435094ec241 | 670 | |
mbed_official | 155:8435094ec241 | 671 | /** |
mbed_official | 155:8435094ec241 | 672 | * @brief Configures the number of bytes to be transmitted/received. |
mbed_official | 155:8435094ec241 | 673 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 674 | * @param Number_Bytes: specifies the number of bytes to be programmed. |
mbed_official | 155:8435094ec241 | 675 | * @retval None |
mbed_official | 155:8435094ec241 | 676 | */ |
mbed_official | 155:8435094ec241 | 677 | void I2C_NumberOfBytesConfig(I2C_TypeDef* I2Cx, uint8_t Number_Bytes) |
mbed_official | 155:8435094ec241 | 678 | { |
mbed_official | 155:8435094ec241 | 679 | uint32_t tmpreg = 0; |
mbed_official | 155:8435094ec241 | 680 | |
mbed_official | 155:8435094ec241 | 681 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 682 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 683 | |
mbed_official | 155:8435094ec241 | 684 | /* Get the old register value */ |
mbed_official | 155:8435094ec241 | 685 | tmpreg = I2Cx->CR2; |
mbed_official | 155:8435094ec241 | 686 | |
mbed_official | 155:8435094ec241 | 687 | /* Reset I2Cx Nbytes bit [7:0] */ |
mbed_official | 155:8435094ec241 | 688 | tmpreg &= (uint32_t)~((uint32_t)I2C_CR2_NBYTES); |
mbed_official | 155:8435094ec241 | 689 | |
mbed_official | 155:8435094ec241 | 690 | /* Set I2Cx Nbytes */ |
mbed_official | 155:8435094ec241 | 691 | tmpreg |= (uint32_t)(((uint32_t)Number_Bytes << 16 ) & I2C_CR2_NBYTES); |
mbed_official | 155:8435094ec241 | 692 | |
mbed_official | 155:8435094ec241 | 693 | /* Store the new register value */ |
mbed_official | 155:8435094ec241 | 694 | I2Cx->CR2 = tmpreg; |
mbed_official | 155:8435094ec241 | 695 | } |
mbed_official | 155:8435094ec241 | 696 | |
mbed_official | 155:8435094ec241 | 697 | /** |
mbed_official | 155:8435094ec241 | 698 | * @brief Configures the type of transfer request for the master. |
mbed_official | 155:8435094ec241 | 699 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 700 | * @param I2C_Direction: specifies the transfer request direction to be programmed. |
mbed_official | 155:8435094ec241 | 701 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 702 | * @arg I2C_Direction_Transmitter: Master request a write transfer |
mbed_official | 155:8435094ec241 | 703 | * @arg I2C_Direction_Receiver: Master request a read transfer |
mbed_official | 155:8435094ec241 | 704 | * @retval None |
mbed_official | 155:8435094ec241 | 705 | */ |
mbed_official | 155:8435094ec241 | 706 | void I2C_MasterRequestConfig(I2C_TypeDef* I2Cx, uint16_t I2C_Direction) |
mbed_official | 155:8435094ec241 | 707 | { |
mbed_official | 155:8435094ec241 | 708 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 709 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 710 | assert_param(IS_I2C_DIRECTION(I2C_Direction)); |
mbed_official | 155:8435094ec241 | 711 | |
mbed_official | 155:8435094ec241 | 712 | /* Test on the direction to set/reset the read/write bit */ |
mbed_official | 155:8435094ec241 | 713 | if (I2C_Direction == I2C_Direction_Transmitter) |
mbed_official | 155:8435094ec241 | 714 | { |
mbed_official | 155:8435094ec241 | 715 | /* Request a write Transfer */ |
mbed_official | 155:8435094ec241 | 716 | I2Cx->CR2 &= (uint32_t)~((uint32_t)I2C_CR2_RD_WRN); |
mbed_official | 155:8435094ec241 | 717 | } |
mbed_official | 155:8435094ec241 | 718 | else |
mbed_official | 155:8435094ec241 | 719 | { |
mbed_official | 155:8435094ec241 | 720 | /* Request a read Transfer */ |
mbed_official | 155:8435094ec241 | 721 | I2Cx->CR2 |= I2C_CR2_RD_WRN; |
mbed_official | 155:8435094ec241 | 722 | } |
mbed_official | 155:8435094ec241 | 723 | } |
mbed_official | 155:8435094ec241 | 724 | |
mbed_official | 155:8435094ec241 | 725 | /** |
mbed_official | 155:8435094ec241 | 726 | * @brief Generates I2Cx communication START condition. |
mbed_official | 155:8435094ec241 | 727 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 728 | * @param NewState: new state of the I2C START condition generation. |
mbed_official | 155:8435094ec241 | 729 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 730 | * @retval None |
mbed_official | 155:8435094ec241 | 731 | */ |
mbed_official | 155:8435094ec241 | 732 | void I2C_GenerateSTART(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 733 | { |
mbed_official | 155:8435094ec241 | 734 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 735 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 736 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 737 | |
mbed_official | 155:8435094ec241 | 738 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 739 | { |
mbed_official | 155:8435094ec241 | 740 | /* Generate a START condition */ |
mbed_official | 155:8435094ec241 | 741 | I2Cx->CR2 |= I2C_CR2_START; |
mbed_official | 155:8435094ec241 | 742 | } |
mbed_official | 155:8435094ec241 | 743 | else |
mbed_official | 155:8435094ec241 | 744 | { |
mbed_official | 155:8435094ec241 | 745 | /* Disable the START condition generation */ |
mbed_official | 155:8435094ec241 | 746 | I2Cx->CR2 &= (uint32_t)~((uint32_t)I2C_CR2_START); |
mbed_official | 155:8435094ec241 | 747 | } |
mbed_official | 155:8435094ec241 | 748 | } |
mbed_official | 155:8435094ec241 | 749 | |
mbed_official | 155:8435094ec241 | 750 | /** |
mbed_official | 155:8435094ec241 | 751 | * @brief Generates I2Cx communication STOP condition. |
mbed_official | 155:8435094ec241 | 752 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 753 | * @param NewState: new state of the I2C STOP condition generation. |
mbed_official | 155:8435094ec241 | 754 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 755 | * @retval None |
mbed_official | 155:8435094ec241 | 756 | */ |
mbed_official | 155:8435094ec241 | 757 | void I2C_GenerateSTOP(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 758 | { |
mbed_official | 155:8435094ec241 | 759 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 760 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 761 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 762 | |
mbed_official | 155:8435094ec241 | 763 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 764 | { |
mbed_official | 155:8435094ec241 | 765 | /* Generate a STOP condition */ |
mbed_official | 155:8435094ec241 | 766 | I2Cx->CR2 |= I2C_CR2_STOP; |
mbed_official | 155:8435094ec241 | 767 | } |
mbed_official | 155:8435094ec241 | 768 | else |
mbed_official | 155:8435094ec241 | 769 | { |
mbed_official | 155:8435094ec241 | 770 | /* Disable the STOP condition generation */ |
mbed_official | 155:8435094ec241 | 771 | I2Cx->CR2 &= (uint32_t)~((uint32_t)I2C_CR2_STOP); |
mbed_official | 155:8435094ec241 | 772 | } |
mbed_official | 155:8435094ec241 | 773 | } |
mbed_official | 155:8435094ec241 | 774 | |
mbed_official | 155:8435094ec241 | 775 | /** |
mbed_official | 155:8435094ec241 | 776 | * @brief Enables or disables the I2C 10-bit header only mode with read direction. |
mbed_official | 155:8435094ec241 | 777 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 778 | * @param NewState: new state of the I2C 10-bit header only mode. |
mbed_official | 155:8435094ec241 | 779 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 780 | * @note This mode can be used only when switching from master transmitter mode |
mbed_official | 155:8435094ec241 | 781 | * to master receiver mode. |
mbed_official | 155:8435094ec241 | 782 | * @retval None |
mbed_official | 155:8435094ec241 | 783 | */ |
mbed_official | 155:8435094ec241 | 784 | void I2C_10BitAddressHeaderCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 785 | { |
mbed_official | 155:8435094ec241 | 786 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 787 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 788 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 789 | |
mbed_official | 155:8435094ec241 | 790 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 791 | { |
mbed_official | 155:8435094ec241 | 792 | /* Enable 10-bit header only mode */ |
mbed_official | 155:8435094ec241 | 793 | I2Cx->CR2 |= I2C_CR2_HEAD10R; |
mbed_official | 155:8435094ec241 | 794 | } |
mbed_official | 155:8435094ec241 | 795 | else |
mbed_official | 155:8435094ec241 | 796 | { |
mbed_official | 155:8435094ec241 | 797 | /* Disable 10-bit header only mode */ |
mbed_official | 155:8435094ec241 | 798 | I2Cx->CR2 &= (uint32_t)~((uint32_t)I2C_CR2_HEAD10R); |
mbed_official | 155:8435094ec241 | 799 | } |
mbed_official | 155:8435094ec241 | 800 | } |
mbed_official | 155:8435094ec241 | 801 | |
mbed_official | 155:8435094ec241 | 802 | /** |
mbed_official | 155:8435094ec241 | 803 | * @brief Generates I2C communication Acknowledge. |
mbed_official | 155:8435094ec241 | 804 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 805 | * @param NewState: new state of the Acknowledge. |
mbed_official | 155:8435094ec241 | 806 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 807 | * @retval None |
mbed_official | 155:8435094ec241 | 808 | */ |
mbed_official | 155:8435094ec241 | 809 | void I2C_AcknowledgeConfig(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 810 | { |
mbed_official | 155:8435094ec241 | 811 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 812 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 813 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 814 | |
mbed_official | 155:8435094ec241 | 815 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 816 | { |
mbed_official | 155:8435094ec241 | 817 | /* Enable ACK generation */ |
mbed_official | 155:8435094ec241 | 818 | I2Cx->CR2 &= (uint32_t)~((uint32_t)I2C_CR2_NACK); |
mbed_official | 155:8435094ec241 | 819 | } |
mbed_official | 155:8435094ec241 | 820 | else |
mbed_official | 155:8435094ec241 | 821 | { |
mbed_official | 155:8435094ec241 | 822 | /* Enable NACK generation */ |
mbed_official | 155:8435094ec241 | 823 | I2Cx->CR2 |= I2C_CR2_NACK; |
mbed_official | 155:8435094ec241 | 824 | } |
mbed_official | 155:8435094ec241 | 825 | } |
mbed_official | 155:8435094ec241 | 826 | |
mbed_official | 155:8435094ec241 | 827 | /** |
mbed_official | 155:8435094ec241 | 828 | * @brief Returns the I2C slave matched address . |
mbed_official | 155:8435094ec241 | 829 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 830 | * @retval The value of the slave matched address . |
mbed_official | 155:8435094ec241 | 831 | */ |
mbed_official | 155:8435094ec241 | 832 | uint8_t I2C_GetAddressMatched(I2C_TypeDef* I2Cx) |
mbed_official | 155:8435094ec241 | 833 | { |
mbed_official | 155:8435094ec241 | 834 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 835 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 836 | |
mbed_official | 155:8435094ec241 | 837 | /* Return the slave matched address in the SR1 register */ |
mbed_official | 155:8435094ec241 | 838 | return (uint8_t)(((uint32_t)I2Cx->ISR & I2C_ISR_ADDCODE) >> 16) ; |
mbed_official | 155:8435094ec241 | 839 | } |
mbed_official | 155:8435094ec241 | 840 | |
mbed_official | 155:8435094ec241 | 841 | /** |
mbed_official | 155:8435094ec241 | 842 | * @brief Returns the I2C slave received request. |
mbed_official | 155:8435094ec241 | 843 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 844 | * @retval The value of the received request. |
mbed_official | 155:8435094ec241 | 845 | */ |
mbed_official | 155:8435094ec241 | 846 | uint16_t I2C_GetTransferDirection(I2C_TypeDef* I2Cx) |
mbed_official | 155:8435094ec241 | 847 | { |
mbed_official | 155:8435094ec241 | 848 | uint32_t tmpreg = 0; |
mbed_official | 155:8435094ec241 | 849 | uint16_t direction = 0; |
mbed_official | 155:8435094ec241 | 850 | |
mbed_official | 155:8435094ec241 | 851 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 852 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 853 | |
mbed_official | 155:8435094ec241 | 854 | /* Return the slave matched address in the SR1 register */ |
mbed_official | 155:8435094ec241 | 855 | tmpreg = (uint32_t)(I2Cx->ISR & I2C_ISR_DIR); |
mbed_official | 155:8435094ec241 | 856 | |
mbed_official | 155:8435094ec241 | 857 | /* If write transfer is requested */ |
mbed_official | 155:8435094ec241 | 858 | if (tmpreg == 0) |
mbed_official | 155:8435094ec241 | 859 | { |
mbed_official | 155:8435094ec241 | 860 | /* write transfer is requested */ |
mbed_official | 155:8435094ec241 | 861 | direction = I2C_Direction_Transmitter; |
mbed_official | 155:8435094ec241 | 862 | } |
mbed_official | 155:8435094ec241 | 863 | else |
mbed_official | 155:8435094ec241 | 864 | { |
mbed_official | 155:8435094ec241 | 865 | /* Read transfer is requested */ |
mbed_official | 155:8435094ec241 | 866 | direction = I2C_Direction_Receiver; |
mbed_official | 155:8435094ec241 | 867 | } |
mbed_official | 155:8435094ec241 | 868 | return direction; |
mbed_official | 155:8435094ec241 | 869 | } |
mbed_official | 155:8435094ec241 | 870 | |
mbed_official | 155:8435094ec241 | 871 | /** |
mbed_official | 155:8435094ec241 | 872 | * @brief Handles I2Cx communication when starting transfer or during transfer (TC or TCR flag are set). |
mbed_official | 155:8435094ec241 | 873 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 874 | * @param Address: specifies the slave address to be programmed. |
mbed_official | 155:8435094ec241 | 875 | * @param Number_Bytes: specifies the number of bytes to be programmed. |
mbed_official | 155:8435094ec241 | 876 | * This parameter must be a value between 0 and 255. |
mbed_official | 155:8435094ec241 | 877 | * @param ReloadEndMode: new state of the I2C START condition generation. |
mbed_official | 155:8435094ec241 | 878 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 879 | * @arg I2C_Reload_Mode: Enable Reload mode . |
mbed_official | 155:8435094ec241 | 880 | * @arg I2C_AutoEnd_Mode: Enable Automatic end mode. |
mbed_official | 155:8435094ec241 | 881 | * @arg I2C_SoftEnd_Mode: Enable Software end mode. |
mbed_official | 155:8435094ec241 | 882 | * @param StartStopMode: new state of the I2C START condition generation. |
mbed_official | 155:8435094ec241 | 883 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 884 | * @arg I2C_No_StartStop: Don't Generate stop and start condition. |
mbed_official | 155:8435094ec241 | 885 | * @arg I2C_Generate_Stop: Generate stop condition (Number_Bytes should be set to 0). |
mbed_official | 155:8435094ec241 | 886 | * @arg I2C_Generate_Start_Read: Generate Restart for read request. |
mbed_official | 155:8435094ec241 | 887 | * @arg I2C_Generate_Start_Write: Generate Restart for write request. |
mbed_official | 155:8435094ec241 | 888 | * @retval None |
mbed_official | 155:8435094ec241 | 889 | */ |
mbed_official | 155:8435094ec241 | 890 | void I2C_TransferHandling(I2C_TypeDef* I2Cx, uint16_t Address, uint8_t Number_Bytes, uint32_t ReloadEndMode, uint32_t StartStopMode) |
mbed_official | 155:8435094ec241 | 891 | { |
mbed_official | 155:8435094ec241 | 892 | uint32_t tmpreg = 0; |
mbed_official | 155:8435094ec241 | 893 | |
mbed_official | 155:8435094ec241 | 894 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 895 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 896 | assert_param(IS_I2C_SLAVE_ADDRESS(Address)); |
mbed_official | 155:8435094ec241 | 897 | assert_param(IS_RELOAD_END_MODE(ReloadEndMode)); |
mbed_official | 155:8435094ec241 | 898 | assert_param(IS_START_STOP_MODE(StartStopMode)); |
mbed_official | 155:8435094ec241 | 899 | |
mbed_official | 155:8435094ec241 | 900 | /* Get the CR2 register value */ |
mbed_official | 155:8435094ec241 | 901 | tmpreg = I2Cx->CR2; |
mbed_official | 155:8435094ec241 | 902 | |
mbed_official | 155:8435094ec241 | 903 | /* clear tmpreg specific bits */ |
mbed_official | 155:8435094ec241 | 904 | tmpreg &= (uint32_t)~((uint32_t)(I2C_CR2_SADD | I2C_CR2_NBYTES | I2C_CR2_RELOAD | I2C_CR2_AUTOEND | I2C_CR2_RD_WRN | I2C_CR2_START | I2C_CR2_STOP)); |
mbed_official | 155:8435094ec241 | 905 | |
mbed_official | 155:8435094ec241 | 906 | /* update tmpreg */ |
mbed_official | 155:8435094ec241 | 907 | tmpreg |= (uint32_t)(((uint32_t)Address & I2C_CR2_SADD) | (((uint32_t)Number_Bytes << 16 ) & I2C_CR2_NBYTES) | \ |
mbed_official | 155:8435094ec241 | 908 | (uint32_t)ReloadEndMode | (uint32_t)StartStopMode); |
mbed_official | 155:8435094ec241 | 909 | |
mbed_official | 155:8435094ec241 | 910 | /* update CR2 register */ |
mbed_official | 155:8435094ec241 | 911 | I2Cx->CR2 = tmpreg; |
mbed_official | 155:8435094ec241 | 912 | } |
mbed_official | 155:8435094ec241 | 913 | |
mbed_official | 155:8435094ec241 | 914 | /** |
mbed_official | 155:8435094ec241 | 915 | * @} |
mbed_official | 155:8435094ec241 | 916 | */ |
mbed_official | 155:8435094ec241 | 917 | |
mbed_official | 155:8435094ec241 | 918 | |
mbed_official | 155:8435094ec241 | 919 | /** @defgroup I2C_Group3 SMBUS management functions |
mbed_official | 155:8435094ec241 | 920 | * @brief SMBUS management functions |
mbed_official | 155:8435094ec241 | 921 | * |
mbed_official | 155:8435094ec241 | 922 | @verbatim |
mbed_official | 155:8435094ec241 | 923 | =============================================================================== |
mbed_official | 155:8435094ec241 | 924 | ##### SMBUS management functions ##### |
mbed_official | 155:8435094ec241 | 925 | =============================================================================== |
mbed_official | 155:8435094ec241 | 926 | [..] This section provides a set of functions that handles SMBus communication |
mbed_official | 155:8435094ec241 | 927 | and timeouts detection. |
mbed_official | 155:8435094ec241 | 928 | |
mbed_official | 155:8435094ec241 | 929 | [..] The SMBus Device default address (0b1100 001) is enabled by calling I2C_Init() |
mbed_official | 155:8435094ec241 | 930 | function and setting I2C_Mode member of I2C_InitTypeDef() structure to |
mbed_official | 155:8435094ec241 | 931 | I2C_Mode_SMBusDevice. |
mbed_official | 155:8435094ec241 | 932 | |
mbed_official | 155:8435094ec241 | 933 | [..] The SMBus Host address (0b0001 000) is enabled by calling I2C_Init() |
mbed_official | 155:8435094ec241 | 934 | function and setting I2C_Mode member of I2C_InitTypeDef() structure to |
mbed_official | 155:8435094ec241 | 935 | I2C_Mode_SMBusHost. |
mbed_official | 155:8435094ec241 | 936 | |
mbed_official | 155:8435094ec241 | 937 | [..] The Alert Response Address (0b0001 100) is enabled using I2C_SMBusAlertCmd() |
mbed_official | 155:8435094ec241 | 938 | function. |
mbed_official | 155:8435094ec241 | 939 | |
mbed_official | 155:8435094ec241 | 940 | [..] To detect cumulative SCL stretch in master and slave mode, TIMEOUTB should be |
mbed_official | 155:8435094ec241 | 941 | configured (in accordance to SMBus specification) using I2C_TimeoutBConfig() |
mbed_official | 155:8435094ec241 | 942 | function then I2C_ExtendedClockTimeoutCmd() function should be called to enable |
mbed_official | 155:8435094ec241 | 943 | the detection. |
mbed_official | 155:8435094ec241 | 944 | |
mbed_official | 155:8435094ec241 | 945 | [..] SCL low timeout is detected by configuring TIMEOUTB using I2C_TimeoutBConfig() |
mbed_official | 155:8435094ec241 | 946 | function followed by the call of I2C_ClockTimeoutCmd(). When adding to this |
mbed_official | 155:8435094ec241 | 947 | procedure the call of I2C_IdleClockTimeoutCmd() function, Bus Idle condition |
mbed_official | 155:8435094ec241 | 948 | (both SCL and SDA high) is detected also. |
mbed_official | 155:8435094ec241 | 949 | |
mbed_official | 155:8435094ec241 | 950 | @endverbatim |
mbed_official | 155:8435094ec241 | 951 | * @{ |
mbed_official | 155:8435094ec241 | 952 | */ |
mbed_official | 155:8435094ec241 | 953 | |
mbed_official | 155:8435094ec241 | 954 | /** |
mbed_official | 155:8435094ec241 | 955 | * @brief Enables or disables I2C SMBus alert. |
mbed_official | 155:8435094ec241 | 956 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 957 | * @param NewState: new state of the I2Cx SMBus alert. |
mbed_official | 155:8435094ec241 | 958 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 959 | * @retval None |
mbed_official | 155:8435094ec241 | 960 | */ |
mbed_official | 155:8435094ec241 | 961 | void I2C_SMBusAlertCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 962 | { |
mbed_official | 155:8435094ec241 | 963 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 964 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 965 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 966 | |
mbed_official | 155:8435094ec241 | 967 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 968 | { |
mbed_official | 155:8435094ec241 | 969 | /* Enable SMBus alert */ |
mbed_official | 155:8435094ec241 | 970 | I2Cx->CR1 |= I2C_CR1_ALERTEN; |
mbed_official | 155:8435094ec241 | 971 | } |
mbed_official | 155:8435094ec241 | 972 | else |
mbed_official | 155:8435094ec241 | 973 | { |
mbed_official | 155:8435094ec241 | 974 | /* Disable SMBus alert */ |
mbed_official | 155:8435094ec241 | 975 | I2Cx->CR1 &= (uint32_t)~((uint32_t)I2C_CR1_ALERTEN); |
mbed_official | 155:8435094ec241 | 976 | } |
mbed_official | 155:8435094ec241 | 977 | } |
mbed_official | 155:8435094ec241 | 978 | |
mbed_official | 155:8435094ec241 | 979 | /** |
mbed_official | 155:8435094ec241 | 980 | * @brief Enables or disables I2C Clock Timeout (SCL Timeout detection). |
mbed_official | 155:8435094ec241 | 981 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 982 | * @param NewState: new state of the I2Cx clock Timeout. |
mbed_official | 155:8435094ec241 | 983 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 984 | * @retval None |
mbed_official | 155:8435094ec241 | 985 | */ |
mbed_official | 155:8435094ec241 | 986 | void I2C_ClockTimeoutCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 987 | { |
mbed_official | 155:8435094ec241 | 988 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 989 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 990 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 991 | |
mbed_official | 155:8435094ec241 | 992 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 993 | { |
mbed_official | 155:8435094ec241 | 994 | /* Enable Clock Timeout */ |
mbed_official | 155:8435094ec241 | 995 | I2Cx->TIMEOUTR |= I2C_TIMEOUTR_TIMOUTEN; |
mbed_official | 155:8435094ec241 | 996 | } |
mbed_official | 155:8435094ec241 | 997 | else |
mbed_official | 155:8435094ec241 | 998 | { |
mbed_official | 155:8435094ec241 | 999 | /* Disable Clock Timeout */ |
mbed_official | 155:8435094ec241 | 1000 | I2Cx->TIMEOUTR &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TIMOUTEN); |
mbed_official | 155:8435094ec241 | 1001 | } |
mbed_official | 155:8435094ec241 | 1002 | } |
mbed_official | 155:8435094ec241 | 1003 | |
mbed_official | 155:8435094ec241 | 1004 | /** |
mbed_official | 155:8435094ec241 | 1005 | * @brief Enables or disables I2C Extended Clock Timeout (SCL cumulative Timeout detection). |
mbed_official | 155:8435094ec241 | 1006 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1007 | * @param NewState: new state of the I2Cx Extended clock Timeout. |
mbed_official | 155:8435094ec241 | 1008 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1009 | * @retval None |
mbed_official | 155:8435094ec241 | 1010 | */ |
mbed_official | 155:8435094ec241 | 1011 | void I2C_ExtendedClockTimeoutCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1012 | { |
mbed_official | 155:8435094ec241 | 1013 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1014 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1015 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1016 | |
mbed_official | 155:8435094ec241 | 1017 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1018 | { |
mbed_official | 155:8435094ec241 | 1019 | /* Enable Clock Timeout */ |
mbed_official | 155:8435094ec241 | 1020 | I2Cx->TIMEOUTR |= I2C_TIMEOUTR_TEXTEN; |
mbed_official | 155:8435094ec241 | 1021 | } |
mbed_official | 155:8435094ec241 | 1022 | else |
mbed_official | 155:8435094ec241 | 1023 | { |
mbed_official | 155:8435094ec241 | 1024 | /* Disable Clock Timeout */ |
mbed_official | 155:8435094ec241 | 1025 | I2Cx->TIMEOUTR &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TEXTEN); |
mbed_official | 155:8435094ec241 | 1026 | } |
mbed_official | 155:8435094ec241 | 1027 | } |
mbed_official | 155:8435094ec241 | 1028 | |
mbed_official | 155:8435094ec241 | 1029 | /** |
mbed_official | 155:8435094ec241 | 1030 | * @brief Enables or disables I2C Idle Clock Timeout (Bus idle SCL and SDA |
mbed_official | 155:8435094ec241 | 1031 | * high detection). |
mbed_official | 155:8435094ec241 | 1032 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1033 | * @param NewState: new state of the I2Cx Idle clock Timeout. |
mbed_official | 155:8435094ec241 | 1034 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1035 | * @retval None |
mbed_official | 155:8435094ec241 | 1036 | */ |
mbed_official | 155:8435094ec241 | 1037 | void I2C_IdleClockTimeoutCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1038 | { |
mbed_official | 155:8435094ec241 | 1039 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1040 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1041 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1042 | |
mbed_official | 155:8435094ec241 | 1043 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1044 | { |
mbed_official | 155:8435094ec241 | 1045 | /* Enable Clock Timeout */ |
mbed_official | 155:8435094ec241 | 1046 | I2Cx->TIMEOUTR |= I2C_TIMEOUTR_TIDLE; |
mbed_official | 155:8435094ec241 | 1047 | } |
mbed_official | 155:8435094ec241 | 1048 | else |
mbed_official | 155:8435094ec241 | 1049 | { |
mbed_official | 155:8435094ec241 | 1050 | /* Disable Clock Timeout */ |
mbed_official | 155:8435094ec241 | 1051 | I2Cx->TIMEOUTR &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TIDLE); |
mbed_official | 155:8435094ec241 | 1052 | } |
mbed_official | 155:8435094ec241 | 1053 | } |
mbed_official | 155:8435094ec241 | 1054 | |
mbed_official | 155:8435094ec241 | 1055 | /** |
mbed_official | 155:8435094ec241 | 1056 | * @brief Configures the I2C Bus Timeout A (SCL Timeout when TIDLE = 0 or Bus |
mbed_official | 155:8435094ec241 | 1057 | * idle SCL and SDA high when TIDLE = 1). |
mbed_official | 155:8435094ec241 | 1058 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1059 | * @param Timeout: specifies the TimeoutA to be programmed. |
mbed_official | 155:8435094ec241 | 1060 | * @retval None |
mbed_official | 155:8435094ec241 | 1061 | */ |
mbed_official | 155:8435094ec241 | 1062 | void I2C_TimeoutAConfig(I2C_TypeDef* I2Cx, uint16_t Timeout) |
mbed_official | 155:8435094ec241 | 1063 | { |
mbed_official | 155:8435094ec241 | 1064 | uint32_t tmpreg = 0; |
mbed_official | 155:8435094ec241 | 1065 | |
mbed_official | 155:8435094ec241 | 1066 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1067 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1068 | assert_param(IS_I2C_TIMEOUT(Timeout)); |
mbed_official | 155:8435094ec241 | 1069 | |
mbed_official | 155:8435094ec241 | 1070 | /* Get the old register value */ |
mbed_official | 155:8435094ec241 | 1071 | tmpreg = I2Cx->TIMEOUTR; |
mbed_official | 155:8435094ec241 | 1072 | |
mbed_official | 155:8435094ec241 | 1073 | /* Reset I2Cx TIMEOUTA bit [11:0] */ |
mbed_official | 155:8435094ec241 | 1074 | tmpreg &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TIMEOUTA); |
mbed_official | 155:8435094ec241 | 1075 | |
mbed_official | 155:8435094ec241 | 1076 | /* Set I2Cx TIMEOUTA */ |
mbed_official | 155:8435094ec241 | 1077 | tmpreg |= (uint32_t)((uint32_t)Timeout & I2C_TIMEOUTR_TIMEOUTA) ; |
mbed_official | 155:8435094ec241 | 1078 | |
mbed_official | 155:8435094ec241 | 1079 | /* Store the new register value */ |
mbed_official | 155:8435094ec241 | 1080 | I2Cx->TIMEOUTR = tmpreg; |
mbed_official | 155:8435094ec241 | 1081 | } |
mbed_official | 155:8435094ec241 | 1082 | |
mbed_official | 155:8435094ec241 | 1083 | /** |
mbed_official | 155:8435094ec241 | 1084 | * @brief Configures the I2C Bus Timeout B (SCL cumulative Timeout). |
mbed_official | 155:8435094ec241 | 1085 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1086 | * @param Timeout: specifies the TimeoutB to be programmed. |
mbed_official | 155:8435094ec241 | 1087 | * @retval None |
mbed_official | 155:8435094ec241 | 1088 | */ |
mbed_official | 155:8435094ec241 | 1089 | void I2C_TimeoutBConfig(I2C_TypeDef* I2Cx, uint16_t Timeout) |
mbed_official | 155:8435094ec241 | 1090 | { |
mbed_official | 155:8435094ec241 | 1091 | uint32_t tmpreg = 0; |
mbed_official | 155:8435094ec241 | 1092 | |
mbed_official | 155:8435094ec241 | 1093 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1094 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1095 | assert_param(IS_I2C_TIMEOUT(Timeout)); |
mbed_official | 155:8435094ec241 | 1096 | |
mbed_official | 155:8435094ec241 | 1097 | /* Get the old register value */ |
mbed_official | 155:8435094ec241 | 1098 | tmpreg = I2Cx->TIMEOUTR; |
mbed_official | 155:8435094ec241 | 1099 | |
mbed_official | 155:8435094ec241 | 1100 | /* Reset I2Cx TIMEOUTB bit [11:0] */ |
mbed_official | 155:8435094ec241 | 1101 | tmpreg &= (uint32_t)~((uint32_t)I2C_TIMEOUTR_TIMEOUTB); |
mbed_official | 155:8435094ec241 | 1102 | |
mbed_official | 155:8435094ec241 | 1103 | /* Set I2Cx TIMEOUTB */ |
mbed_official | 155:8435094ec241 | 1104 | tmpreg |= (uint32_t)(((uint32_t)Timeout << 16) & I2C_TIMEOUTR_TIMEOUTB) ; |
mbed_official | 155:8435094ec241 | 1105 | |
mbed_official | 155:8435094ec241 | 1106 | /* Store the new register value */ |
mbed_official | 155:8435094ec241 | 1107 | I2Cx->TIMEOUTR = tmpreg; |
mbed_official | 155:8435094ec241 | 1108 | } |
mbed_official | 155:8435094ec241 | 1109 | |
mbed_official | 155:8435094ec241 | 1110 | /** |
mbed_official | 155:8435094ec241 | 1111 | * @brief Enables or disables I2C PEC calculation. |
mbed_official | 155:8435094ec241 | 1112 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1113 | * @param NewState: new state of the I2Cx PEC calculation. |
mbed_official | 155:8435094ec241 | 1114 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1115 | * @retval None |
mbed_official | 155:8435094ec241 | 1116 | */ |
mbed_official | 155:8435094ec241 | 1117 | void I2C_CalculatePEC(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1118 | { |
mbed_official | 155:8435094ec241 | 1119 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1120 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1121 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1122 | |
mbed_official | 155:8435094ec241 | 1123 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1124 | { |
mbed_official | 155:8435094ec241 | 1125 | /* Enable PEC calculation */ |
mbed_official | 155:8435094ec241 | 1126 | I2Cx->CR1 |= I2C_CR1_PECEN; |
mbed_official | 155:8435094ec241 | 1127 | } |
mbed_official | 155:8435094ec241 | 1128 | else |
mbed_official | 155:8435094ec241 | 1129 | { |
mbed_official | 155:8435094ec241 | 1130 | /* Disable PEC calculation */ |
mbed_official | 155:8435094ec241 | 1131 | I2Cx->CR1 &= (uint32_t)~((uint32_t)I2C_CR1_PECEN); |
mbed_official | 155:8435094ec241 | 1132 | } |
mbed_official | 155:8435094ec241 | 1133 | } |
mbed_official | 155:8435094ec241 | 1134 | |
mbed_official | 155:8435094ec241 | 1135 | /** |
mbed_official | 155:8435094ec241 | 1136 | * @brief Enables or disables I2C PEC transmission/reception request. |
mbed_official | 155:8435094ec241 | 1137 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1138 | * @param NewState: new state of the I2Cx PEC request. |
mbed_official | 155:8435094ec241 | 1139 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1140 | * @retval None |
mbed_official | 155:8435094ec241 | 1141 | */ |
mbed_official | 155:8435094ec241 | 1142 | void I2C_PECRequestCmd(I2C_TypeDef* I2Cx, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1143 | { |
mbed_official | 155:8435094ec241 | 1144 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1145 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1146 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1147 | |
mbed_official | 155:8435094ec241 | 1148 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1149 | { |
mbed_official | 155:8435094ec241 | 1150 | /* Enable PEC transmission/reception request */ |
mbed_official | 155:8435094ec241 | 1151 | I2Cx->CR1 |= I2C_CR2_PECBYTE; |
mbed_official | 155:8435094ec241 | 1152 | } |
mbed_official | 155:8435094ec241 | 1153 | else |
mbed_official | 155:8435094ec241 | 1154 | { |
mbed_official | 155:8435094ec241 | 1155 | /* Disable PEC transmission/reception request */ |
mbed_official | 155:8435094ec241 | 1156 | I2Cx->CR1 &= (uint32_t)~((uint32_t)I2C_CR2_PECBYTE); |
mbed_official | 155:8435094ec241 | 1157 | } |
mbed_official | 155:8435094ec241 | 1158 | } |
mbed_official | 155:8435094ec241 | 1159 | |
mbed_official | 155:8435094ec241 | 1160 | /** |
mbed_official | 155:8435094ec241 | 1161 | * @brief Returns the I2C PEC. |
mbed_official | 155:8435094ec241 | 1162 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1163 | * @retval The value of the PEC . |
mbed_official | 155:8435094ec241 | 1164 | */ |
mbed_official | 155:8435094ec241 | 1165 | uint8_t I2C_GetPEC(I2C_TypeDef* I2Cx) |
mbed_official | 155:8435094ec241 | 1166 | { |
mbed_official | 155:8435094ec241 | 1167 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1168 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1169 | |
mbed_official | 155:8435094ec241 | 1170 | /* Return the slave matched address in the SR1 register */ |
mbed_official | 155:8435094ec241 | 1171 | return (uint8_t)((uint32_t)I2Cx->PECR & I2C_PECR_PEC); |
mbed_official | 155:8435094ec241 | 1172 | } |
mbed_official | 155:8435094ec241 | 1173 | |
mbed_official | 155:8435094ec241 | 1174 | /** |
mbed_official | 155:8435094ec241 | 1175 | * @} |
mbed_official | 155:8435094ec241 | 1176 | */ |
mbed_official | 155:8435094ec241 | 1177 | |
mbed_official | 155:8435094ec241 | 1178 | |
mbed_official | 155:8435094ec241 | 1179 | /** @defgroup I2C_Group4 I2C registers management functions |
mbed_official | 155:8435094ec241 | 1180 | * @brief I2C registers management functions |
mbed_official | 155:8435094ec241 | 1181 | * |
mbed_official | 155:8435094ec241 | 1182 | @verbatim |
mbed_official | 155:8435094ec241 | 1183 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1184 | ##### I2C registers management functions ##### |
mbed_official | 155:8435094ec241 | 1185 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1186 | [..] This section provides a functions that allow user the management of |
mbed_official | 155:8435094ec241 | 1187 | I2C registers. |
mbed_official | 155:8435094ec241 | 1188 | |
mbed_official | 155:8435094ec241 | 1189 | @endverbatim |
mbed_official | 155:8435094ec241 | 1190 | * @{ |
mbed_official | 155:8435094ec241 | 1191 | */ |
mbed_official | 155:8435094ec241 | 1192 | |
mbed_official | 155:8435094ec241 | 1193 | /** |
mbed_official | 155:8435094ec241 | 1194 | * @brief Reads the specified I2C register and returns its value. |
mbed_official | 155:8435094ec241 | 1195 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1196 | * @param I2C_Register: specifies the register to read. |
mbed_official | 155:8435094ec241 | 1197 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 1198 | * @arg I2C_Register_CR1: CR1 register. |
mbed_official | 155:8435094ec241 | 1199 | * @arg I2C_Register_CR2: CR2 register. |
mbed_official | 155:8435094ec241 | 1200 | * @arg I2C_Register_OAR1: OAR1 register. |
mbed_official | 155:8435094ec241 | 1201 | * @arg I2C_Register_OAR2: OAR2 register. |
mbed_official | 155:8435094ec241 | 1202 | * @arg I2C_Register_TIMINGR: TIMING register. |
mbed_official | 155:8435094ec241 | 1203 | * @arg I2C_Register_TIMEOUTR: TIMEOUTR register. |
mbed_official | 155:8435094ec241 | 1204 | * @arg I2C_Register_ISR: ISR register. |
mbed_official | 155:8435094ec241 | 1205 | * @arg I2C_Register_ICR: ICR register. |
mbed_official | 155:8435094ec241 | 1206 | * @arg I2C_Register_PECR: PECR register. |
mbed_official | 155:8435094ec241 | 1207 | * @arg I2C_Register_RXDR: RXDR register. |
mbed_official | 155:8435094ec241 | 1208 | * @arg I2C_Register_TXDR: TXDR register. |
mbed_official | 155:8435094ec241 | 1209 | * @retval The value of the read register. |
mbed_official | 155:8435094ec241 | 1210 | */ |
mbed_official | 155:8435094ec241 | 1211 | uint32_t I2C_ReadRegister(I2C_TypeDef* I2Cx, uint8_t I2C_Register) |
mbed_official | 155:8435094ec241 | 1212 | { |
mbed_official | 155:8435094ec241 | 1213 | __IO uint32_t tmp = 0; |
mbed_official | 155:8435094ec241 | 1214 | |
mbed_official | 155:8435094ec241 | 1215 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1216 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1217 | assert_param(IS_I2C_REGISTER(I2C_Register)); |
mbed_official | 155:8435094ec241 | 1218 | |
mbed_official | 155:8435094ec241 | 1219 | tmp = (uint32_t)I2Cx; |
mbed_official | 155:8435094ec241 | 1220 | tmp += I2C_Register; |
mbed_official | 155:8435094ec241 | 1221 | |
mbed_official | 155:8435094ec241 | 1222 | /* Return the selected register value */ |
mbed_official | 155:8435094ec241 | 1223 | return (*(__IO uint32_t *) tmp); |
mbed_official | 155:8435094ec241 | 1224 | } |
mbed_official | 155:8435094ec241 | 1225 | |
mbed_official | 155:8435094ec241 | 1226 | /** |
mbed_official | 155:8435094ec241 | 1227 | * @} |
mbed_official | 155:8435094ec241 | 1228 | */ |
mbed_official | 155:8435094ec241 | 1229 | |
mbed_official | 155:8435094ec241 | 1230 | /** @defgroup I2C_Group5 Data transfers management functions |
mbed_official | 155:8435094ec241 | 1231 | * @brief Data transfers management functions |
mbed_official | 155:8435094ec241 | 1232 | * |
mbed_official | 155:8435094ec241 | 1233 | @verbatim |
mbed_official | 155:8435094ec241 | 1234 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1235 | ##### Data transfers management functions ##### |
mbed_official | 155:8435094ec241 | 1236 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1237 | [..] This subsection provides a set of functions allowing to manage |
mbed_official | 155:8435094ec241 | 1238 | the I2C data transfers. |
mbed_official | 155:8435094ec241 | 1239 | |
mbed_official | 155:8435094ec241 | 1240 | [..] The read access of the I2C_RXDR register can be done using |
mbed_official | 155:8435094ec241 | 1241 | the I2C_ReceiveData() function and returns the received value. |
mbed_official | 155:8435094ec241 | 1242 | Whereas a write access to the I2C_TXDR can be done using I2C_SendData() |
mbed_official | 155:8435094ec241 | 1243 | function and stores the written data into TXDR. |
mbed_official | 155:8435094ec241 | 1244 | @endverbatim |
mbed_official | 155:8435094ec241 | 1245 | * @{ |
mbed_official | 155:8435094ec241 | 1246 | */ |
mbed_official | 155:8435094ec241 | 1247 | |
mbed_official | 155:8435094ec241 | 1248 | /** |
mbed_official | 155:8435094ec241 | 1249 | * @brief Sends a data byte through the I2Cx peripheral. |
mbed_official | 155:8435094ec241 | 1250 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1251 | * @param Data: Byte to be transmitted.. |
mbed_official | 155:8435094ec241 | 1252 | * @retval None |
mbed_official | 155:8435094ec241 | 1253 | */ |
mbed_official | 155:8435094ec241 | 1254 | void I2C_SendData(I2C_TypeDef* I2Cx, uint8_t Data) |
mbed_official | 155:8435094ec241 | 1255 | { |
mbed_official | 155:8435094ec241 | 1256 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1257 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1258 | |
mbed_official | 155:8435094ec241 | 1259 | /* Write in the DR register the data to be sent */ |
mbed_official | 155:8435094ec241 | 1260 | I2Cx->TXDR = (uint8_t)Data; |
mbed_official | 155:8435094ec241 | 1261 | } |
mbed_official | 155:8435094ec241 | 1262 | |
mbed_official | 155:8435094ec241 | 1263 | /** |
mbed_official | 155:8435094ec241 | 1264 | * @brief Returns the most recent received data by the I2Cx peripheral. |
mbed_official | 155:8435094ec241 | 1265 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1266 | * @retval The value of the received data. |
mbed_official | 155:8435094ec241 | 1267 | */ |
mbed_official | 155:8435094ec241 | 1268 | uint8_t I2C_ReceiveData(I2C_TypeDef* I2Cx) |
mbed_official | 155:8435094ec241 | 1269 | { |
mbed_official | 155:8435094ec241 | 1270 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1271 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1272 | |
mbed_official | 155:8435094ec241 | 1273 | /* Return the data in the DR register */ |
mbed_official | 155:8435094ec241 | 1274 | return (uint8_t)I2Cx->RXDR; |
mbed_official | 155:8435094ec241 | 1275 | } |
mbed_official | 155:8435094ec241 | 1276 | |
mbed_official | 155:8435094ec241 | 1277 | /** |
mbed_official | 155:8435094ec241 | 1278 | * @} |
mbed_official | 155:8435094ec241 | 1279 | */ |
mbed_official | 155:8435094ec241 | 1280 | |
mbed_official | 155:8435094ec241 | 1281 | |
mbed_official | 155:8435094ec241 | 1282 | /** @defgroup I2C_Group6 DMA transfers management functions |
mbed_official | 155:8435094ec241 | 1283 | * @brief DMA transfers management functions |
mbed_official | 155:8435094ec241 | 1284 | * |
mbed_official | 155:8435094ec241 | 1285 | @verbatim |
mbed_official | 155:8435094ec241 | 1286 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1287 | ##### DMA transfers management functions ##### |
mbed_official | 155:8435094ec241 | 1288 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1289 | [..] This section provides two functions that can be used only in DMA mode. |
mbed_official | 155:8435094ec241 | 1290 | [..] In DMA Mode, the I2C communication can be managed by 2 DMA Channel |
mbed_official | 155:8435094ec241 | 1291 | requests: |
mbed_official | 155:8435094ec241 | 1292 | (#) I2C_DMAReq_Tx: specifies the Tx buffer DMA transfer request. |
mbed_official | 155:8435094ec241 | 1293 | (#) I2C_DMAReq_Rx: specifies the Rx buffer DMA transfer request. |
mbed_official | 155:8435094ec241 | 1294 | [..] In this Mode it is advised to use the following function: |
mbed_official | 155:8435094ec241 | 1295 | (+) I2C_DMACmd(I2C_TypeDef* I2Cx, uint32_t I2C_DMAReq, FunctionalState NewState); |
mbed_official | 155:8435094ec241 | 1296 | @endverbatim |
mbed_official | 155:8435094ec241 | 1297 | * @{ |
mbed_official | 155:8435094ec241 | 1298 | */ |
mbed_official | 155:8435094ec241 | 1299 | |
mbed_official | 155:8435094ec241 | 1300 | /** |
mbed_official | 155:8435094ec241 | 1301 | * @brief Enables or disables the I2C DMA interface. |
mbed_official | 155:8435094ec241 | 1302 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1303 | * @param I2C_DMAReq: specifies the I2C DMA transfer request to be enabled or disabled. |
mbed_official | 155:8435094ec241 | 1304 | * This parameter can be any combination of the following values: |
mbed_official | 155:8435094ec241 | 1305 | * @arg I2C_DMAReq_Tx: Tx DMA transfer request |
mbed_official | 155:8435094ec241 | 1306 | * @arg I2C_DMAReq_Rx: Rx DMA transfer request |
mbed_official | 155:8435094ec241 | 1307 | * @param NewState: new state of the selected I2C DMA transfer request. |
mbed_official | 155:8435094ec241 | 1308 | * This parameter can be: ENABLE or DISABLE. |
mbed_official | 155:8435094ec241 | 1309 | * @retval None |
mbed_official | 155:8435094ec241 | 1310 | */ |
mbed_official | 155:8435094ec241 | 1311 | void I2C_DMACmd(I2C_TypeDef* I2Cx, uint32_t I2C_DMAReq, FunctionalState NewState) |
mbed_official | 155:8435094ec241 | 1312 | { |
mbed_official | 155:8435094ec241 | 1313 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1314 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1315 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 155:8435094ec241 | 1316 | assert_param(IS_I2C_DMA_REQ(I2C_DMAReq)); |
mbed_official | 155:8435094ec241 | 1317 | |
mbed_official | 155:8435094ec241 | 1318 | if (NewState != DISABLE) |
mbed_official | 155:8435094ec241 | 1319 | { |
mbed_official | 155:8435094ec241 | 1320 | /* Enable the selected I2C DMA requests */ |
mbed_official | 155:8435094ec241 | 1321 | I2Cx->CR1 |= I2C_DMAReq; |
mbed_official | 155:8435094ec241 | 1322 | } |
mbed_official | 155:8435094ec241 | 1323 | else |
mbed_official | 155:8435094ec241 | 1324 | { |
mbed_official | 155:8435094ec241 | 1325 | /* Disable the selected I2C DMA requests */ |
mbed_official | 155:8435094ec241 | 1326 | I2Cx->CR1 &= (uint32_t)~I2C_DMAReq; |
mbed_official | 155:8435094ec241 | 1327 | } |
mbed_official | 155:8435094ec241 | 1328 | } |
mbed_official | 155:8435094ec241 | 1329 | /** |
mbed_official | 155:8435094ec241 | 1330 | * @} |
mbed_official | 155:8435094ec241 | 1331 | */ |
mbed_official | 155:8435094ec241 | 1332 | |
mbed_official | 155:8435094ec241 | 1333 | |
mbed_official | 155:8435094ec241 | 1334 | /** @defgroup I2C_Group7 Interrupts and flags management functions |
mbed_official | 155:8435094ec241 | 1335 | * @brief Interrupts and flags management functions |
mbed_official | 155:8435094ec241 | 1336 | * |
mbed_official | 155:8435094ec241 | 1337 | @verbatim |
mbed_official | 155:8435094ec241 | 1338 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1339 | ##### Interrupts and flags management functions ##### |
mbed_official | 155:8435094ec241 | 1340 | =============================================================================== |
mbed_official | 155:8435094ec241 | 1341 | [..] This section provides functions allowing to configure the I2C Interrupts |
mbed_official | 155:8435094ec241 | 1342 | sources and check or clear the flags or pending bits status. |
mbed_official | 155:8435094ec241 | 1343 | The user should identify which mode will be used in his application to manage |
mbed_official | 155:8435094ec241 | 1344 | the communication: Polling mode, Interrupt mode or DMA mode(refer I2C_Group6) . |
mbed_official | 155:8435094ec241 | 1345 | |
mbed_official | 155:8435094ec241 | 1346 | *** Polling Mode *** |
mbed_official | 155:8435094ec241 | 1347 | ==================== |
mbed_official | 155:8435094ec241 | 1348 | [..] In Polling Mode, the I2C communication can be managed by 15 flags: |
mbed_official | 155:8435094ec241 | 1349 | (#) I2C_FLAG_TXE: to indicate the status of Transmit data register empty flag. |
mbed_official | 155:8435094ec241 | 1350 | (#) I2C_FLAG_TXIS: to indicate the status of Transmit interrupt status flag . |
mbed_official | 155:8435094ec241 | 1351 | (#) I2C_FLAG_RXNE: to indicate the status of Receive data register not empty flag. |
mbed_official | 155:8435094ec241 | 1352 | (#) I2C_FLAG_ADDR: to indicate the status of Address matched flag (slave mode). |
mbed_official | 155:8435094ec241 | 1353 | (#) I2C_FLAG_NACKF: to indicate the status of NACK received flag. |
mbed_official | 155:8435094ec241 | 1354 | (#) I2C_FLAG_STOPF: to indicate the status of STOP detection flag. |
mbed_official | 155:8435094ec241 | 1355 | (#) I2C_FLAG_TC: to indicate the status of Transfer complete flag(master mode). |
mbed_official | 155:8435094ec241 | 1356 | (#) I2C_FLAG_TCR: to indicate the status of Transfer complete reload flag. |
mbed_official | 155:8435094ec241 | 1357 | (#) I2C_FLAG_BERR: to indicate the status of Bus error flag. |
mbed_official | 155:8435094ec241 | 1358 | (#) I2C_FLAG_ARLO: to indicate the status of Arbitration lost flag. |
mbed_official | 155:8435094ec241 | 1359 | (#) I2C_FLAG_OVR: to indicate the status of Overrun/Underrun flag. |
mbed_official | 155:8435094ec241 | 1360 | (#) I2C_FLAG_PECERR: to indicate the status of PEC error in reception flag. |
mbed_official | 155:8435094ec241 | 1361 | (#) I2C_FLAG_TIMEOUT: to indicate the status of Timeout or Tlow detection flag. |
mbed_official | 155:8435094ec241 | 1362 | (#) I2C_FLAG_ALERT: to indicate the status of SMBus Alert flag. |
mbed_official | 155:8435094ec241 | 1363 | (#) I2C_FLAG_BUSY: to indicate the status of Bus busy flag. |
mbed_official | 155:8435094ec241 | 1364 | |
mbed_official | 155:8435094ec241 | 1365 | [..] In this Mode it is advised to use the following functions: |
mbed_official | 155:8435094ec241 | 1366 | (+) FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG); |
mbed_official | 155:8435094ec241 | 1367 | (+) void I2C_ClearFlag(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG); |
mbed_official | 155:8435094ec241 | 1368 | |
mbed_official | 155:8435094ec241 | 1369 | [..] |
mbed_official | 155:8435094ec241 | 1370 | (@)Do not use the BUSY flag to handle each data transmission or reception.It is |
mbed_official | 155:8435094ec241 | 1371 | better to use the TXIS and RXNE flags instead. |
mbed_official | 155:8435094ec241 | 1372 | |
mbed_official | 155:8435094ec241 | 1373 | *** Interrupt Mode *** |
mbed_official | 155:8435094ec241 | 1374 | ====================== |
mbed_official | 155:8435094ec241 | 1375 | [..] In Interrupt Mode, the I2C communication can be managed by 7 interrupt sources |
mbed_official | 155:8435094ec241 | 1376 | and 15 pending bits: |
mbed_official | 155:8435094ec241 | 1377 | [..] Interrupt Source: |
mbed_official | 155:8435094ec241 | 1378 | (#) I2C_IT_ERRI: specifies the interrupt source for the Error interrupt. |
mbed_official | 155:8435094ec241 | 1379 | (#) I2C_IT_TCI: specifies the interrupt source for the Transfer Complete interrupt. |
mbed_official | 155:8435094ec241 | 1380 | (#) I2C_IT_STOPI: specifies the interrupt source for the Stop Detection interrupt. |
mbed_official | 155:8435094ec241 | 1381 | (#) I2C_IT_NACKI: specifies the interrupt source for the Not Acknowledge received interrupt. |
mbed_official | 155:8435094ec241 | 1382 | (#) I2C_IT_ADDRI: specifies the interrupt source for the Address Match interrupt. |
mbed_official | 155:8435094ec241 | 1383 | (#) I2C_IT_RXI: specifies the interrupt source for the RX interrupt. |
mbed_official | 155:8435094ec241 | 1384 | (#) I2C_IT_TXI: specifies the interrupt source for the TX interrupt. |
mbed_official | 155:8435094ec241 | 1385 | |
mbed_official | 155:8435094ec241 | 1386 | [..] Pending Bits: |
mbed_official | 155:8435094ec241 | 1387 | (#) I2C_IT_TXIS: to indicate the status of Transmit interrupt status flag. |
mbed_official | 155:8435094ec241 | 1388 | (#) I2C_IT_RXNE: to indicate the status of Receive data register not empty flag. |
mbed_official | 155:8435094ec241 | 1389 | (#) I2C_IT_ADDR: to indicate the status of Address matched flag (slave mode). |
mbed_official | 155:8435094ec241 | 1390 | (#) I2C_IT_NACKF: to indicate the status of NACK received flag. |
mbed_official | 155:8435094ec241 | 1391 | (#) I2C_IT_STOPF: to indicate the status of STOP detection flag. |
mbed_official | 155:8435094ec241 | 1392 | (#) I2C_IT_TC: to indicate the status of Transfer complete flag (master mode). |
mbed_official | 155:8435094ec241 | 1393 | (#) I2C_IT_TCR: to indicate the status of Transfer complete reload flag. |
mbed_official | 155:8435094ec241 | 1394 | (#) I2C_IT_BERR: to indicate the status of Bus error flag. |
mbed_official | 155:8435094ec241 | 1395 | (#) I2C_IT_ARLO: to indicate the status of Arbitration lost flag. |
mbed_official | 155:8435094ec241 | 1396 | (#) I2C_IT_OVR: to indicate the status of Overrun/Underrun flag. |
mbed_official | 155:8435094ec241 | 1397 | (#) I2C_IT_PECERR: to indicate the status of PEC error in reception flag. |
mbed_official | 155:8435094ec241 | 1398 | (#) I2C_IT_TIMEOUT: to indicate the status of Timeout or Tlow detection flag. |
mbed_official | 155:8435094ec241 | 1399 | (#) I2C_IT_ALERT: to indicate the status of SMBus Alert flag. |
mbed_official | 155:8435094ec241 | 1400 | |
mbed_official | 155:8435094ec241 | 1401 | [..] In this Mode it is advised to use the following functions: |
mbed_official | 155:8435094ec241 | 1402 | (+) void I2C_ClearITPendingBit(I2C_TypeDef* I2Cx, uint32_t I2C_IT); |
mbed_official | 155:8435094ec241 | 1403 | (+) ITStatus I2C_GetITStatus(I2C_TypeDef* I2Cx, uint32_t I2C_IT); |
mbed_official | 155:8435094ec241 | 1404 | |
mbed_official | 155:8435094ec241 | 1405 | @endverbatim |
mbed_official | 155:8435094ec241 | 1406 | * @{ |
mbed_official | 155:8435094ec241 | 1407 | */ |
mbed_official | 155:8435094ec241 | 1408 | |
mbed_official | 155:8435094ec241 | 1409 | /** |
mbed_official | 155:8435094ec241 | 1410 | * @brief Checks whether the specified I2C flag is set or not. |
mbed_official | 155:8435094ec241 | 1411 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1412 | * @param I2C_FLAG: specifies the flag to check. |
mbed_official | 155:8435094ec241 | 1413 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 1414 | * @arg I2C_FLAG_TXE: Transmit data register empty |
mbed_official | 155:8435094ec241 | 1415 | * @arg I2C_FLAG_TXIS: Transmit interrupt status |
mbed_official | 155:8435094ec241 | 1416 | * @arg I2C_FLAG_RXNE: Receive data register not empty |
mbed_official | 155:8435094ec241 | 1417 | * @arg I2C_FLAG_ADDR: Address matched (slave mode) |
mbed_official | 155:8435094ec241 | 1418 | * @arg I2C_FLAG_NACKF: NACK received flag |
mbed_official | 155:8435094ec241 | 1419 | * @arg I2C_FLAG_STOPF: STOP detection flag |
mbed_official | 155:8435094ec241 | 1420 | * @arg I2C_FLAG_TC: Transfer complete (master mode) |
mbed_official | 155:8435094ec241 | 1421 | * @arg I2C_FLAG_TCR: Transfer complete reload |
mbed_official | 155:8435094ec241 | 1422 | * @arg I2C_FLAG_BERR: Bus error |
mbed_official | 155:8435094ec241 | 1423 | * @arg I2C_FLAG_ARLO: Arbitration lost |
mbed_official | 155:8435094ec241 | 1424 | * @arg I2C_FLAG_OVR: Overrun/Underrun |
mbed_official | 155:8435094ec241 | 1425 | * @arg I2C_FLAG_PECERR: PEC error in reception |
mbed_official | 155:8435094ec241 | 1426 | * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow detection flag |
mbed_official | 155:8435094ec241 | 1427 | * @arg I2C_FLAG_ALERT: SMBus Alert |
mbed_official | 155:8435094ec241 | 1428 | * @arg I2C_FLAG_BUSY: Bus busy |
mbed_official | 155:8435094ec241 | 1429 | * @retval The new state of I2C_FLAG (SET or RESET). |
mbed_official | 155:8435094ec241 | 1430 | */ |
mbed_official | 155:8435094ec241 | 1431 | FlagStatus I2C_GetFlagStatus(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG) |
mbed_official | 155:8435094ec241 | 1432 | { |
mbed_official | 155:8435094ec241 | 1433 | uint32_t tmpreg = 0; |
mbed_official | 155:8435094ec241 | 1434 | FlagStatus bitstatus = RESET; |
mbed_official | 155:8435094ec241 | 1435 | |
mbed_official | 155:8435094ec241 | 1436 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1437 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1438 | assert_param(IS_I2C_GET_FLAG(I2C_FLAG)); |
mbed_official | 155:8435094ec241 | 1439 | |
mbed_official | 155:8435094ec241 | 1440 | /* Get the ISR register value */ |
mbed_official | 155:8435094ec241 | 1441 | tmpreg = I2Cx->ISR; |
mbed_official | 155:8435094ec241 | 1442 | |
mbed_official | 155:8435094ec241 | 1443 | /* Get flag status */ |
mbed_official | 155:8435094ec241 | 1444 | tmpreg &= I2C_FLAG; |
mbed_official | 155:8435094ec241 | 1445 | |
mbed_official | 155:8435094ec241 | 1446 | if(tmpreg != 0) |
mbed_official | 155:8435094ec241 | 1447 | { |
mbed_official | 155:8435094ec241 | 1448 | /* I2C_FLAG is set */ |
mbed_official | 155:8435094ec241 | 1449 | bitstatus = SET; |
mbed_official | 155:8435094ec241 | 1450 | } |
mbed_official | 155:8435094ec241 | 1451 | else |
mbed_official | 155:8435094ec241 | 1452 | { |
mbed_official | 155:8435094ec241 | 1453 | /* I2C_FLAG is reset */ |
mbed_official | 155:8435094ec241 | 1454 | bitstatus = RESET; |
mbed_official | 155:8435094ec241 | 1455 | } |
mbed_official | 155:8435094ec241 | 1456 | return bitstatus; |
mbed_official | 155:8435094ec241 | 1457 | } |
mbed_official | 155:8435094ec241 | 1458 | |
mbed_official | 155:8435094ec241 | 1459 | /** |
mbed_official | 155:8435094ec241 | 1460 | * @brief Clears the I2Cx's pending flags. |
mbed_official | 155:8435094ec241 | 1461 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1462 | * @param I2C_FLAG: specifies the flag to clear. |
mbed_official | 155:8435094ec241 | 1463 | * This parameter can be any combination of the following values: |
mbed_official | 155:8435094ec241 | 1464 | * @arg I2C_FLAG_ADDR: Address matched (slave mode) |
mbed_official | 155:8435094ec241 | 1465 | * @arg I2C_FLAG_NACKF: NACK received flag |
mbed_official | 155:8435094ec241 | 1466 | * @arg I2C_FLAG_STOPF: STOP detection flag |
mbed_official | 155:8435094ec241 | 1467 | * @arg I2C_FLAG_BERR: Bus error |
mbed_official | 155:8435094ec241 | 1468 | * @arg I2C_FLAG_ARLO: Arbitration lost |
mbed_official | 155:8435094ec241 | 1469 | * @arg I2C_FLAG_OVR: Overrun/Underrun |
mbed_official | 155:8435094ec241 | 1470 | * @arg I2C_FLAG_PECERR: PEC error in reception |
mbed_official | 155:8435094ec241 | 1471 | * @arg I2C_FLAG_TIMEOUT: Timeout or Tlow detection flag |
mbed_official | 155:8435094ec241 | 1472 | * @arg I2C_FLAG_ALERT: SMBus Alert |
mbed_official | 155:8435094ec241 | 1473 | * @retval The new state of I2C_FLAG (SET or RESET). |
mbed_official | 155:8435094ec241 | 1474 | */ |
mbed_official | 155:8435094ec241 | 1475 | void I2C_ClearFlag(I2C_TypeDef* I2Cx, uint32_t I2C_FLAG) |
mbed_official | 155:8435094ec241 | 1476 | { |
mbed_official | 155:8435094ec241 | 1477 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1478 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1479 | assert_param(IS_I2C_CLEAR_FLAG(I2C_FLAG)); |
mbed_official | 155:8435094ec241 | 1480 | |
mbed_official | 155:8435094ec241 | 1481 | /* Clear the selected flag */ |
mbed_official | 155:8435094ec241 | 1482 | I2Cx->ICR = I2C_FLAG; |
mbed_official | 155:8435094ec241 | 1483 | } |
mbed_official | 155:8435094ec241 | 1484 | |
mbed_official | 155:8435094ec241 | 1485 | /** |
mbed_official | 155:8435094ec241 | 1486 | * @brief Checks whether the specified I2C interrupt has occurred or not. |
mbed_official | 155:8435094ec241 | 1487 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1488 | * @param I2C_IT: specifies the interrupt source to check. |
mbed_official | 155:8435094ec241 | 1489 | * This parameter can be one of the following values: |
mbed_official | 155:8435094ec241 | 1490 | * @arg I2C_IT_TXIS: Transmit interrupt status |
mbed_official | 155:8435094ec241 | 1491 | * @arg I2C_IT_RXNE: Receive data register not empty |
mbed_official | 155:8435094ec241 | 1492 | * @arg I2C_IT_ADDR: Address matched (slave mode) |
mbed_official | 155:8435094ec241 | 1493 | * @arg I2C_IT_NACKF: NACK received flag |
mbed_official | 155:8435094ec241 | 1494 | * @arg I2C_IT_STOPF: STOP detection flag |
mbed_official | 155:8435094ec241 | 1495 | * @arg I2C_IT_TC: Transfer complete (master mode) |
mbed_official | 155:8435094ec241 | 1496 | * @arg I2C_IT_TCR: Transfer complete reload |
mbed_official | 155:8435094ec241 | 1497 | * @arg I2C_IT_BERR: Bus error |
mbed_official | 155:8435094ec241 | 1498 | * @arg I2C_IT_ARLO: Arbitration lost |
mbed_official | 155:8435094ec241 | 1499 | * @arg I2C_IT_OVR: Overrun/Underrun |
mbed_official | 155:8435094ec241 | 1500 | * @arg I2C_IT_PECERR: PEC error in reception |
mbed_official | 155:8435094ec241 | 1501 | * @arg I2C_IT_TIMEOUT: Timeout or Tlow detection flag |
mbed_official | 155:8435094ec241 | 1502 | * @arg I2C_IT_ALERT: SMBus Alert |
mbed_official | 155:8435094ec241 | 1503 | * @retval The new state of I2C_IT (SET or RESET). |
mbed_official | 155:8435094ec241 | 1504 | */ |
mbed_official | 155:8435094ec241 | 1505 | ITStatus I2C_GetITStatus(I2C_TypeDef* I2Cx, uint32_t I2C_IT) |
mbed_official | 155:8435094ec241 | 1506 | { |
mbed_official | 155:8435094ec241 | 1507 | uint32_t tmpreg = 0; |
mbed_official | 155:8435094ec241 | 1508 | ITStatus bitstatus = RESET; |
mbed_official | 155:8435094ec241 | 1509 | uint32_t enablestatus = 0; |
mbed_official | 155:8435094ec241 | 1510 | |
mbed_official | 155:8435094ec241 | 1511 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1512 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1513 | assert_param(IS_I2C_GET_IT(I2C_IT)); |
mbed_official | 155:8435094ec241 | 1514 | |
mbed_official | 155:8435094ec241 | 1515 | /* Check if the interrupt source is enabled or not */ |
mbed_official | 155:8435094ec241 | 1516 | /* If Error interrupt */ |
mbed_official | 155:8435094ec241 | 1517 | if((uint32_t)(I2C_IT & ERROR_IT_MASK)) |
mbed_official | 155:8435094ec241 | 1518 | { |
mbed_official | 155:8435094ec241 | 1519 | enablestatus = (uint32_t)((I2C_CR1_ERRIE) & (I2Cx->CR1)); |
mbed_official | 155:8435094ec241 | 1520 | } |
mbed_official | 155:8435094ec241 | 1521 | /* If TC interrupt */ |
mbed_official | 155:8435094ec241 | 1522 | else if((uint32_t)(I2C_IT & TC_IT_MASK)) |
mbed_official | 155:8435094ec241 | 1523 | { |
mbed_official | 155:8435094ec241 | 1524 | enablestatus = (uint32_t)((I2C_CR1_TCIE) & (I2Cx->CR1)); |
mbed_official | 155:8435094ec241 | 1525 | } |
mbed_official | 155:8435094ec241 | 1526 | else |
mbed_official | 155:8435094ec241 | 1527 | { |
mbed_official | 155:8435094ec241 | 1528 | enablestatus = (uint32_t)((I2C_IT) & (I2Cx->CR1)); |
mbed_official | 155:8435094ec241 | 1529 | } |
mbed_official | 155:8435094ec241 | 1530 | |
mbed_official | 155:8435094ec241 | 1531 | /* Get the ISR register value */ |
mbed_official | 155:8435094ec241 | 1532 | tmpreg = I2Cx->ISR; |
mbed_official | 155:8435094ec241 | 1533 | |
mbed_official | 155:8435094ec241 | 1534 | /* Get flag status */ |
mbed_official | 155:8435094ec241 | 1535 | tmpreg &= I2C_IT; |
mbed_official | 155:8435094ec241 | 1536 | |
mbed_official | 155:8435094ec241 | 1537 | /* Check the status of the specified I2C flag */ |
mbed_official | 155:8435094ec241 | 1538 | if((tmpreg != RESET) && enablestatus) |
mbed_official | 155:8435094ec241 | 1539 | { |
mbed_official | 155:8435094ec241 | 1540 | /* I2C_IT is set */ |
mbed_official | 155:8435094ec241 | 1541 | bitstatus = SET; |
mbed_official | 155:8435094ec241 | 1542 | } |
mbed_official | 155:8435094ec241 | 1543 | else |
mbed_official | 155:8435094ec241 | 1544 | { |
mbed_official | 155:8435094ec241 | 1545 | /* I2C_IT is reset */ |
mbed_official | 155:8435094ec241 | 1546 | bitstatus = RESET; |
mbed_official | 155:8435094ec241 | 1547 | } |
mbed_official | 155:8435094ec241 | 1548 | |
mbed_official | 155:8435094ec241 | 1549 | /* Return the I2C_IT status */ |
mbed_official | 155:8435094ec241 | 1550 | return bitstatus; |
mbed_official | 155:8435094ec241 | 1551 | } |
mbed_official | 155:8435094ec241 | 1552 | |
mbed_official | 155:8435094ec241 | 1553 | /** |
mbed_official | 155:8435094ec241 | 1554 | * @brief Clears the I2Cx's interrupt pending bits. |
mbed_official | 155:8435094ec241 | 1555 | * @param I2Cx: where x can be 1 or 2 to select the I2C peripheral. |
mbed_official | 155:8435094ec241 | 1556 | * @param I2C_IT: specifies the interrupt pending bit to clear. |
mbed_official | 155:8435094ec241 | 1557 | * This parameter can be any combination of the following values: |
mbed_official | 155:8435094ec241 | 1558 | * @arg I2C_IT_ADDR: Address matched (slave mode) |
mbed_official | 155:8435094ec241 | 1559 | * @arg I2C_IT_NACKF: NACK received flag |
mbed_official | 155:8435094ec241 | 1560 | * @arg I2C_IT_STOPF: STOP detection flag |
mbed_official | 155:8435094ec241 | 1561 | * @arg I2C_IT_BERR: Bus error |
mbed_official | 155:8435094ec241 | 1562 | * @arg I2C_IT_ARLO: Arbitration lost |
mbed_official | 155:8435094ec241 | 1563 | * @arg I2C_IT_OVR: Overrun/Underrun |
mbed_official | 155:8435094ec241 | 1564 | * @arg I2C_IT_PECERR: PEC error in reception |
mbed_official | 155:8435094ec241 | 1565 | * @arg I2C_IT_TIMEOUT: Timeout or Tlow detection flag |
mbed_official | 155:8435094ec241 | 1566 | * @arg I2C_IT_ALERT: SMBus Alert |
mbed_official | 155:8435094ec241 | 1567 | * @retval The new state of I2C_IT (SET or RESET). |
mbed_official | 155:8435094ec241 | 1568 | */ |
mbed_official | 155:8435094ec241 | 1569 | void I2C_ClearITPendingBit(I2C_TypeDef* I2Cx, uint32_t I2C_IT) |
mbed_official | 155:8435094ec241 | 1570 | { |
mbed_official | 155:8435094ec241 | 1571 | /* Check the parameters */ |
mbed_official | 155:8435094ec241 | 1572 | assert_param(IS_I2C_ALL_PERIPH(I2Cx)); |
mbed_official | 155:8435094ec241 | 1573 | assert_param(IS_I2C_CLEAR_IT(I2C_IT)); |
mbed_official | 155:8435094ec241 | 1574 | |
mbed_official | 155:8435094ec241 | 1575 | /* Clear the selected flag */ |
mbed_official | 155:8435094ec241 | 1576 | I2Cx->ICR = I2C_IT; |
mbed_official | 155:8435094ec241 | 1577 | } |
mbed_official | 155:8435094ec241 | 1578 | |
mbed_official | 155:8435094ec241 | 1579 | /** |
mbed_official | 155:8435094ec241 | 1580 | * @} |
mbed_official | 155:8435094ec241 | 1581 | */ |
mbed_official | 155:8435094ec241 | 1582 | |
mbed_official | 155:8435094ec241 | 1583 | /** |
mbed_official | 155:8435094ec241 | 1584 | * @} |
mbed_official | 155:8435094ec241 | 1585 | */ |
mbed_official | 155:8435094ec241 | 1586 | |
mbed_official | 155:8435094ec241 | 1587 | /** |
mbed_official | 155:8435094ec241 | 1588 | * @} |
mbed_official | 155:8435094ec241 | 1589 | */ |
mbed_official | 155:8435094ec241 | 1590 | |
mbed_official | 155:8435094ec241 | 1591 | /** |
mbed_official | 155:8435094ec241 | 1592 | * @} |
mbed_official | 155:8435094ec241 | 1593 | */ |
mbed_official | 155:8435094ec241 | 1594 | |
mbed_official | 155:8435094ec241 | 1595 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |