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