![]() |
|
|||
File indexing completed on 2025-05-11 08:23:06
0001 /** 0002 ****************************************************************************** 0003 * @file stm32h7xx_hal.c 0004 * @author MCD Application Team 0005 * @brief HAL module driver. 0006 * This is the common part of the HAL initialization 0007 * 0008 ****************************************************************************** 0009 * @attention 0010 * 0011 * Copyright (c) 2017 STMicroelectronics. 0012 * All rights reserved. 0013 * 0014 * This software is licensed under terms that can be found in the LICENSE file 0015 * in the root directory of this software component. 0016 * If no LICENSE file comes with this software, it is provided AS-IS. 0017 * 0018 ****************************************************************************** 0019 @verbatim 0020 ============================================================================== 0021 ##### How to use this driver ##### 0022 ============================================================================== 0023 [..] 0024 The common HAL driver contains a set of generic and common APIs that can be 0025 used by the PPP peripheral drivers and the user to start using the HAL. 0026 [..] 0027 The HAL contains two APIs' categories: 0028 (+) Common HAL APIs 0029 (+) Services HAL APIs 0030 0031 @endverbatim 0032 ****************************************************************************** 0033 */ 0034 0035 /* Includes ------------------------------------------------------------------*/ 0036 #include "stm32h7xx_hal.h" 0037 0038 /** @addtogroup STM32H7xx_HAL_Driver 0039 * @{ 0040 */ 0041 0042 /** @defgroup HAL HAL 0043 * @ingroup RTEMSBSPsARMSTM32H7 0044 * @brief HAL module driver. 0045 * @{ 0046 */ 0047 0048 /* Private typedef -----------------------------------------------------------*/ 0049 /* Private define ------------------------------------------------------------*/ 0050 /** 0051 * @brief STM32H7xx HAL Driver version number 0052 */ 0053 #define __STM32H7xx_HAL_VERSION_MAIN (0x01UL) /*!< [31:24] main version */ 0054 #define __STM32H7xx_HAL_VERSION_SUB1 (0x0BUL) /*!< [23:16] sub1 version */ 0055 #define __STM32H7xx_HAL_VERSION_SUB2 (0x03UL) /*!< [15:8] sub2 version */ 0056 #define __STM32H7xx_HAL_VERSION_RC (0x00UL) /*!< [7:0] release candidate */ 0057 #define __STM32H7xx_HAL_VERSION ((__STM32H7xx_HAL_VERSION_MAIN << 24)\ 0058 |(__STM32H7xx_HAL_VERSION_SUB1 << 16)\ 0059 |(__STM32H7xx_HAL_VERSION_SUB2 << 8 )\ 0060 |(__STM32H7xx_HAL_VERSION_RC)) 0061 0062 #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF) 0063 #define VREFBUF_TIMEOUT_VALUE (uint32_t)10 /* 10 ms */ 0064 0065 /* Private macro -------------------------------------------------------------*/ 0066 /* Private variables ---------------------------------------------------------*/ 0067 /* Exported variables --------------------------------------------------------*/ 0068 0069 /** @defgroup HAL_Exported_Variables HAL Exported Variables 0070 * @ingroup RTEMSBSPsARMSTM32H7 0071 * @{ 0072 */ 0073 #ifndef __rtems__ 0074 __IO uint32_t uwTick; 0075 uint32_t uwTickPrio = (1UL << __NVIC_PRIO_BITS); /* Invalid PRIO */ 0076 HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */ 0077 #endif /* __rtems__ */ 0078 /** 0079 * @} 0080 */ 0081 0082 /* Private function prototypes -----------------------------------------------*/ 0083 /* Private functions ---------------------------------------------------------*/ 0084 0085 /** @addtogroup HAL_Exported_Functions 0086 * @{ 0087 */ 0088 0089 /** @addtogroup HAL_Group1 0090 * @brief Initialization and de-initialization functions 0091 * 0092 @verbatim 0093 =============================================================================== 0094 ##### Initialization and de-initialization functions ##### 0095 =============================================================================== 0096 [..] This section provides functions allowing to: 0097 (+) Initializes the Flash interface the NVIC allocation and initial clock 0098 configuration. It initializes the systick also when timeout is needed 0099 and the backup domain when enabled. 0100 (+) De-Initializes common part of the HAL. 0101 (+) Configure The time base source to have 1ms time base with a dedicated 0102 Tick interrupt priority. 0103 (++) SysTick timer is used by default as source of time base, but user 0104 can eventually implement his proper time base source (a general purpose 0105 timer for example or other time source), keeping in mind that Time base 0106 duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and 0107 handled in milliseconds basis. 0108 (++) Time base configuration function (HAL_InitTick ()) is called automatically 0109 at the beginning of the program after reset by HAL_Init() or at any time 0110 when clock is configured, by HAL_RCC_ClockConfig(). 0111 (++) Source of time base is configured to generate interrupts at regular 0112 time intervals. Care must be taken if HAL_Delay() is called from a 0113 peripheral ISR process, the Tick interrupt line must have higher priority 0114 (numerically lower) than the peripheral interrupt. Otherwise the caller 0115 ISR process will be blocked. 0116 (++) functions affecting time base configurations are declared as __weak 0117 to make override possible in case of other implementations in user file. 0118 @endverbatim 0119 * @{ 0120 */ 0121 0122 /** 0123 * @brief This function is used to initialize the HAL Library; it must be the first 0124 * instruction to be executed in the main program (before to call any other 0125 * HAL function), it performs the following: 0126 * Configures the SysTick to generate an interrupt each 1 millisecond, 0127 * which is clocked by the HSI (at this stage, the clock is not yet 0128 * configured and thus the system is running from the internal HSI at 16 MHz). 0129 * Set NVIC Group Priority to 4. 0130 * Calls the HAL_MspInit() callback function defined in user file 0131 * "stm32h7xx_hal_msp.c" to do the global low level hardware initialization 0132 * 0133 * @note SysTick is used as time base for the HAL_Delay() function, the application 0134 * need to ensure that the SysTick time base is always set to 1 millisecond 0135 * to have correct HAL operation. 0136 * @retval HAL status 0137 */ 0138 HAL_StatusTypeDef HAL_Init(void) 0139 { 0140 0141 uint32_t common_system_clock; 0142 0143 #if defined(DUAL_CORE) && defined(CORE_CM4) 0144 /* Configure Cortex-M4 Instruction cache through ART accelerator */ 0145 __HAL_RCC_ART_CLK_ENABLE(); /* Enable the Cortex-M4 ART Clock */ 0146 __HAL_ART_CONFIG_BASE_ADDRESS(0x08100000UL); /* Configure the Cortex-M4 ART Base address to the Flash Bank 2 : */ 0147 __HAL_ART_ENABLE(); /* Enable the Cortex-M4 ART */ 0148 #endif /* DUAL_CORE && CORE_CM4 */ 0149 0150 /* Set Interrupt Group Priority */ 0151 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); 0152 0153 /* Update the SystemCoreClock global variable */ 0154 #if defined(RCC_D1CFGR_D1CPRE) 0155 common_system_clock = HAL_RCC_GetSysClockFreq() >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]) & 0x1FU); 0156 #else 0157 common_system_clock = HAL_RCC_GetSysClockFreq() >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE)>> RCC_CDCFGR1_CDCPRE_Pos]) & 0x1FU); 0158 #endif 0159 0160 /* Update the SystemD2Clock global variable */ 0161 #if defined(RCC_D1CFGR_HPRE) 0162 SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU)); 0163 #else 0164 SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE)>> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU)); 0165 #endif 0166 0167 #if defined(DUAL_CORE) && defined(CORE_CM4) 0168 SystemCoreClock = SystemD2Clock; 0169 #else 0170 SystemCoreClock = common_system_clock; 0171 #endif /* DUAL_CORE && CORE_CM4 */ 0172 0173 #ifndef __rtems__ 0174 /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */ 0175 if(HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) 0176 { 0177 return HAL_ERROR; 0178 } 0179 #endif /* __rtems__ */ 0180 0181 /* Init the low level hardware */ 0182 HAL_MspInit(); 0183 0184 /* Return function status */ 0185 return HAL_OK; 0186 } 0187 0188 #ifndef __rtems__ 0189 /** 0190 * @brief This function de-Initializes common part of the HAL and stops the systick. 0191 * This function is optional. 0192 * @retval HAL status 0193 */ 0194 HAL_StatusTypeDef HAL_DeInit(void) 0195 { 0196 /* Reset of all peripherals */ 0197 __HAL_RCC_AHB3_FORCE_RESET(); 0198 __HAL_RCC_AHB3_RELEASE_RESET(); 0199 0200 __HAL_RCC_AHB1_FORCE_RESET(); 0201 __HAL_RCC_AHB1_RELEASE_RESET(); 0202 0203 __HAL_RCC_AHB2_FORCE_RESET(); 0204 __HAL_RCC_AHB2_RELEASE_RESET(); 0205 0206 __HAL_RCC_AHB4_FORCE_RESET(); 0207 __HAL_RCC_AHB4_RELEASE_RESET(); 0208 0209 __HAL_RCC_APB3_FORCE_RESET(); 0210 __HAL_RCC_APB3_RELEASE_RESET(); 0211 0212 __HAL_RCC_APB1L_FORCE_RESET(); 0213 __HAL_RCC_APB1L_RELEASE_RESET(); 0214 0215 __HAL_RCC_APB1H_FORCE_RESET(); 0216 __HAL_RCC_APB1H_RELEASE_RESET(); 0217 0218 __HAL_RCC_APB2_FORCE_RESET(); 0219 __HAL_RCC_APB2_RELEASE_RESET(); 0220 0221 __HAL_RCC_APB4_FORCE_RESET(); 0222 __HAL_RCC_APB4_RELEASE_RESET(); 0223 0224 /* De-Init the low level hardware */ 0225 HAL_MspDeInit(); 0226 0227 /* Return function status */ 0228 return HAL_OK; 0229 } 0230 #endif /* __rtems__ */ 0231 0232 #ifndef __rtems__ 0233 /** 0234 * @brief Initializes the MSP. 0235 * @retval None 0236 */ 0237 __weak void HAL_MspInit(void) 0238 { 0239 /* NOTE : This function Should not be modified, when the callback is needed, 0240 the HAL_MspInit could be implemented in the user file 0241 */ 0242 } 0243 0244 /** 0245 * @brief DeInitializes the MSP. 0246 * @retval None 0247 */ 0248 __weak void HAL_MspDeInit(void) 0249 { 0250 /* NOTE : This function Should not be modified, when the callback is needed, 0251 the HAL_MspDeInit could be implemented in the user file 0252 */ 0253 } 0254 0255 /** 0256 * @brief This function configures the source of the time base. 0257 * The time source is configured to have 1ms time base with a dedicated 0258 * Tick interrupt priority. 0259 * @note This function is called automatically at the beginning of program after 0260 * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig(). 0261 * @note In the default implementation, SysTick timer is the source of time base. 0262 * It is used to generate interrupts at regular time intervals. 0263 * Care must be taken if HAL_Delay() is called from a peripheral ISR process, 0264 * the SysTick interrupt must have higher priority (numerically lower) 0265 * than the peripheral interrupt. Otherwise the caller ISR process will be blocked. 0266 * The function is declared as __weak to be overwritten in case of other 0267 * implementation in user file. 0268 * @param TickPriority: Tick interrupt priority. 0269 * @retval HAL status 0270 */ 0271 __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority) 0272 { 0273 /* Check uwTickFreq for MisraC 2012 (even if uwTickFreq is a enum type that don't take the value zero)*/ 0274 if((uint32_t)uwTickFreq == 0UL) 0275 { 0276 return HAL_ERROR; 0277 } 0278 0279 /* Configure the SysTick to have interrupt in 1ms time basis*/ 0280 if (HAL_SYSTICK_Config(SystemCoreClock / (1000UL / (uint32_t)uwTickFreq)) > 0U) 0281 { 0282 return HAL_ERROR; 0283 } 0284 0285 /* Configure the SysTick IRQ priority */ 0286 if (TickPriority < (1UL << __NVIC_PRIO_BITS)) 0287 { 0288 HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U); 0289 uwTickPrio = TickPriority; 0290 } 0291 else 0292 { 0293 return HAL_ERROR; 0294 } 0295 0296 /* Return function status */ 0297 return HAL_OK; 0298 } 0299 #endif /* __rtems__ */ 0300 0301 /** 0302 * @} 0303 */ 0304 0305 /** @addtogroup HAL_Group2 0306 * @brief HAL Control functions 0307 * 0308 @verbatim 0309 =============================================================================== 0310 ##### HAL Control functions ##### 0311 =============================================================================== 0312 [..] This section provides functions allowing to: 0313 (+) Provide a tick value in millisecond 0314 (+) Provide a blocking delay in millisecond 0315 (+) Suspend the time base source interrupt 0316 (+) Resume the time base source interrupt 0317 (+) Get the HAL API driver version 0318 (+) Get the device identifier 0319 (+) Get the device revision identifier 0320 (+) Enable/Disable Debug module during SLEEP mode 0321 (+) Enable/Disable Debug module during STOP mode 0322 (+) Enable/Disable Debug module during STANDBY mode 0323 0324 @endverbatim 0325 * @{ 0326 */ 0327 0328 #ifndef __rtems__ 0329 /** 0330 * @brief This function is called to increment a global variable "uwTick" 0331 * used as application time base. 0332 * @note In the default implementation, this variable is incremented each 1ms 0333 * in Systick ISR. 0334 * @note This function is declared as __weak to be overwritten in case of other 0335 * implementations in user file. 0336 * @retval None 0337 */ 0338 __weak void HAL_IncTick(void) 0339 { 0340 uwTick += (uint32_t)uwTickFreq; 0341 } 0342 0343 /** 0344 * @brief Provides a tick value in millisecond. 0345 * @note This function is declared as __weak to be overwritten in case of other 0346 * implementations in user file. 0347 * @retval tick value 0348 */ 0349 __weak uint32_t HAL_GetTick(void) 0350 { 0351 return uwTick; 0352 } 0353 0354 /** 0355 * @brief This function returns a tick priority. 0356 * @retval tick priority 0357 */ 0358 uint32_t HAL_GetTickPrio(void) 0359 { 0360 return uwTickPrio; 0361 } 0362 0363 /** 0364 * @brief Set new tick Freq. 0365 * @retval Status 0366 */ 0367 HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq) 0368 { 0369 HAL_StatusTypeDef status = HAL_OK; 0370 HAL_TickFreqTypeDef prevTickFreq; 0371 0372 assert_param(IS_TICKFREQ(Freq)); 0373 0374 if (uwTickFreq != Freq) 0375 { 0376 0377 /* Back up uwTickFreq frequency */ 0378 prevTickFreq = uwTickFreq; 0379 0380 /* Update uwTickFreq global variable used by HAL_InitTick() */ 0381 uwTickFreq = Freq; 0382 0383 /* Apply the new tick Freq */ 0384 status = HAL_InitTick(uwTickPrio); 0385 if (status != HAL_OK) 0386 { 0387 /* Restore previous tick frequency */ 0388 uwTickFreq = prevTickFreq; 0389 } 0390 } 0391 0392 return status; 0393 } 0394 0395 /** 0396 * @brief Return tick frequency. 0397 * @retval Tick frequency. 0398 * Value of @ref HAL_TickFreqTypeDef. 0399 */ 0400 HAL_TickFreqTypeDef HAL_GetTickFreq(void) 0401 { 0402 return uwTickFreq; 0403 } 0404 0405 /** 0406 * @brief This function provides minimum delay (in milliseconds) based 0407 * on variable incremented. 0408 * @note In the default implementation , SysTick timer is the source of time base. 0409 * It is used to generate interrupts at regular time intervals where uwTick 0410 * is incremented. 0411 * @note This function is declared as __weak to be overwritten in case of other 0412 * implementations in user file. 0413 * @param Delay specifies the delay time length, in milliseconds. 0414 * @retval None 0415 */ 0416 __weak void HAL_Delay(uint32_t Delay) 0417 { 0418 uint32_t tickstart = HAL_GetTick(); 0419 uint32_t wait = Delay; 0420 0421 /* Add a freq to guarantee minimum wait */ 0422 if (wait < HAL_MAX_DELAY) 0423 { 0424 wait += (uint32_t)(uwTickFreq); 0425 } 0426 0427 while ((HAL_GetTick() - tickstart) < wait) 0428 { 0429 } 0430 } 0431 0432 /** 0433 * @brief Suspend Tick increment. 0434 * @note In the default implementation , SysTick timer is the source of time base. It is 0435 * used to generate interrupts at regular time intervals. Once HAL_SuspendTick() 0436 * is called, the SysTick interrupt will be disabled and so Tick increment 0437 * is suspended. 0438 * @note This function is declared as __weak to be overwritten in case of other 0439 * implementations in user file. 0440 * @retval None 0441 */ 0442 __weak void HAL_SuspendTick(void) 0443 { 0444 /* Disable SysTick Interrupt */ 0445 SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk; 0446 } 0447 0448 /** 0449 * @brief Resume Tick increment. 0450 * @note In the default implementation , SysTick timer is the source of time base. It is 0451 * used to generate interrupts at regular time intervals. Once HAL_ResumeTick() 0452 * is called, the SysTick interrupt will be enabled and so Tick increment 0453 * is resumed. 0454 * @note This function is declared as __weak to be overwritten in case of other 0455 * implementations in user file. 0456 * @retval None 0457 */ 0458 __weak void HAL_ResumeTick(void) 0459 { 0460 /* Enable SysTick Interrupt */ 0461 SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk; 0462 } 0463 #endif /* __rtems__ */ 0464 0465 /** 0466 * @brief Returns the HAL revision 0467 * @retval version : 0xXYZR (8bits for each decimal, R for RC) 0468 */ 0469 uint32_t HAL_GetHalVersion(void) 0470 { 0471 return __STM32H7xx_HAL_VERSION; 0472 } 0473 0474 /** 0475 * @brief Returns the device revision identifier. 0476 * @retval Device revision identifier 0477 */ 0478 uint32_t HAL_GetREVID(void) 0479 { 0480 return((DBGMCU->IDCODE) >> 16); 0481 } 0482 0483 /** 0484 * @brief Returns the device identifier. 0485 * @retval Device identifier 0486 */ 0487 uint32_t HAL_GetDEVID(void) 0488 { 0489 return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK); 0490 } 0491 0492 /** 0493 * @brief Return the first word of the unique device identifier (UID based on 96 bits) 0494 * @retval Device identifier 0495 */ 0496 uint32_t HAL_GetUIDw0(void) 0497 { 0498 return(READ_REG(*((uint32_t *)UID_BASE))); 0499 } 0500 0501 /** 0502 * @brief Return the second word of the unique device identifier (UID based on 96 bits) 0503 * @retval Device identifier 0504 */ 0505 uint32_t HAL_GetUIDw1(void) 0506 { 0507 return(READ_REG(*((uint32_t *)(UID_BASE + 4U)))); 0508 } 0509 0510 /** 0511 * @brief Return the third word of the unique device identifier (UID based on 96 bits) 0512 * @retval Device identifier 0513 */ 0514 uint32_t HAL_GetUIDw2(void) 0515 { 0516 return(READ_REG(*((uint32_t *)(UID_BASE + 8U)))); 0517 } 0518 0519 /** 0520 * @brief Configure the internal voltage reference buffer voltage scale. 0521 * @param VoltageScaling specifies the output voltage to achieve 0522 * This parameter can be one of the following values: 0523 * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE0: VREF_OUT1 around 2.5 V. 0524 * This requires VDDA equal to or higher than 2.8 V. 0525 * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE1: VREF_OUT2 around 2.048 V. 0526 * This requires VDDA equal to or higher than 2.4 V. 0527 * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE2: VREF_OUT3 around 1.8 V. 0528 * This requires VDDA equal to or higher than 2.1 V. 0529 * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE3: VREF_OUT4 around 1.5 V. 0530 * This requires VDDA equal to or higher than 1.8 V. 0531 * @retval None 0532 */ 0533 void HAL_SYSCFG_VREFBUF_VoltageScalingConfig(uint32_t VoltageScaling) 0534 { 0535 /* Check the parameters */ 0536 assert_param(IS_SYSCFG_VREFBUF_VOLTAGE_SCALE(VoltageScaling)); 0537 0538 MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_VRS, VoltageScaling); 0539 } 0540 0541 /** 0542 * @brief Configure the internal voltage reference buffer high impedance mode. 0543 * @param Mode specifies the high impedance mode 0544 * This parameter can be one of the following values: 0545 * @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE: VREF+ pin is internally connect to VREFINT output. 0546 * @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE: VREF+ pin is high impedance. 0547 * @retval None 0548 */ 0549 void HAL_SYSCFG_VREFBUF_HighImpedanceConfig(uint32_t Mode) 0550 { 0551 /* Check the parameters */ 0552 assert_param(IS_SYSCFG_VREFBUF_HIGH_IMPEDANCE(Mode)); 0553 0554 MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_HIZ, Mode); 0555 } 0556 0557 /** 0558 * @brief Tune the Internal Voltage Reference buffer (VREFBUF). 0559 * @retval None 0560 */ 0561 void HAL_SYSCFG_VREFBUF_TrimmingConfig(uint32_t TrimmingValue) 0562 { 0563 /* Check the parameters */ 0564 assert_param(IS_SYSCFG_VREFBUF_TRIMMING(TrimmingValue)); 0565 0566 MODIFY_REG(VREFBUF->CCR, VREFBUF_CCR_TRIM, TrimmingValue); 0567 } 0568 0569 /** 0570 * @brief Enable the Internal Voltage Reference buffer (VREFBUF). 0571 * @retval HAL_OK/HAL_TIMEOUT 0572 */ 0573 HAL_StatusTypeDef HAL_SYSCFG_EnableVREFBUF(void) 0574 { 0575 uint32_t tickstart; 0576 0577 SET_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR); 0578 0579 /* Get Start Tick*/ 0580 tickstart = HAL_GetTick(); 0581 0582 /* Wait for VRR bit */ 0583 while(READ_BIT(VREFBUF->CSR, VREFBUF_CSR_VRR) == 0UL) 0584 { 0585 if((HAL_GetTick() - tickstart) > VREFBUF_TIMEOUT_VALUE) 0586 { 0587 return HAL_TIMEOUT; 0588 } 0589 } 0590 0591 return HAL_OK; 0592 } 0593 0594 /** 0595 * @brief Disable the Internal Voltage Reference buffer (VREFBUF). 0596 * 0597 * @retval None 0598 */ 0599 void HAL_SYSCFG_DisableVREFBUF(void) 0600 { 0601 CLEAR_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR); 0602 } 0603 0604 #if defined(SYSCFG_PMCR_EPIS_SEL) 0605 /** 0606 * @brief Ethernet PHY Interface Selection either MII or RMII 0607 * @param SYSCFG_ETHInterface: Selects the Ethernet PHY interface 0608 * This parameter can be one of the following values: 0609 * @arg SYSCFG_ETH_MII : Select the Media Independent Interface 0610 * @arg SYSCFG_ETH_RMII: Select the Reduced Media Independent Interface 0611 * @retval None 0612 */ 0613 void HAL_SYSCFG_ETHInterfaceSelect(uint32_t SYSCFG_ETHInterface) 0614 { 0615 /* Check the parameter */ 0616 assert_param(IS_SYSCFG_ETHERNET_CONFIG(SYSCFG_ETHInterface)); 0617 0618 MODIFY_REG(SYSCFG->PMCR, SYSCFG_PMCR_EPIS_SEL, (uint32_t)(SYSCFG_ETHInterface)); 0619 } 0620 #endif /* SYSCFG_PMCR_EPIS_SEL */ 0621 0622 /** 0623 * @brief Analog Switch control for dual analog pads. 0624 * @param SYSCFG_AnalogSwitch: Selects the analog pad 0625 * This parameter can be one or a combination of the following values: 0626 * @arg SYSCFG_SWITCH_PA0 : Select PA0 analog switch 0627 * @arg SYSCFG_SWITCH_PA1: Select PA1 analog switch 0628 * @arg SYSCFG_SWITCH_PC2 : Select PC2 analog switch 0629 * @arg SYSCFG_SWITCH_PC3: Select PC3 analog switch 0630 * @param SYSCFG_SwitchState: Open or Close the analog switch between dual pads (PXn and PXn_C) 0631 * This parameter can be one or a combination of the following values: 0632 * @arg SYSCFG_SWITCH_PA0_OPEN 0633 * @arg SYSCFG_SWITCH_PA0_CLOSE 0634 * @arg SYSCFG_SWITCH_PA1_OPEN 0635 * @arg SYSCFG_SWITCH_PA1_CLOSE 0636 * @arg SYSCFG_SWITCH_PC2_OPEN 0637 * @arg SYSCFG_SWITCH_PC2_CLOSE 0638 * @arg SYSCFG_SWITCH_PC3_OPEN 0639 * @arg SYSCFG_SWITCH_PC3_CLOSE 0640 * @retval None 0641 */ 0642 0643 void HAL_SYSCFG_AnalogSwitchConfig(uint32_t SYSCFG_AnalogSwitch , uint32_t SYSCFG_SwitchState ) 0644 { 0645 /* Check the parameter */ 0646 assert_param(IS_SYSCFG_ANALOG_SWITCH(SYSCFG_AnalogSwitch)); 0647 assert_param(IS_SYSCFG_SWITCH_STATE(SYSCFG_SwitchState)); 0648 0649 MODIFY_REG(SYSCFG->PMCR, (uint32_t) SYSCFG_AnalogSwitch, (uint32_t)(SYSCFG_SwitchState)); 0650 } 0651 0652 #if defined(SYSCFG_PMCR_BOOSTEN) 0653 /** 0654 * @brief Enables the booster to reduce the total harmonic distortion of the analog 0655 * switch when the supply voltage is lower than 2.7 V. 0656 * @note Activating the booster allows to guaranty the analog switch AC performance 0657 * when the supply voltage is below 2.7 V: in this case, the analog switch 0658 * performance is the same on the full voltage range 0659 * @retval None 0660 */ 0661 void HAL_SYSCFG_EnableBOOST(void) 0662 { 0663 SET_BIT(SYSCFG->PMCR, SYSCFG_PMCR_BOOSTEN) ; 0664 } 0665 0666 /** 0667 * @brief Disables the booster 0668 * @note Activating the booster allows to guaranty the analog switch AC performance 0669 * when the supply voltage is below 2.7 V: in this case, the analog switch 0670 * performance is the same on the full voltage range 0671 * @retval None 0672 */ 0673 void HAL_SYSCFG_DisableBOOST(void) 0674 { 0675 CLEAR_BIT(SYSCFG->PMCR, SYSCFG_PMCR_BOOSTEN) ; 0676 } 0677 #endif /* SYSCFG_PMCR_BOOSTEN */ 0678 0679 #if defined (SYSCFG_UR2_BOOT_ADD0) || defined (SYSCFG_UR2_BCM7_ADD0) 0680 /** 0681 * @brief BootCM7 address 0 configuration 0682 * @param BootRegister :Specifies the Boot Address register (Address0 or Address1) 0683 * This parameter can be one of the following values: 0684 * @arg SYSCFG_BOOT_ADDR0 : Select the boot address0 0685 * @arg SYSCFG_BOOT_ADDR1: Select the boot address1 0686 * @param BootAddress :Specifies the CM7 Boot Address to be loaded in Address0 or Address1 0687 * @retval None 0688 */ 0689 void HAL_SYSCFG_CM7BootAddConfig(uint32_t BootRegister, uint32_t BootAddress) 0690 { 0691 /* Check the parameters */ 0692 assert_param(IS_SYSCFG_BOOT_REGISTER(BootRegister)); 0693 assert_param(IS_SYSCFG_BOOT_ADDRESS(BootAddress)); 0694 if ( BootRegister == SYSCFG_BOOT_ADDR0 ) 0695 { 0696 /* Configure CM7 BOOT ADD0 */ 0697 #if defined(DUAL_CORE) 0698 MODIFY_REG(SYSCFG->UR2, SYSCFG_UR2_BCM7_ADD0, ((BootAddress >> 16) << SYSCFG_UR2_BCM7_ADD0_Pos)); 0699 #else 0700 MODIFY_REG(SYSCFG->UR2, SYSCFG_UR2_BOOT_ADD0, ((BootAddress >> 16) << SYSCFG_UR2_BOOT_ADD0_Pos)); 0701 #endif /*DUAL_CORE*/ 0702 } 0703 else 0704 { 0705 /* Configure CM7 BOOT ADD1 */ 0706 #if defined(DUAL_CORE) 0707 MODIFY_REG(SYSCFG->UR3, SYSCFG_UR3_BCM7_ADD1, (BootAddress >> 16)); 0708 #else 0709 MODIFY_REG(SYSCFG->UR3, SYSCFG_UR3_BOOT_ADD1, (BootAddress >> 16)); 0710 #endif /*DUAL_CORE*/ 0711 } 0712 } 0713 #endif /* SYSCFG_UR2_BOOT_ADD0 || SYSCFG_UR2_BCM7_ADD0 */ 0714 0715 #if defined(DUAL_CORE) 0716 /** 0717 * @brief BootCM4 address 0 configuration 0718 * @param BootRegister :Specifies the Boot Address register (Address0 or Address1) 0719 * This parameter can be one of the following values: 0720 * @arg SYSCFG_BOOT_ADDR0 : Select the boot address0 0721 * @arg SYSCFG_BOOT_ADDR1: Select the boot address1 0722 * @param BootAddress :Specifies the CM4 Boot Address to be loaded in Address0 or Address1 0723 * @retval None 0724 */ 0725 void HAL_SYSCFG_CM4BootAddConfig(uint32_t BootRegister, uint32_t BootAddress) 0726 { 0727 /* Check the parameters */ 0728 assert_param(IS_SYSCFG_BOOT_REGISTER(BootRegister)); 0729 assert_param(IS_SYSCFG_BOOT_ADDRESS(BootAddress)); 0730 0731 if ( BootRegister == SYSCFG_BOOT_ADDR0 ) 0732 { 0733 /* Configure CM4 BOOT ADD0 */ 0734 MODIFY_REG(SYSCFG->UR3, SYSCFG_UR3_BCM4_ADD0, ((BootAddress >> 16)<< SYSCFG_UR3_BCM4_ADD0_Pos)); 0735 } 0736 0737 else 0738 { 0739 /* Configure CM4 BOOT ADD1 */ 0740 MODIFY_REG(SYSCFG->UR4, SYSCFG_UR4_BCM4_ADD1, (BootAddress >> 16)); 0741 } 0742 } 0743 0744 /** 0745 * @brief Enables the Cortex-M7 boot 0746 * @retval None 0747 */ 0748 void HAL_SYSCFG_EnableCM7BOOT(void) 0749 { 0750 SET_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM7); 0751 } 0752 0753 /** 0754 * @brief Disables the Cortex-M7 boot 0755 * @note Disabling the boot will gate the CPU clock 0756 * @retval None 0757 */ 0758 void HAL_SYSCFG_DisableCM7BOOT(void) 0759 { 0760 CLEAR_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM7) ; 0761 } 0762 0763 /** 0764 * @brief Enables the Cortex-M4 boot 0765 * @retval None 0766 */ 0767 void HAL_SYSCFG_EnableCM4BOOT(void) 0768 { 0769 SET_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM4); 0770 } 0771 0772 /** 0773 * @brief Disables the Cortex-M4 boot 0774 * @note Disabling the boot will gate the CPU clock 0775 * @retval None 0776 */ 0777 void HAL_SYSCFG_DisableCM4BOOT(void) 0778 { 0779 CLEAR_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM4); 0780 } 0781 #endif /*DUAL_CORE*/ 0782 /** 0783 * @brief Enables the I/O Compensation Cell. 0784 * @note The I/O compensation cell can be used only when the device supply 0785 * voltage ranges from 1.62 to 2.0 V and from 2.7 to 3.6 V. 0786 * @retval None 0787 */ 0788 void HAL_EnableCompensationCell(void) 0789 { 0790 SET_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_EN) ; 0791 } 0792 0793 /** 0794 * @brief Power-down the I/O Compensation Cell. 0795 * @note The I/O compensation cell can be used only when the device supply 0796 * voltage ranges from 1.62 to 2.0 V and from 2.7 to 3.6 V. 0797 * @retval None 0798 */ 0799 void HAL_DisableCompensationCell(void) 0800 { 0801 CLEAR_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_EN); 0802 } 0803 0804 0805 /** 0806 * @brief To Enable optimize the I/O speed when the product voltage is low. 0807 * @note This bit is active only if PRODUCT_BELOW_25V user option bit is set. It must be 0808 * used only if the product supply voltage is below 2.5 V. Setting this bit when VDD is 0809 * higher than 2.5 V might be destructive. 0810 * @retval None 0811 */ 0812 void HAL_SYSCFG_EnableIOSpeedOptimize(void) 0813 { 0814 #if defined(SYSCFG_CCCSR_HSLV) 0815 SET_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_HSLV); 0816 #else 0817 SET_BIT(SYSCFG->CCCSR, (SYSCFG_CCCSR_HSLV0| SYSCFG_CCCSR_HSLV1 | SYSCFG_CCCSR_HSLV2 | SYSCFG_CCCSR_HSLV3)); 0818 #endif /* SYSCFG_CCCSR_HSLV */ 0819 } 0820 0821 /** 0822 * @brief To Disable optimize the I/O speed when the product voltage is low. 0823 * @note This bit is active only if PRODUCT_BELOW_25V user option bit is set. It must be 0824 * used only if the product supply voltage is below 2.5 V. Setting this bit when VDD is 0825 * higher than 2.5 V might be destructive. 0826 * @retval None 0827 */ 0828 void HAL_SYSCFG_DisableIOSpeedOptimize(void) 0829 { 0830 #if defined(SYSCFG_CCCSR_HSLV) 0831 CLEAR_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_HSLV); 0832 #else 0833 CLEAR_BIT(SYSCFG->CCCSR, (SYSCFG_CCCSR_HSLV0| SYSCFG_CCCSR_HSLV1 | SYSCFG_CCCSR_HSLV2 | SYSCFG_CCCSR_HSLV3)); 0834 #endif /* SYSCFG_CCCSR_HSLV */ 0835 } 0836 0837 /** 0838 * @brief Code selection for the I/O Compensation cell 0839 * @param SYSCFG_CompCode: Selects the code to be applied for the I/O compensation cell 0840 * This parameter can be one of the following values: 0841 * @arg SYSCFG_CELL_CODE : Select Code from the cell (available in the SYSCFG_CCVR) 0842 * @arg SYSCFG_REGISTER_CODE: Select Code from the SYSCFG compensation cell code register (SYSCFG_CCCR) 0843 * @retval None 0844 */ 0845 void HAL_SYSCFG_CompensationCodeSelect(uint32_t SYSCFG_CompCode) 0846 { 0847 /* Check the parameter */ 0848 assert_param(IS_SYSCFG_CODE_SELECT(SYSCFG_CompCode)); 0849 MODIFY_REG(SYSCFG->CCCSR, SYSCFG_CCCSR_CS, (uint32_t)(SYSCFG_CompCode)); 0850 } 0851 0852 /** 0853 * @brief Code selection for the I/O Compensation cell 0854 * @param SYSCFG_PMOSCode: PMOS compensation code 0855 * This code is applied to the I/O compensation cell when the CS bit of the 0856 * SYSCFG_CMPCR is set 0857 * @param SYSCFG_NMOSCode: NMOS compensation code 0858 * This code is applied to the I/O compensation cell when the CS bit of the 0859 * SYSCFG_CMPCR is set 0860 * @retval None 0861 */ 0862 void HAL_SYSCFG_CompensationCodeConfig(uint32_t SYSCFG_PMOSCode, uint32_t SYSCFG_NMOSCode ) 0863 { 0864 /* Check the parameter */ 0865 assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_PMOSCode)); 0866 assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_NMOSCode)); 0867 MODIFY_REG(SYSCFG->CCCR, SYSCFG_CCCR_NCC|SYSCFG_CCCR_PCC, (((uint32_t)(SYSCFG_PMOSCode)<< 4)|(uint32_t)(SYSCFG_NMOSCode)) ); 0868 } 0869 0870 #if defined(SYSCFG_CCCR_NCC_MMC) 0871 /** 0872 * @brief Code selection for the I/O Compensation cell 0873 * @param SYSCFG_PMOSCode: VDDMMC PMOS compensation code 0874 * This code is applied to the I/O compensation cell when the CS bit of the 0875 * SYSCFG_CMPCR is set 0876 * @param SYSCFG_NMOSCode: VDDMMC NMOS compensation code 0877 * This code is applied to the I/O compensation cell when the CS bit of the 0878 * SYSCFG_CMPCR is set 0879 * @retval None 0880 */ 0881 void HAL_SYSCFG_VDDMMC_CompensationCodeConfig(uint32_t SYSCFG_PMOSCode, uint32_t SYSCFG_NMOSCode ) 0882 { 0883 /* Check the parameter */ 0884 assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_PMOSCode)); 0885 assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_NMOSCode)); 0886 MODIFY_REG(SYSCFG->CCCR, (SYSCFG_CCCR_NCC_MMC | SYSCFG_CCCR_PCC_MMC), (((uint32_t)(SYSCFG_PMOSCode)<< 4)|(uint32_t)(SYSCFG_NMOSCode)) ); 0887 } 0888 #endif /* SYSCFG_CCCR_NCC_MMC */ 0889 0890 #if defined(SYSCFG_ADC2ALT_ADC2_ROUT0) 0891 /** @brief SYSCFG ADC2 internal input alternate connection macros 0892 * @param Adc2AltRout0 This parameter can be a value of : 0893 * @arg @ref SYSCFG_ADC2_ROUT0_DAC1_1 DAC1_out1 connected to ADC2 VINP[16] 0894 * @arg @ref SYSCFG_ADC2_ROUT0_VBAT4 VBAT/4 connected to ADC2 VINP[16] 0895 */ 0896 void HAL_SYSCFG_ADC2ALT_Rout0Config(uint32_t Adc2AltRout0) 0897 { 0898 /* Check the parameters */ 0899 assert_param(IS_SYSCFG_ADC2ALT_ROUT0(Adc2AltRout0)); 0900 0901 MODIFY_REG(SYSCFG->ADC2ALT, SYSCFG_ADC2ALT_ADC2_ROUT0, Adc2AltRout0); 0902 } 0903 #endif /*SYSCFG_ADC2ALT_ADC2_ROUT0*/ 0904 0905 #if defined(SYSCFG_ADC2ALT_ADC2_ROUT1) 0906 /** @brief SYSCFG ADC2 internal input alternate connection macros 0907 * @param Adc2AltRout1 This parameter can be a value of : 0908 * @arg @ref SYSCFG_ADC2_ROUT1_DAC1_2 DAC1_out2 connected to ADC2 VINP[17] 0909 * @arg @ref SYSCFG_ADC2_ROUT1_VREFINT VREFINT connected to ADC2 VINP[17] 0910 */ 0911 void HAL_SYSCFG_ADC2ALT_Rout1Config(uint32_t Adc2AltRout1) 0912 { 0913 /* Check the parameters */ 0914 assert_param(IS_SYSCFG_ADC2ALT_ROUT1(Adc2AltRout1)); 0915 0916 MODIFY_REG(SYSCFG->ADC2ALT, SYSCFG_ADC2ALT_ADC2_ROUT1, Adc2AltRout1); 0917 } 0918 #endif /*SYSCFG_ADC2ALT_ADC2_ROUT1*/ 0919 0920 /** 0921 * @brief Enable the Debug Module during Domain1/CDomain SLEEP mode 0922 * @retval None 0923 */ 0924 void HAL_DBGMCU_EnableDBGSleepMode(void) 0925 { 0926 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD1); 0927 } 0928 0929 /** 0930 * @brief Disable the Debug Module during Domain1/CDomain SLEEP mode 0931 * @retval None 0932 */ 0933 void HAL_DBGMCU_DisableDBGSleepMode(void) 0934 { 0935 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD1); 0936 } 0937 0938 0939 /** 0940 * @brief Enable the Debug Module during Domain1/CDomain STOP mode 0941 * @retval None 0942 */ 0943 void HAL_DBGMCU_EnableDBGStopMode(void) 0944 { 0945 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD1); 0946 } 0947 0948 /** 0949 * @brief Disable the Debug Module during Domain1/CDomain STOP mode 0950 * @retval None 0951 */ 0952 void HAL_DBGMCU_DisableDBGStopMode(void) 0953 { 0954 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD1); 0955 } 0956 0957 /** 0958 * @brief Enable the Debug Module during Domain1/CDomain STANDBY mode 0959 * @retval None 0960 */ 0961 void HAL_DBGMCU_EnableDBGStandbyMode(void) 0962 { 0963 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD1); 0964 } 0965 0966 /** 0967 * @brief Disable the Debug Module during Domain1/CDomain STANDBY mode 0968 * @retval None 0969 */ 0970 void HAL_DBGMCU_DisableDBGStandbyMode(void) 0971 { 0972 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD1); 0973 } 0974 0975 #if defined(DUAL_CORE) 0976 /** 0977 * @brief Enable the Debug Module during Domain1 SLEEP mode 0978 * @retval None 0979 */ 0980 void HAL_EnableDomain2DBGSleepMode(void) 0981 { 0982 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD2); 0983 } 0984 0985 /** 0986 * @brief Disable the Debug Module during Domain2 SLEEP mode 0987 * @retval None 0988 */ 0989 void HAL_DisableDomain2DBGSleepMode(void) 0990 { 0991 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD2); 0992 } 0993 0994 /** 0995 * @brief Enable the Debug Module during Domain2 STOP mode 0996 * @retval None 0997 */ 0998 void HAL_EnableDomain2DBGStopMode(void) 0999 { 1000 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD2); 1001 } 1002 1003 /** 1004 * @brief Disable the Debug Module during Domain2 STOP mode 1005 * @retval None 1006 */ 1007 void HAL_DisableDomain2DBGStopMode(void) 1008 { 1009 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD2); 1010 } 1011 1012 /** 1013 * @brief Enable the Debug Module during Domain2 STANDBY mode 1014 * @retval None 1015 */ 1016 void HAL_EnableDomain2DBGStandbyMode(void) 1017 { 1018 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD2); 1019 } 1020 1021 /** 1022 * @brief Disable the Debug Module during Domain2 STANDBY mode 1023 * @retval None 1024 */ 1025 void HAL_DisableDomain2DBGStandbyMode(void) 1026 { 1027 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD2); 1028 } 1029 #endif /*DUAL_CORE*/ 1030 1031 #if defined(DBGMCU_CR_DBG_STOPD3) 1032 /** 1033 * @brief Enable the Debug Module during Domain3/SRDomain STOP mode 1034 * @retval None 1035 */ 1036 void HAL_EnableDomain3DBGStopMode(void) 1037 { 1038 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD3); 1039 } 1040 1041 /** 1042 * @brief Disable the Debug Module during Domain3/SRDomain STOP mode 1043 * @retval None 1044 */ 1045 void HAL_DisableDomain3DBGStopMode(void) 1046 { 1047 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD3); 1048 } 1049 #endif /*DBGMCU_CR_DBG_STOPD3*/ 1050 1051 #if defined(DBGMCU_CR_DBG_STANDBYD3) 1052 /** 1053 * @brief Enable the Debug Module during Domain3/SRDomain STANDBY mode 1054 * @retval None 1055 */ 1056 void HAL_EnableDomain3DBGStandbyMode(void) 1057 { 1058 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD3); 1059 } 1060 1061 /** 1062 * @brief Disable the Debug Module during Domain3/SRDomain STANDBY mode 1063 * @retval None 1064 */ 1065 void HAL_DisableDomain3DBGStandbyMode(void) 1066 { 1067 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD3); 1068 } 1069 #endif /*DBGMCU_CR_DBG_STANDBYD3*/ 1070 1071 /** 1072 * @brief Set the FMC Memory Mapping Swapping config. 1073 * @param BankMapConfig: Defines the FMC Bank mapping configuration. This parameter can be 1074 FMC_SWAPBMAP_DISABLE, FMC_SWAPBMAP_SDRAM_SRAM, FMC_SWAPBMAP_SDRAMB2 1075 * @retval HAL state 1076 */ 1077 void HAL_SetFMCMemorySwappingConfig(uint32_t BankMapConfig) 1078 { 1079 /* Check the parameter */ 1080 assert_param(IS_FMC_SWAPBMAP_MODE(BankMapConfig)); 1081 MODIFY_REG(FMC_Bank1_R->BTCR[0], FMC_BCR1_BMAP, BankMapConfig); 1082 } 1083 1084 /** 1085 * @brief Get FMC Bank mapping mode. 1086 * @retval The FMC Bank mapping mode. This parameter can be 1087 FMC_SWAPBMAP_DISABLE, FMC_SWAPBMAP_SDRAM_SRAM, FMC_SWAPBMAP_SDRAMB2 1088 */ 1089 uint32_t HAL_GetFMCMemorySwappingConfig(void) 1090 { 1091 return READ_BIT(FMC_Bank1_R->BTCR[0], FMC_BCR1_BMAP); 1092 } 1093 1094 /** 1095 * @brief Configure the EXTI input event line edge 1096 * @note No edge configuration for direct lines but for configurable lines:(EXTI_LINE0..EXTI_LINE21), 1097 * EXTI_LINE49,EXTI_LINE51,EXTI_LINE82,EXTI_LINE84,EXTI_LINE85 and EXTI_LINE86. 1098 * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values, 1099 * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved 1100 * @param EXTI_Edge: Specifies EXTI line Edge used. 1101 * This parameter can be one of the following values : 1102 * @arg EXTI_RISING_EDGE : Configurable line, with Rising edge trigger detection 1103 * @arg EXTI_FALLING_EDGE: Configurable line, with Falling edge trigger detection 1104 * @retval None 1105 */ 1106 void HAL_EXTI_EdgeConfig(uint32_t EXTI_Line , uint32_t EXTI_Edge ) 1107 { 1108 /* Check the parameter */ 1109 assert_param(IS_HAL_EXTI_CONFIG_LINE(EXTI_Line)); 1110 assert_param(IS_EXTI_EDGE_LINE(EXTI_Edge)); 1111 1112 /* Clear Rising Falling edge configuration */ 1113 CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->FTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL))); 1114 CLEAR_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI->RTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL))); 1115 1116 if( (EXTI_Edge & EXTI_RISING_EDGE) == EXTI_RISING_EDGE) 1117 { 1118 SET_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI->RTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL))); 1119 } 1120 if( (EXTI_Edge & EXTI_FALLING_EDGE) == EXTI_FALLING_EDGE) 1121 { 1122 SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->FTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL))); 1123 } 1124 } 1125 1126 /** 1127 * @brief Generates a Software interrupt on selected EXTI line. 1128 * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values, 1129 * (EXTI_LINE0..EXTI_LINE21),EXTI_LINE49,EXTI_LINE51,EXTI_LINE82,EXTI_LINE84,EXTI_LINE85 and EXTI_LINE86. 1130 * @retval None 1131 */ 1132 void HAL_EXTI_GenerateSWInterrupt(uint32_t EXTI_Line) 1133 { 1134 /* Check the parameters */ 1135 assert_param(IS_HAL_EXTI_CONFIG_LINE(EXTI_Line)); 1136 1137 SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->SWIER1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL))); 1138 } 1139 1140 1141 /** 1142 * @brief Clears the EXTI's line pending flags for Domain D1 1143 * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values, 1144 * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved 1145 * @retval None 1146 */ 1147 void HAL_EXTI_D1_ClearFlag(uint32_t EXTI_Line) 1148 { 1149 /* Check the parameters */ 1150 assert_param(IS_EXTI_D1_LINE(EXTI_Line)); 1151 WRITE_REG(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->PR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL))); 1152 1153 } 1154 1155 #if defined(DUAL_CORE) 1156 /** 1157 * @brief Clears the EXTI's line pending flags for Domain D2 1158 * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values, 1159 * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved 1160 * @retval None 1161 */ 1162 void HAL_EXTI_D2_ClearFlag(uint32_t EXTI_Line) 1163 { 1164 /* Check the parameters */ 1165 assert_param(IS_EXTI_D2_LINE(EXTI_Line)); 1166 WRITE_REG(*(__IO uint32_t *) (((uint32_t) &(EXTI_D2->PR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL))); 1167 } 1168 1169 #endif /*DUAL_CORE*/ 1170 /** 1171 * @brief Configure the EXTI input event line for Domain D1 1172 * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values, 1173 * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved 1174 * @param EXTI_Mode: Specifies which EXTI line is used as interrupt or an event. 1175 * This parameter can be one or a combination of the following values : 1176 * @arg EXTI_MODE_IT : Interrupt Mode selected 1177 * @arg EXTI_MODE_EVT : Event Mode selected 1178 * @param EXTI_LineCmd controls (Enable/Disable) the EXTI line. 1179 1180 * @retval None 1181 */ 1182 void HAL_EXTI_D1_EventInputConfig(uint32_t EXTI_Line , uint32_t EXTI_Mode, uint32_t EXTI_LineCmd ) 1183 { 1184 /* Check the parameter */ 1185 assert_param(IS_EXTI_D1_LINE(EXTI_Line)); 1186 assert_param(IS_EXTI_MODE_LINE(EXTI_Mode)); 1187 1188 if( (EXTI_Mode & EXTI_MODE_IT) == EXTI_MODE_IT) 1189 { 1190 if( EXTI_LineCmd == 0UL) 1191 { 1192 /* Clear EXTI line configuration */ 1193 CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)),(uint32_t)(1UL << (EXTI_Line & 0x1FUL)) ); 1194 } 1195 else 1196 { 1197 SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL))); 1198 } 1199 } 1200 1201 if( (EXTI_Mode & EXTI_MODE_EVT) == EXTI_MODE_EVT) 1202 { 1203 if( EXTI_LineCmd == 0UL) 1204 { 1205 /* Clear EXTI line configuration */ 1206 CLEAR_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI_D1->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL))); 1207 } 1208 else 1209 { 1210 SET_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI_D1->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL))); 1211 } 1212 } 1213 } 1214 1215 #if defined(DUAL_CORE) 1216 /** 1217 * @brief Configure the EXTI input event line for Domain D2 1218 * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values, 1219 * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved 1220 * @param EXTI_Mode: Specifies which EXTI line is used as interrupt or an event. 1221 * This parameter can be one or a combination of the following values : 1222 * @arg EXTI_MODE_IT : Interrupt Mode selected 1223 * @arg EXTI_MODE_EVT : Event Mode selected 1224 * @param EXTI_LineCmd controls (Enable/Disable) the EXTI line. 1225 1226 * @retval None 1227 */ 1228 void HAL_EXTI_D2_EventInputConfig(uint32_t EXTI_Line , uint32_t EXTI_Mode, uint32_t EXTI_LineCmd ) 1229 { 1230 /* Check the parameter */ 1231 assert_param(IS_EXTI_D2_LINE(EXTI_Line)); 1232 assert_param(IS_EXTI_MODE_LINE(EXTI_Mode)); 1233 1234 if( (EXTI_Mode & EXTI_MODE_IT) == EXTI_MODE_IT) 1235 { 1236 if( EXTI_LineCmd == 0UL) 1237 { 1238 /* Clear EXTI line configuration */ 1239 CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D2->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)),(uint32_t)(1UL << (EXTI_Line & 0x1FUL)) ); 1240 } 1241 else 1242 { 1243 SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D2->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL))); 1244 } 1245 } 1246 1247 if( (EXTI_Mode & EXTI_MODE_EVT) == EXTI_MODE_EVT) 1248 { 1249 if( EXTI_LineCmd == 0UL) 1250 { 1251 /* Clear EXTI line configuration */ 1252 CLEAR_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI_D2->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL))); 1253 } 1254 else 1255 { 1256 SET_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI_D2->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL))); 1257 } 1258 } 1259 } 1260 #endif /*DUAL_CORE*/ 1261 1262 /** 1263 * @brief Configure the EXTI input event line for Domain D3 1264 * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values, 1265 * (EXTI_LINE0...EXTI_LINE15),(EXTI_LINE19...EXTI_LINE21),EXTI_LINE25, EXTI_LINE34, 1266 * EXTI_LINE35,EXTI_LINE41,(EXTI_LINE48...EXTI_LINE53) 1267 * @param EXTI_LineCmd controls (Enable/Disable) the EXTI line. 1268 * @param EXTI_ClearSrc: Specifies the clear source of D3 pending event. 1269 * This parameter can be one of the following values : 1270 * @arg BDMA_CH6_CLEAR : BDMA ch6 event selected as D3 domain pendclear source 1271 * @arg BDMA_CH7_CLEAR : BDMA ch7 event selected as D3 domain pendclear source 1272 * @arg LPTIM4_OUT_CLEAR : LPTIM4 out selected as D3 domain pendclear source 1273 * @arg LPTIM5_OUT_CLEAR : LPTIM5 out selected as D3 domain pendclear source 1274 * @retval None 1275 */ 1276 void HAL_EXTI_D3_EventInputConfig(uint32_t EXTI_Line, uint32_t EXTI_LineCmd , uint32_t EXTI_ClearSrc ) 1277 { 1278 __IO uint32_t *pRegv; 1279 1280 /* Check the parameter */ 1281 assert_param(IS_EXTI_D3_LINE(EXTI_Line)); 1282 assert_param(IS_EXTI_D3_CLEAR(EXTI_ClearSrc)); 1283 1284 if( EXTI_LineCmd == 0UL) 1285 { 1286 /* Clear EXTI line configuration */ 1287 CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->D3PMR1)) + ((EXTI_Line >> 5 ) * 0x20UL)),(uint32_t)(1UL << (EXTI_Line & 0x1FUL)) ); 1288 } 1289 else 1290 { 1291 SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->D3PMR1)) +((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL))); 1292 } 1293 1294 if(((EXTI_Line>>4)%2UL) == 0UL) 1295 { 1296 pRegv = (__IO uint32_t *) (((uint32_t) &(EXTI->D3PCR1L)) + ((EXTI_Line >> 5 ) * 0x20UL)); 1297 } 1298 else 1299 { 1300 pRegv = (__IO uint32_t *) (((uint32_t) &(EXTI->D3PCR1H)) + ((EXTI_Line >> 5 ) * 0x20UL)); 1301 } 1302 MODIFY_REG(*pRegv, (uint32_t)(3UL << ((EXTI_Line*2UL) & 0x1FUL)), (uint32_t)(EXTI_ClearSrc << ((EXTI_Line*2UL) & 0x1FUL))); 1303 1304 } 1305 1306 1307 1308 /** 1309 * @} 1310 */ 1311 1312 /** 1313 * @} 1314 */ 1315 1316 /** 1317 * @} 1318 */ 1319 1320 /** 1321 * @} 1322 */ 1323 1324
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |