mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

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

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

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

Import librarymbed

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

Committer:
mbed_official
Date:
Thu Jul 02 16:30:08 2015 +0100
Revision:
581:39197bcd20f2
Parent:
532:fe11edbda85c
Child:
613:bc40b8d2aec4
Synchronized with git revision ae2d3cdffe70184eb8736d94f76c45c93f4b7724

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

Make it possible to build the core mbed library with yotta

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 87:085cde657901 1 /**
mbed_official 87:085cde657901 2 ******************************************************************************
mbed_official 87:085cde657901 3 * @file stm32f4xx_hal_i2c_ex.c
mbed_official 87:085cde657901 4 * @author MCD Application Team
mbed_official 532:fe11edbda85c 5 * @version V1.3.0
mbed_official 532:fe11edbda85c 6 * @date 09-March-2015
mbed_official 87:085cde657901 7 * @brief I2C Extension HAL module driver.
mbed_official 87:085cde657901 8 * This file provides firmware functions to manage the following
mbed_official 87:085cde657901 9 * functionalities of I2C extension peripheral:
mbed_official 87:085cde657901 10 * + Extension features functions
mbed_official 87:085cde657901 11 *
mbed_official 87:085cde657901 12 @verbatim
mbed_official 87:085cde657901 13 ==============================================================================
mbed_official 87:085cde657901 14 ##### I2C peripheral extension features #####
mbed_official 87:085cde657901 15 ==============================================================================
mbed_official 87:085cde657901 16
mbed_official 226:b062af740e40 17 [..] Comparing to other previous devices, the I2C interface for STM32F427xx/437xx/
mbed_official 226:b062af740e40 18 429xx/439xx devices contains the following additional features :
mbed_official 87:085cde657901 19
mbed_official 87:085cde657901 20 (+) Possibility to disable or enable Analog Noise Filter
mbed_official 87:085cde657901 21 (+) Use of a configured Digital Noise Filter
mbed_official 87:085cde657901 22
mbed_official 87:085cde657901 23 ##### How to use this driver #####
mbed_official 87:085cde657901 24 ==============================================================================
mbed_official 87:085cde657901 25 [..] This driver provides functions to configure Noise Filter
mbed_official 87:085cde657901 26 (#) Configure I2C Analog noise filter using the function HAL_I2C_AnalogFilter_Config()
mbed_official 87:085cde657901 27 (#) Configure I2C Digital noise filter using the function HAL_I2C_DigitalFilter_Config()
mbed_official 87:085cde657901 28
mbed_official 87:085cde657901 29 @endverbatim
mbed_official 87:085cde657901 30 ******************************************************************************
mbed_official 87:085cde657901 31 * @attention
mbed_official 87:085cde657901 32 *
mbed_official 532:fe11edbda85c 33 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
mbed_official 87:085cde657901 34 *
mbed_official 87:085cde657901 35 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 87:085cde657901 36 * are permitted provided that the following conditions are met:
mbed_official 87:085cde657901 37 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 87:085cde657901 38 * this list of conditions and the following disclaimer.
mbed_official 87:085cde657901 39 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 87:085cde657901 40 * this list of conditions and the following disclaimer in the documentation
mbed_official 87:085cde657901 41 * and/or other materials provided with the distribution.
mbed_official 87:085cde657901 42 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 87:085cde657901 43 * may be used to endorse or promote products derived from this software
mbed_official 87:085cde657901 44 * without specific prior written permission.
mbed_official 87:085cde657901 45 *
mbed_official 87:085cde657901 46 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 87:085cde657901 47 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 87:085cde657901 48 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 87:085cde657901 49 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 87:085cde657901 50 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 87:085cde657901 51 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 87:085cde657901 52 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 87:085cde657901 53 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 87:085cde657901 54 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 87:085cde657901 55 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 87:085cde657901 56 *
mbed_official 87:085cde657901 57 ******************************************************************************
mbed_official 87:085cde657901 58 */
mbed_official 87:085cde657901 59
mbed_official 87:085cde657901 60 /* Includes ------------------------------------------------------------------*/
mbed_official 87:085cde657901 61 #include "stm32f4xx_hal.h"
mbed_official 87:085cde657901 62
mbed_official 87:085cde657901 63 /** @addtogroup STM32F4xx_HAL_Driver
mbed_official 87:085cde657901 64 * @{
mbed_official 87:085cde657901 65 */
mbed_official 87:085cde657901 66
mbed_official 532:fe11edbda85c 67 /** @defgroup I2CEx I2CEx
mbed_official 87:085cde657901 68 * @brief I2C HAL module driver
mbed_official 87:085cde657901 69 * @{
mbed_official 87:085cde657901 70 */
mbed_official 87:085cde657901 71
mbed_official 87:085cde657901 72 #ifdef HAL_I2C_MODULE_ENABLED
mbed_official 87:085cde657901 73
mbed_official 532:fe11edbda85c 74 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) ||\
mbed_official 532:fe11edbda85c 75 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx)
mbed_official 87:085cde657901 76 /* Private typedef -----------------------------------------------------------*/
mbed_official 87:085cde657901 77 /* Private define ------------------------------------------------------------*/
mbed_official 87:085cde657901 78 /* Private macro -------------------------------------------------------------*/
mbed_official 87:085cde657901 79 /* Private variables ---------------------------------------------------------*/
mbed_official 87:085cde657901 80 /* Private function prototypes -----------------------------------------------*/
mbed_official 532:fe11edbda85c 81 /* Exported functions --------------------------------------------------------*/
mbed_official 532:fe11edbda85c 82 /** @defgroup I2CEx_Exported_Functions I2C Exported Functions
mbed_official 87:085cde657901 83 * @{
mbed_official 87:085cde657901 84 */
mbed_official 87:085cde657901 85
mbed_official 87:085cde657901 86
mbed_official 532:fe11edbda85c 87 /** @defgroup I2CEx_Exported_Functions_Group1 Extension features functions
mbed_official 87:085cde657901 88 * @brief Extension features functions
mbed_official 87:085cde657901 89 *
mbed_official 87:085cde657901 90 @verbatim
mbed_official 87:085cde657901 91 ===============================================================================
mbed_official 87:085cde657901 92 ##### Extension features functions #####
mbed_official 87:085cde657901 93 ===============================================================================
mbed_official 87:085cde657901 94 [..] This section provides functions allowing to:
mbed_official 87:085cde657901 95 (+) Configure Noise Filters
mbed_official 87:085cde657901 96
mbed_official 87:085cde657901 97 @endverbatim
mbed_official 87:085cde657901 98 * @{
mbed_official 87:085cde657901 99 */
mbed_official 87:085cde657901 100
mbed_official 87:085cde657901 101 /**
mbed_official 87:085cde657901 102 * @brief Configures I2C Analog noise filter.
mbed_official 226:b062af740e40 103 * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains
mbed_official 87:085cde657901 104 * the configuration information for the specified I2Cx peripheral.
mbed_official 226:b062af740e40 105 * @param AnalogFilter: new state of the Analog filter.
mbed_official 87:085cde657901 106 * @retval HAL status
mbed_official 87:085cde657901 107 */
mbed_official 532:fe11edbda85c 108 HAL_StatusTypeDef HAL_I2CEx_ConfigAnalogFilter(I2C_HandleTypeDef *hi2c, uint32_t AnalogFilter)
mbed_official 87:085cde657901 109 {
mbed_official 87:085cde657901 110 uint32_t tmp = 0;
mbed_official 87:085cde657901 111
mbed_official 87:085cde657901 112 /* Check the parameters */
mbed_official 87:085cde657901 113 assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
mbed_official 87:085cde657901 114 assert_param(IS_I2C_ANALOG_FILTER(AnalogFilter));
mbed_official 87:085cde657901 115
mbed_official 87:085cde657901 116 tmp = hi2c->State;
mbed_official 87:085cde657901 117 if((tmp == HAL_I2C_STATE_BUSY) || (tmp == HAL_I2C_STATE_BUSY_TX) || (tmp == HAL_I2C_STATE_BUSY_RX))
mbed_official 87:085cde657901 118 {
mbed_official 87:085cde657901 119 return HAL_BUSY;
mbed_official 87:085cde657901 120 }
mbed_official 87:085cde657901 121
mbed_official 87:085cde657901 122 hi2c->State = HAL_I2C_STATE_BUSY;
mbed_official 87:085cde657901 123
mbed_official 87:085cde657901 124 /* Disable the selected I2C peripheral */
mbed_official 87:085cde657901 125 __HAL_I2C_DISABLE(hi2c);
mbed_official 87:085cde657901 126
mbed_official 87:085cde657901 127 /* Reset I2Cx ANOFF bit */
mbed_official 87:085cde657901 128 hi2c->Instance->FLTR &= ~(I2C_FLTR_ANOFF);
mbed_official 87:085cde657901 129
mbed_official 87:085cde657901 130 /* Disable the analog filter */
mbed_official 87:085cde657901 131 hi2c->Instance->FLTR |= AnalogFilter;
mbed_official 87:085cde657901 132
mbed_official 87:085cde657901 133 __HAL_I2C_ENABLE(hi2c);
mbed_official 87:085cde657901 134
mbed_official 87:085cde657901 135 hi2c->State = HAL_I2C_STATE_READY;
mbed_official 87:085cde657901 136
mbed_official 87:085cde657901 137 return HAL_OK;
mbed_official 87:085cde657901 138 }
mbed_official 87:085cde657901 139
mbed_official 87:085cde657901 140 /**
mbed_official 87:085cde657901 141 * @brief Configures I2C Digital noise filter.
mbed_official 226:b062af740e40 142 * @param hi2c: pointer to a I2C_HandleTypeDef structure that contains
mbed_official 87:085cde657901 143 * the configuration information for the specified I2Cx peripheral.
mbed_official 226:b062af740e40 144 * @param DigitalFilter: Coefficient of digital noise filter between 0x00 and 0x0F.
mbed_official 87:085cde657901 145 * @retval HAL status
mbed_official 87:085cde657901 146 */
mbed_official 532:fe11edbda85c 147 HAL_StatusTypeDef HAL_I2CEx_ConfigDigitalFilter(I2C_HandleTypeDef *hi2c, uint32_t DigitalFilter)
mbed_official 87:085cde657901 148 {
mbed_official 87:085cde657901 149 uint16_t tmpreg = 0;
mbed_official 87:085cde657901 150 uint32_t tmp = 0;
mbed_official 87:085cde657901 151
mbed_official 87:085cde657901 152 /* Check the parameters */
mbed_official 87:085cde657901 153 assert_param(IS_I2C_ALL_INSTANCE(hi2c->Instance));
mbed_official 87:085cde657901 154 assert_param(IS_I2C_DIGITAL_FILTER(DigitalFilter));
mbed_official 87:085cde657901 155
mbed_official 87:085cde657901 156 tmp = hi2c->State;
mbed_official 87:085cde657901 157 if((tmp == HAL_I2C_STATE_BUSY) || (tmp == HAL_I2C_STATE_BUSY_TX) || (tmp == HAL_I2C_STATE_BUSY_RX))
mbed_official 87:085cde657901 158 {
mbed_official 87:085cde657901 159 return HAL_BUSY;
mbed_official 87:085cde657901 160 }
mbed_official 87:085cde657901 161
mbed_official 87:085cde657901 162 hi2c->State = HAL_I2C_STATE_BUSY;
mbed_official 87:085cde657901 163
mbed_official 87:085cde657901 164 /* Disable the selected I2C peripheral */
mbed_official 87:085cde657901 165 __HAL_I2C_DISABLE(hi2c);
mbed_official 87:085cde657901 166
mbed_official 87:085cde657901 167 /* Get the old register value */
mbed_official 87:085cde657901 168 tmpreg = hi2c->Instance->FLTR;
mbed_official 87:085cde657901 169
mbed_official 87:085cde657901 170 /* Reset I2Cx DNF bit [3:0] */
mbed_official 87:085cde657901 171 tmpreg &= ~(I2C_FLTR_DNF);
mbed_official 87:085cde657901 172
mbed_official 87:085cde657901 173 /* Set I2Cx DNF coefficient */
mbed_official 87:085cde657901 174 tmpreg |= DigitalFilter;
mbed_official 87:085cde657901 175
mbed_official 87:085cde657901 176 /* Store the new register value */
mbed_official 87:085cde657901 177 hi2c->Instance->FLTR = tmpreg;
mbed_official 87:085cde657901 178
mbed_official 87:085cde657901 179 __HAL_I2C_ENABLE(hi2c);
mbed_official 87:085cde657901 180
mbed_official 87:085cde657901 181 hi2c->State = HAL_I2C_STATE_READY;
mbed_official 87:085cde657901 182
mbed_official 87:085cde657901 183 return HAL_OK;
mbed_official 87:085cde657901 184 }
mbed_official 87:085cde657901 185
mbed_official 87:085cde657901 186 /**
mbed_official 87:085cde657901 187 * @}
mbed_official 87:085cde657901 188 */
mbed_official 87:085cde657901 189
mbed_official 87:085cde657901 190 /**
mbed_official 87:085cde657901 191 * @}
mbed_official 87:085cde657901 192 */
mbed_official 532:fe11edbda85c 193 #endif /* STM32F427xx || STM32F429xx || STM32F437xx || STM32F439xx || STM32F401xC || STM32F401xE || STM32F446xx */
mbed_official 87:085cde657901 194
mbed_official 87:085cde657901 195 #endif /* HAL_I2C_MODULE_ENABLED */
mbed_official 87:085cde657901 196 /**
mbed_official 87:085cde657901 197 * @}
mbed_official 87:085cde657901 198 */
mbed_official 87:085cde657901 199
mbed_official 87:085cde657901 200 /**
mbed_official 87:085cde657901 201 * @}
mbed_official 87:085cde657901 202 */
mbed_official 87:085cde657901 203
mbed_official 87:085cde657901 204 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/