Merge pull request #11494 from haslinghuis/dshot_gpio
[betaflight.git] / lib / main / STM32H7 / Drivers / STM32H7xx_HAL_Driver / Src / stm32h7xx_hal.c
blobc1281454faba4cd798b1a53c737b434a4f7c0b6a
1 /**
2 ******************************************************************************
3 * @file stm32h7xx_hal.c
4 * @author MCD Application Team
5 * @brief HAL module driver.
6 * This is the common part of the HAL initialization
8 @verbatim
9 ==============================================================================
10 ##### How to use this driver #####
11 ==============================================================================
12 [..]
13 The common HAL driver contains a set of generic and common APIs that can be
14 used by the PPP peripheral drivers and the user to start using the HAL.
15 [..]
16 The HAL contains two APIs' categories:
17 (+) Common HAL APIs
18 (+) Services HAL APIs
20 @endverbatim
21 ******************************************************************************
22 * @attention
24 * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
25 * All rights reserved.</center></h2>
27 * This software component is licensed by ST under BSD 3-Clause license,
28 * the "License"; You may not use this file except in compliance with the
29 * License. You may obtain a copy of the License at:
30 * opensource.org/licenses/BSD-3-Clause
32 ******************************************************************************
35 /* Includes ------------------------------------------------------------------*/
36 #include "stm32h7xx_hal.h"
38 /** @addtogroup STM32H7xx_HAL_Driver
39 * @{
42 /** @defgroup HAL HAL
43 * @brief HAL module driver.
44 * @{
47 /* Private typedef -----------------------------------------------------------*/
48 /* Private define ------------------------------------------------------------*/
49 /**
50 * @brief STM32H7xx HAL Driver version number V1.9.0
52 #define __STM32H7xx_HAL_VERSION_MAIN (0x01UL) /*!< [31:24] main version */
53 #define __STM32H7xx_HAL_VERSION_SUB1 (0x09UL) /*!< [23:16] sub1 version */
54 #define __STM32H7xx_HAL_VERSION_SUB2 (0x00UL) /*!< [15:8] sub2 version */
55 #define __STM32H7xx_HAL_VERSION_RC (0x00UL) /*!< [7:0] release candidate */
56 #define __STM32H7xx_HAL_VERSION ((__STM32H7xx_HAL_VERSION_MAIN << 24)\
57 |(__STM32H7xx_HAL_VERSION_SUB1 << 16)\
58 |(__STM32H7xx_HAL_VERSION_SUB2 << 8 )\
59 |(__STM32H7xx_HAL_VERSION_RC))
61 #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
62 #define VREFBUF_TIMEOUT_VALUE (uint32_t)10 /* 10 ms */
64 /* Private macro -------------------------------------------------------------*/
65 /* Private variables ---------------------------------------------------------*/
66 /* Exported variables --------------------------------------------------------*/
68 /** @defgroup HAL_Exported_Variables HAL Exported Variables
69 * @{
71 __IO uint32_t uwTick;
72 uint32_t uwTickPrio = (1UL << __NVIC_PRIO_BITS); /* Invalid PRIO */
73 HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */
74 /**
75 * @}
78 /* Private function prototypes -----------------------------------------------*/
79 /* Private functions ---------------------------------------------------------*/
81 /** @defgroup HAL_Private_Functions HAL Private Functions
82 * @{
85 /** @defgroup HAL_Group1 Initialization and de-initialization Functions
86 * @brief Initialization and de-initialization functions
88 @verbatim
89 ===============================================================================
90 ##### Initialization and de-initialization functions #####
91 ===============================================================================
92 [..] This section provides functions allowing to:
93 (+) Initializes the Flash interface the NVIC allocation and initial clock
94 configuration. It initializes the systick also when timeout is needed
95 and the backup domain when enabled.
96 (+) De-Initializes common part of the HAL.
97 (+) Configure The time base source to have 1ms time base with a dedicated
98 Tick interrupt priority.
99 (++) SysTick timer is used by default as source of time base, but user
100 can eventually implement his proper time base source (a general purpose
101 timer for example or other time source), keeping in mind that Time base
102 duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
103 handled in milliseconds basis.
104 (++) Time base configuration function (HAL_InitTick ()) is called automatically
105 at the beginning of the program after reset by HAL_Init() or at any time
106 when clock is configured, by HAL_RCC_ClockConfig().
107 (++) Source of time base is configured to generate interrupts at regular
108 time intervals. Care must be taken if HAL_Delay() is called from a
109 peripheral ISR process, the Tick interrupt line must have higher priority
110 (numerically lower) than the peripheral interrupt. Otherwise the caller
111 ISR process will be blocked.
112 (++) functions affecting time base configurations are declared as __weak
113 to make override possible in case of other implementations in user file.
114 @endverbatim
115 * @{
119 * @brief This function is used to initialize the HAL Library; it must be the first
120 * instruction to be executed in the main program (before to call any other
121 * HAL function), it performs the following:
122 * Configures the SysTick to generate an interrupt each 1 millisecond,
123 * which is clocked by the HSI (at this stage, the clock is not yet
124 * configured and thus the system is running from the internal HSI at 16 MHz).
125 * Set NVIC Group Priority to 4.
126 * Calls the HAL_MspInit() callback function defined in user file
127 * "stm32h7xx_hal_msp.c" to do the global low level hardware initialization
129 * @note SysTick is used as time base for the HAL_Delay() function, the application
130 * need to ensure that the SysTick time base is always set to 1 millisecond
131 * to have correct HAL operation.
132 * @retval HAL status
134 HAL_StatusTypeDef HAL_Init(void)
137 uint32_t common_system_clock;
139 #if defined(DUAL_CORE) && defined(CORE_CM4)
140 /* Configure Cortex-M4 Instruction cache through ART accelerator */
141 __HAL_RCC_ART_CLK_ENABLE(); /* Enable the Cortex-M4 ART Clock */
142 __HAL_ART_CONFIG_BASE_ADDRESS(0x08100000UL); /* Configure the Cortex-M4 ART Base address to the Flash Bank 2 : */
143 __HAL_ART_ENABLE(); /* Enable the Cortex-M4 ART */
144 #endif /* DUAL_CORE && CORE_CM4 */
146 /* Set Interrupt Group Priority */
147 HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
149 /* Update the SystemCoreClock global variable */
150 #if defined(RCC_D1CFGR_D1CPRE)
151 common_system_clock = HAL_RCC_GetSysClockFreq() >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]) & 0x1FU);
152 #else
153 common_system_clock = HAL_RCC_GetSysClockFreq() >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE)>> RCC_CDCFGR1_CDCPRE_Pos]) & 0x1FU);
154 #endif
156 /* Update the SystemD2Clock global variable */
157 #if defined(RCC_D1CFGR_HPRE)
158 SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU));
159 #else
160 SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE)>> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU));
161 #endif
163 #if defined(DUAL_CORE) && defined(CORE_CM4)
164 SystemCoreClock = SystemD2Clock;
165 #else
166 SystemCoreClock = common_system_clock;
167 #endif /* DUAL_CORE && CORE_CM4 */
169 /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
170 if(HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK)
172 return HAL_ERROR;
175 /* Init the low level hardware */
176 HAL_MspInit();
178 /* Return function status */
179 return HAL_OK;
183 * @brief This function de-Initializes common part of the HAL and stops the systick.
184 * This function is optional.
185 * @retval HAL status
187 HAL_StatusTypeDef HAL_DeInit(void)
189 /* Reset of all peripherals */
190 __HAL_RCC_AHB3_FORCE_RESET();
191 __HAL_RCC_AHB3_RELEASE_RESET();
193 __HAL_RCC_AHB1_FORCE_RESET();
194 __HAL_RCC_AHB1_RELEASE_RESET();
196 __HAL_RCC_AHB2_FORCE_RESET();
197 __HAL_RCC_AHB2_RELEASE_RESET();
199 __HAL_RCC_AHB4_FORCE_RESET();
200 __HAL_RCC_AHB4_RELEASE_RESET();
202 __HAL_RCC_APB3_FORCE_RESET();
203 __HAL_RCC_APB3_RELEASE_RESET();
205 __HAL_RCC_APB1L_FORCE_RESET();
206 __HAL_RCC_APB1L_RELEASE_RESET();
208 __HAL_RCC_APB1H_FORCE_RESET();
209 __HAL_RCC_APB1H_RELEASE_RESET();
211 __HAL_RCC_APB2_FORCE_RESET();
212 __HAL_RCC_APB2_RELEASE_RESET();
214 __HAL_RCC_APB4_FORCE_RESET();
215 __HAL_RCC_APB4_RELEASE_RESET();
217 /* De-Init the low level hardware */
218 HAL_MspDeInit();
220 /* Return function status */
221 return HAL_OK;
225 * @brief Initializes the MSP.
226 * @retval None
228 __weak void HAL_MspInit(void)
230 /* NOTE : This function Should not be modified, when the callback is needed,
231 the HAL_MspInit could be implemented in the user file
236 * @brief DeInitializes the MSP.
237 * @retval None
239 __weak void HAL_MspDeInit(void)
241 /* NOTE : This function Should not be modified, when the callback is needed,
242 the HAL_MspDeInit could be implemented in the user file
247 * @brief This function configures the source of the time base.
248 * The time source is configured to have 1ms time base with a dedicated
249 * Tick interrupt priority.
250 * @note This function is called automatically at the beginning of program after
251 * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig().
252 * @note In the default implementation, SysTick timer is the source of time base.
253 * It is used to generate interrupts at regular time intervals.
254 * Care must be taken if HAL_Delay() is called from a peripheral ISR process,
255 * The the SysTick interrupt must have higher priority (numerically lower)
256 * than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
257 * The function is declared as __weak to be overwritten in case of other
258 * implementation in user file.
259 * @param TickPriority: Tick interrupt priority.
260 * @retval HAL status
262 __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
264 /* Check uwTickFreq for MisraC 2012 (even if uwTickFreq is a enum type that don't take the value zero)*/
265 if((uint32_t)uwTickFreq == 0UL)
267 return HAL_ERROR;
270 /* Configure the SysTick to have interrupt in 1ms time basis*/
271 if (HAL_SYSTICK_Config(SystemCoreClock / (1000UL / (uint32_t)uwTickFreq)) > 0U)
273 return HAL_ERROR;
276 /* Configure the SysTick IRQ priority */
277 if (TickPriority < (1UL << __NVIC_PRIO_BITS))
279 HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
280 uwTickPrio = TickPriority;
282 else
284 return HAL_ERROR;
287 /* Return function status */
288 return HAL_OK;
292 * @}
295 /** @defgroup HAL_Group2 HAL Control functions
296 * @brief HAL Control functions
298 @verbatim
299 ===============================================================================
300 ##### HAL Control functions #####
301 ===============================================================================
302 [..] This section provides functions allowing to:
303 (+) Provide a tick value in millisecond
304 (+) Provide a blocking delay in millisecond
305 (+) Suspend the time base source interrupt
306 (+) Resume the time base source interrupt
307 (+) Get the HAL API driver version
308 (+) Get the device identifier
309 (+) Get the device revision identifier
310 (+) Enable/Disable Debug module during SLEEP mode
311 (+) Enable/Disable Debug module during STOP mode
312 (+) Enable/Disable Debug module during STANDBY mode
314 @endverbatim
315 * @{
319 * @brief This function is called to increment a global variable "uwTick"
320 * used as application time base.
321 * @note In the default implementation, this variable is incremented each 1ms
322 * in Systick ISR.
323 * @note This function is declared as __weak to be overwritten in case of other
324 * implementations in user file.
325 * @retval None
327 __weak void HAL_IncTick(void)
329 uwTick += (uint32_t)uwTickFreq;
333 * @brief Provides a tick value in millisecond.
334 * @note This function is declared as __weak to be overwritten in case of other
335 * implementations in user file.
336 * @retval tick value
338 __weak uint32_t HAL_GetTick(void)
340 return uwTick;
344 * @brief This function returns a tick priority.
345 * @retval tick priority
347 uint32_t HAL_GetTickPrio(void)
349 return uwTickPrio;
353 * @brief Set new tick Freq.
354 * @retval Status
356 HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq)
358 HAL_StatusTypeDef status = HAL_OK;
359 HAL_TickFreqTypeDef prevTickFreq;
361 assert_param(IS_TICKFREQ(Freq));
363 if (uwTickFreq != Freq)
366 /* Back up uwTickFreq frequency */
367 prevTickFreq = uwTickFreq;
369 /* Update uwTickFreq global variable used by HAL_InitTick() */
370 uwTickFreq = Freq;
372 /* Apply the new tick Freq */
373 status = HAL_InitTick(uwTickPrio);
374 if (status != HAL_OK)
376 /* Restore previous tick frequency */
377 uwTickFreq = prevTickFreq;
381 return status;
385 * @brief Return tick frequency.
386 * @retval tick period in Hz
388 HAL_TickFreqTypeDef HAL_GetTickFreq(void)
390 return uwTickFreq;
394 * @brief This function provides minimum delay (in milliseconds) based
395 * on variable incremented.
396 * @note In the default implementation , SysTick timer is the source of time base.
397 * It is used to generate interrupts at regular time intervals where uwTick
398 * is incremented.
399 * @note This function is declared as __weak to be overwritten in case of other
400 * implementations in user file.
401 * @param Delay specifies the delay time length, in milliseconds.
402 * @retval None
404 __weak void HAL_Delay(uint32_t Delay)
406 uint32_t tickstart = HAL_GetTick();
407 uint32_t wait = Delay;
409 /* Add a freq to guarantee minimum wait */
410 if (wait < HAL_MAX_DELAY)
412 wait += (uint32_t)(uwTickFreq);
415 while ((HAL_GetTick() - tickstart) < wait)
421 * @brief Suspend Tick increment.
422 * @note In the default implementation , SysTick timer is the source of time base. It is
423 * used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
424 * is called, the the SysTick interrupt will be disabled and so Tick increment
425 * is suspended.
426 * @note This function is declared as __weak to be overwritten in case of other
427 * implementations in user file.
428 * @retval None
430 __weak void HAL_SuspendTick(void)
432 /* Disable SysTick Interrupt */
433 SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
437 * @brief Resume Tick increment.
438 * @note In the default implementation , SysTick timer is the source of time base. It is
439 * used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
440 * is called, the the SysTick interrupt will be enabled and so Tick increment
441 * is resumed.
442 * @note This function is declared as __weak to be overwritten in case of other
443 * implementations in user file.
444 * @retval None
446 __weak void HAL_ResumeTick(void)
448 /* Enable SysTick Interrupt */
449 SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
453 * @brief Returns the HAL revision
454 * @retval version : 0xXYZR (8bits for each decimal, R for RC)
456 uint32_t HAL_GetHalVersion(void)
458 return __STM32H7xx_HAL_VERSION;
462 * @brief Returns the device revision identifier.
463 * @retval Device revision identifier
465 uint32_t HAL_GetREVID(void)
467 return((DBGMCU->IDCODE) >> 16);
471 * @brief Returns the device identifier.
472 * @retval Device identifier
474 uint32_t HAL_GetDEVID(void)
476 return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
480 * @brief Return the first word of the unique device identifier (UID based on 96 bits)
481 * @retval Device identifier
483 uint32_t HAL_GetUIDw0(void)
485 return(READ_REG(*((uint32_t *)UID_BASE)));
489 * @brief Return the second word of the unique device identifier (UID based on 96 bits)
490 * @retval Device identifier
492 uint32_t HAL_GetUIDw1(void)
494 return(READ_REG(*((uint32_t *)(UID_BASE + 4U))));
498 * @brief Return the third word of the unique device identifier (UID based on 96 bits)
499 * @retval Device identifier
501 uint32_t HAL_GetUIDw2(void)
503 return(READ_REG(*((uint32_t *)(UID_BASE + 8U))));
507 * @brief Configure the internal voltage reference buffer voltage scale.
508 * @param VoltageScaling specifies the output voltage to achieve
509 * This parameter can be one of the following values:
510 * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE0: VREF_OUT1 around 2.048 V.
511 * This requires VDDA equal to or higher than 2.4 V.
512 * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE1: VREF_OUT2 around 2.5 V.
513 * This requires VDDA equal to or higher than 2.8 V.
514 * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE2: VREF_OUT3 around 1.5 V.
515 * This requires VDDA equal to or higher than 1.8 V.
516 * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE3: VREF_OUT4 around 1.8 V.
517 * This requires VDDA equal to or higher than 2.1 V.
518 * @retval None
520 void HAL_SYSCFG_VREFBUF_VoltageScalingConfig(uint32_t VoltageScaling)
522 /* Check the parameters */
523 assert_param(IS_SYSCFG_VREFBUF_VOLTAGE_SCALE(VoltageScaling));
525 MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_VRS, VoltageScaling);
529 * @brief Configure the internal voltage reference buffer high impedance mode.
530 * @param Mode specifies the high impedance mode
531 * This parameter can be one of the following values:
532 * @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE: VREF+ pin is internally connect to VREFINT output.
533 * @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE: VREF+ pin is high impedance.
534 * @retval None
536 void HAL_SYSCFG_VREFBUF_HighImpedanceConfig(uint32_t Mode)
538 /* Check the parameters */
539 assert_param(IS_SYSCFG_VREFBUF_HIGH_IMPEDANCE(Mode));
541 MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_HIZ, Mode);
545 * @brief Tune the Internal Voltage Reference buffer (VREFBUF).
546 * @retval None
548 void HAL_SYSCFG_VREFBUF_TrimmingConfig(uint32_t TrimmingValue)
550 /* Check the parameters */
551 assert_param(IS_SYSCFG_VREFBUF_TRIMMING(TrimmingValue));
553 MODIFY_REG(VREFBUF->CCR, VREFBUF_CCR_TRIM, TrimmingValue);
557 * @brief Enable the Internal Voltage Reference buffer (VREFBUF).
558 * @retval HAL_OK/HAL_TIMEOUT
560 HAL_StatusTypeDef HAL_SYSCFG_EnableVREFBUF(void)
562 uint32_t tickstart;
564 SET_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR);
566 /* Get Start Tick*/
567 tickstart = HAL_GetTick();
569 /* Wait for VRR bit */
570 while(READ_BIT(VREFBUF->CSR, VREFBUF_CSR_VRR) == 0UL)
572 if((HAL_GetTick() - tickstart) > VREFBUF_TIMEOUT_VALUE)
574 return HAL_TIMEOUT;
578 return HAL_OK;
582 * @brief Disable the Internal Voltage Reference buffer (VREFBUF).
584 * @retval None
586 void HAL_SYSCFG_DisableVREFBUF(void)
588 CLEAR_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR);
591 #if defined(SYSCFG_PMCR_EPIS_SEL)
593 * @brief Ethernet PHY Interface Selection either MII or RMII
594 * @param SYSCFG_ETHInterface: Selects the Ethernet PHY interface
595 * This parameter can be one of the following values:
596 * @arg SYSCFG_ETH_MII : Select the Media Independent Interface
597 * @arg SYSCFG_ETH_RMII: Select the Reduced Media Independent Interface
598 * @retval None
600 void HAL_SYSCFG_ETHInterfaceSelect(uint32_t SYSCFG_ETHInterface)
602 /* Check the parameter */
603 assert_param(IS_SYSCFG_ETHERNET_CONFIG(SYSCFG_ETHInterface));
605 MODIFY_REG(SYSCFG->PMCR, SYSCFG_PMCR_EPIS_SEL, (uint32_t)(SYSCFG_ETHInterface));
607 #endif /* SYSCFG_PMCR_EPIS_SEL */
610 * @brief Analog Switch control for dual analog pads.
611 * @param SYSCFG_AnalogSwitch: Selects the analog pad
612 * This parameter can be one or a combination of the following values:
613 * @arg SYSCFG_SWITCH_PA0 : Select PA0 analog switch
614 * @arg SYSCFG_SWITCH_PA1: Select PA1 analog switch
615 * @arg SYSCFG_SWITCH_PC2 : Select PC2 analog switch
616 * @arg SYSCFG_SWITCH_PC3: Select PC3 analog switch
617 * @param SYSCFG_SwitchState: Open or Close the analog switch between dual pads (PXn and PXn_C)
618 * This parameter can be one or a combination of the following values:
619 * @arg SYSCFG_SWITCH_PA0_OPEN
620 * @arg SYSCFG_SWITCH_PA0_CLOSE
621 * @arg SYSCFG_SWITCH_PA1_OPEN
622 * @arg SYSCFG_SWITCH_PA1_CLOSE
623 * @arg SYSCFG_SWITCH_PC2_OPEN
624 * @arg SYSCFG_SWITCH_PC2_CLOSE
625 * @arg SYSCFG_SWITCH_PC3_OPEN
626 * @arg SYSCFG_SWITCH_PC3_CLOSE
627 * @retval None
630 void HAL_SYSCFG_AnalogSwitchConfig(uint32_t SYSCFG_AnalogSwitch , uint32_t SYSCFG_SwitchState )
632 /* Check the parameter */
633 assert_param(IS_SYSCFG_ANALOG_SWITCH(SYSCFG_AnalogSwitch));
634 assert_param(IS_SYSCFG_SWITCH_STATE(SYSCFG_SwitchState));
636 MODIFY_REG(SYSCFG->PMCR, (uint32_t) SYSCFG_AnalogSwitch, (uint32_t)(SYSCFG_SwitchState));
639 #if defined(SYSCFG_PMCR_BOOSTEN)
641 * @brief Enables the booster to reduce the total harmonic distortion of the analog
642 * switch when the supply voltage is lower than 2.7 V.
643 * @note Activating the booster allows to guaranty the analog switch AC performance
644 * when the supply voltage is below 2.7 V: in this case, the analog switch
645 * performance is the same on the full voltage range
646 * @retval None
648 void HAL_SYSCFG_EnableBOOST(void)
650 SET_BIT(SYSCFG->PMCR, SYSCFG_PMCR_BOOSTEN) ;
654 * @brief Disables the booster
655 * @note Activating the booster allows to guaranty the analog switch AC performance
656 * when the supply voltage is below 2.7 V: in this case, the analog switch
657 * performance is the same on the full voltage range
658 * @retval None
660 void HAL_SYSCFG_DisableBOOST(void)
662 CLEAR_BIT(SYSCFG->PMCR, SYSCFG_PMCR_BOOSTEN) ;
664 #endif /* SYSCFG_PMCR_BOOSTEN */
666 #if defined (SYSCFG_UR2_BOOT_ADD0) || defined (SYSCFG_UR2_BCM7_ADD0)
668 * @brief BootCM7 address 0 configuration
669 * @param BootRegister :Specifies the Boot Address register (Address0 or Address1)
670 * This parameter can be one of the following values:
671 * @arg SYSCFG_BOOT_ADDR0 : Select the boot address0
672 * @arg SYSCFG_BOOT_ADDR1: Select the boot address1
673 * @param BootAddress :Specifies the CM7 Boot Address to be loaded in Address0 or Address1
674 * @retval None
676 void HAL_SYSCFG_CM7BootAddConfig(uint32_t BootRegister, uint32_t BootAddress)
678 /* Check the parameters */
679 assert_param(IS_SYSCFG_BOOT_REGISTER(BootRegister));
680 assert_param(IS_SYSCFG_BOOT_ADDRESS(BootAddress));
681 if ( BootRegister == SYSCFG_BOOT_ADDR0 )
683 /* Configure CM7 BOOT ADD0 */
684 #if defined(DUAL_CORE)
685 MODIFY_REG(SYSCFG->UR2, SYSCFG_UR2_BCM7_ADD0, ((BootAddress >> 16) << SYSCFG_UR2_BCM7_ADD0_Pos));
686 #else
687 MODIFY_REG(SYSCFG->UR2, SYSCFG_UR2_BOOT_ADD0, ((BootAddress >> 16) << SYSCFG_UR2_BOOT_ADD0_Pos));
688 #endif /*DUAL_CORE*/
690 else
692 /* Configure CM7 BOOT ADD1 */
693 #if defined(DUAL_CORE)
694 MODIFY_REG(SYSCFG->UR3, SYSCFG_UR3_BCM7_ADD1, (BootAddress >> 16));
695 #else
696 MODIFY_REG(SYSCFG->UR3, SYSCFG_UR3_BOOT_ADD1, (BootAddress >> 16));
697 #endif /*DUAL_CORE*/
700 #endif /* SYSCFG_UR2_BOOT_ADD0 || SYSCFG_UR2_BCM7_ADD0 */
702 #if defined(DUAL_CORE)
704 * @brief BootCM4 address 0 configuration
705 * @param BootRegister :Specifies the Boot Address register (Address0 or Address1)
706 * This parameter can be one of the following values:
707 * @arg SYSCFG_BOOT_ADDR0 : Select the boot address0
708 * @arg SYSCFG_BOOT_ADDR1: Select the boot address1
709 * @param BootAddress :Specifies the CM4 Boot Address to be loaded in Address0 or Address1
710 * @retval None
712 void HAL_SYSCFG_CM4BootAddConfig(uint32_t BootRegister, uint32_t BootAddress)
714 /* Check the parameters */
715 assert_param(IS_SYSCFG_BOOT_REGISTER(BootRegister));
716 assert_param(IS_SYSCFG_BOOT_ADDRESS(BootAddress));
718 if ( BootRegister == SYSCFG_BOOT_ADDR0 )
720 /* Configure CM4 BOOT ADD0 */
721 MODIFY_REG(SYSCFG->UR3, SYSCFG_UR3_BCM4_ADD0, ((BootAddress >> 16)<< SYSCFG_UR3_BCM4_ADD0_Pos));
724 else
726 /* Configure CM4 BOOT ADD1 */
727 MODIFY_REG(SYSCFG->UR4, SYSCFG_UR4_BCM4_ADD1, (BootAddress >> 16));
732 * @brief Enables the Cortex-M7 boot
733 * @retval None
735 void HAL_SYSCFG_EnableCM7BOOT(void)
737 SET_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM7);
741 * @brief Disables the Cortex-M7 boot
742 * @note Disabling the boot will gate the CPU clock
743 * @retval None
745 void HAL_SYSCFG_DisableCM7BOOT(void)
747 CLEAR_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM7) ;
751 * @brief Enables the Cortex-M4 boot
752 * @retval None
754 void HAL_SYSCFG_EnableCM4BOOT(void)
756 SET_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM4);
760 * @brief Disables the Cortex-M4 boot
761 * @note Disabling the boot will gate the CPU clock
762 * @retval None
764 void HAL_SYSCFG_DisableCM4BOOT(void)
766 CLEAR_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM4);
768 #endif /*DUAL_CORE*/
770 * @brief Enables the I/O Compensation Cell.
771 * @note The I/O compensation cell can be used only when the device supply
772 * voltage ranges from 2.4 to 3.6 V.
773 * @retval None
775 void HAL_EnableCompensationCell(void)
777 SET_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_EN) ;
781 * @brief Power-down the I/O Compensation Cell.
782 * @note The I/O compensation cell can be used only when the device supply
783 * voltage ranges from 2.4 to 3.6 V.
784 * @retval None
786 void HAL_DisableCompensationCell(void)
788 CLEAR_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_EN);
793 * @brief To Enable optimize the I/O speed when the product voltage is low.
794 * @note This bit is active only if PRODUCT_BELOW_25V user option bit is set. It must be
795 * used only if the product supply voltage is below 2.5 V. Setting this bit when VDD is
796 * higher than 2.5 V might be destructive.
797 * @retval None
799 void HAL_SYSCFG_EnableIOSpeedOptimize(void)
801 #if defined(SYSCFG_CCCSR_HSLV)
802 SET_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_HSLV);
803 #else
804 SET_BIT(SYSCFG->CCCSR, (SYSCFG_CCCSR_HSLV0| SYSCFG_CCCSR_HSLV1 | SYSCFG_CCCSR_HSLV2 | SYSCFG_CCCSR_HSLV3));
805 #endif /* SYSCFG_CCCSR_HSLV */
809 * @brief To Disable optimize the I/O speed when the product voltage is low.
810 * @note This bit is active only if PRODUCT_BELOW_25V user option bit is set. It must be
811 * used only if the product supply voltage is below 2.5 V. Setting this bit when VDD is
812 * higher than 2.5 V might be destructive.
813 * @retval None
815 void HAL_SYSCFG_DisableIOSpeedOptimize(void)
817 #if defined(SYSCFG_CCCSR_HSLV)
818 CLEAR_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_HSLV);
819 #else
820 CLEAR_BIT(SYSCFG->CCCSR, (SYSCFG_CCCSR_HSLV0| SYSCFG_CCCSR_HSLV1 | SYSCFG_CCCSR_HSLV2 | SYSCFG_CCCSR_HSLV3));
821 #endif /* SYSCFG_CCCSR_HSLV */
825 * @brief Code selection for the I/O Compensation cell
826 * @param SYSCFG_CompCode: Selects the code to be applied for the I/O compensation cell
827 * This parameter can be one of the following values:
828 * @arg SYSCFG_CELL_CODE : Select Code from the cell (available in the SYSCFG_CCVR)
829 * @arg SYSCFG_REGISTER_CODE: Select Code from the SYSCFG compensation cell code register (SYSCFG_CCCR)
830 * @retval None
832 void HAL_SYSCFG_CompensationCodeSelect(uint32_t SYSCFG_CompCode)
834 /* Check the parameter */
835 assert_param(IS_SYSCFG_CODE_SELECT(SYSCFG_CompCode));
836 MODIFY_REG(SYSCFG->CCCSR, SYSCFG_CCCSR_CS, (uint32_t)(SYSCFG_CompCode));
840 * @brief Code selection for the I/O Compensation cell
841 * @param SYSCFG_PMOSCode: PMOS compensation code
842 * This code is applied to the I/O compensation cell when the CS bit of the
843 * SYSCFG_CMPCR is set
844 * @param SYSCFG_NMOSCode: NMOS compensation code
845 * This code is applied to the I/O compensation cell when the CS bit of the
846 * SYSCFG_CMPCR is set
847 * @retval None
849 void HAL_SYSCFG_CompensationCodeConfig(uint32_t SYSCFG_PMOSCode, uint32_t SYSCFG_NMOSCode )
851 /* Check the parameter */
852 assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_PMOSCode));
853 assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_NMOSCode));
854 MODIFY_REG(SYSCFG->CCCR, SYSCFG_CCCR_NCC|SYSCFG_CCCR_PCC, (((uint32_t)(SYSCFG_PMOSCode)<< 4)|(uint32_t)(SYSCFG_NMOSCode)) );
857 #if defined(SYSCFG_CCCR_NCC_MMC)
859 * @brief Code selection for the I/O Compensation cell
860 * @param SYSCFG_PMOSCode: VDDMMC PMOS compensation code
861 * This code is applied to the I/O compensation cell when the CS bit of the
862 * SYSCFG_CMPCR is set
863 * @param SYSCFG_NMOSCode: VDDMMC NMOS compensation code
864 * This code is applied to the I/O compensation cell when the CS bit of the
865 * SYSCFG_CMPCR is set
866 * @retval None
868 void HAL_SYSCFG_VDDMMC_CompensationCodeConfig(uint32_t SYSCFG_PMOSCode, uint32_t SYSCFG_NMOSCode )
870 /* Check the parameter */
871 assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_PMOSCode));
872 assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_NMOSCode));
873 MODIFY_REG(SYSCFG->CCCR, (SYSCFG_CCCR_NCC_MMC | SYSCFG_CCCR_PCC_MMC), (((uint32_t)(SYSCFG_PMOSCode)<< 4)|(uint32_t)(SYSCFG_NMOSCode)) );
875 #endif /* SYSCFG_CCCR_NCC_MMC */
877 #if defined(SYSCFG_ADC2ALT_ADC2_ROUT0)
878 /** @brief SYSCFG ADC2 internal input alternate connection macros
879 * @param Adc2AltRout0 This parameter can be a value of :
880 * @arg @ref SYSCFG_ADC2_ROUT0_DAC1_1 DAC1_out1 connected to ADC2 VINP[16]
881 * @arg @ref SYSCFG_ADC2_ROUT0_VBAT4 VBAT/4 connected to ADC2 VINP[16]
883 void HAL_SYSCFG_ADC2ALT_Rout0Config(uint32_t Adc2AltRout0)
885 /* Check the parameters */
886 assert_param(IS_SYSCFG_ADC2ALT_ROUT0(Adc2AltRout0));
888 MODIFY_REG(SYSCFG->ADC2ALT, SYSCFG_ADC2ALT_ADC2_ROUT0, Adc2AltRout0);
891 * @}
893 #endif /*SYSCFG_ADC2ALT_ADC2_ROUT0*/
895 #if defined(SYSCFG_ADC2ALT_ADC2_ROUT1)
896 /** @brief SYSCFG ADC2 internal input alternate connection macros
897 * @param Adc2AltRout1 This parameter can be a value of :
898 * @arg @ref SYSCFG_ADC2_ROUT1_DAC1_2 DAC1_out2 connected to ADC2 VINP[17]
899 * @arg @ref SYSCFG_ADC2_ROUT1_VREFINT VREFINT connected to ADC2 VINP[17]
901 void HAL_SYSCFG_ADC2ALT_Rout1Config(uint32_t Adc2AltRout1)
903 /* Check the parameters */
904 assert_param(IS_SYSCFG_ADC2ALT_ROUT1(Adc2AltRout1));
906 MODIFY_REG(SYSCFG->ADC2ALT, SYSCFG_ADC2ALT_ADC2_ROUT1, Adc2AltRout1);
909 * @}
911 #endif /*SYSCFG_ADC2ALT_ADC2_ROUT1*/
914 * @brief Enable the Debug Module during Domain1/CDomain SLEEP mode
915 * @retval None
917 void HAL_EnableDBGSleepMode(void)
919 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD1);
923 * @brief Disable the Debug Module during Domain1/CDomain SLEEP mode
924 * @retval None
926 void HAL_DisableDBGSleepMode(void)
928 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD1);
933 * @brief Enable the Debug Module during Domain1/CDomain STOP mode
934 * @retval None
936 void HAL_EnableDBGStopMode(void)
938 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD1);
942 * @brief Disable the Debug Module during Domain1/CDomain STOP mode
943 * @retval None
945 void HAL_DisableDBGStopMode(void)
947 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD1);
951 * @brief Enable the Debug Module during Domain1/CDomain STANDBY mode
952 * @retval None
954 void HAL_EnableDBGStandbyMode(void)
956 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD1);
960 * @brief Disable the Debug Module during Domain1/CDomain STANDBY mode
961 * @retval None
963 void HAL_DisableDBGStandbyMode(void)
965 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD1);
968 #if defined(DUAL_CORE)
970 * @brief Enable the Debug Module during Domain1 SLEEP mode
971 * @retval None
973 void HAL_EnableDomain2DBGSleepMode(void)
975 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD2);
979 * @brief Disable the Debug Module during Domain2 SLEEP mode
980 * @retval None
982 void HAL_DisableDomain2DBGSleepMode(void)
984 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD2);
988 * @brief Enable the Debug Module during Domain2 STOP mode
989 * @retval None
991 void HAL_EnableDomain2DBGStopMode(void)
993 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD2);
997 * @brief Disable the Debug Module during Domain2 STOP mode
998 * @retval None
1000 void HAL_DisableDomain2DBGStopMode(void)
1002 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD2);
1006 * @brief Enable the Debug Module during Domain2 STANDBY mode
1007 * @retval None
1009 void HAL_EnableDomain2DBGStandbyMode(void)
1011 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD2);
1015 * @brief Disable the Debug Module during Domain2 STANDBY mode
1016 * @retval None
1018 void HAL_DisableDomain2DBGStandbyMode(void)
1020 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD2);
1022 #endif /*DUAL_CORE*/
1025 * @brief Enable the Debug Module during Domain3/SRDomain STOP mode
1026 * @retval None
1028 void HAL_EnableDomain3DBGStopMode(void)
1030 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD3);
1033 * @brief Disable the Debug Module during Domain3/SRDomain STOP mode
1034 * @retval None
1036 void HAL_DisableDomain3DBGStopMode(void)
1038 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD3);
1042 * @brief Enable the Debug Module during Domain3/SRDomain STANDBY mode
1043 * @retval None
1045 void HAL_EnableDomain3DBGStandbyMode(void)
1047 SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD3);
1051 * @brief Disable the Debug Module during Domain3/SRDomain STANDBY mode
1052 * @retval None
1054 void HAL_DisableDomain3DBGStandbyMode(void)
1056 CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD3);
1060 * @brief Set the FMC Memory Mapping Swapping config.
1061 * @param BankMapConfig: Defines the FMC Bank mapping configuration. This parameter can be
1062 FMC_SWAPBMAP_DISABLE, FMC_SWAPBMAP_SDRAM_SRAM, FMC_SWAPBMAP_SDRAMB2
1063 * @retval HAL state
1065 void HAL_SetFMCMemorySwappingConfig(uint32_t BankMapConfig)
1067 /* Check the parameter */
1068 assert_param(IS_FMC_SWAPBMAP_MODE(BankMapConfig));
1069 MODIFY_REG(FMC_Bank1_R->BTCR[0], FMC_BCR1_BMAP, BankMapConfig);
1073 * @brief Get FMC Bank mapping mode.
1074 * @retval The FMC Bank mapping mode. This parameter can be
1075 FMC_SWAPBMAP_DISABLE, FMC_SWAPBMAP_SDRAM_SRAM, FMC_SWAPBMAP_SDRAMB2
1077 uint32_t HAL_GetFMCMemorySwappingConfig(void)
1079 return READ_BIT(FMC_Bank1_R->BTCR[0], FMC_BCR1_BMAP);
1083 * @brief Configure the EXTI input event line edge
1084 * @note No edge configuration for direct lines but for configurable lines:(EXTI_LINE0..EXTI_LINE21),
1085 * EXTI_LINE49,EXTI_LINE51,EXTI_LINE82,EXTI_LINE84,EXTI_LINE85 and EXTI_LINE86.
1086 * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
1087 * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
1088 * @param EXTI_Edge: Specifies EXTI line Edge used.
1089 * This parameter can be one of the following values :
1090 * @arg EXTI_RISING_EDGE : Configurable line, with Rising edge trigger detection
1091 * @arg EXTI_FALLING_EDGE: Configurable line, with Falling edge trigger detection
1092 * @retval None
1094 void HAL_EXTI_EdgeConfig(uint32_t EXTI_Line , uint32_t EXTI_Edge )
1096 /* Check the parameter */
1097 assert_param(IS_HAL_EXTI_CONFIG_LINE(EXTI_Line));
1098 assert_param(IS_EXTI_EDGE_LINE(EXTI_Edge));
1100 /* Clear Rising Falling edge configuration */
1101 CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->FTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1102 CLEAR_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI->RTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1104 if( (EXTI_Edge & EXTI_RISING_EDGE) == EXTI_RISING_EDGE)
1106 SET_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI->RTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1108 if( (EXTI_Edge & EXTI_FALLING_EDGE) == EXTI_FALLING_EDGE)
1110 SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->FTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1115 * @brief Generates a Software interrupt on selected EXTI line.
1116 * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
1117 * (EXTI_LINE0..EXTI_LINE21),EXTI_LINE49,EXTI_LINE51,EXTI_LINE82,EXTI_LINE84,EXTI_LINE85 and EXTI_LINE86.
1118 * @retval None
1120 void HAL_EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
1122 /* Check the parameters */
1123 assert_param(IS_HAL_EXTI_CONFIG_LINE(EXTI_Line));
1125 SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->SWIER1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1130 * @brief Clears the EXTI's line pending flags for Domain D1
1131 * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
1132 * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
1133 * @retval None
1135 void HAL_EXTI_D1_ClearFlag(uint32_t EXTI_Line)
1137 /* Check the parameters */
1138 assert_param(IS_EXTI_D1_LINE(EXTI_Line));
1139 WRITE_REG(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->PR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1143 #if defined(DUAL_CORE)
1145 * @brief Clears the EXTI's line pending flags for Domain D2
1146 * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
1147 * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
1148 * @retval None
1150 void HAL_EXTI_D2_ClearFlag(uint32_t EXTI_Line)
1152 /* Check the parameters */
1153 assert_param(IS_EXTI_D2_LINE(EXTI_Line));
1154 WRITE_REG(*(__IO uint32_t *) (((uint32_t) &(EXTI_D2->PR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1157 #endif /*DUAL_CORE*/
1159 * @brief Configure the EXTI input event line for Domain D1
1160 * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
1161 * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
1162 * @param EXTI_Mode: Specifies which EXTI line is used as interrupt or an event.
1163 * This parameter can be one or a combination of the following values :
1164 * @arg EXTI_MODE_IT : Interrupt Mode selected
1165 * @arg EXTI_MODE_EVT : Event Mode selected
1166 * @param EXTI_LineCmd controls (Enable/Disable) the EXTI line.
1168 * @retval None
1170 void HAL_EXTI_D1_EventInputConfig(uint32_t EXTI_Line , uint32_t EXTI_Mode, uint32_t EXTI_LineCmd )
1172 /* Check the parameter */
1173 assert_param(IS_EXTI_D1_LINE(EXTI_Line));
1174 assert_param(IS_EXTI_MODE_LINE(EXTI_Mode));
1176 if( (EXTI_Mode & EXTI_MODE_IT) == EXTI_MODE_IT)
1178 if( EXTI_LineCmd == 0UL)
1180 /* Clear EXTI line configuration */
1181 CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)),(uint32_t)(1UL << (EXTI_Line & 0x1FUL)) );
1183 else
1185 SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1189 if( (EXTI_Mode & EXTI_MODE_EVT) == EXTI_MODE_EVT)
1191 if( EXTI_LineCmd == 0UL)
1193 /* Clear EXTI line configuration */
1194 CLEAR_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI_D1->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1196 else
1198 SET_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI_D1->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1203 #if defined(DUAL_CORE)
1205 * @brief Configure the EXTI input event line for Domain D2
1206 * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
1207 * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
1208 * @param EXTI_Mode: Specifies which EXTI line is used as interrupt or an event.
1209 * This parameter can be one or a combination of the following values :
1210 * @arg EXTI_MODE_IT : Interrupt Mode selected
1211 * @arg EXTI_MODE_EVT : Event Mode selected
1212 * @param EXTI_LineCmd controls (Enable/Disable) the EXTI line.
1214 * @retval None
1216 void HAL_EXTI_D2_EventInputConfig(uint32_t EXTI_Line , uint32_t EXTI_Mode, uint32_t EXTI_LineCmd )
1218 /* Check the parameter */
1219 assert_param(IS_EXTI_D2_LINE(EXTI_Line));
1220 assert_param(IS_EXTI_MODE_LINE(EXTI_Mode));
1222 if( (EXTI_Mode & EXTI_MODE_IT) == EXTI_MODE_IT)
1224 if( EXTI_LineCmd == 0UL)
1226 /* Clear EXTI line configuration */
1227 CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D2->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)),(uint32_t)(1UL << (EXTI_Line & 0x1FUL)) );
1229 else
1231 SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D2->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1235 if( (EXTI_Mode & EXTI_MODE_EVT) == EXTI_MODE_EVT)
1237 if( EXTI_LineCmd == 0UL)
1239 /* Clear EXTI line configuration */
1240 CLEAR_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI_D2->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1242 else
1244 SET_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI_D2->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1248 #endif /*DUAL_CORE*/
1251 * @brief Configure the EXTI input event line for Domain D3
1252 * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
1253 * (EXTI_LINE0...EXTI_LINE15),(EXTI_LINE19...EXTI_LINE21),EXTI_LINE25, EXTI_LINE34,
1254 * EXTI_LINE35,EXTI_LINE41,(EXTI_LINE48...EXTI_LINE53)
1255 * @param EXTI_LineCmd controls (Enable/Disable) the EXTI line.
1256 * @param EXTI_ClearSrc: Specifies the clear source of D3 pending event.
1257 * This parameter can be one of the following values :
1258 * @arg BDMA_CH6_CLEAR : BDMA ch6 event selected as D3 domain pendclear source
1259 * @arg BDMA_CH7_CLEAR : BDMA ch7 event selected as D3 domain pendclear source
1260 * @arg LPTIM4_OUT_CLEAR : LPTIM4 out selected as D3 domain pendclear source
1261 * @arg LPTIM5_OUT_CLEAR : LPTIM5 out selected as D3 domain pendclear source
1262 * @retval None
1264 void HAL_EXTI_D3_EventInputConfig(uint32_t EXTI_Line, uint32_t EXTI_LineCmd , uint32_t EXTI_ClearSrc )
1266 __IO uint32_t *pRegv;
1268 /* Check the parameter */
1269 assert_param(IS_EXTI_D3_LINE(EXTI_Line));
1270 assert_param(IS_EXTI_D3_CLEAR(EXTI_ClearSrc));
1272 if( EXTI_LineCmd == 0UL)
1274 /* Clear EXTI line configuration */
1275 CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->D3PMR1)) + ((EXTI_Line >> 5 ) * 0x20UL)),(uint32_t)(1UL << (EXTI_Line & 0x1FUL)) );
1277 else
1279 SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->D3PMR1)) +((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
1282 if(((EXTI_Line>>4)%2UL) == 0UL)
1284 pRegv = (__IO uint32_t *) (((uint32_t) &(EXTI->D3PCR1L)) + ((EXTI_Line >> 5 ) * 0x20UL));
1286 else
1288 pRegv = (__IO uint32_t *) (((uint32_t) &(EXTI->D3PCR1H)) + ((EXTI_Line >> 5 ) * 0x20UL));
1290 MODIFY_REG(*pRegv, (uint32_t)(3UL << ((EXTI_Line*2UL) & 0x1FUL)), (uint32_t)(EXTI_ClearSrc << ((EXTI_Line*2UL) & 0x1FUL)));
1297 * @}
1301 * @}
1305 * @}
1309 * @}
1312 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/