mbed library sources
Fork of mbed-src by
targets/cmsis/TARGET_STM/TARGET_NUCLEO_L152RE/stm32l1xx_syscfg.c@106:ced8cbb51063, 2014-02-26 (annotated)
- Committer:
- mbed_official
- Date:
- Wed Feb 26 09:45:12 2014 +0000
- Revision:
- 106:ced8cbb51063
- Parent:
- 80:66393a7b209d
Synchronized with git revision 4222735eff5868389433f0e9271976b39c8115cd
Full URL: https://github.com/mbedmicro/mbed/commit/4222735eff5868389433f0e9271976b39c8115cd/
[NUCLEO_xxx] Update STM32CubeF4 driver V1.0.0 + update license
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbed_official | 76:aeb1df146756 | 1 | /** |
mbed_official | 76:aeb1df146756 | 2 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 3 | * @file stm32l1xx_syscfg.c |
mbed_official | 76:aeb1df146756 | 4 | * @author MCD Application Team |
mbed_official | 80:66393a7b209d | 5 | * @version V1.3.0 |
mbed_official | 80:66393a7b209d | 6 | * @date 31-January-2014 |
mbed_official | 76:aeb1df146756 | 7 | * @brief This file provides firmware functions to manage the following |
mbed_official | 76:aeb1df146756 | 8 | * functionalities of the SYSCFG and RI peripherals: |
mbed_official | 76:aeb1df146756 | 9 | * + SYSCFG Initialization and Configuration |
mbed_official | 76:aeb1df146756 | 10 | * + RI Initialization and Configuration |
mbed_official | 76:aeb1df146756 | 11 | * |
mbed_official | 76:aeb1df146756 | 12 | @verbatim |
mbed_official | 76:aeb1df146756 | 13 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 14 | ##### How to use this driver ##### |
mbed_official | 76:aeb1df146756 | 15 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 16 | [..] This driver provides functions for: |
mbed_official | 76:aeb1df146756 | 17 | (#) Remapping the memory accessible in the code area using |
mbed_official | 76:aeb1df146756 | 18 | SYSCFG_MemoryRemapConfig(). |
mbed_official | 76:aeb1df146756 | 19 | (#) Manage the EXTI lines connection to the GPIOs using |
mbed_official | 76:aeb1df146756 | 20 | SYSCFG_EXTILineConfig(). |
mbed_official | 76:aeb1df146756 | 21 | (#) Routing of I/Os toward the input captures of timers (TIM2, TIM3 and TIM4). |
mbed_official | 76:aeb1df146756 | 22 | (#) Input routing of COMP1 and COMP2. |
mbed_official | 76:aeb1df146756 | 23 | (#) Routing of internal reference voltage VREFINT to PB0 and PB1. |
mbed_official | 76:aeb1df146756 | 24 | (#) The RI registers can be accessed only when the comparator |
mbed_official | 76:aeb1df146756 | 25 | APB interface clock is enabled. |
mbed_official | 76:aeb1df146756 | 26 | To enable comparator clock use: |
mbed_official | 76:aeb1df146756 | 27 | RCC_APB1PeriphClockCmd(RCC_APB1Periph_COMP, ENABLE). |
mbed_official | 76:aeb1df146756 | 28 | Following functions uses RI registers: |
mbed_official | 76:aeb1df146756 | 29 | (++) SYSCFG_RIDeInit() |
mbed_official | 76:aeb1df146756 | 30 | (++) SYSCFG_RITIMSelect() |
mbed_official | 76:aeb1df146756 | 31 | (++) SYSCFG_RITIMInputCaptureConfig() |
mbed_official | 76:aeb1df146756 | 32 | (++) SYSCFG_RIResistorConfig() |
mbed_official | 76:aeb1df146756 | 33 | (++) SYSCFG_RIChannelSpeedConfig() |
mbed_official | 76:aeb1df146756 | 34 | (++) SYSCFG_RIIOSwitchConfig() |
mbed_official | 76:aeb1df146756 | 35 | (++) SYSCFG_RISwitchControlModeCmd() |
mbed_official | 76:aeb1df146756 | 36 | (++) SYSCFG_RIHysteresisConfig() |
mbed_official | 76:aeb1df146756 | 37 | (#) The SYSCFG registers can be accessed only when the SYSCFG |
mbed_official | 76:aeb1df146756 | 38 | interface APB clock is enabled. |
mbed_official | 76:aeb1df146756 | 39 | To enable SYSCFG APB clock use: |
mbed_official | 76:aeb1df146756 | 40 | RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE); |
mbed_official | 76:aeb1df146756 | 41 | Following functions uses SYSCFG registers: |
mbed_official | 76:aeb1df146756 | 42 | (++) SYSCFG_DeInit() |
mbed_official | 76:aeb1df146756 | 43 | (++) SYSCFG_MemoryRemapConfig() |
mbed_official | 76:aeb1df146756 | 44 | (++) SYSCFG_GetBootMode() |
mbed_official | 76:aeb1df146756 | 45 | (++) SYSCFG_USBPuCmd() |
mbed_official | 76:aeb1df146756 | 46 | (++) SYSCFG_EXTILineConfig() |
mbed_official | 76:aeb1df146756 | 47 | @endverbatim |
mbed_official | 76:aeb1df146756 | 48 | * |
mbed_official | 76:aeb1df146756 | 49 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 50 | * @attention |
mbed_official | 76:aeb1df146756 | 51 | * |
mbed_official | 106:ced8cbb51063 | 52 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
mbed_official | 76:aeb1df146756 | 53 | * |
mbed_official | 106:ced8cbb51063 | 54 | * Redistribution and use in source and binary forms, with or without modification, |
mbed_official | 106:ced8cbb51063 | 55 | * are permitted provided that the following conditions are met: |
mbed_official | 106:ced8cbb51063 | 56 | * 1. Redistributions of source code must retain the above copyright notice, |
mbed_official | 106:ced8cbb51063 | 57 | * this list of conditions and the following disclaimer. |
mbed_official | 106:ced8cbb51063 | 58 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
mbed_official | 106:ced8cbb51063 | 59 | * this list of conditions and the following disclaimer in the documentation |
mbed_official | 106:ced8cbb51063 | 60 | * and/or other materials provided with the distribution. |
mbed_official | 106:ced8cbb51063 | 61 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
mbed_official | 106:ced8cbb51063 | 62 | * may be used to endorse or promote products derived from this software |
mbed_official | 106:ced8cbb51063 | 63 | * without specific prior written permission. |
mbed_official | 76:aeb1df146756 | 64 | * |
mbed_official | 106:ced8cbb51063 | 65 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
mbed_official | 106:ced8cbb51063 | 66 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
mbed_official | 106:ced8cbb51063 | 67 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
mbed_official | 106:ced8cbb51063 | 68 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
mbed_official | 106:ced8cbb51063 | 69 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
mbed_official | 106:ced8cbb51063 | 70 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
mbed_official | 106:ced8cbb51063 | 71 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
mbed_official | 106:ced8cbb51063 | 72 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
mbed_official | 106:ced8cbb51063 | 73 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
mbed_official | 106:ced8cbb51063 | 74 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
mbed_official | 76:aeb1df146756 | 75 | * |
mbed_official | 76:aeb1df146756 | 76 | ****************************************************************************** |
mbed_official | 76:aeb1df146756 | 77 | */ |
mbed_official | 76:aeb1df146756 | 78 | |
mbed_official | 76:aeb1df146756 | 79 | /* Includes ------------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 80 | #include "stm32l1xx_syscfg.h" |
mbed_official | 76:aeb1df146756 | 81 | #include "stm32l1xx_rcc.h" |
mbed_official | 76:aeb1df146756 | 82 | |
mbed_official | 76:aeb1df146756 | 83 | /** @addtogroup STM32L1xx_StdPeriph_Driver |
mbed_official | 76:aeb1df146756 | 84 | * @{ |
mbed_official | 76:aeb1df146756 | 85 | */ |
mbed_official | 76:aeb1df146756 | 86 | |
mbed_official | 76:aeb1df146756 | 87 | /** @defgroup SYSCFG |
mbed_official | 76:aeb1df146756 | 88 | * @brief SYSCFG driver modules |
mbed_official | 76:aeb1df146756 | 89 | * @{ |
mbed_official | 76:aeb1df146756 | 90 | */ |
mbed_official | 76:aeb1df146756 | 91 | |
mbed_official | 76:aeb1df146756 | 92 | /* Private typedef -----------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 93 | /* Private define ------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 94 | #define TIM_SELECT_MASK ((uint32_t)0xFFFCFFFF) /*!< TIM select mask */ |
mbed_official | 76:aeb1df146756 | 95 | #define IC_ROUTING_MASK ((uint32_t)0x0000000F) /*!< Input Capture routing mask */ |
mbed_official | 76:aeb1df146756 | 96 | |
mbed_official | 76:aeb1df146756 | 97 | /* Private macro -------------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 98 | /* Private variables ---------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 99 | /* Private function prototypes -----------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 100 | /* Private functions ---------------------------------------------------------*/ |
mbed_official | 76:aeb1df146756 | 101 | |
mbed_official | 76:aeb1df146756 | 102 | /** @defgroup SYSCFG_Private_Functions |
mbed_official | 76:aeb1df146756 | 103 | * @{ |
mbed_official | 76:aeb1df146756 | 104 | */ |
mbed_official | 76:aeb1df146756 | 105 | |
mbed_official | 76:aeb1df146756 | 106 | /** @defgroup SYSCFG_Group1 SYSCFG Initialization and Configuration functions |
mbed_official | 76:aeb1df146756 | 107 | * @brief SYSCFG Initialization and Configuration functions |
mbed_official | 76:aeb1df146756 | 108 | * |
mbed_official | 76:aeb1df146756 | 109 | @verbatim |
mbed_official | 76:aeb1df146756 | 110 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 111 | ##### SYSCFG Initialization and Configuration functions ##### |
mbed_official | 76:aeb1df146756 | 112 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 113 | |
mbed_official | 76:aeb1df146756 | 114 | @endverbatim |
mbed_official | 76:aeb1df146756 | 115 | * @{ |
mbed_official | 76:aeb1df146756 | 116 | */ |
mbed_official | 76:aeb1df146756 | 117 | |
mbed_official | 76:aeb1df146756 | 118 | /** |
mbed_official | 76:aeb1df146756 | 119 | * @brief Deinitializes the SYSCFG registers to their default reset values. |
mbed_official | 76:aeb1df146756 | 120 | * @param None. |
mbed_official | 76:aeb1df146756 | 121 | * @retval None. |
mbed_official | 76:aeb1df146756 | 122 | * @Note: MEMRMP bits are not reset by APB2 reset. |
mbed_official | 76:aeb1df146756 | 123 | */ |
mbed_official | 76:aeb1df146756 | 124 | void SYSCFG_DeInit(void) |
mbed_official | 76:aeb1df146756 | 125 | { |
mbed_official | 76:aeb1df146756 | 126 | RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, ENABLE); |
mbed_official | 76:aeb1df146756 | 127 | RCC_APB2PeriphResetCmd(RCC_APB2Periph_SYSCFG, DISABLE); |
mbed_official | 76:aeb1df146756 | 128 | } |
mbed_official | 76:aeb1df146756 | 129 | |
mbed_official | 76:aeb1df146756 | 130 | /** |
mbed_official | 76:aeb1df146756 | 131 | * @brief Deinitializes the RI registers to their default reset values. |
mbed_official | 76:aeb1df146756 | 132 | * @param None. |
mbed_official | 76:aeb1df146756 | 133 | * @retval None. |
mbed_official | 76:aeb1df146756 | 134 | */ |
mbed_official | 76:aeb1df146756 | 135 | void SYSCFG_RIDeInit(void) |
mbed_official | 76:aeb1df146756 | 136 | { |
mbed_official | 76:aeb1df146756 | 137 | RI->ICR = ((uint32_t)0x00000000); /*!< Set RI->ICR to reset value */ |
mbed_official | 76:aeb1df146756 | 138 | RI->ASCR1 = ((uint32_t)0x00000000); /*!< Set RI->ASCR1 to reset value */ |
mbed_official | 76:aeb1df146756 | 139 | RI->ASCR2 = ((uint32_t)0x00000000); /*!< Set RI->ASCR2 to reset value */ |
mbed_official | 76:aeb1df146756 | 140 | RI->HYSCR1 = ((uint32_t)0x00000000); /*!< Set RI->HYSCR1 to reset value */ |
mbed_official | 76:aeb1df146756 | 141 | RI->HYSCR2 = ((uint32_t)0x00000000); /*!< Set RI->HYSCR2 to reset value */ |
mbed_official | 76:aeb1df146756 | 142 | RI->HYSCR3 = ((uint32_t)0x00000000); /*!< Set RI->HYSCR3 to reset value */ |
mbed_official | 76:aeb1df146756 | 143 | RI->HYSCR4 = ((uint32_t)0x00000000); /*!< Set RI->HYSCR4 to reset value */ |
mbed_official | 76:aeb1df146756 | 144 | } |
mbed_official | 76:aeb1df146756 | 145 | |
mbed_official | 76:aeb1df146756 | 146 | /** |
mbed_official | 76:aeb1df146756 | 147 | * @brief Changes the mapping of the specified memory. |
mbed_official | 76:aeb1df146756 | 148 | * @param SYSCFG_Memory: selects the memory remapping. |
mbed_official | 76:aeb1df146756 | 149 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 150 | * @arg SYSCFG_MemoryRemap_Flash: Main Flash memory mapped at 0x00000000 |
mbed_official | 76:aeb1df146756 | 151 | * @arg SYSCFG_MemoryRemap_SystemFlash: System Flash memory mapped at 0x00000000 |
mbed_official | 76:aeb1df146756 | 152 | * @arg SYSCFG_MemoryRemap_FSMC: FSMC memory mapped at 0x00000000 |
mbed_official | 76:aeb1df146756 | 153 | * @arg SYSCFG_MemoryRemap_SRAM: Embedded SRAM mapped at 0x00000000 |
mbed_official | 76:aeb1df146756 | 154 | * @retval None |
mbed_official | 76:aeb1df146756 | 155 | */ |
mbed_official | 76:aeb1df146756 | 156 | void SYSCFG_MemoryRemapConfig(uint8_t SYSCFG_MemoryRemap) |
mbed_official | 76:aeb1df146756 | 157 | { |
mbed_official | 76:aeb1df146756 | 158 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 159 | assert_param(IS_SYSCFG_MEMORY_REMAP_CONFING(SYSCFG_MemoryRemap)); |
mbed_official | 76:aeb1df146756 | 160 | SYSCFG->MEMRMP = SYSCFG_MemoryRemap; |
mbed_official | 76:aeb1df146756 | 161 | } |
mbed_official | 76:aeb1df146756 | 162 | |
mbed_official | 76:aeb1df146756 | 163 | /** |
mbed_official | 76:aeb1df146756 | 164 | * @brief Returns the boot mode as configured by user. |
mbed_official | 76:aeb1df146756 | 165 | * @param None. |
mbed_official | 76:aeb1df146756 | 166 | * @retval The boot mode as configured by user. The returned value can be one |
mbed_official | 76:aeb1df146756 | 167 | * of the following values: |
mbed_official | 76:aeb1df146756 | 168 | * - 0x00000000: Boot is configured in Main Flash memory |
mbed_official | 76:aeb1df146756 | 169 | * - 0x00000100: Boot is configured in System Flash memory |
mbed_official | 76:aeb1df146756 | 170 | * - 0x00000200: Boot is configured in FSMC memory |
mbed_official | 76:aeb1df146756 | 171 | * - 0x00000300: Boot is configured in Embedded SRAM memory |
mbed_official | 76:aeb1df146756 | 172 | */ |
mbed_official | 76:aeb1df146756 | 173 | uint32_t SYSCFG_GetBootMode(void) |
mbed_official | 76:aeb1df146756 | 174 | { |
mbed_official | 76:aeb1df146756 | 175 | return (SYSCFG->MEMRMP & SYSCFG_MEMRMP_BOOT_MODE); |
mbed_official | 76:aeb1df146756 | 176 | } |
mbed_official | 76:aeb1df146756 | 177 | |
mbed_official | 76:aeb1df146756 | 178 | /** |
mbed_official | 76:aeb1df146756 | 179 | * @brief Control the internal pull-up on USB DP line. |
mbed_official | 76:aeb1df146756 | 180 | * @param NewState: New state of the internal pull-up on USB DP line. |
mbed_official | 76:aeb1df146756 | 181 | * This parameter can be ENABLE: Connect internal pull-up on USB DP line. |
mbed_official | 76:aeb1df146756 | 182 | * or DISABLE: Disconnect internal pull-up on USB DP line. |
mbed_official | 76:aeb1df146756 | 183 | * @retval None |
mbed_official | 76:aeb1df146756 | 184 | */ |
mbed_official | 76:aeb1df146756 | 185 | void SYSCFG_USBPuCmd(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 186 | { |
mbed_official | 76:aeb1df146756 | 187 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 188 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 189 | |
mbed_official | 76:aeb1df146756 | 190 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 191 | { |
mbed_official | 76:aeb1df146756 | 192 | /* Connect internal pull-up on USB DP line */ |
mbed_official | 76:aeb1df146756 | 193 | SYSCFG->PMC |= (uint32_t) SYSCFG_PMC_USB_PU; |
mbed_official | 76:aeb1df146756 | 194 | } |
mbed_official | 76:aeb1df146756 | 195 | else |
mbed_official | 76:aeb1df146756 | 196 | { |
mbed_official | 76:aeb1df146756 | 197 | /* Disconnect internal pull-up on USB DP line */ |
mbed_official | 76:aeb1df146756 | 198 | SYSCFG->PMC &= (uint32_t)(~SYSCFG_PMC_USB_PU); |
mbed_official | 76:aeb1df146756 | 199 | } |
mbed_official | 76:aeb1df146756 | 200 | } |
mbed_official | 76:aeb1df146756 | 201 | |
mbed_official | 76:aeb1df146756 | 202 | /** |
mbed_official | 76:aeb1df146756 | 203 | * @brief Selects the GPIO pin used as EXTI Line. |
mbed_official | 76:aeb1df146756 | 204 | * @param EXTI_PortSourceGPIOx : selects the GPIO port to be used as source |
mbed_official | 76:aeb1df146756 | 205 | * for EXTI lines where x can be (A, B, C, D, E, F, G or H). |
mbed_official | 76:aeb1df146756 | 206 | * @param EXTI_PinSourcex: specifies the EXTI line to be configured. |
mbed_official | 76:aeb1df146756 | 207 | * This parameter can be EXTI_PinSourcex where x can be (0..15). |
mbed_official | 76:aeb1df146756 | 208 | * @retval None |
mbed_official | 76:aeb1df146756 | 209 | */ |
mbed_official | 76:aeb1df146756 | 210 | void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex) |
mbed_official | 76:aeb1df146756 | 211 | { |
mbed_official | 76:aeb1df146756 | 212 | uint32_t tmp = 0x00; |
mbed_official | 76:aeb1df146756 | 213 | |
mbed_official | 76:aeb1df146756 | 214 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 215 | assert_param(IS_EXTI_PORT_SOURCE(EXTI_PortSourceGPIOx)); |
mbed_official | 76:aeb1df146756 | 216 | assert_param(IS_EXTI_PIN_SOURCE(EXTI_PinSourcex)); |
mbed_official | 76:aeb1df146756 | 217 | |
mbed_official | 76:aeb1df146756 | 218 | tmp = ((uint32_t)0x0F) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03)); |
mbed_official | 76:aeb1df146756 | 219 | SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] &= ~tmp; |
mbed_official | 76:aeb1df146756 | 220 | SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] |= (((uint32_t)EXTI_PortSourceGPIOx) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03))); |
mbed_official | 76:aeb1df146756 | 221 | } |
mbed_official | 76:aeb1df146756 | 222 | |
mbed_official | 76:aeb1df146756 | 223 | /** |
mbed_official | 76:aeb1df146756 | 224 | * @} |
mbed_official | 76:aeb1df146756 | 225 | */ |
mbed_official | 76:aeb1df146756 | 226 | |
mbed_official | 76:aeb1df146756 | 227 | /** @defgroup SYSCFG_Group2 RI Initialization and Configuration functions |
mbed_official | 76:aeb1df146756 | 228 | * @brief RI Initialization and Configuration functions |
mbed_official | 76:aeb1df146756 | 229 | * |
mbed_official | 76:aeb1df146756 | 230 | @verbatim |
mbed_official | 76:aeb1df146756 | 231 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 232 | ##### RI Initialization and Configuration functions ##### |
mbed_official | 76:aeb1df146756 | 233 | =============================================================================== |
mbed_official | 76:aeb1df146756 | 234 | |
mbed_official | 76:aeb1df146756 | 235 | @endverbatim |
mbed_official | 76:aeb1df146756 | 236 | * @{ |
mbed_official | 76:aeb1df146756 | 237 | */ |
mbed_official | 76:aeb1df146756 | 238 | |
mbed_official | 76:aeb1df146756 | 239 | /** |
mbed_official | 76:aeb1df146756 | 240 | * @brief Configures the routing interface to select which Timer to be routed. |
mbed_official | 76:aeb1df146756 | 241 | * @note Routing capability can be applied only on one of the three timers |
mbed_official | 76:aeb1df146756 | 242 | * (TIM2, TIM3 or TIM4) at a time. |
mbed_official | 76:aeb1df146756 | 243 | * @param TIM_Select: Timer select. |
mbed_official | 76:aeb1df146756 | 244 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 245 | * @arg TIM_Select_None: No timer selected and default Timer mapping is enabled. |
mbed_official | 76:aeb1df146756 | 246 | * @arg TIM_Select_TIM2: Timer 2 Input Captures to be routed. |
mbed_official | 76:aeb1df146756 | 247 | * @arg TIM_Select_TIM3: Timer 3 Input Captures to be routed. |
mbed_official | 76:aeb1df146756 | 248 | * @arg TIM_Select_TIM4: Timer 4 Input Captures to be routed. |
mbed_official | 76:aeb1df146756 | 249 | * @retval None. |
mbed_official | 76:aeb1df146756 | 250 | */ |
mbed_official | 76:aeb1df146756 | 251 | void SYSCFG_RITIMSelect(uint32_t TIM_Select) |
mbed_official | 76:aeb1df146756 | 252 | { |
mbed_official | 76:aeb1df146756 | 253 | uint32_t tmpreg = 0; |
mbed_official | 76:aeb1df146756 | 254 | |
mbed_official | 76:aeb1df146756 | 255 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 256 | assert_param(IS_RI_TIM(TIM_Select)); |
mbed_official | 76:aeb1df146756 | 257 | |
mbed_official | 76:aeb1df146756 | 258 | /* Get the old register value */ |
mbed_official | 76:aeb1df146756 | 259 | tmpreg = RI->ICR; |
mbed_official | 76:aeb1df146756 | 260 | |
mbed_official | 76:aeb1df146756 | 261 | /* Clear the TIMx select bits */ |
mbed_official | 76:aeb1df146756 | 262 | tmpreg &= TIM_SELECT_MASK; |
mbed_official | 76:aeb1df146756 | 263 | |
mbed_official | 76:aeb1df146756 | 264 | /* Select the Timer */ |
mbed_official | 76:aeb1df146756 | 265 | tmpreg |= (TIM_Select); |
mbed_official | 76:aeb1df146756 | 266 | |
mbed_official | 76:aeb1df146756 | 267 | /* Write to RI->ICR register */ |
mbed_official | 76:aeb1df146756 | 268 | RI->ICR = tmpreg; |
mbed_official | 76:aeb1df146756 | 269 | } |
mbed_official | 76:aeb1df146756 | 270 | |
mbed_official | 76:aeb1df146756 | 271 | /** |
mbed_official | 76:aeb1df146756 | 272 | * @brief Configures the routing interface to map Input Capture 1, 2, 3 or 4 |
mbed_official | 76:aeb1df146756 | 273 | * to a selected I/O pin. |
mbed_official | 76:aeb1df146756 | 274 | * @param RI_InputCapture selects which input capture to be routed. |
mbed_official | 76:aeb1df146756 | 275 | * This parameter can be one (or combination) of the following parameters: |
mbed_official | 76:aeb1df146756 | 276 | * @arg RI_InputCapture_IC1: Input capture 1 is selected. |
mbed_official | 76:aeb1df146756 | 277 | * @arg RI_InputCapture_IC2: Input capture 2 is selected. |
mbed_official | 76:aeb1df146756 | 278 | * @arg RI_InputCapture_IC3: Input capture 3 is selected. |
mbed_official | 76:aeb1df146756 | 279 | * @arg RI_InputCapture_IC4: Input capture 4 is selected. |
mbed_official | 76:aeb1df146756 | 280 | * @param RI_InputCaptureRouting: selects which pin to be routed to Input Capture. |
mbed_official | 76:aeb1df146756 | 281 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 282 | * @param RI_InputCaptureRouting_0 to RI_InputCaptureRouting_15 |
mbed_official | 76:aeb1df146756 | 283 | * e.g. |
mbed_official | 76:aeb1df146756 | 284 | * SYSCFG_RITIMSelect(TIM_Select_TIM2) |
mbed_official | 76:aeb1df146756 | 285 | * SYSCFG_RITIMInputCaptureConfig(RI_InputCapture_IC1, RI_InputCaptureRouting_1) |
mbed_official | 76:aeb1df146756 | 286 | * allows routing of Input capture IC1 of TIM2 to PA4. |
mbed_official | 76:aeb1df146756 | 287 | * For details about correspondence between RI_InputCaptureRouting_x |
mbed_official | 76:aeb1df146756 | 288 | * and I/O pins refer to the parameters' description in the header file |
mbed_official | 76:aeb1df146756 | 289 | * or refer to the product reference manual. |
mbed_official | 76:aeb1df146756 | 290 | * @note Input capture selection bits are not reset by this function. |
mbed_official | 76:aeb1df146756 | 291 | * To reset input capture selection bits, use SYSCFG_RIDeInit() function. |
mbed_official | 76:aeb1df146756 | 292 | * @note The I/O should be configured in alternate function mode (AF14) using |
mbed_official | 76:aeb1df146756 | 293 | * GPIO_PinAFConfig() function. |
mbed_official | 76:aeb1df146756 | 294 | * @retval None. |
mbed_official | 76:aeb1df146756 | 295 | */ |
mbed_official | 76:aeb1df146756 | 296 | void SYSCFG_RITIMInputCaptureConfig(uint32_t RI_InputCapture, uint32_t RI_InputCaptureRouting) |
mbed_official | 76:aeb1df146756 | 297 | { |
mbed_official | 76:aeb1df146756 | 298 | uint32_t tmpreg = 0; |
mbed_official | 76:aeb1df146756 | 299 | |
mbed_official | 76:aeb1df146756 | 300 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 301 | assert_param(IS_RI_INPUTCAPTURE(RI_InputCapture)); |
mbed_official | 76:aeb1df146756 | 302 | assert_param(IS_RI_INPUTCAPTURE_ROUTING(RI_InputCaptureRouting)); |
mbed_official | 76:aeb1df146756 | 303 | |
mbed_official | 76:aeb1df146756 | 304 | /* Get the old register value */ |
mbed_official | 76:aeb1df146756 | 305 | tmpreg = RI->ICR; |
mbed_official | 76:aeb1df146756 | 306 | |
mbed_official | 76:aeb1df146756 | 307 | /* Select input captures to be routed */ |
mbed_official | 76:aeb1df146756 | 308 | tmpreg |= (RI_InputCapture); |
mbed_official | 76:aeb1df146756 | 309 | |
mbed_official | 76:aeb1df146756 | 310 | if((RI_InputCapture & RI_InputCapture_IC1) == RI_InputCapture_IC1) |
mbed_official | 76:aeb1df146756 | 311 | { |
mbed_official | 76:aeb1df146756 | 312 | /* Clear the input capture select bits */ |
mbed_official | 76:aeb1df146756 | 313 | tmpreg &= (uint32_t)(~IC_ROUTING_MASK); |
mbed_official | 76:aeb1df146756 | 314 | |
mbed_official | 76:aeb1df146756 | 315 | /* Set RI_InputCaptureRouting bits */ |
mbed_official | 76:aeb1df146756 | 316 | tmpreg |= (uint32_t)( RI_InputCaptureRouting); |
mbed_official | 76:aeb1df146756 | 317 | } |
mbed_official | 76:aeb1df146756 | 318 | |
mbed_official | 76:aeb1df146756 | 319 | if((RI_InputCapture & RI_InputCapture_IC2) == RI_InputCapture_IC2) |
mbed_official | 76:aeb1df146756 | 320 | { |
mbed_official | 76:aeb1df146756 | 321 | /* Clear the input capture select bits */ |
mbed_official | 76:aeb1df146756 | 322 | tmpreg &= (uint32_t)(~(IC_ROUTING_MASK << 4)); |
mbed_official | 76:aeb1df146756 | 323 | |
mbed_official | 76:aeb1df146756 | 324 | /* Set RI_InputCaptureRouting bits */ |
mbed_official | 76:aeb1df146756 | 325 | tmpreg |= (uint32_t)( (RI_InputCaptureRouting << 4)); |
mbed_official | 76:aeb1df146756 | 326 | } |
mbed_official | 76:aeb1df146756 | 327 | |
mbed_official | 76:aeb1df146756 | 328 | if((RI_InputCapture & RI_InputCapture_IC3) == RI_InputCapture_IC3) |
mbed_official | 76:aeb1df146756 | 329 | { |
mbed_official | 76:aeb1df146756 | 330 | /* Clear the input capture select bits */ |
mbed_official | 76:aeb1df146756 | 331 | tmpreg &= (uint32_t)(~(IC_ROUTING_MASK << 8)); |
mbed_official | 76:aeb1df146756 | 332 | |
mbed_official | 76:aeb1df146756 | 333 | /* Set RI_InputCaptureRouting bits */ |
mbed_official | 76:aeb1df146756 | 334 | tmpreg |= (uint32_t)( (RI_InputCaptureRouting << 8)); |
mbed_official | 76:aeb1df146756 | 335 | } |
mbed_official | 76:aeb1df146756 | 336 | |
mbed_official | 76:aeb1df146756 | 337 | if((RI_InputCapture & RI_InputCapture_IC4) == RI_InputCapture_IC4) |
mbed_official | 76:aeb1df146756 | 338 | { |
mbed_official | 76:aeb1df146756 | 339 | /* Clear the input capture select bits */ |
mbed_official | 76:aeb1df146756 | 340 | tmpreg &= (uint32_t)(~(IC_ROUTING_MASK << 12)); |
mbed_official | 76:aeb1df146756 | 341 | |
mbed_official | 76:aeb1df146756 | 342 | /* Set RI_InputCaptureRouting bits */ |
mbed_official | 76:aeb1df146756 | 343 | tmpreg |= (uint32_t)( (RI_InputCaptureRouting << 12)); |
mbed_official | 76:aeb1df146756 | 344 | } |
mbed_official | 76:aeb1df146756 | 345 | |
mbed_official | 76:aeb1df146756 | 346 | /* Write to RI->ICR register */ |
mbed_official | 76:aeb1df146756 | 347 | RI->ICR = tmpreg; |
mbed_official | 76:aeb1df146756 | 348 | } |
mbed_official | 76:aeb1df146756 | 349 | |
mbed_official | 76:aeb1df146756 | 350 | /** |
mbed_official | 76:aeb1df146756 | 351 | * @brief Configures the Pull-up and Pull-down Resistors |
mbed_official | 76:aeb1df146756 | 352 | * @param RI_Resistor selects the resistor to connect. |
mbed_official | 76:aeb1df146756 | 353 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 354 | * @arg RI_Resistor_10KPU: 10K pull-up resistor. |
mbed_official | 76:aeb1df146756 | 355 | * @arg RI_Resistor_400KPU: 400K pull-up resistor. |
mbed_official | 76:aeb1df146756 | 356 | * @arg RI_Resistor_10KPD: 10K pull-down resistor. |
mbed_official | 76:aeb1df146756 | 357 | * @arg RI_Resistor_400KPD: 400K pull-down resistor. |
mbed_official | 76:aeb1df146756 | 358 | * @param NewState: New state of the analog switch associated to the selected |
mbed_official | 76:aeb1df146756 | 359 | * resistor. |
mbed_official | 76:aeb1df146756 | 360 | * This parameter can be: |
mbed_official | 76:aeb1df146756 | 361 | * ENABLE so the selected resistor is connected |
mbed_official | 76:aeb1df146756 | 362 | * or DISABLE so the selected resistor is disconnected. |
mbed_official | 76:aeb1df146756 | 363 | * @note To avoid extra power consumption, only one resistor should be enabled |
mbed_official | 76:aeb1df146756 | 364 | * at a time. |
mbed_official | 76:aeb1df146756 | 365 | * @retval None |
mbed_official | 76:aeb1df146756 | 366 | */ |
mbed_official | 76:aeb1df146756 | 367 | void SYSCFG_RIResistorConfig(uint32_t RI_Resistor, FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 368 | { |
mbed_official | 76:aeb1df146756 | 369 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 370 | assert_param(IS_RI_RESISTOR(RI_Resistor)); |
mbed_official | 76:aeb1df146756 | 371 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 372 | |
mbed_official | 76:aeb1df146756 | 373 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 374 | { |
mbed_official | 76:aeb1df146756 | 375 | /* Enable the resistor */ |
mbed_official | 76:aeb1df146756 | 376 | COMP->CSR |= (uint32_t) RI_Resistor; |
mbed_official | 76:aeb1df146756 | 377 | } |
mbed_official | 76:aeb1df146756 | 378 | else |
mbed_official | 76:aeb1df146756 | 379 | { |
mbed_official | 76:aeb1df146756 | 380 | /* Disable the Resistor */ |
mbed_official | 76:aeb1df146756 | 381 | COMP->CSR &= (uint32_t) (~RI_Resistor); |
mbed_official | 76:aeb1df146756 | 382 | } |
mbed_official | 76:aeb1df146756 | 383 | } |
mbed_official | 76:aeb1df146756 | 384 | |
mbed_official | 76:aeb1df146756 | 385 | /** |
mbed_official | 76:aeb1df146756 | 386 | * @brief Configures the ADC channels speed. |
mbed_official | 76:aeb1df146756 | 387 | * @param RI_Channel selects the channel. |
mbed_official | 76:aeb1df146756 | 388 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 389 | * @arg RI_Channel_3: Channel 3 is selected. |
mbed_official | 76:aeb1df146756 | 390 | * @arg RI_Channel_8: Channel 8 is selected. |
mbed_official | 76:aeb1df146756 | 391 | * @arg RI_Channel_13: Channel 13 is selected. |
mbed_official | 76:aeb1df146756 | 392 | * @param RI_ChannelSpeed: The speed of the selected ADC channel |
mbed_official | 76:aeb1df146756 | 393 | * This parameter can be: |
mbed_official | 76:aeb1df146756 | 394 | * RI_ChannelSpeed_Fast: The selected channel is a fast ADC channel |
mbed_official | 76:aeb1df146756 | 395 | * or RI_ChannelSpeed_Slow: The selected channel is a slow ADC channel. |
mbed_official | 76:aeb1df146756 | 396 | * @retval None |
mbed_official | 76:aeb1df146756 | 397 | */ |
mbed_official | 76:aeb1df146756 | 398 | void SYSCFG_RIChannelSpeedConfig(uint32_t RI_Channel, uint32_t RI_ChannelSpeed) |
mbed_official | 76:aeb1df146756 | 399 | { |
mbed_official | 76:aeb1df146756 | 400 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 401 | assert_param(IS_RI_CHANNEL(RI_Channel)); |
mbed_official | 76:aeb1df146756 | 402 | assert_param(IS_RI_CHANNELSPEED(RI_ChannelSpeed)); |
mbed_official | 76:aeb1df146756 | 403 | |
mbed_official | 76:aeb1df146756 | 404 | if(RI_ChannelSpeed != RI_ChannelSpeed_Fast) |
mbed_official | 76:aeb1df146756 | 405 | { |
mbed_official | 76:aeb1df146756 | 406 | /* Set the selected channel as a slow ADC channel */ |
mbed_official | 76:aeb1df146756 | 407 | COMP->CSR &= (uint32_t) (~RI_Channel); |
mbed_official | 76:aeb1df146756 | 408 | } |
mbed_official | 76:aeb1df146756 | 409 | else |
mbed_official | 76:aeb1df146756 | 410 | { |
mbed_official | 76:aeb1df146756 | 411 | /* Set the selected channel as a fast ADC channel */ |
mbed_official | 76:aeb1df146756 | 412 | COMP->CSR |= (uint32_t) (RI_Channel); |
mbed_official | 76:aeb1df146756 | 413 | } |
mbed_official | 76:aeb1df146756 | 414 | } |
mbed_official | 76:aeb1df146756 | 415 | |
mbed_official | 76:aeb1df146756 | 416 | /** |
mbed_official | 76:aeb1df146756 | 417 | * @brief Close or Open the routing interface Input Output switches. |
mbed_official | 76:aeb1df146756 | 418 | * @param RI_IOSwitch: selects the I/O analog switch number. |
mbed_official | 76:aeb1df146756 | 419 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 420 | * @param RI_IOSwitch_CH0 --> RI_IOSwitch_CH15. |
mbed_official | 76:aeb1df146756 | 421 | * @param RI_IOSwitch_CH18 --> RI_IOSwitch_CH25. |
mbed_official | 76:aeb1df146756 | 422 | * @param RI_IOSwitch_GR10_1 --> RI_IOSwitch_GR10_4. |
mbed_official | 76:aeb1df146756 | 423 | * @param RI_IOSwitch_GR6_1 --> RI_IOSwitch_GR6_2. |
mbed_official | 76:aeb1df146756 | 424 | * @param RI_IOSwitch_GR5_1 --> RI_IOSwitch_GR5_3. |
mbed_official | 76:aeb1df146756 | 425 | * @param RI_IOSwitch_GR4_1 --> RI_IOSwitch_GR4_3. |
mbed_official | 76:aeb1df146756 | 426 | * @param RI_IOSwitch_VCOMP |
mbed_official | 76:aeb1df146756 | 427 | * RI_IOSwitch_CH27 |
mbed_official | 76:aeb1df146756 | 428 | * @param RI_IOSwitch_CH28 --> RI_IOSwitch_CH30 |
mbed_official | 76:aeb1df146756 | 429 | * @param RI_IOSwitch_GR10_1 --> RI_IOSwitch_GR10_4 |
mbed_official | 76:aeb1df146756 | 430 | * @param RI_IOSwitch_GR6_1 |
mbed_official | 76:aeb1df146756 | 431 | * @param RI_IOSwitch_GR6_2 |
mbed_official | 76:aeb1df146756 | 432 | * @param RI_IOSwitch_GR5_1 --> RI_IOSwitch_GR5_3 |
mbed_official | 76:aeb1df146756 | 433 | * @param RI_IOSwitch_GR4_1 --> RI_IOSwitch_GR4_4 |
mbed_official | 76:aeb1df146756 | 434 | * @param RI_IOSwitch_CH0b --> RI_IOSwitch_CH3b |
mbed_official | 76:aeb1df146756 | 435 | * @param RI_IOSwitch_CH6b --> RI_IOSwitch_CH12b |
mbed_official | 76:aeb1df146756 | 436 | * @param RI_IOSwitch_GR6_3 |
mbed_official | 76:aeb1df146756 | 437 | * @param RI_IOSwitch_GR6_4 |
mbed_official | 76:aeb1df146756 | 438 | * @param RI_IOSwitch_GR5_4 |
mbed_official | 76:aeb1df146756 | 439 | |
mbed_official | 76:aeb1df146756 | 440 | * @param NewState: New state of the analog switch. |
mbed_official | 76:aeb1df146756 | 441 | * This parameter can be |
mbed_official | 76:aeb1df146756 | 442 | * ENABLE so the Input Output switch is closed |
mbed_official | 76:aeb1df146756 | 443 | * or DISABLE so the Input Output switch is open. |
mbed_official | 76:aeb1df146756 | 444 | * @retval None |
mbed_official | 76:aeb1df146756 | 445 | */ |
mbed_official | 76:aeb1df146756 | 446 | void SYSCFG_RIIOSwitchConfig(uint32_t RI_IOSwitch, FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 447 | { |
mbed_official | 76:aeb1df146756 | 448 | uint32_t ioswitchmask = 0; |
mbed_official | 76:aeb1df146756 | 449 | |
mbed_official | 76:aeb1df146756 | 450 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 451 | assert_param(IS_RI_IOSWITCH(RI_IOSwitch)); |
mbed_official | 76:aeb1df146756 | 452 | |
mbed_official | 76:aeb1df146756 | 453 | /* Read Analog switch register index */ |
mbed_official | 76:aeb1df146756 | 454 | ioswitchmask = RI_IOSwitch >> 31; |
mbed_official | 76:aeb1df146756 | 455 | |
mbed_official | 76:aeb1df146756 | 456 | /* Get Bits[30:0] of the IO switch */ |
mbed_official | 76:aeb1df146756 | 457 | RI_IOSwitch &= 0x7FFFFFFF; |
mbed_official | 76:aeb1df146756 | 458 | |
mbed_official | 76:aeb1df146756 | 459 | |
mbed_official | 76:aeb1df146756 | 460 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 461 | { |
mbed_official | 76:aeb1df146756 | 462 | if (ioswitchmask != 0) |
mbed_official | 76:aeb1df146756 | 463 | { |
mbed_official | 76:aeb1df146756 | 464 | /* Close the analog switches */ |
mbed_official | 76:aeb1df146756 | 465 | RI->ASCR1 |= RI_IOSwitch; |
mbed_official | 76:aeb1df146756 | 466 | } |
mbed_official | 76:aeb1df146756 | 467 | else |
mbed_official | 76:aeb1df146756 | 468 | { |
mbed_official | 76:aeb1df146756 | 469 | /* Open the analog switches */ |
mbed_official | 76:aeb1df146756 | 470 | RI->ASCR2 |= RI_IOSwitch; |
mbed_official | 76:aeb1df146756 | 471 | } |
mbed_official | 76:aeb1df146756 | 472 | } |
mbed_official | 76:aeb1df146756 | 473 | else |
mbed_official | 76:aeb1df146756 | 474 | { |
mbed_official | 76:aeb1df146756 | 475 | if (ioswitchmask != 0) |
mbed_official | 76:aeb1df146756 | 476 | { |
mbed_official | 76:aeb1df146756 | 477 | /* Close the analog switches */ |
mbed_official | 76:aeb1df146756 | 478 | RI->ASCR1 &= (~ (uint32_t)RI_IOSwitch); |
mbed_official | 76:aeb1df146756 | 479 | } |
mbed_official | 76:aeb1df146756 | 480 | else |
mbed_official | 76:aeb1df146756 | 481 | { |
mbed_official | 76:aeb1df146756 | 482 | /* Open the analog switches */ |
mbed_official | 76:aeb1df146756 | 483 | RI->ASCR2 &= (~ (uint32_t)RI_IOSwitch); |
mbed_official | 76:aeb1df146756 | 484 | } |
mbed_official | 76:aeb1df146756 | 485 | } |
mbed_official | 76:aeb1df146756 | 486 | } |
mbed_official | 76:aeb1df146756 | 487 | |
mbed_official | 76:aeb1df146756 | 488 | /** |
mbed_official | 76:aeb1df146756 | 489 | * @brief Enable or disable the switch control mode. |
mbed_official | 76:aeb1df146756 | 490 | * @param NewState: New state of the switch control mode. This parameter can |
mbed_official | 76:aeb1df146756 | 491 | * be ENABLE: ADC analog switches closed if the corresponding |
mbed_official | 76:aeb1df146756 | 492 | * I/O switch is also closed. |
mbed_official | 76:aeb1df146756 | 493 | * When using COMP1, switch control mode must be enabled. |
mbed_official | 76:aeb1df146756 | 494 | * or DISABLE: ADC analog switches open or controlled by the ADC interface. |
mbed_official | 76:aeb1df146756 | 495 | * When using the ADC for acquisition, switch control mode |
mbed_official | 76:aeb1df146756 | 496 | * must be disabled. |
mbed_official | 76:aeb1df146756 | 497 | * @note COMP1 comparator and ADC cannot be used at the same time since |
mbed_official | 76:aeb1df146756 | 498 | * they share the ADC switch matrix. |
mbed_official | 76:aeb1df146756 | 499 | * @retval None |
mbed_official | 76:aeb1df146756 | 500 | */ |
mbed_official | 76:aeb1df146756 | 501 | void SYSCFG_RISwitchControlModeCmd(FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 502 | { |
mbed_official | 76:aeb1df146756 | 503 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 504 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 505 | |
mbed_official | 76:aeb1df146756 | 506 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 507 | { |
mbed_official | 76:aeb1df146756 | 508 | /* Enable the Switch control mode */ |
mbed_official | 76:aeb1df146756 | 509 | RI->ASCR1 |= (uint32_t) RI_ASCR1_SCM; |
mbed_official | 76:aeb1df146756 | 510 | } |
mbed_official | 76:aeb1df146756 | 511 | else |
mbed_official | 76:aeb1df146756 | 512 | { |
mbed_official | 76:aeb1df146756 | 513 | /* Disable the Switch control mode */ |
mbed_official | 76:aeb1df146756 | 514 | RI->ASCR1 &= (uint32_t)(~RI_ASCR1_SCM); |
mbed_official | 76:aeb1df146756 | 515 | } |
mbed_official | 76:aeb1df146756 | 516 | } |
mbed_official | 76:aeb1df146756 | 517 | |
mbed_official | 76:aeb1df146756 | 518 | /** |
mbed_official | 76:aeb1df146756 | 519 | * @brief Enable or disable Hysteresis of the input schmitt triger of Ports A..E |
mbed_official | 76:aeb1df146756 | 520 | * When the I/Os are programmed in input mode by standard I/O port |
mbed_official | 76:aeb1df146756 | 521 | * registers, the Schmitt trigger and the hysteresis are enabled by default. |
mbed_official | 76:aeb1df146756 | 522 | * When hysteresis is disabled, it is possible to read the |
mbed_official | 76:aeb1df146756 | 523 | * corresponding port with a trigger level of VDDIO/2. |
mbed_official | 76:aeb1df146756 | 524 | * @param RI_Port: selects the GPIO Port. |
mbed_official | 76:aeb1df146756 | 525 | * This parameter can be one of the following values: |
mbed_official | 76:aeb1df146756 | 526 | * @arg RI_PortA: Port A is selected |
mbed_official | 76:aeb1df146756 | 527 | * @arg RI_PortB: Port B is selected |
mbed_official | 76:aeb1df146756 | 528 | * @arg RI_PortC: Port C is selected |
mbed_official | 76:aeb1df146756 | 529 | * @arg RI_PortD: Port D is selected |
mbed_official | 76:aeb1df146756 | 530 | * @arg RI_PortE: Port E is selected |
mbed_official | 76:aeb1df146756 | 531 | * @arg RI_PortF: Port F is selected |
mbed_official | 76:aeb1df146756 | 532 | * @arg RI_PortG: Port G is selected |
mbed_official | 76:aeb1df146756 | 533 | * @param RI_Pin : Selects the pin(s) on which to enable or disable hysteresis. |
mbed_official | 76:aeb1df146756 | 534 | * This parameter can any value from RI_Pin_x where x can be (0..15) or RI_Pin_All. |
mbed_official | 76:aeb1df146756 | 535 | * @param NewState new state of the Hysteresis. |
mbed_official | 76:aeb1df146756 | 536 | * This parameter can be: |
mbed_official | 76:aeb1df146756 | 537 | * ENABLE so the Hysteresis is on |
mbed_official | 76:aeb1df146756 | 538 | * or DISABLE so the Hysteresis is off |
mbed_official | 76:aeb1df146756 | 539 | * @retval None |
mbed_official | 76:aeb1df146756 | 540 | */ |
mbed_official | 76:aeb1df146756 | 541 | void SYSCFG_RIHysteresisConfig(uint8_t RI_Port, uint16_t RI_Pin, |
mbed_official | 76:aeb1df146756 | 542 | FunctionalState NewState) |
mbed_official | 76:aeb1df146756 | 543 | { |
mbed_official | 76:aeb1df146756 | 544 | /* Check the parameters */ |
mbed_official | 76:aeb1df146756 | 545 | assert_param(IS_RI_PORT(RI_Port)); |
mbed_official | 76:aeb1df146756 | 546 | assert_param(IS_RI_PIN(RI_Pin)); |
mbed_official | 76:aeb1df146756 | 547 | assert_param(IS_FUNCTIONAL_STATE(NewState)); |
mbed_official | 76:aeb1df146756 | 548 | |
mbed_official | 76:aeb1df146756 | 549 | if(RI_Port == RI_PortA) |
mbed_official | 76:aeb1df146756 | 550 | { |
mbed_official | 76:aeb1df146756 | 551 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 552 | { |
mbed_official | 76:aeb1df146756 | 553 | /* Hysteresis on */ |
mbed_official | 76:aeb1df146756 | 554 | RI->HYSCR1 &= (uint32_t)~((uint32_t)RI_Pin); |
mbed_official | 76:aeb1df146756 | 555 | } |
mbed_official | 76:aeb1df146756 | 556 | else |
mbed_official | 76:aeb1df146756 | 557 | { |
mbed_official | 76:aeb1df146756 | 558 | /* Hysteresis off */ |
mbed_official | 76:aeb1df146756 | 559 | RI->HYSCR1 |= (uint32_t) RI_Pin; |
mbed_official | 76:aeb1df146756 | 560 | } |
mbed_official | 76:aeb1df146756 | 561 | } |
mbed_official | 76:aeb1df146756 | 562 | |
mbed_official | 76:aeb1df146756 | 563 | else if(RI_Port == RI_PortB) |
mbed_official | 76:aeb1df146756 | 564 | { |
mbed_official | 76:aeb1df146756 | 565 | |
mbed_official | 76:aeb1df146756 | 566 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 567 | { |
mbed_official | 76:aeb1df146756 | 568 | /* Hysteresis on */ |
mbed_official | 76:aeb1df146756 | 569 | RI->HYSCR1 &= (uint32_t) (~((uint32_t)RI_Pin) << 16); |
mbed_official | 76:aeb1df146756 | 570 | } |
mbed_official | 76:aeb1df146756 | 571 | else |
mbed_official | 76:aeb1df146756 | 572 | { |
mbed_official | 76:aeb1df146756 | 573 | /* Hysteresis off */ |
mbed_official | 76:aeb1df146756 | 574 | RI->HYSCR1 |= (uint32_t) ((uint32_t)(RI_Pin) << 16); |
mbed_official | 76:aeb1df146756 | 575 | } |
mbed_official | 76:aeb1df146756 | 576 | } |
mbed_official | 76:aeb1df146756 | 577 | |
mbed_official | 76:aeb1df146756 | 578 | else if(RI_Port == RI_PortC) |
mbed_official | 76:aeb1df146756 | 579 | { |
mbed_official | 76:aeb1df146756 | 580 | |
mbed_official | 76:aeb1df146756 | 581 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 582 | { |
mbed_official | 76:aeb1df146756 | 583 | /* Hysteresis on */ |
mbed_official | 76:aeb1df146756 | 584 | RI->HYSCR2 &= (uint32_t) (~((uint32_t)RI_Pin)); |
mbed_official | 76:aeb1df146756 | 585 | } |
mbed_official | 76:aeb1df146756 | 586 | else |
mbed_official | 76:aeb1df146756 | 587 | { |
mbed_official | 76:aeb1df146756 | 588 | /* Hysteresis off */ |
mbed_official | 76:aeb1df146756 | 589 | RI->HYSCR2 |= (uint32_t) (RI_Pin ); |
mbed_official | 76:aeb1df146756 | 590 | } |
mbed_official | 76:aeb1df146756 | 591 | } |
mbed_official | 76:aeb1df146756 | 592 | else if(RI_Port == RI_PortD) |
mbed_official | 76:aeb1df146756 | 593 | { |
mbed_official | 76:aeb1df146756 | 594 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 595 | { |
mbed_official | 76:aeb1df146756 | 596 | /* Hysteresis on */ |
mbed_official | 76:aeb1df146756 | 597 | RI->HYSCR2 &= (uint32_t) (~((uint32_t)RI_Pin) << 16); |
mbed_official | 76:aeb1df146756 | 598 | } |
mbed_official | 76:aeb1df146756 | 599 | else |
mbed_official | 76:aeb1df146756 | 600 | { |
mbed_official | 76:aeb1df146756 | 601 | /* Hysteresis off */ |
mbed_official | 76:aeb1df146756 | 602 | RI->HYSCR2 |= (uint32_t) ((uint32_t)(RI_Pin) << 16); |
mbed_official | 76:aeb1df146756 | 603 | |
mbed_official | 76:aeb1df146756 | 604 | } |
mbed_official | 76:aeb1df146756 | 605 | } |
mbed_official | 76:aeb1df146756 | 606 | else if(RI_Port == RI_PortE) |
mbed_official | 76:aeb1df146756 | 607 | { |
mbed_official | 76:aeb1df146756 | 608 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 609 | { |
mbed_official | 76:aeb1df146756 | 610 | /* Hysteresis on */ |
mbed_official | 76:aeb1df146756 | 611 | RI->HYSCR3 &= (uint32_t) (~((uint32_t)RI_Pin)); |
mbed_official | 76:aeb1df146756 | 612 | } |
mbed_official | 76:aeb1df146756 | 613 | else |
mbed_official | 76:aeb1df146756 | 614 | { |
mbed_official | 76:aeb1df146756 | 615 | /* Hysteresis off */ |
mbed_official | 76:aeb1df146756 | 616 | RI->HYSCR3 |= (uint32_t) (RI_Pin ); |
mbed_official | 76:aeb1df146756 | 617 | } |
mbed_official | 76:aeb1df146756 | 618 | } |
mbed_official | 76:aeb1df146756 | 619 | else if(RI_Port == RI_PortF) |
mbed_official | 76:aeb1df146756 | 620 | { |
mbed_official | 76:aeb1df146756 | 621 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 622 | { |
mbed_official | 76:aeb1df146756 | 623 | /* Hysteresis on */ |
mbed_official | 76:aeb1df146756 | 624 | RI->HYSCR3 &= (uint32_t) (~((uint32_t)RI_Pin) << 16); |
mbed_official | 76:aeb1df146756 | 625 | } |
mbed_official | 76:aeb1df146756 | 626 | else |
mbed_official | 76:aeb1df146756 | 627 | { |
mbed_official | 76:aeb1df146756 | 628 | /* Hysteresis off */ |
mbed_official | 76:aeb1df146756 | 629 | RI->HYSCR3 |= (uint32_t) ((uint32_t)(RI_Pin) << 16); |
mbed_official | 76:aeb1df146756 | 630 | } |
mbed_official | 76:aeb1df146756 | 631 | } |
mbed_official | 76:aeb1df146756 | 632 | else /* RI_Port == RI_PortG */ |
mbed_official | 76:aeb1df146756 | 633 | { |
mbed_official | 76:aeb1df146756 | 634 | if (NewState != DISABLE) |
mbed_official | 76:aeb1df146756 | 635 | { |
mbed_official | 76:aeb1df146756 | 636 | /* Hysteresis on */ |
mbed_official | 76:aeb1df146756 | 637 | RI->HYSCR4 &= (uint32_t) (~((uint32_t)RI_Pin)); |
mbed_official | 76:aeb1df146756 | 638 | } |
mbed_official | 76:aeb1df146756 | 639 | else |
mbed_official | 76:aeb1df146756 | 640 | { |
mbed_official | 76:aeb1df146756 | 641 | /* Hysteresis off */ |
mbed_official | 76:aeb1df146756 | 642 | RI->HYSCR4 |= (uint32_t) (RI_Pin); |
mbed_official | 76:aeb1df146756 | 643 | } |
mbed_official | 76:aeb1df146756 | 644 | } |
mbed_official | 76:aeb1df146756 | 645 | } |
mbed_official | 76:aeb1df146756 | 646 | |
mbed_official | 76:aeb1df146756 | 647 | /** |
mbed_official | 76:aeb1df146756 | 648 | * @} |
mbed_official | 76:aeb1df146756 | 649 | */ |
mbed_official | 76:aeb1df146756 | 650 | |
mbed_official | 76:aeb1df146756 | 651 | /** |
mbed_official | 76:aeb1df146756 | 652 | * @} |
mbed_official | 76:aeb1df146756 | 653 | */ |
mbed_official | 76:aeb1df146756 | 654 | |
mbed_official | 76:aeb1df146756 | 655 | /** |
mbed_official | 76:aeb1df146756 | 656 | * @} |
mbed_official | 76:aeb1df146756 | 657 | */ |
mbed_official | 76:aeb1df146756 | 658 | |
mbed_official | 76:aeb1df146756 | 659 | /** |
mbed_official | 76:aeb1df146756 | 660 | * @} |
mbed_official | 76:aeb1df146756 | 661 | */ |
mbed_official | 76:aeb1df146756 | 662 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |