mbed library sources

Dependents:   Marvino mbot

Fork of mbed-src by mbed official

Committer:
jaerts
Date:
Tue Dec 22 13:22:16 2015 +0000
Revision:
637:ed69428d4850
Parent:
155:8435094ec241
Add very shady LPC1768 CAN Filter implementation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 155:8435094ec241 1 /**
mbed_official 155:8435094ec241 2 ******************************************************************************
mbed_official 155:8435094ec241 3 * @file stm32f30x_syscfg.c
mbed_official 155:8435094ec241 4 * @author MCD Application Team
mbed_official 155:8435094ec241 5 * @version V1.1.0
mbed_official 155:8435094ec241 6 * @date 27-February-2014
mbed_official 155:8435094ec241 7 * @brief This file provides firmware functions to manage the following
mbed_official 155:8435094ec241 8 * functionalities of the SYSCFG peripheral:
mbed_official 155:8435094ec241 9 * + Remapping the memory mapped at 0x00000000
mbed_official 155:8435094ec241 10 * + Remapping the DMA channels
mbed_official 155:8435094ec241 11 * + Enabling I2C fast mode plus driving capability for I2C plus
mbed_official 155:8435094ec241 12 * + Remapping USB interrupt line
mbed_official 155:8435094ec241 13 * + Configuring the EXTI lines connection to the GPIO port
mbed_official 155:8435094ec241 14 * + Configuring the CLASSB requirements
mbed_official 155:8435094ec241 15 *
mbed_official 155:8435094ec241 16 @verbatim
mbed_official 155:8435094ec241 17
mbed_official 155:8435094ec241 18 ===============================================================================
mbed_official 155:8435094ec241 19 ##### How to use this driver #####
mbed_official 155:8435094ec241 20 ===============================================================================
mbed_official 155:8435094ec241 21 [..] The SYSCFG registers can be accessed only when the SYSCFG
mbed_official 155:8435094ec241 22 interface APB clock is enabled.
mbed_official 155:8435094ec241 23 [..] To enable SYSCFG APB clock use:
mbed_official 155:8435094ec241 24 RCC_APBPeriphClockCmd(RCC_APBPeriph_SYSCFG, ENABLE);
mbed_official 155:8435094ec241 25
mbed_official 155:8435094ec241 26 @endverbatim
mbed_official 155:8435094ec241 27
mbed_official 155:8435094ec241 28 ******************************************************************************
mbed_official 155:8435094ec241 29 * @attention
mbed_official 155:8435094ec241 30 *
mbed_official 155:8435094ec241 31 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
mbed_official 155:8435094ec241 32 *
mbed_official 155:8435094ec241 33 * Redistribution and use in source and binary forms, with or without modification,
mbed_official 155:8435094ec241 34 * are permitted provided that the following conditions are met:
mbed_official 155:8435094ec241 35 * 1. Redistributions of source code must retain the above copyright notice,
mbed_official 155:8435094ec241 36 * this list of conditions and the following disclaimer.
mbed_official 155:8435094ec241 37 * 2. Redistributions in binary form must reproduce the above copyright notice,
mbed_official 155:8435094ec241 38 * this list of conditions and the following disclaimer in the documentation
mbed_official 155:8435094ec241 39 * and/or other materials provided with the distribution.
mbed_official 155:8435094ec241 40 * 3. Neither the name of STMicroelectronics nor the names of its contributors
mbed_official 155:8435094ec241 41 * may be used to endorse or promote products derived from this software
mbed_official 155:8435094ec241 42 * without specific prior written permission.
mbed_official 155:8435094ec241 43 *
mbed_official 155:8435094ec241 44 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
mbed_official 155:8435094ec241 45 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
mbed_official 155:8435094ec241 46 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
mbed_official 155:8435094ec241 47 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
mbed_official 155:8435094ec241 48 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
mbed_official 155:8435094ec241 49 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
mbed_official 155:8435094ec241 50 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
mbed_official 155:8435094ec241 51 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
mbed_official 155:8435094ec241 52 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
mbed_official 155:8435094ec241 53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mbed_official 155:8435094ec241 54 *
mbed_official 155:8435094ec241 55 ******************************************************************************
mbed_official 155:8435094ec241 56 */
mbed_official 155:8435094ec241 57
mbed_official 155:8435094ec241 58 /* Includes ------------------------------------------------------------------*/
mbed_official 155:8435094ec241 59 #include "stm32f30x_syscfg.h"
mbed_official 155:8435094ec241 60
mbed_official 155:8435094ec241 61 /** @addtogroup STM32F30x_StdPeriph_Driver
mbed_official 155:8435094ec241 62 * @{
mbed_official 155:8435094ec241 63 */
mbed_official 155:8435094ec241 64
mbed_official 155:8435094ec241 65 /** @defgroup SYSCFG
mbed_official 155:8435094ec241 66 * @brief SYSCFG driver modules
mbed_official 155:8435094ec241 67 * @{
mbed_official 155:8435094ec241 68 */
mbed_official 155:8435094ec241 69
mbed_official 155:8435094ec241 70 /* Private typedef -----------------------------------------------------------*/
mbed_official 155:8435094ec241 71 /* Private define ------------------------------------------------------------*/
mbed_official 155:8435094ec241 72 /* Reset value od SYSCFG_CFGR1 register */
mbed_official 155:8435094ec241 73 #define CFGR1_CLEAR_MASK ((uint32_t)0x7C000000)
mbed_official 155:8435094ec241 74
mbed_official 155:8435094ec241 75 /* ------------ SYSCFG registers bit address in the alias region -------------*/
mbed_official 155:8435094ec241 76 #define SYSCFG_OFFSET (SYSCFG_BASE - PERIPH_BASE)
mbed_official 155:8435094ec241 77
mbed_official 155:8435094ec241 78 /* --- CFGR1 Register ---*/
mbed_official 155:8435094ec241 79 /* Alias word address of USB_IT_RMP bit */
mbed_official 155:8435094ec241 80 #define CFGR1_OFFSET (SYSCFG_OFFSET + 0x00)
mbed_official 155:8435094ec241 81 #define USBITRMP_BitNumber 0x05
mbed_official 155:8435094ec241 82 #define CFGR1_USBITRMP_BB (PERIPH_BB_BASE + (CFGR1_OFFSET * 32) + (USBITRMP_BitNumber * 4))
mbed_official 155:8435094ec241 83
mbed_official 155:8435094ec241 84 /* --- CFGR2 Register ---*/
mbed_official 155:8435094ec241 85 /* Alias word address of BYP_ADDR_PAR bit */
mbed_official 155:8435094ec241 86 #define CFGR2_OFFSET (SYSCFG_OFFSET + 0x18)
mbed_official 155:8435094ec241 87 #define BYPADDRPAR_BitNumber 0x04
mbed_official 155:8435094ec241 88 #define CFGR1_BYPADDRPAR_BB (PERIPH_BB_BASE + (CFGR2_OFFSET * 32) + (BYPADDRPAR_BitNumber * 4))
mbed_official 155:8435094ec241 89
mbed_official 155:8435094ec241 90 /* Private macro -------------------------------------------------------------*/
mbed_official 155:8435094ec241 91 /* Private variables ---------------------------------------------------------*/
mbed_official 155:8435094ec241 92 /* Private function prototypes -----------------------------------------------*/
mbed_official 155:8435094ec241 93 /* Private functions ---------------------------------------------------------*/
mbed_official 155:8435094ec241 94
mbed_official 155:8435094ec241 95 /** @defgroup SYSCFG_Private_Functions
mbed_official 155:8435094ec241 96 * @{
mbed_official 155:8435094ec241 97 */
mbed_official 155:8435094ec241 98
mbed_official 155:8435094ec241 99 /** @defgroup SYSCFG_Group1 SYSCFG Initialization and Configuration functions
mbed_official 155:8435094ec241 100 * @brief SYSCFG Initialization and Configuration functions
mbed_official 155:8435094ec241 101 *
mbed_official 155:8435094ec241 102 @verbatim
mbed_official 155:8435094ec241 103 ===============================================================================
mbed_official 155:8435094ec241 104 ##### SYSCFG Initialization and Configuration functions #####
mbed_official 155:8435094ec241 105 ===============================================================================
mbed_official 155:8435094ec241 106
mbed_official 155:8435094ec241 107 @endverbatim
mbed_official 155:8435094ec241 108 * @{
mbed_official 155:8435094ec241 109 */
mbed_official 155:8435094ec241 110
mbed_official 155:8435094ec241 111 /**
mbed_official 155:8435094ec241 112 * @brief Deinitializes the SYSCFG registers to their default reset values.
mbed_official 155:8435094ec241 113 * @param None
mbed_official 155:8435094ec241 114 * @retval None
mbed_official 155:8435094ec241 115 * @note MEM_MODE bits are not affected by APB reset.
mbed_official 155:8435094ec241 116 * MEM_MODE bits took the value from the user option bytes.
mbed_official 155:8435094ec241 117 */
mbed_official 155:8435094ec241 118 void SYSCFG_DeInit(void)
mbed_official 155:8435094ec241 119 {
mbed_official 155:8435094ec241 120 /* Reset SYSCFG_CFGR1 register to reset value without affecting MEM_MODE bits */
mbed_official 155:8435094ec241 121 SYSCFG->CFGR1 &= SYSCFG_CFGR1_MEM_MODE;
mbed_official 155:8435094ec241 122 /* Set FPU Interrupt Enable bits to default value */
mbed_official 155:8435094ec241 123 SYSCFG->CFGR1 |= 0x7C000000;
mbed_official 155:8435094ec241 124 /* Reset RAM Write protection bits to default value */
mbed_official 155:8435094ec241 125 SYSCFG->RCR = 0x00000000;
mbed_official 155:8435094ec241 126 /* Set EXTICRx registers to reset value */
mbed_official 155:8435094ec241 127 SYSCFG->EXTICR[0] = 0;
mbed_official 155:8435094ec241 128 SYSCFG->EXTICR[1] = 0;
mbed_official 155:8435094ec241 129 SYSCFG->EXTICR[2] = 0;
mbed_official 155:8435094ec241 130 SYSCFG->EXTICR[3] = 0;
mbed_official 155:8435094ec241 131 /* Set CFGR2 register to reset value */
mbed_official 155:8435094ec241 132 SYSCFG->CFGR2 = 0;
mbed_official 155:8435094ec241 133 /* Set CFGR3 register to reset value */
mbed_official 155:8435094ec241 134 SYSCFG->CFGR3 = 0;
mbed_official 155:8435094ec241 135 }
mbed_official 155:8435094ec241 136
mbed_official 155:8435094ec241 137 /**
mbed_official 155:8435094ec241 138 * @brief Configures the memory mapping at address 0x00000000.
mbed_official 155:8435094ec241 139 * @param SYSCFG_MemoryRemap: selects the memory remapping.
mbed_official 155:8435094ec241 140 * This parameter can be one of the following values:
mbed_official 155:8435094ec241 141 * @arg SYSCFG_MemoryRemap_Flash: Main Flash memory mapped at 0x00000000
mbed_official 155:8435094ec241 142 * @arg SYSCFG_MemoryRemap_SystemMemory: System Flash memory mapped at 0x00000000
mbed_official 155:8435094ec241 143 * @arg SYSCFG_MemoryRemap_SRAM: Embedded SRAM mapped at 0x00000000
mbed_official 155:8435094ec241 144 * @retval None
mbed_official 155:8435094ec241 145 */
mbed_official 155:8435094ec241 146 void SYSCFG_MemoryRemapConfig(uint32_t SYSCFG_MemoryRemap)
mbed_official 155:8435094ec241 147 {
mbed_official 155:8435094ec241 148 uint32_t tmpcfgr1 = 0;
mbed_official 155:8435094ec241 149
mbed_official 155:8435094ec241 150 /* Check the parameter */
mbed_official 155:8435094ec241 151 assert_param(IS_SYSCFG_MEMORY_REMAP(SYSCFG_MemoryRemap));
mbed_official 155:8435094ec241 152
mbed_official 155:8435094ec241 153 /* Get CFGR1 register value */
mbed_official 155:8435094ec241 154 tmpcfgr1 = SYSCFG->CFGR1;
mbed_official 155:8435094ec241 155
mbed_official 155:8435094ec241 156 /* Clear MEM_MODE bits */
mbed_official 155:8435094ec241 157 tmpcfgr1 &= (uint32_t) (~SYSCFG_CFGR1_MEM_MODE);
mbed_official 155:8435094ec241 158
mbed_official 155:8435094ec241 159 /* Set the new MEM_MODE bits value */
mbed_official 155:8435094ec241 160 tmpcfgr1 |= (uint32_t) SYSCFG_MemoryRemap;
mbed_official 155:8435094ec241 161
mbed_official 155:8435094ec241 162 /* Set CFGR1 register with the new memory remap configuration */
mbed_official 155:8435094ec241 163 SYSCFG->CFGR1 = tmpcfgr1;
mbed_official 155:8435094ec241 164 }
mbed_official 155:8435094ec241 165
mbed_official 155:8435094ec241 166 /**
mbed_official 155:8435094ec241 167 * @brief Configures the DMA channels remapping.
mbed_official 155:8435094ec241 168 * @param SYSCFG_DMARemap: selects the DMA channels remap.
mbed_official 155:8435094ec241 169 * This parameter can be one of the following values:
mbed_official 155:8435094ec241 170 * @arg SYSCFG_DMARemap_TIM17: Remap TIM17 DMA requests from DMA1 channel1 to channel2
mbed_official 155:8435094ec241 171 * @arg SYSCFG_DMARemap_TIM16: Remap TIM16 DMA requests from DMA1 channel3 to channel4
mbed_official 155:8435094ec241 172 * @arg SYSCFG_DMARemap_TIM6DAC1Ch1: Remap TIM6/DAC1 DMA requests from DMA2 channel 3 to DMA1 channel 3
mbed_official 155:8435094ec241 173 * @arg SYSCFG_DMARemap_TIM7DAC1Ch2: Remap TIM7/DAC2 DMA requests from DMA2 channel 4 to DMA1 channel 4
mbed_official 155:8435094ec241 174 * @arg SYSCFG_DMARemap_ADC2ADC4: Remap ADC2 and ADC4 DMA requests from DMA2 channel1/channel3 to channel3/channel4
mbed_official 155:8435094ec241 175 * @arg SYSCFG_DMARemap_DAC2Ch1: Remap DAC2 DMA requests to DMA1 channel5
mbed_official 155:8435094ec241 176 * @arg SYSCFG_DMARemapCh2_SPI1_RX: Remap SPI1 RX DMA1 CH2 requests
mbed_official 155:8435094ec241 177 * @arg SYSCFG_DMARemapCh4_SPI1_RX: Remap SPI1 RX DMA CH4 requests
mbed_official 155:8435094ec241 178 * @arg SYSCFG_DMARemapCh6_SPI1_RX: Remap SPI1 RX DMA CH6 requests
mbed_official 155:8435094ec241 179 * @arg SYSCFG_DMARemapCh3_SPI1_TX: Remap SPI1 TX DMA CH2 requests
mbed_official 155:8435094ec241 180 * @arg SYSCFG_DMARemapCh5_SPI1_TX: Remap SPI1 TX DMA CH5 requests
mbed_official 155:8435094ec241 181 * @arg SYSCFG_DMARemapCh7_SPI1_TX: Remap SPI1 TX DMA CH7 requests
mbed_official 155:8435094ec241 182 * @arg SYSCFG_DMARemapCh7_I2C1_RX: Remap I2C1 RX DMA CH7 requests
mbed_official 155:8435094ec241 183 * @arg SYSCFG_DMARemapCh3_I2C1_RX: Remap I2C1 RX DMA CH3 requests
mbed_official 155:8435094ec241 184 * @arg SYSCFG_DMARemapCh5_I2C1_RX: Remap I2C1 RX DMA CH5 requests
mbed_official 155:8435094ec241 185 * @arg SYSCFG_DMARemapCh6_I2C1_TX: Remap I2C1 TX DMA CH6 requests
mbed_official 155:8435094ec241 186 * @arg SYSCFG_DMARemapCh2_I2C1_TX: Remap I2C1 TX DMA CH2 requests
mbed_official 155:8435094ec241 187 * @arg SYSCFG_DMARemapCh4_I2C1_TX: Remap I2C1 TX DMA CH4 requests
mbed_official 155:8435094ec241 188 * @arg SYSCFG_DMARemapCh4_ADC2: Remap ADC2 DMA1 Ch4 requests
mbed_official 155:8435094ec241 189 * @arg SYSCFG_DMARemapCh2_ADC2: Remap ADC2 DMA1 Ch2 requests
mbed_official 155:8435094ec241 190 * @param NewState: new state of the DMA channel remapping.
mbed_official 155:8435094ec241 191 * This parameter can be: Enable or Disable.
mbed_official 155:8435094ec241 192 * @note When enabled, DMA channel of the selected peripheral is remapped
mbed_official 155:8435094ec241 193 * @note When disabled, Default DMA channel is mapped to the selected peripheral
mbed_official 155:8435094ec241 194 * @note
mbed_official 155:8435094ec241 195 * By default TIM17 DMA requests is mapped to channel 1
mbed_official 155:8435094ec241 196 * use SYSCFG_DMAChannelRemapConfig(SYSCFG_DMARemap_TIM17, Enable)
mbed_official 155:8435094ec241 197 * to remap TIM17 DMA requests to DMA1 channel 2
mbed_official 155:8435094ec241 198 * use SYSCFG_DMAChannelRemapConfig(SYSCFG_DMARemap_TIM17, Disable)
mbed_official 155:8435094ec241 199 * to map TIM17 DMA requests to DMA1 channel 1 (default mapping)
mbed_official 155:8435094ec241 200 * @retval None
mbed_official 155:8435094ec241 201 */
mbed_official 155:8435094ec241 202 void SYSCFG_DMAChannelRemapConfig(uint32_t SYSCFG_DMARemap, FunctionalState NewState)
mbed_official 155:8435094ec241 203 {
mbed_official 155:8435094ec241 204 /* Check the parameters */
mbed_official 155:8435094ec241 205 assert_param(IS_SYSCFG_DMA_REMAP(SYSCFG_DMARemap));
mbed_official 155:8435094ec241 206 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 155:8435094ec241 207
mbed_official 155:8435094ec241 208 if ((SYSCFG_DMARemap & 0x80000000)!= 0x80000000)
mbed_official 155:8435094ec241 209 {
mbed_official 155:8435094ec241 210 if (NewState != DISABLE)
mbed_official 155:8435094ec241 211 {
mbed_official 155:8435094ec241 212 /* Remap the DMA channel */
mbed_official 155:8435094ec241 213 SYSCFG->CFGR1 |= (uint32_t)SYSCFG_DMARemap;
mbed_official 155:8435094ec241 214 }
mbed_official 155:8435094ec241 215 else
mbed_official 155:8435094ec241 216 {
mbed_official 155:8435094ec241 217 /* use the default DMA channel mapping */
mbed_official 155:8435094ec241 218 SYSCFG->CFGR1 &= (uint32_t)(~SYSCFG_DMARemap);
mbed_official 155:8435094ec241 219 }
mbed_official 155:8435094ec241 220 }
mbed_official 155:8435094ec241 221 else
mbed_official 155:8435094ec241 222 {
mbed_official 155:8435094ec241 223 if (NewState != DISABLE)
mbed_official 155:8435094ec241 224 {
mbed_official 155:8435094ec241 225 /* Remap the DMA channel */
mbed_official 155:8435094ec241 226 SYSCFG->CFGR3 |= (uint32_t)SYSCFG_DMARemap;
mbed_official 155:8435094ec241 227 }
mbed_official 155:8435094ec241 228 else
mbed_official 155:8435094ec241 229 {
mbed_official 155:8435094ec241 230 /* use the default DMA channel mapping */
mbed_official 155:8435094ec241 231 SYSCFG->CFGR3 &= (uint32_t)(~SYSCFG_DMARemap);
mbed_official 155:8435094ec241 232 }
mbed_official 155:8435094ec241 233 }
mbed_official 155:8435094ec241 234 }
mbed_official 155:8435094ec241 235
mbed_official 155:8435094ec241 236 /**
mbed_official 155:8435094ec241 237 * @brief Configures the remapping capabilities of DAC/TIM triggers.
mbed_official 155:8435094ec241 238 * @param SYSCFG_TriggerRemap: selects the trigger to be remapped.
mbed_official 155:8435094ec241 239 * This parameter can be one of the following values:
mbed_official 155:8435094ec241 240 * @arg SYSCFG_TriggerRemap_DACTIM3: Remap DAC trigger from TIM8 to TIM3
mbed_official 155:8435094ec241 241 * @arg SYSCFG_TriggerRemap_TIM1TIM17: Remap TIM1 ITR3 from TIM4 TRGO to TIM17 OC
mbed_official 155:8435094ec241 242 * @arg SYSCFG_TriggerRemap_DACHRTIM1_TRIG1: Remap DAC trigger to HRTIM1 TRIG1
mbed_official 155:8435094ec241 243 * @arg SYSCFG_TriggerRemap_DACHRTIM1_TRIG2: Remap DAC trigger to HRTIM1 TRIG2
mbed_official 155:8435094ec241 244 * @param NewState: new state of the trigger mapping.
mbed_official 155:8435094ec241 245 * This parameter can be: ENABLE or DISABLE.
mbed_official 155:8435094ec241 246 * @note ENABLE: Enable fast mode plus driving capability for selected pin
mbed_official 155:8435094ec241 247 * @note DISABLE: Disable fast mode plus driving capability for selected pin
mbed_official 155:8435094ec241 248 * @retval None
mbed_official 155:8435094ec241 249 */
mbed_official 155:8435094ec241 250 void SYSCFG_TriggerRemapConfig(uint32_t SYSCFG_TriggerRemap, FunctionalState NewState)
mbed_official 155:8435094ec241 251 {
mbed_official 155:8435094ec241 252 /* Check the parameters */
mbed_official 155:8435094ec241 253 assert_param(IS_SYSCFG_TRIGGER_REMAP(SYSCFG_TriggerRemap));
mbed_official 155:8435094ec241 254 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 155:8435094ec241 255
mbed_official 155:8435094ec241 256 if ((SYSCFG_TriggerRemap & 0x80000000)!= 0x80000000)
mbed_official 155:8435094ec241 257 {
mbed_official 155:8435094ec241 258 if (NewState != DISABLE)
mbed_official 155:8435094ec241 259 {
mbed_official 155:8435094ec241 260 /* Remap the trigger */
mbed_official 155:8435094ec241 261 SYSCFG->CFGR1 |= (uint32_t)SYSCFG_TriggerRemap;
mbed_official 155:8435094ec241 262 }
mbed_official 155:8435094ec241 263 else
mbed_official 155:8435094ec241 264 {
mbed_official 155:8435094ec241 265 /* Use the default trigger mapping */
mbed_official 155:8435094ec241 266 SYSCFG->CFGR1 &= (uint32_t)(~SYSCFG_TriggerRemap);
mbed_official 155:8435094ec241 267 }
mbed_official 155:8435094ec241 268 }
mbed_official 155:8435094ec241 269 else
mbed_official 155:8435094ec241 270 {
mbed_official 155:8435094ec241 271 if (NewState != DISABLE)
mbed_official 155:8435094ec241 272 {
mbed_official 155:8435094ec241 273 /* Remap the trigger */
mbed_official 155:8435094ec241 274 SYSCFG->CFGR3 |= (uint32_t)SYSCFG_TriggerRemap;
mbed_official 155:8435094ec241 275 }
mbed_official 155:8435094ec241 276 else
mbed_official 155:8435094ec241 277 {
mbed_official 155:8435094ec241 278 /* Use the default trigger mapping */
mbed_official 155:8435094ec241 279 SYSCFG->CFGR3 &= (uint32_t)(~SYSCFG_TriggerRemap);
mbed_official 155:8435094ec241 280 }
mbed_official 155:8435094ec241 281 }
mbed_official 155:8435094ec241 282 }
mbed_official 155:8435094ec241 283
mbed_official 155:8435094ec241 284 /**
mbed_official 155:8435094ec241 285 * @brief Configures the remapping capabilities of encoder mode.
mbed_official 155:8435094ec241 286 * @ note This feature implement the so-called M/T method for measuring speed
mbed_official 155:8435094ec241 287 * and position using quadrature encoders.
mbed_official 155:8435094ec241 288 * @param SYSCFG_EncoderRemap: selects the remap option for encoder mode.
mbed_official 155:8435094ec241 289 * This parameter can be one of the following values:
mbed_official 155:8435094ec241 290 * @arg SYSCFG_EncoderRemap_No: No remap
mbed_official 155:8435094ec241 291 * @arg SYSCFG_EncoderRemap_TIM2: Timer 2 IC1 and IC2 connected to TIM15 IC1 and IC2
mbed_official 155:8435094ec241 292 * @arg SYSCFG_EncoderRemap_TIM3: Timer 3 IC1 and IC2 connected to TIM15 IC1 and IC2
mbed_official 155:8435094ec241 293 * @arg SYSCFG_EncoderRemap_TIM4: Timer 4 IC1 and IC2 connected to TIM15 IC1 and IC2
mbed_official 155:8435094ec241 294 * @retval None
mbed_official 155:8435094ec241 295 */
mbed_official 155:8435094ec241 296 void SYSCFG_EncoderRemapConfig(uint32_t SYSCFG_EncoderRemap)
mbed_official 155:8435094ec241 297 {
mbed_official 155:8435094ec241 298 /* Check the parameter */
mbed_official 155:8435094ec241 299 assert_param(IS_SYSCFG_ENCODER_REMAP(SYSCFG_EncoderRemap));
mbed_official 155:8435094ec241 300
mbed_official 155:8435094ec241 301 /* Reset the encoder mode remapping bits */
mbed_official 155:8435094ec241 302 SYSCFG->CFGR1 &= (uint32_t)(~SYSCFG_CFGR1_ENCODER_MODE);
mbed_official 155:8435094ec241 303
mbed_official 155:8435094ec241 304 /* Set the selected configuration */
mbed_official 155:8435094ec241 305 SYSCFG->CFGR1 |= (uint32_t)(SYSCFG_EncoderRemap);
mbed_official 155:8435094ec241 306 }
mbed_official 155:8435094ec241 307
mbed_official 155:8435094ec241 308 /**
mbed_official 155:8435094ec241 309 * @brief Remaps the USB interrupt lines.
mbed_official 155:8435094ec241 310 * @param NewState: new state of the mapping of USB interrupt lines.
mbed_official 155:8435094ec241 311 * This parameter can be:
mbed_official 155:8435094ec241 312 * @param ENABLE: Remap the USB interrupt line as following:
mbed_official 155:8435094ec241 313 * @arg USB Device High Priority (USB_HP) interrupt mapped to line 74.
mbed_official 155:8435094ec241 314 * @arg USB Device Low Priority (USB_LP) interrupt mapped to line 75.
mbed_official 155:8435094ec241 315 * @arg USB Wakeup Interrupt (USB_WKUP) interrupt mapped to line 76.
mbed_official 155:8435094ec241 316 * @param DISABLE: Use the default USB interrupt line:
mbed_official 155:8435094ec241 317 * @arg USB Device High Priority (USB_HP) interrupt mapped to line 19.
mbed_official 155:8435094ec241 318 * @arg USB Device Low Priority (USB_LP) interrupt mapped to line 20.
mbed_official 155:8435094ec241 319 * @arg USB Wakeup Interrupt (USB_WKUP) interrupt mapped to line 42.
mbed_official 155:8435094ec241 320 * @retval None
mbed_official 155:8435094ec241 321 */
mbed_official 155:8435094ec241 322 void SYSCFG_USBInterruptLineRemapCmd(FunctionalState NewState)
mbed_official 155:8435094ec241 323 {
mbed_official 155:8435094ec241 324 /* Check the parameter */
mbed_official 155:8435094ec241 325 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 155:8435094ec241 326
mbed_official 155:8435094ec241 327 /* Remap the USB interupt lines */
mbed_official 155:8435094ec241 328 *(__IO uint32_t *) CFGR1_USBITRMP_BB = (uint32_t)NewState;
mbed_official 155:8435094ec241 329 }
mbed_official 155:8435094ec241 330
mbed_official 155:8435094ec241 331 /**
mbed_official 155:8435094ec241 332 * @brief Configures the I2C fast mode plus driving capability.
mbed_official 155:8435094ec241 333 * @param SYSCFG_I2CFastModePlus: selects the pin.
mbed_official 155:8435094ec241 334 * This parameter can be one of the following values:
mbed_official 155:8435094ec241 335 * @arg SYSCFG_I2CFastModePlus_PB6: Configure fast mode plus driving capability for PB6
mbed_official 155:8435094ec241 336 * @arg SYSCFG_I2CFastModePlus_PB7: Configure fast mode plus driving capability for PB7
mbed_official 155:8435094ec241 337 * @arg SYSCFG_I2CFastModePlus_PB8: Configure fast mode plus driving capability for PB8
mbed_official 155:8435094ec241 338 * @arg SYSCFG_I2CFastModePlus_PB9: Configure fast mode plus driving capability for PB9
mbed_official 155:8435094ec241 339 * @arg SYSCFG_I2CFastModePlus_I2C1: Configure fast mode plus driving capability for I2C1 pins
mbed_official 155:8435094ec241 340 * @arg SYSCFG_I2CFastModePlus_I2C2: Configure fast mode plus driving capability for I2C2 pins
mbed_official 155:8435094ec241 341 * @param NewState: new state of the DMA channel remapping.
mbed_official 155:8435094ec241 342 * This parameter can be:
mbed_official 155:8435094ec241 343 * @arg ENABLE: Enable fast mode plus driving capability for selected I2C pin
mbed_official 155:8435094ec241 344 * @arg DISABLE: Disable fast mode plus driving capability for selected I2C pin
mbed_official 155:8435094ec241 345 * @note For I2C1, fast mode plus driving capability can be enabled on all selected
mbed_official 155:8435094ec241 346 * I2C1 pins using SYSCFG_I2CFastModePlus_I2C1 parameter or independently
mbed_official 155:8435094ec241 347 * on each one of the following pins PB6, PB7, PB8 and PB9.
mbed_official 155:8435094ec241 348 * @note For remaing I2C1 pins (PA14, PA15...) fast mode plus driving capability
mbed_official 155:8435094ec241 349 * can be enabled only by using SYSCFG_I2CFastModePlus_I2C1 parameter.
mbed_official 155:8435094ec241 350 * @note For all I2C2 pins fast mode plus driving capability can be enabled
mbed_official 155:8435094ec241 351 * only by using SYSCFG_I2CFastModePlus_I2C2 parameter.
mbed_official 155:8435094ec241 352 * @retval None
mbed_official 155:8435094ec241 353 */
mbed_official 155:8435094ec241 354 void SYSCFG_I2CFastModePlusConfig(uint32_t SYSCFG_I2CFastModePlus, FunctionalState NewState)
mbed_official 155:8435094ec241 355 {
mbed_official 155:8435094ec241 356 /* Check the parameters */
mbed_official 155:8435094ec241 357 assert_param(IS_SYSCFG_I2C_FMP(SYSCFG_I2CFastModePlus));
mbed_official 155:8435094ec241 358 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 155:8435094ec241 359
mbed_official 155:8435094ec241 360 if (NewState != DISABLE)
mbed_official 155:8435094ec241 361 {
mbed_official 155:8435094ec241 362 /* Enable fast mode plus driving capability for selected I2C pin */
mbed_official 155:8435094ec241 363 SYSCFG->CFGR1 |= (uint32_t)SYSCFG_I2CFastModePlus;
mbed_official 155:8435094ec241 364 }
mbed_official 155:8435094ec241 365 else
mbed_official 155:8435094ec241 366 {
mbed_official 155:8435094ec241 367 /* Disable fast mode plus driving capability for selected I2C pin */
mbed_official 155:8435094ec241 368 SYSCFG->CFGR1 &= (uint32_t)(~SYSCFG_I2CFastModePlus);
mbed_official 155:8435094ec241 369 }
mbed_official 155:8435094ec241 370 }
mbed_official 155:8435094ec241 371
mbed_official 155:8435094ec241 372 /**
mbed_official 155:8435094ec241 373 * @brief Enables or disables the selected SYSCFG interrupts.
mbed_official 155:8435094ec241 374 * @param SYSCFG_IT: specifies the SYSCFG interrupt sources to be enabled or disabled.
mbed_official 155:8435094ec241 375 * This parameter can be one of the following values:
mbed_official 155:8435094ec241 376 * @arg SYSCFG_IT_IXC: Inexact Interrupt
mbed_official 155:8435094ec241 377 * @arg SYSCFG_IT_IDC: Input denormal Interrupt
mbed_official 155:8435094ec241 378 * @arg SYSCFG_IT_OFC: Overflow Interrupt
mbed_official 155:8435094ec241 379 * @arg SYSCFG_IT_UFC: Underflow Interrupt
mbed_official 155:8435094ec241 380 * @arg SYSCFG_IT_DZC: Divide-by-zero Interrupt
mbed_official 155:8435094ec241 381 * @arg SYSCFG_IT_IOC: Invalid operation Interrupt
mbed_official 155:8435094ec241 382 * @param NewState: new state of the specified SYSCFG interrupts.
mbed_official 155:8435094ec241 383 * This parameter can be: ENABLE or DISABLE.
mbed_official 155:8435094ec241 384 * @retval None
mbed_official 155:8435094ec241 385 */
mbed_official 155:8435094ec241 386 void SYSCFG_ITConfig(uint32_t SYSCFG_IT, FunctionalState NewState)
mbed_official 155:8435094ec241 387 {
mbed_official 155:8435094ec241 388 /* Check the parameters */
mbed_official 155:8435094ec241 389 assert_param(IS_FUNCTIONAL_STATE(NewState));
mbed_official 155:8435094ec241 390 assert_param(IS_SYSCFG_IT(SYSCFG_IT));
mbed_official 155:8435094ec241 391
mbed_official 155:8435094ec241 392 if (NewState != DISABLE)
mbed_official 155:8435094ec241 393 {
mbed_official 155:8435094ec241 394 /* Enable the selected SYSCFG interrupts */
mbed_official 155:8435094ec241 395 SYSCFG->CFGR1 |= SYSCFG_IT;
mbed_official 155:8435094ec241 396 }
mbed_official 155:8435094ec241 397 else
mbed_official 155:8435094ec241 398 {
mbed_official 155:8435094ec241 399 /* Disable the selected SYSCFG interrupts */
mbed_official 155:8435094ec241 400 SYSCFG->CFGR1 &= ((uint32_t)~SYSCFG_IT);
mbed_official 155:8435094ec241 401 }
mbed_official 155:8435094ec241 402 }
mbed_official 155:8435094ec241 403
mbed_official 155:8435094ec241 404 /**
mbed_official 155:8435094ec241 405 * @brief Selects the GPIO pin used as EXTI Line.
mbed_official 155:8435094ec241 406 * @param EXTI_PortSourceGPIOx : selects the GPIO port to be used as source
mbed_official 155:8435094ec241 407 * for EXTI lines where x can be (A, B, C, D, E or F).
mbed_official 155:8435094ec241 408 * @param EXTI_PinSourcex: specifies the EXTI line to be configured.
mbed_official 155:8435094ec241 409 * This parameter can be EXTI_PinSourcex where x can be (0..15)
mbed_official 155:8435094ec241 410 * @retval None
mbed_official 155:8435094ec241 411 */
mbed_official 155:8435094ec241 412 void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex)
mbed_official 155:8435094ec241 413 {
mbed_official 155:8435094ec241 414 uint32_t tmp = 0x00;
mbed_official 155:8435094ec241 415
mbed_official 155:8435094ec241 416 /* Check the parameters */
mbed_official 155:8435094ec241 417 assert_param(IS_EXTI_PORT_SOURCE(EXTI_PortSourceGPIOx));
mbed_official 155:8435094ec241 418 assert_param(IS_EXTI_PIN_SOURCE(EXTI_PinSourcex));
mbed_official 155:8435094ec241 419
mbed_official 155:8435094ec241 420 tmp = ((uint32_t)0x0F) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03));
mbed_official 155:8435094ec241 421 SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] &= ~tmp;
mbed_official 155:8435094ec241 422 SYSCFG->EXTICR[EXTI_PinSourcex >> 0x02] |= (((uint32_t)EXTI_PortSourceGPIOx) << (0x04 * (EXTI_PinSourcex & (uint8_t)0x03)));
mbed_official 155:8435094ec241 423 }
mbed_official 155:8435094ec241 424
mbed_official 155:8435094ec241 425 /**
mbed_official 155:8435094ec241 426 * @brief Connects the selected parameter to the break input of TIM1.
mbed_official 155:8435094ec241 427 * @note The selected configuration is locked and can be unlocked by system reset
mbed_official 155:8435094ec241 428 * @param SYSCFG_Break: selects the configuration to be connected to break
mbed_official 155:8435094ec241 429 * input of TIM1
mbed_official 155:8435094ec241 430 * This parameter can be any combination of the following values:
mbed_official 155:8435094ec241 431 * @arg SYSCFG_Break_PVD: PVD interrupt is connected to the break input of TIM1.
mbed_official 155:8435094ec241 432 * @arg SYSCFG_Break_SRAMParity: SRAM Parity error is connected to the break input of TIM1.
mbed_official 155:8435094ec241 433 * @arg SYSCFG_Break_HardFault: Lockup output of CortexM4 is connected to the break input of TIM1.
mbed_official 155:8435094ec241 434 * @retval None
mbed_official 155:8435094ec241 435 */
mbed_official 155:8435094ec241 436 void SYSCFG_BreakConfig(uint32_t SYSCFG_Break)
mbed_official 155:8435094ec241 437 {
mbed_official 155:8435094ec241 438 /* Check the parameter */
mbed_official 155:8435094ec241 439 assert_param(IS_SYSCFG_LOCK_CONFIG(SYSCFG_Break));
mbed_official 155:8435094ec241 440
mbed_official 155:8435094ec241 441 SYSCFG->CFGR2 |= (uint32_t) SYSCFG_Break;
mbed_official 155:8435094ec241 442 }
mbed_official 155:8435094ec241 443
mbed_official 155:8435094ec241 444 /**
mbed_official 155:8435094ec241 445 * @brief Disables the parity check on RAM.
mbed_official 155:8435094ec241 446 * @note Disabling the parity check on RAM locks the configuration bit.
mbed_official 155:8435094ec241 447 * To re-enable the parity check on RAM perform a system reset.
mbed_official 155:8435094ec241 448 * @param None
mbed_official 155:8435094ec241 449 * @retval None
mbed_official 155:8435094ec241 450 */
mbed_official 155:8435094ec241 451 void SYSCFG_BypassParityCheckDisable(void)
mbed_official 155:8435094ec241 452 {
mbed_official 155:8435094ec241 453 /* Disable the adddress parity check on RAM */
mbed_official 155:8435094ec241 454 *(__IO uint32_t *) CFGR1_BYPADDRPAR_BB = (uint32_t)0x00000001;
mbed_official 155:8435094ec241 455 }
mbed_official 155:8435094ec241 456
mbed_official 155:8435094ec241 457 /**
mbed_official 155:8435094ec241 458 * @brief Enables the ICODE SRAM write protection.
mbed_official 155:8435094ec241 459 * @note Enabling the ICODE SRAM write protection locks the configuration bit.
mbed_official 155:8435094ec241 460 * To disable the ICODE SRAM write protection perform a system reset.
mbed_official 155:8435094ec241 461 * @param None
mbed_official 155:8435094ec241 462 * @retval None
mbed_official 155:8435094ec241 463 */
mbed_official 155:8435094ec241 464 void SYSCFG_SRAMWRPEnable(uint32_t SYSCFG_SRAMWRP)
mbed_official 155:8435094ec241 465 {
mbed_official 155:8435094ec241 466 /* Check the parameter */
mbed_official 155:8435094ec241 467 assert_param(IS_SYSCFG_PAGE(SYSCFG_SRAMWRP));
mbed_official 155:8435094ec241 468
mbed_official 155:8435094ec241 469 /* Enable the write-protection on the selected ICODE SRAM page */
mbed_official 155:8435094ec241 470 SYSCFG->RCR |= (uint32_t)SYSCFG_SRAMWRP;
mbed_official 155:8435094ec241 471 }
mbed_official 155:8435094ec241 472
mbed_official 155:8435094ec241 473 /**
mbed_official 155:8435094ec241 474 * @brief Checks whether the specified SYSCFG flag is set or not.
mbed_official 155:8435094ec241 475 * @param SYSCFG_Flag: specifies the SYSCFG flag to check.
mbed_official 155:8435094ec241 476 * This parameter can be one of the following values:
mbed_official 155:8435094ec241 477 * @arg SYSCFG_FLAG_PE: SRAM parity error flag.
mbed_official 155:8435094ec241 478 * @retval The new state of SYSCFG_Flag (SET or RESET).
mbed_official 155:8435094ec241 479 */
mbed_official 155:8435094ec241 480 FlagStatus SYSCFG_GetFlagStatus(uint32_t SYSCFG_Flag)
mbed_official 155:8435094ec241 481 {
mbed_official 155:8435094ec241 482 FlagStatus bitstatus = RESET;
mbed_official 155:8435094ec241 483
mbed_official 155:8435094ec241 484 /* Check the parameter */
mbed_official 155:8435094ec241 485 assert_param(IS_SYSCFG_FLAG(SYSCFG_Flag));
mbed_official 155:8435094ec241 486
mbed_official 155:8435094ec241 487 /* Check the status of the specified SPI flag */
mbed_official 155:8435094ec241 488 if ((SYSCFG->CFGR2 & SYSCFG_CFGR2_SRAM_PE) != (uint32_t)RESET)
mbed_official 155:8435094ec241 489 {
mbed_official 155:8435094ec241 490 /* SYSCFG_Flag is set */
mbed_official 155:8435094ec241 491 bitstatus = SET;
mbed_official 155:8435094ec241 492 }
mbed_official 155:8435094ec241 493 else
mbed_official 155:8435094ec241 494 {
mbed_official 155:8435094ec241 495 /* SYSCFG_Flag is reset */
mbed_official 155:8435094ec241 496 bitstatus = RESET;
mbed_official 155:8435094ec241 497 }
mbed_official 155:8435094ec241 498 /* Return the SYSCFG_Flag status */
mbed_official 155:8435094ec241 499 return bitstatus;
mbed_official 155:8435094ec241 500 }
mbed_official 155:8435094ec241 501
mbed_official 155:8435094ec241 502 /**
mbed_official 155:8435094ec241 503 * @brief Clears the selected SYSCFG flag.
mbed_official 155:8435094ec241 504 * @param SYSCFG_Flag: selects the flag to be cleared.
mbed_official 155:8435094ec241 505 * This parameter can be any combination of the following values:
mbed_official 155:8435094ec241 506 * @arg SYSCFG_FLAG_PE: SRAM parity error flag.
mbed_official 155:8435094ec241 507 * @retval None
mbed_official 155:8435094ec241 508 */
mbed_official 155:8435094ec241 509 void SYSCFG_ClearFlag(uint32_t SYSCFG_Flag)
mbed_official 155:8435094ec241 510 {
mbed_official 155:8435094ec241 511 /* Check the parameter */
mbed_official 155:8435094ec241 512 assert_param(IS_SYSCFG_FLAG(SYSCFG_Flag));
mbed_official 155:8435094ec241 513
mbed_official 155:8435094ec241 514 SYSCFG->CFGR2 |= (uint32_t) SYSCFG_Flag;
mbed_official 155:8435094ec241 515 }
mbed_official 155:8435094ec241 516
mbed_official 155:8435094ec241 517 /**
mbed_official 155:8435094ec241 518 * @}
mbed_official 155:8435094ec241 519 */
mbed_official 155:8435094ec241 520
mbed_official 155:8435094ec241 521 /**
mbed_official 155:8435094ec241 522 * @}
mbed_official 155:8435094ec241 523 */
mbed_official 155:8435094ec241 524
mbed_official 155:8435094ec241 525 /**
mbed_official 155:8435094ec241 526 * @}
mbed_official 155:8435094ec241 527 */
mbed_official 155:8435094ec241 528
mbed_official 155:8435094ec241 529 /**
mbed_official 155:8435094ec241 530 * @}
mbed_official 155:8435094ec241 531 */
mbed_official 155:8435094ec241 532 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
mbed_official 155:8435094ec241 533