STM32H735xx HAL User Manual
stm32h7xx_hal.c
Go to the documentation of this file.
00001 /**
00002   ******************************************************************************
00003   * @file    stm32h7xx_hal.c
00004   * @author  MCD Application Team
00005   * @brief   HAL module driver.
00006   *          This is the common part of the HAL initialization
00007   *
00008   ******************************************************************************
00009   * @attention
00010   *
00011   * Copyright (c) 2017 STMicroelectronics.
00012   * All rights reserved.
00013   *
00014   * This software is licensed under terms that can be found in the LICENSE file
00015   * in the root directory of this software component.
00016   * If no LICENSE file comes with this software, it is provided AS-IS.
00017   *
00018   ******************************************************************************
00019   @verbatim
00020   ==============================================================================
00021                      ##### How to use this driver #####
00022   ==============================================================================
00023     [..]
00024     The common HAL driver contains a set of generic and common APIs that can be
00025     used by the PPP peripheral drivers and the user to start using the HAL.
00026     [..]
00027     The HAL contains two APIs' categories:
00028          (+) Common HAL APIs
00029          (+) Services HAL APIs
00030 
00031   @endverbatim
00032   ******************************************************************************
00033   */
00034 
00035 /* Includes ------------------------------------------------------------------*/
00036 #include "stm32h7xx_hal.h"
00037 
00038 /** @addtogroup STM32H7xx_HAL_Driver
00039   * @{
00040   */
00041 
00042 /** @defgroup HAL  HAL
00043   * @brief HAL module driver.
00044   * @{
00045   */
00046 
00047 /* Private typedef -----------------------------------------------------------*/
00048 /* Private define ------------------------------------------------------------*/
00049 /**
00050  * @brief STM32H7xx HAL Driver version number V1.10.1
00051    */
00052 #define __STM32H7xx_HAL_VERSION_MAIN   (0x01UL) /*!< [31:24] main version */
00053 #define __STM32H7xx_HAL_VERSION_SUB1   (0x0AUL) /*!< [23:16] sub1 version */
00054 #define __STM32H7xx_HAL_VERSION_SUB2   (0x01UL) /*!< [15:8]  sub2 version */
00055 #define __STM32H7xx_HAL_VERSION_RC     (0x00UL) /*!< [7:0]  release candidate */
00056 #define __STM32H7xx_HAL_VERSION         ((__STM32H7xx_HAL_VERSION_MAIN << 24)\
00057                                         |(__STM32H7xx_HAL_VERSION_SUB1 << 16)\
00058                                         |(__STM32H7xx_HAL_VERSION_SUB2 << 8 )\
00059                                         |(__STM32H7xx_HAL_VERSION_RC))
00060 
00061 #define IDCODE_DEVID_MASK    ((uint32_t)0x00000FFF)
00062 #define VREFBUF_TIMEOUT_VALUE     (uint32_t)10   /* 10 ms  */
00063 
00064 /* Private macro -------------------------------------------------------------*/
00065 /* Private variables ---------------------------------------------------------*/
00066 /* Exported variables --------------------------------------------------------*/
00067 
00068 /** @defgroup HAL_Exported_Variables HAL Exported Variables
00069   * @{
00070   */
00071 __IO uint32_t uwTick;
00072 uint32_t uwTickPrio   = (1UL << __NVIC_PRIO_BITS); /* Invalid PRIO */
00073 HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_DEFAULT;  /* 1KHz */
00074 /**
00075   * @}
00076   */
00077 
00078 /* Private function prototypes -----------------------------------------------*/
00079 /* Private functions ---------------------------------------------------------*/
00080 
00081 /** @defgroup HAL_Private_Functions  HAL Private Functions
00082   * @{
00083   */
00084 
00085 /** @defgroup HAL_Group1 Initialization and de-initialization Functions
00086  *  @brief    Initialization and de-initialization functions
00087  *
00088 @verbatim
00089  ===============================================================================
00090               ##### Initialization and de-initialization functions #####
00091  ===============================================================================
00092     [..]  This section provides functions allowing to:
00093       (+) Initializes the Flash interface the NVIC allocation and initial clock
00094           configuration. It initializes the systick also when timeout is needed
00095           and the backup domain when enabled.
00096       (+) De-Initializes common part of the HAL.
00097       (+) Configure The time base source to have 1ms time base with a dedicated
00098           Tick interrupt priority.
00099         (++) SysTick timer is used by default as source of time base, but user
00100              can eventually implement his proper time base source (a general purpose
00101              timer for example or other time source), keeping in mind that Time base
00102              duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
00103              handled in milliseconds basis.
00104         (++) Time base configuration function (HAL_InitTick ()) is called automatically
00105              at the beginning of the program after reset by HAL_Init() or at any time
00106              when clock is configured, by HAL_RCC_ClockConfig().
00107         (++) Source of time base is configured  to generate interrupts at regular
00108              time intervals. Care must be taken if HAL_Delay() is called from a
00109              peripheral ISR process, the Tick interrupt line must have higher priority
00110             (numerically lower) than the peripheral interrupt. Otherwise the caller
00111             ISR process will be blocked.
00112        (++) functions affecting time base configurations are declared as __weak
00113              to make  override possible  in case of other  implementations in user file.
00114 @endverbatim
00115   * @{
00116   */
00117 
00118 /**
00119   * @brief  This function is used to initialize the HAL Library; it must be the first
00120   *         instruction to be executed in the main program (before to call any other
00121   *         HAL function), it performs the following:
00122   *           Configures the SysTick to generate an interrupt each 1 millisecond,
00123   *           which is clocked by the HSI (at this stage, the clock is not yet
00124   *           configured and thus the system is running from the internal HSI at 16 MHz).
00125   *           Set NVIC Group Priority to 4.
00126   *           Calls the HAL_MspInit() callback function defined in user file
00127   *           "stm32h7xx_hal_msp.c" to do the global low level hardware initialization
00128   *
00129   * @note   SysTick is used as time base for the HAL_Delay() function, the application
00130   *         need to ensure that the SysTick time base is always set to 1 millisecond
00131   *         to have correct HAL operation.
00132   * @retval HAL status
00133   */
00134 HAL_StatusTypeDef HAL_Init(void)
00135 {
00136 
00137 uint32_t common_system_clock;
00138 
00139 #if defined(DUAL_CORE) && defined(CORE_CM4)
00140    /* Configure Cortex-M4 Instruction cache through ART accelerator */
00141    __HAL_RCC_ART_CLK_ENABLE();                   /* Enable the Cortex-M4 ART Clock */
00142    __HAL_ART_CONFIG_BASE_ADDRESS(0x08100000UL);  /* Configure the Cortex-M4 ART Base address to the Flash Bank 2 : */
00143    __HAL_ART_ENABLE();                           /* Enable the Cortex-M4 ART */
00144 #endif /* DUAL_CORE &&  CORE_CM4 */
00145 
00146   /* Set Interrupt Group Priority */
00147   HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
00148 
00149   /* Update the SystemCoreClock global variable */
00150 #if defined(RCC_D1CFGR_D1CPRE)
00151   common_system_clock = HAL_RCC_GetSysClockFreq() >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]) & 0x1FU);
00152 #else
00153   common_system_clock = HAL_RCC_GetSysClockFreq() >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE)>> RCC_CDCFGR1_CDCPRE_Pos]) & 0x1FU);
00154 #endif
00155 
00156   /* Update the SystemD2Clock global variable */
00157 #if defined(RCC_D1CFGR_HPRE)
00158   SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU));
00159 #else
00160   SystemD2Clock = (common_system_clock >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE)>> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU));
00161 #endif
00162 
00163 #if defined(DUAL_CORE) && defined(CORE_CM4)
00164   SystemCoreClock = SystemD2Clock;
00165 #else
00166   SystemCoreClock = common_system_clock;
00167 #endif /* DUAL_CORE && CORE_CM4 */
00168 
00169   /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
00170   if(HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK)
00171   {
00172     return HAL_ERROR;
00173   }
00174 
00175   /* Init the low level hardware */
00176   HAL_MspInit();
00177 
00178   /* Return function status */
00179   return HAL_OK;
00180 }
00181 
00182 /**
00183   * @brief  This function de-Initializes common part of the HAL and stops the systick.
00184   *         This function is optional.
00185   * @retval HAL status
00186   */
00187 HAL_StatusTypeDef HAL_DeInit(void)
00188 {
00189   /* Reset of all peripherals */
00190   __HAL_RCC_AHB3_FORCE_RESET();
00191   __HAL_RCC_AHB3_RELEASE_RESET();
00192 
00193   __HAL_RCC_AHB1_FORCE_RESET();
00194   __HAL_RCC_AHB1_RELEASE_RESET();
00195 
00196   __HAL_RCC_AHB2_FORCE_RESET();
00197   __HAL_RCC_AHB2_RELEASE_RESET();
00198 
00199   __HAL_RCC_AHB4_FORCE_RESET();
00200  __HAL_RCC_AHB4_RELEASE_RESET();
00201 
00202   __HAL_RCC_APB3_FORCE_RESET();
00203   __HAL_RCC_APB3_RELEASE_RESET();
00204 
00205   __HAL_RCC_APB1L_FORCE_RESET();
00206   __HAL_RCC_APB1L_RELEASE_RESET();
00207 
00208   __HAL_RCC_APB1H_FORCE_RESET();
00209   __HAL_RCC_APB1H_RELEASE_RESET();
00210 
00211    __HAL_RCC_APB2_FORCE_RESET();
00212    __HAL_RCC_APB2_RELEASE_RESET();
00213 
00214   __HAL_RCC_APB4_FORCE_RESET();
00215   __HAL_RCC_APB4_RELEASE_RESET();
00216 
00217   /* De-Init the low level hardware */
00218   HAL_MspDeInit();
00219 
00220   /* Return function status */
00221   return HAL_OK;
00222 }
00223 
00224 /**
00225   * @brief  Initializes the MSP.
00226   * @retval None
00227   */
00228 __weak void HAL_MspInit(void)
00229 {
00230   /* NOTE : This function Should not be modified, when the callback is needed,
00231             the HAL_MspInit could be implemented in the user file
00232    */
00233 }
00234 
00235 /**
00236   * @brief  DeInitializes the MSP.
00237   * @retval None
00238   */
00239 __weak void HAL_MspDeInit(void)
00240 {
00241   /* NOTE : This function Should not be modified, when the callback is needed,
00242             the HAL_MspDeInit could be implemented in the user file
00243    */
00244 }
00245 
00246 /**
00247   * @brief This function configures the source of the time base.
00248   *        The time source is configured  to have 1ms time base with a dedicated
00249   *        Tick interrupt priority.
00250   * @note This function is called  automatically at the beginning of program after
00251   *       reset by HAL_Init() or at any time when clock is reconfigured  by HAL_RCC_ClockConfig().
00252   * @note In the default implementation, SysTick timer is the source of time base.
00253   *       It is used to generate interrupts at regular time intervals.
00254   *       Care must be taken if HAL_Delay() is called from a peripheral ISR process,
00255   *       The the SysTick interrupt must have higher priority (numerically lower)
00256   *       than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
00257   *       The function is declared as __weak  to be overwritten  in case of other
00258   *       implementation  in user file.
00259   * @param TickPriority: Tick interrupt priority.
00260   * @retval HAL status
00261   */
00262 __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
00263 {
00264   /* Check uwTickFreq for MisraC 2012 (even if uwTickFreq is a enum type that don't take the value zero)*/
00265   if((uint32_t)uwTickFreq == 0UL)
00266   {
00267     return HAL_ERROR;
00268   }
00269 
00270     /* Configure the SysTick to have interrupt in 1ms time basis*/
00271     if (HAL_SYSTICK_Config(SystemCoreClock / (1000UL / (uint32_t)uwTickFreq)) > 0U)
00272     {
00273       return HAL_ERROR;
00274     }
00275 
00276   /* Configure the SysTick IRQ priority */
00277   if (TickPriority < (1UL << __NVIC_PRIO_BITS))
00278   {
00279     HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
00280     uwTickPrio = TickPriority;
00281   }
00282   else
00283   {
00284     return HAL_ERROR;
00285   }
00286 
00287   /* Return function status */
00288   return HAL_OK;
00289 }
00290 
00291 /**
00292   * @}
00293   */
00294 
00295 /** @defgroup HAL_Group2 HAL Control functions
00296  *  @brief    HAL Control functions
00297  *
00298 @verbatim
00299  ===============================================================================
00300                       ##### HAL Control functions #####
00301  ===============================================================================
00302     [..]  This section provides functions allowing to:
00303       (+) Provide a tick value in millisecond
00304       (+) Provide a blocking delay in millisecond
00305       (+) Suspend the time base source interrupt
00306       (+) Resume the time base source interrupt
00307       (+) Get the HAL API driver version
00308       (+) Get the device identifier
00309       (+) Get the device revision identifier
00310       (+) Enable/Disable Debug module during SLEEP mode
00311       (+) Enable/Disable Debug module during STOP mode
00312       (+) Enable/Disable Debug module during STANDBY mode
00313 
00314 @endverbatim
00315   * @{
00316   */
00317 
00318 /**
00319   * @brief This function is called to increment  a global variable "uwTick"
00320   *        used as application time base.
00321   * @note In the default implementation, this variable is incremented each 1ms
00322   *       in Systick ISR.
00323  * @note This function is declared as __weak to be overwritten in case of other
00324   *      implementations in user file.
00325   * @retval None
00326   */
00327 __weak void HAL_IncTick(void)
00328 {
00329   uwTick += (uint32_t)uwTickFreq;
00330 }
00331 
00332 /**
00333   * @brief Provides a tick value in millisecond.
00334   * @note This function is declared as __weak to be overwritten in case of other
00335   *       implementations in user file.
00336   * @retval tick value
00337   */
00338 __weak uint32_t HAL_GetTick(void)
00339 {
00340   return uwTick;
00341 }
00342 
00343 /**
00344   * @brief This function returns a tick priority.
00345   * @retval tick priority
00346   */
00347 uint32_t HAL_GetTickPrio(void)
00348 {
00349   return uwTickPrio;
00350 }
00351 
00352 /**
00353   * @brief Set new tick Freq.
00354   * @retval Status
00355   */
00356 HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq)
00357 {
00358   HAL_StatusTypeDef status  = HAL_OK;
00359   HAL_TickFreqTypeDef prevTickFreq;
00360 
00361   assert_param(IS_TICKFREQ(Freq));
00362 
00363   if (uwTickFreq != Freq)
00364   {
00365 
00366     /* Back up uwTickFreq frequency */
00367     prevTickFreq = uwTickFreq;
00368 
00369     /* Update uwTickFreq global variable used by HAL_InitTick() */
00370     uwTickFreq = Freq;
00371 
00372     /* Apply the new tick Freq  */
00373     status = HAL_InitTick(uwTickPrio);
00374     if (status != HAL_OK)
00375     {
00376       /* Restore previous tick frequency */
00377       uwTickFreq = prevTickFreq;
00378     }
00379   }
00380 
00381   return status;
00382 }
00383 
00384 /**
00385   * @brief Return tick frequency.
00386   * @retval tick period in Hz
00387   */
00388 HAL_TickFreqTypeDef HAL_GetTickFreq(void)
00389 {
00390   return uwTickFreq;
00391 }
00392 
00393 /**
00394   * @brief This function provides minimum delay (in milliseconds) based
00395   *        on variable incremented.
00396   * @note In the default implementation , SysTick timer is the source of time base.
00397   *       It is used to generate interrupts at regular time intervals where uwTick
00398   *       is incremented.
00399   * @note This function is declared as __weak to be overwritten in case of other
00400   *       implementations in user file.
00401   * @param Delay  specifies the delay time length, in milliseconds.
00402   * @retval None
00403   */
00404 __weak void HAL_Delay(uint32_t Delay)
00405 {
00406   uint32_t tickstart = HAL_GetTick();
00407   uint32_t wait = Delay;
00408 
00409   /* Add a freq to guarantee minimum wait */
00410   if (wait < HAL_MAX_DELAY)
00411   {
00412     wait += (uint32_t)(uwTickFreq);
00413   }
00414 
00415   while ((HAL_GetTick() - tickstart) < wait)
00416   {
00417   }
00418 }
00419 
00420 /**
00421   * @brief Suspend Tick increment.
00422   * @note In the default implementation , SysTick timer is the source of time base. It is
00423   *       used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
00424   *       is called, the the SysTick interrupt will be disabled and so Tick increment
00425   *       is suspended.
00426   * @note This function is declared as __weak to be overwritten in case of other
00427   *       implementations in user file.
00428   * @retval None
00429   */
00430 __weak void HAL_SuspendTick(void)
00431 {
00432   /* Disable SysTick Interrupt */
00433   SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
00434 }
00435 
00436 /**
00437   * @brief Resume Tick increment.
00438   * @note In the default implementation , SysTick timer is the source of time base. It is
00439   *       used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
00440   *       is called, the the SysTick interrupt will be enabled and so Tick increment
00441   *       is resumed.
00442   * @note This function is declared as __weak to be overwritten in case of other
00443   *       implementations in user file.
00444   * @retval None
00445   */
00446 __weak void HAL_ResumeTick(void)
00447 {
00448   /* Enable SysTick Interrupt */
00449   SysTick->CTRL  |= SysTick_CTRL_TICKINT_Msk;
00450 }
00451 
00452 /**
00453   * @brief  Returns the HAL revision
00454   * @retval version : 0xXYZR (8bits for each decimal, R for RC)
00455   */
00456 uint32_t HAL_GetHalVersion(void)
00457 {
00458  return __STM32H7xx_HAL_VERSION;
00459 }
00460 
00461 /**
00462   * @brief  Returns the device revision identifier.
00463   * @retval Device revision identifier
00464   */
00465 uint32_t HAL_GetREVID(void)
00466 {
00467    return((DBGMCU->IDCODE) >> 16);
00468 }
00469 
00470 /**
00471   * @brief  Returns the device identifier.
00472   * @retval Device identifier
00473   */
00474 uint32_t HAL_GetDEVID(void)
00475 {
00476    return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
00477 }
00478 
00479 /**
00480   * @brief  Return the first word of the unique device identifier (UID based on 96 bits)
00481   * @retval Device identifier
00482   */
00483 uint32_t HAL_GetUIDw0(void)
00484 {
00485   return(READ_REG(*((uint32_t *)UID_BASE)));
00486 }
00487 
00488 /**
00489   * @brief  Return the second word of the unique device identifier (UID based on 96 bits)
00490   * @retval Device identifier
00491   */
00492 uint32_t HAL_GetUIDw1(void)
00493 {
00494   return(READ_REG(*((uint32_t *)(UID_BASE + 4U))));
00495 }
00496 
00497 /**
00498   * @brief  Return the third word of the unique device identifier (UID based on 96 bits)
00499   * @retval Device identifier
00500   */
00501 uint32_t HAL_GetUIDw2(void)
00502 {
00503   return(READ_REG(*((uint32_t *)(UID_BASE + 8U))));
00504 }
00505 
00506 /**
00507   * @brief Configure the internal voltage reference buffer voltage scale.
00508   * @param VoltageScaling  specifies the output voltage to achieve
00509   *          This parameter can be one of the following values:
00510   *            @arg SYSCFG_VREFBUF_VOLTAGE_SCALE0: VREF_OUT1 around 2.5 V.
00511   *                                                This requires VDDA equal to or higher than 2.8 V.
00512   *            @arg SYSCFG_VREFBUF_VOLTAGE_SCALE1: VREF_OUT2 around 2.048 V.
00513   *                                                This requires VDDA equal to or higher than 2.4 V.
00514   *            @arg SYSCFG_VREFBUF_VOLTAGE_SCALE2: VREF_OUT3 around 1.8 V.
00515   *                                                This requires VDDA equal to or higher than 2.1 V.
00516   *            @arg SYSCFG_VREFBUF_VOLTAGE_SCALE3: VREF_OUT4 around 1.5 V.
00517   *                                                This requires VDDA equal to or higher than 1.8 V.
00518   * @retval None
00519   */
00520 void HAL_SYSCFG_VREFBUF_VoltageScalingConfig(uint32_t VoltageScaling)
00521 {
00522   /* Check the parameters */
00523   assert_param(IS_SYSCFG_VREFBUF_VOLTAGE_SCALE(VoltageScaling));
00524 
00525   MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_VRS, VoltageScaling);
00526 }
00527 
00528 /**
00529   * @brief Configure the internal voltage reference buffer high impedance mode.
00530   * @param Mode  specifies the high impedance mode
00531   *          This parameter can be one of the following values:
00532   *            @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE: VREF+ pin is internally connect to VREFINT output.
00533   *            @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE: VREF+ pin is high impedance.
00534   * @retval None
00535   */
00536 void HAL_SYSCFG_VREFBUF_HighImpedanceConfig(uint32_t Mode)
00537 {
00538   /* Check the parameters */
00539   assert_param(IS_SYSCFG_VREFBUF_HIGH_IMPEDANCE(Mode));
00540 
00541   MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_HIZ, Mode);
00542 }
00543 
00544 /**
00545   * @brief  Tune the Internal Voltage Reference buffer (VREFBUF).
00546   * @retval None
00547   */
00548 void HAL_SYSCFG_VREFBUF_TrimmingConfig(uint32_t TrimmingValue)
00549 {
00550   /* Check the parameters */
00551   assert_param(IS_SYSCFG_VREFBUF_TRIMMING(TrimmingValue));
00552 
00553   MODIFY_REG(VREFBUF->CCR, VREFBUF_CCR_TRIM, TrimmingValue);
00554 }
00555 
00556 /**
00557   * @brief  Enable the Internal Voltage Reference buffer (VREFBUF).
00558   * @retval HAL_OK/HAL_TIMEOUT
00559   */
00560 HAL_StatusTypeDef HAL_SYSCFG_EnableVREFBUF(void)
00561 {
00562   uint32_t  tickstart;
00563 
00564   SET_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR);
00565 
00566   /* Get Start Tick*/
00567   tickstart = HAL_GetTick();
00568 
00569   /* Wait for VRR bit  */
00570   while(READ_BIT(VREFBUF->CSR, VREFBUF_CSR_VRR) == 0UL)
00571   {
00572     if((HAL_GetTick() - tickstart) > VREFBUF_TIMEOUT_VALUE)
00573     {
00574       return HAL_TIMEOUT;
00575     }
00576   }
00577 
00578   return HAL_OK;
00579 }
00580 
00581 /**
00582   * @brief  Disable the Internal Voltage Reference buffer (VREFBUF).
00583   *
00584   * @retval None
00585   */
00586 void HAL_SYSCFG_DisableVREFBUF(void)
00587 {
00588   CLEAR_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR);
00589 }
00590 
00591 #if defined(SYSCFG_PMCR_EPIS_SEL)
00592 /**
00593   * @brief  Ethernet PHY Interface Selection either MII or RMII
00594   * @param  SYSCFG_ETHInterface: Selects the Ethernet PHY interface
00595   *   This parameter can be one of the following values:
00596   *   @arg SYSCFG_ETH_MII : Select the Media Independent Interface
00597   *   @arg SYSCFG_ETH_RMII: Select the Reduced Media Independent Interface
00598   * @retval None
00599   */
00600 void HAL_SYSCFG_ETHInterfaceSelect(uint32_t SYSCFG_ETHInterface)
00601 {
00602   /* Check the parameter */
00603   assert_param(IS_SYSCFG_ETHERNET_CONFIG(SYSCFG_ETHInterface));
00604 
00605   MODIFY_REG(SYSCFG->PMCR, SYSCFG_PMCR_EPIS_SEL, (uint32_t)(SYSCFG_ETHInterface));
00606 }
00607 #endif /* SYSCFG_PMCR_EPIS_SEL */
00608 
00609 /**
00610   * @brief  Analog Switch control for dual analog pads.
00611   * @param  SYSCFG_AnalogSwitch: Selects the analog pad
00612   *   This parameter can be one or a combination of the following values:
00613   *   @arg SYSCFG_SWITCH_PA0 : Select PA0 analog switch
00614   *   @arg SYSCFG_SWITCH_PA1:  Select PA1 analog switch
00615   *   @arg SYSCFG_SWITCH_PC2 : Select PC2 analog switch
00616   *   @arg SYSCFG_SWITCH_PC3:  Select PC3 analog switch
00617   * @param  SYSCFG_SwitchState: Open or Close the analog switch between dual pads (PXn and PXn_C)
00618   *   This parameter can be one or a combination of the following values:
00619   *   @arg SYSCFG_SWITCH_PA0_OPEN
00620   *   @arg SYSCFG_SWITCH_PA0_CLOSE
00621   *   @arg SYSCFG_SWITCH_PA1_OPEN
00622   *   @arg SYSCFG_SWITCH_PA1_CLOSE
00623   *   @arg SYSCFG_SWITCH_PC2_OPEN
00624   *   @arg SYSCFG_SWITCH_PC2_CLOSE
00625   *   @arg SYSCFG_SWITCH_PC3_OPEN
00626   *   @arg SYSCFG_SWITCH_PC3_CLOSE
00627   * @retval None
00628   */
00629 
00630 void HAL_SYSCFG_AnalogSwitchConfig(uint32_t SYSCFG_AnalogSwitch , uint32_t SYSCFG_SwitchState )
00631 {
00632   /* Check the parameter */
00633   assert_param(IS_SYSCFG_ANALOG_SWITCH(SYSCFG_AnalogSwitch));
00634   assert_param(IS_SYSCFG_SWITCH_STATE(SYSCFG_SwitchState));
00635 
00636   MODIFY_REG(SYSCFG->PMCR, (uint32_t) SYSCFG_AnalogSwitch, (uint32_t)(SYSCFG_SwitchState));
00637 }
00638 
00639 #if defined(SYSCFG_PMCR_BOOSTEN)
00640 /**
00641   * @brief  Enables the booster to reduce the total harmonic distortion of the analog
00642   *         switch when the supply voltage is lower than 2.7 V.
00643   * @note   Activating the booster allows to guaranty the analog switch AC performance
00644   *         when the supply voltage is below 2.7 V: in this case, the analog switch
00645   *         performance is the same on the full voltage range
00646   * @retval None
00647   */
00648 void HAL_SYSCFG_EnableBOOST(void)
00649 {
00650  SET_BIT(SYSCFG->PMCR, SYSCFG_PMCR_BOOSTEN) ;
00651 }
00652 
00653 /**
00654   * @brief  Disables the booster
00655   * @note   Activating the booster allows to guaranty the analog switch AC performance
00656   *         when the supply voltage is below 2.7 V: in this case, the analog switch
00657   *         performance is the same on the full voltage range
00658   * @retval None
00659   */
00660 void HAL_SYSCFG_DisableBOOST(void)
00661 {
00662  CLEAR_BIT(SYSCFG->PMCR, SYSCFG_PMCR_BOOSTEN) ;
00663 }
00664 #endif /* SYSCFG_PMCR_BOOSTEN */
00665 
00666 #if defined (SYSCFG_UR2_BOOT_ADD0) ||  defined (SYSCFG_UR2_BCM7_ADD0)
00667 /**
00668   * @brief  BootCM7 address 0 configuration
00669   * @param  BootRegister :Specifies the Boot Address register (Address0 or Address1)
00670   *   This parameter can be one of the following values:
00671   *   @arg SYSCFG_BOOT_ADDR0 : Select the boot address0
00672   *   @arg SYSCFG_BOOT_ADDR1:  Select the boot address1
00673   * @param  BootAddress :Specifies the CM7 Boot Address to be loaded in Address0 or Address1
00674   * @retval None
00675   */
00676 void HAL_SYSCFG_CM7BootAddConfig(uint32_t BootRegister, uint32_t BootAddress)
00677 {
00678   /* Check the parameters */
00679   assert_param(IS_SYSCFG_BOOT_REGISTER(BootRegister));
00680   assert_param(IS_SYSCFG_BOOT_ADDRESS(BootAddress));
00681   if ( BootRegister == SYSCFG_BOOT_ADDR0 )
00682   {
00683     /* Configure CM7 BOOT ADD0 */
00684 #if defined(DUAL_CORE)
00685     MODIFY_REG(SYSCFG->UR2, SYSCFG_UR2_BCM7_ADD0, ((BootAddress >> 16) << SYSCFG_UR2_BCM7_ADD0_Pos));
00686 #else
00687     MODIFY_REG(SYSCFG->UR2, SYSCFG_UR2_BOOT_ADD0, ((BootAddress >> 16) << SYSCFG_UR2_BOOT_ADD0_Pos));
00688 #endif /*DUAL_CORE*/
00689   }
00690   else
00691   {
00692     /* Configure CM7 BOOT ADD1 */
00693 #if defined(DUAL_CORE)
00694     MODIFY_REG(SYSCFG->UR3, SYSCFG_UR3_BCM7_ADD1, (BootAddress >> 16));
00695 #else
00696     MODIFY_REG(SYSCFG->UR3, SYSCFG_UR3_BOOT_ADD1, (BootAddress >> 16));
00697 #endif /*DUAL_CORE*/
00698   }
00699 }
00700 #endif /* SYSCFG_UR2_BOOT_ADD0 || SYSCFG_UR2_BCM7_ADD0 */
00701 
00702 #if defined(DUAL_CORE)
00703 /**
00704   * @brief  BootCM4 address 0 configuration
00705   * @param  BootRegister :Specifies the Boot Address register (Address0 or Address1)
00706   *   This parameter can be one of the following values:
00707   *   @arg SYSCFG_BOOT_ADDR0 : Select the boot address0
00708   *   @arg SYSCFG_BOOT_ADDR1:  Select the boot address1
00709   * @param  BootAddress :Specifies the CM4 Boot Address to be loaded in Address0 or Address1
00710   * @retval None
00711   */
00712 void HAL_SYSCFG_CM4BootAddConfig(uint32_t BootRegister, uint32_t BootAddress)
00713 {
00714   /* Check the parameters */
00715   assert_param(IS_SYSCFG_BOOT_REGISTER(BootRegister));
00716   assert_param(IS_SYSCFG_BOOT_ADDRESS(BootAddress));
00717 
00718   if ( BootRegister == SYSCFG_BOOT_ADDR0 )
00719   {
00720     /* Configure CM4 BOOT ADD0 */
00721     MODIFY_REG(SYSCFG->UR3, SYSCFG_UR3_BCM4_ADD0, ((BootAddress >> 16)<< SYSCFG_UR3_BCM4_ADD0_Pos));
00722   }
00723 
00724   else
00725   {
00726     /* Configure CM4 BOOT ADD1 */
00727     MODIFY_REG(SYSCFG->UR4, SYSCFG_UR4_BCM4_ADD1, (BootAddress >> 16));
00728   }
00729 }
00730 
00731 /**
00732   * @brief  Enables the Cortex-M7 boot
00733   * @retval None
00734   */
00735 void HAL_SYSCFG_EnableCM7BOOT(void)
00736 {
00737  SET_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM7);
00738 }
00739 
00740 /**
00741   * @brief  Disables the Cortex-M7 boot
00742   * @note   Disabling the boot will gate the CPU clock
00743   * @retval None
00744   */
00745 void HAL_SYSCFG_DisableCM7BOOT(void)
00746 {
00747  CLEAR_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM7) ;
00748 }
00749 
00750 /**
00751   * @brief  Enables the Cortex-M4 boot
00752   * @retval None
00753   */
00754 void HAL_SYSCFG_EnableCM4BOOT(void)
00755 {
00756  SET_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM4);
00757 }
00758 
00759 /**
00760   * @brief  Disables the Cortex-M4 boot
00761   * @note   Disabling the boot will gate the CPU clock
00762   * @retval None
00763   */
00764 void HAL_SYSCFG_DisableCM4BOOT(void)
00765 {
00766   CLEAR_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM4);
00767 }
00768 #endif /*DUAL_CORE*/
00769 /**
00770   * @brief  Enables the I/O Compensation Cell.
00771   * @note   The I/O compensation cell can be used only when the device supply
00772   *         voltage ranges from 1.62 to 2.0 V and from 2.7 to 3.6 V.
00773   * @retval None
00774   */
00775 void HAL_EnableCompensationCell(void)
00776 {
00777   SET_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_EN) ;
00778 }
00779 
00780 /**
00781   * @brief  Power-down the I/O Compensation Cell.
00782   * @note   The I/O compensation cell can be used only when the device supply
00783   *         voltage ranges from 1.62 to 2.0 V and from 2.7 to 3.6 V.
00784   * @retval None
00785   */
00786 void HAL_DisableCompensationCell(void)
00787 {
00788   CLEAR_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_EN);
00789 }
00790 
00791 
00792 /**
00793   * @brief  To Enable optimize the I/O speed when the product voltage is low.
00794   * @note   This bit is active only if PRODUCT_BELOW_25V user option bit is set. It must be
00795   *         used only if the product supply voltage is below 2.5 V. Setting this bit when VDD is
00796   *         higher than 2.5 V might be destructive.
00797   * @retval None
00798   */
00799 void HAL_SYSCFG_EnableIOSpeedOptimize(void)
00800 {
00801 #if defined(SYSCFG_CCCSR_HSLV)
00802   SET_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_HSLV);
00803 #else
00804   SET_BIT(SYSCFG->CCCSR, (SYSCFG_CCCSR_HSLV0| SYSCFG_CCCSR_HSLV1 | SYSCFG_CCCSR_HSLV2  | SYSCFG_CCCSR_HSLV3));
00805 #endif   /* SYSCFG_CCCSR_HSLV */
00806 }
00807 
00808 /**
00809   * @brief  To Disable optimize the I/O speed when the product voltage is low.
00810   * @note   This bit is active only if PRODUCT_BELOW_25V user option bit is set. It must be
00811   *         used only if the product supply voltage is below 2.5 V. Setting this bit when VDD is
00812   *         higher than 2.5 V might be destructive.
00813   * @retval None
00814   */
00815 void HAL_SYSCFG_DisableIOSpeedOptimize(void)
00816 {
00817 #if defined(SYSCFG_CCCSR_HSLV)
00818   CLEAR_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_HSLV);
00819 #else
00820   CLEAR_BIT(SYSCFG->CCCSR, (SYSCFG_CCCSR_HSLV0| SYSCFG_CCCSR_HSLV1 | SYSCFG_CCCSR_HSLV2  | SYSCFG_CCCSR_HSLV3));
00821 #endif   /* SYSCFG_CCCSR_HSLV */
00822 }
00823 
00824 /**
00825   * @brief  Code selection for the I/O Compensation cell
00826   * @param  SYSCFG_CompCode: Selects the code to be applied for the I/O compensation cell
00827   *   This parameter can be one of the following values:
00828   *   @arg SYSCFG_CELL_CODE : Select Code from the cell (available in the SYSCFG_CCVR)
00829   *   @arg SYSCFG_REGISTER_CODE: Select Code from the SYSCFG compensation cell code register (SYSCFG_CCCR)
00830   * @retval None
00831   */
00832 void HAL_SYSCFG_CompensationCodeSelect(uint32_t SYSCFG_CompCode)
00833 {
00834   /* Check the parameter */
00835   assert_param(IS_SYSCFG_CODE_SELECT(SYSCFG_CompCode));
00836   MODIFY_REG(SYSCFG->CCCSR, SYSCFG_CCCSR_CS, (uint32_t)(SYSCFG_CompCode));
00837 }
00838 
00839 /**
00840   * @brief  Code selection for the I/O Compensation cell
00841   * @param  SYSCFG_PMOSCode: PMOS compensation code
00842   *         This code is applied to the I/O compensation cell when the CS bit of the
00843   *          SYSCFG_CMPCR is set
00844   * @param  SYSCFG_NMOSCode: NMOS compensation code
00845   *         This code is applied to the I/O compensation cell when the CS bit of the
00846   *          SYSCFG_CMPCR is set
00847   * @retval None
00848   */
00849 void HAL_SYSCFG_CompensationCodeConfig(uint32_t SYSCFG_PMOSCode, uint32_t SYSCFG_NMOSCode )
00850 {
00851   /* Check the parameter */
00852   assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_PMOSCode));
00853   assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_NMOSCode));
00854   MODIFY_REG(SYSCFG->CCCR, SYSCFG_CCCR_NCC|SYSCFG_CCCR_PCC, (((uint32_t)(SYSCFG_PMOSCode)<< 4)|(uint32_t)(SYSCFG_NMOSCode)) );
00855 }
00856 
00857 #if defined(SYSCFG_CCCR_NCC_MMC)
00858 /**
00859   * @brief  Code selection for the I/O Compensation cell
00860   * @param  SYSCFG_PMOSCode: VDDMMC PMOS compensation code
00861   *         This code is applied to the I/O compensation cell when the CS bit of the
00862   *          SYSCFG_CMPCR is set
00863   * @param  SYSCFG_NMOSCode: VDDMMC NMOS compensation code
00864   *         This code is applied to the I/O compensation cell when the CS bit of the
00865   *          SYSCFG_CMPCR is set
00866   * @retval None
00867   */
00868 void HAL_SYSCFG_VDDMMC_CompensationCodeConfig(uint32_t SYSCFG_PMOSCode, uint32_t SYSCFG_NMOSCode )
00869 {
00870   /* Check the parameter */
00871   assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_PMOSCode));
00872   assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_NMOSCode));
00873   MODIFY_REG(SYSCFG->CCCR, (SYSCFG_CCCR_NCC_MMC | SYSCFG_CCCR_PCC_MMC), (((uint32_t)(SYSCFG_PMOSCode)<< 4)|(uint32_t)(SYSCFG_NMOSCode)) );
00874 }
00875 #endif /* SYSCFG_CCCR_NCC_MMC */
00876 
00877 #if defined(SYSCFG_ADC2ALT_ADC2_ROUT0)
00878 /** @brief  SYSCFG ADC2 internal input alternate connection macros
00879   * @param Adc2AltRout0 This parameter can be a value of :
00880   *     @arg @ref SYSCFG_ADC2_ROUT0_DAC1_1   DAC1_out1 connected to ADC2 VINP[16]
00881   *     @arg @ref SYSCFG_ADC2_ROUT0_VBAT4    VBAT/4 connected to ADC2 VINP[16]
00882   */
00883 void HAL_SYSCFG_ADC2ALT_Rout0Config(uint32_t Adc2AltRout0)
00884 {
00885   /* Check the parameters */
00886   assert_param(IS_SYSCFG_ADC2ALT_ROUT0(Adc2AltRout0));
00887 
00888   MODIFY_REG(SYSCFG->ADC2ALT, SYSCFG_ADC2ALT_ADC2_ROUT0, Adc2AltRout0);
00889 }
00890 /**
00891   * @}
00892   */
00893 #endif /*SYSCFG_ADC2ALT_ADC2_ROUT0*/
00894 
00895 #if defined(SYSCFG_ADC2ALT_ADC2_ROUT1)
00896 /** @brief  SYSCFG ADC2 internal input alternate connection macros
00897   * @param Adc2AltRout1  This parameter can be a value of :
00898   *     @arg @ref SYSCFG_ADC2_ROUT1_DAC1_2   DAC1_out2 connected to ADC2 VINP[17]
00899   *     @arg @ref SYSCFG_ADC2_ROUT1_VREFINT  VREFINT connected to ADC2 VINP[17]
00900   */
00901 void HAL_SYSCFG_ADC2ALT_Rout1Config(uint32_t Adc2AltRout1)
00902 {
00903   /* Check the parameters */
00904   assert_param(IS_SYSCFG_ADC2ALT_ROUT1(Adc2AltRout1));
00905 
00906   MODIFY_REG(SYSCFG->ADC2ALT, SYSCFG_ADC2ALT_ADC2_ROUT1, Adc2AltRout1);
00907 }
00908 /**
00909   * @}
00910   */
00911 #endif /*SYSCFG_ADC2ALT_ADC2_ROUT1*/
00912 
00913 /**
00914   * @brief  Enable the Debug Module during Domain1/CDomain SLEEP mode
00915   * @retval None
00916   */
00917 void HAL_DBGMCU_EnableDBGSleepMode(void)
00918 {
00919   SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD1);
00920 }
00921 
00922 /**
00923   * @brief  Disable the Debug Module during Domain1/CDomain SLEEP mode
00924   * @retval None
00925   */
00926 void HAL_DBGMCU_DisableDBGSleepMode(void)
00927 {
00928   CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD1);
00929 }
00930 
00931 
00932 /**
00933   * @brief  Enable the Debug Module during Domain1/CDomain STOP mode
00934   * @retval None
00935   */
00936 void HAL_DBGMCU_EnableDBGStopMode(void)
00937 {
00938   SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD1);
00939 }
00940 
00941 /**
00942   * @brief  Disable the Debug Module during Domain1/CDomain STOP mode
00943   * @retval None
00944   */
00945 void HAL_DBGMCU_DisableDBGStopMode(void)
00946 {
00947   CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD1);
00948 }
00949 
00950 /**
00951   * @brief  Enable the Debug Module during Domain1/CDomain STANDBY mode
00952   * @retval None
00953   */
00954 void HAL_DBGMCU_EnableDBGStandbyMode(void)
00955 {
00956   SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD1);
00957 }
00958 
00959 /**
00960   * @brief  Disable the Debug Module during Domain1/CDomain STANDBY mode
00961   * @retval None
00962   */
00963 void HAL_DBGMCU_DisableDBGStandbyMode(void)
00964 {
00965   CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD1);
00966 }
00967 
00968 #if defined(DUAL_CORE)
00969 /**
00970   * @brief  Enable the Debug Module during Domain1 SLEEP mode
00971   * @retval None
00972   */
00973 void HAL_EnableDomain2DBGSleepMode(void)
00974 {
00975   SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD2);
00976 }
00977 
00978 /**
00979   * @brief  Disable the Debug Module during Domain2 SLEEP mode
00980   * @retval None
00981   */
00982 void HAL_DisableDomain2DBGSleepMode(void)
00983 {
00984   CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD2);
00985 }
00986 
00987 /**
00988   * @brief  Enable the Debug Module during Domain2 STOP mode
00989   * @retval None
00990   */
00991 void HAL_EnableDomain2DBGStopMode(void)
00992 {
00993   SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD2);
00994 }
00995 
00996 /**
00997   * @brief  Disable the Debug Module during Domain2 STOP mode
00998   * @retval None
00999   */
01000 void HAL_DisableDomain2DBGStopMode(void)
01001 {
01002   CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD2);
01003 }
01004 
01005 /**
01006   * @brief  Enable the Debug Module during Domain2 STANDBY mode
01007   * @retval None
01008   */
01009 void HAL_EnableDomain2DBGStandbyMode(void)
01010 {
01011   SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD2);
01012 }
01013 
01014 /**
01015   * @brief  Disable the Debug Module during Domain2 STANDBY mode
01016   * @retval None
01017   */
01018 void HAL_DisableDomain2DBGStandbyMode(void)
01019 {
01020   CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD2);
01021 }
01022 #endif /*DUAL_CORE*/
01023 
01024 #if defined(DBGMCU_CR_DBG_STOPD3)
01025 /**
01026   * @brief  Enable the Debug Module during Domain3/SRDomain STOP mode
01027   * @retval None
01028   */
01029 void HAL_EnableDomain3DBGStopMode(void)
01030 {
01031   SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD3);
01032 }
01033 
01034 /**
01035   * @brief  Disable the Debug Module during Domain3/SRDomain STOP mode
01036   * @retval None
01037   */
01038 void HAL_DisableDomain3DBGStopMode(void)
01039 {
01040   CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD3);
01041 }
01042 #endif /*DBGMCU_CR_DBG_STOPD3*/
01043 
01044 #if defined(DBGMCU_CR_DBG_STANDBYD3)
01045 /**
01046   * @brief  Enable the Debug Module during Domain3/SRDomain STANDBY mode
01047   * @retval None
01048   */
01049 void HAL_EnableDomain3DBGStandbyMode(void)
01050 {
01051   SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD3);
01052 }
01053 
01054 /**
01055   * @brief  Disable the Debug Module during Domain3/SRDomain STANDBY mode
01056   * @retval None
01057   */
01058 void HAL_DisableDomain3DBGStandbyMode(void)
01059 {
01060   CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD3);
01061 }
01062 #endif /*DBGMCU_CR_DBG_STANDBYD3*/
01063 
01064 /**
01065   * @brief  Set the FMC Memory Mapping Swapping config.
01066   * @param  BankMapConfig: Defines the FMC Bank mapping configuration. This parameter can be
01067             FMC_SWAPBMAP_DISABLE, FMC_SWAPBMAP_SDRAM_SRAM, FMC_SWAPBMAP_SDRAMB2
01068   * @retval HAL state
01069   */
01070 void HAL_SetFMCMemorySwappingConfig(uint32_t BankMapConfig)
01071 {
01072   /* Check the parameter */
01073   assert_param(IS_FMC_SWAPBMAP_MODE(BankMapConfig));
01074   MODIFY_REG(FMC_Bank1_R->BTCR[0], FMC_BCR1_BMAP, BankMapConfig);
01075 }
01076 
01077 /**
01078   * @brief  Get FMC Bank mapping mode.
01079   * @retval The FMC Bank mapping mode. This parameter can be
01080             FMC_SWAPBMAP_DISABLE, FMC_SWAPBMAP_SDRAM_SRAM, FMC_SWAPBMAP_SDRAMB2
01081 */
01082 uint32_t HAL_GetFMCMemorySwappingConfig(void)
01083 {
01084   return READ_BIT(FMC_Bank1_R->BTCR[0], FMC_BCR1_BMAP);
01085 }
01086 
01087 /**
01088   * @brief  Configure the EXTI input event line edge
01089   * @note    No edge configuration for direct lines but for configurable lines:(EXTI_LINE0..EXTI_LINE21),
01090   *          EXTI_LINE49,EXTI_LINE51,EXTI_LINE82,EXTI_LINE84,EXTI_LINE85 and EXTI_LINE86.
01091   * @param   EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
01092   *         (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
01093   * @param   EXTI_Edge: Specifies  EXTI line Edge used.
01094   *          This parameter can be one of the following values :
01095   *   @arg EXTI_RISING_EDGE : Configurable line, with Rising edge trigger detection
01096   *   @arg EXTI_FALLING_EDGE: Configurable line, with Falling edge trigger detection
01097   * @retval None
01098   */
01099 void HAL_EXTI_EdgeConfig(uint32_t EXTI_Line , uint32_t EXTI_Edge )
01100 {
01101   /* Check the parameter */
01102   assert_param(IS_HAL_EXTI_CONFIG_LINE(EXTI_Line));
01103   assert_param(IS_EXTI_EDGE_LINE(EXTI_Edge));
01104 
01105   /* Clear Rising Falling edge configuration */
01106   CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->FTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
01107   CLEAR_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI->RTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
01108 
01109   if( (EXTI_Edge & EXTI_RISING_EDGE) == EXTI_RISING_EDGE)
01110   {
01111    SET_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI->RTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
01112   }
01113   if( (EXTI_Edge & EXTI_FALLING_EDGE) == EXTI_FALLING_EDGE)
01114   {
01115    SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->FTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
01116   }
01117 }
01118 
01119 /**
01120   * @brief  Generates a Software interrupt on selected EXTI line.
01121   * @param   EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
01122   *          (EXTI_LINE0..EXTI_LINE21),EXTI_LINE49,EXTI_LINE51,EXTI_LINE82,EXTI_LINE84,EXTI_LINE85 and EXTI_LINE86.
01123   * @retval None
01124   */
01125 void HAL_EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
01126 {
01127   /* Check the parameters */
01128   assert_param(IS_HAL_EXTI_CONFIG_LINE(EXTI_Line));
01129 
01130   SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->SWIER1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
01131 }
01132 
01133 
01134 /**
01135   * @brief  Clears the EXTI's line pending flags for Domain D1
01136   * @param   EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
01137   *         (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
01138   * @retval None
01139   */
01140 void HAL_EXTI_D1_ClearFlag(uint32_t EXTI_Line)
01141 {
01142   /* Check the parameters */
01143  assert_param(IS_EXTI_D1_LINE(EXTI_Line));
01144  WRITE_REG(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->PR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
01145 
01146 }
01147 
01148 #if defined(DUAL_CORE)
01149 /**
01150   * @brief  Clears the EXTI's line pending flags for Domain D2
01151   * @param   EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
01152   *         (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
01153   * @retval None
01154   */
01155 void HAL_EXTI_D2_ClearFlag(uint32_t EXTI_Line)
01156 {
01157   /* Check the parameters */
01158  assert_param(IS_EXTI_D2_LINE(EXTI_Line));
01159  WRITE_REG(*(__IO uint32_t *) (((uint32_t) &(EXTI_D2->PR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
01160 }
01161 
01162 #endif /*DUAL_CORE*/
01163 /**
01164   * @brief  Configure the EXTI input event line for Domain D1
01165   * @param   EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
01166   *         (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
01167   * @param   EXTI_Mode: Specifies which EXTI line is used as interrupt or an event.
01168   *          This parameter can be one or a combination of the following values :
01169   *   @arg EXTI_MODE_IT :  Interrupt Mode selected
01170   *   @arg EXTI_MODE_EVT : Event Mode selected
01171   * @param   EXTI_LineCmd controls (Enable/Disable) the EXTI line.
01172 
01173   * @retval None
01174   */
01175 void HAL_EXTI_D1_EventInputConfig(uint32_t EXTI_Line , uint32_t EXTI_Mode,  uint32_t EXTI_LineCmd )
01176 {
01177   /* Check the parameter */
01178   assert_param(IS_EXTI_D1_LINE(EXTI_Line));
01179   assert_param(IS_EXTI_MODE_LINE(EXTI_Mode));
01180 
01181   if( (EXTI_Mode & EXTI_MODE_IT) == EXTI_MODE_IT)
01182   {
01183      if( EXTI_LineCmd == 0UL)
01184      {
01185        /* Clear EXTI line configuration */
01186         CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)),(uint32_t)(1UL << (EXTI_Line & 0x1FUL)) );
01187      }
01188      else
01189      {
01190         SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
01191      }
01192   }
01193 
01194   if( (EXTI_Mode & EXTI_MODE_EVT) == EXTI_MODE_EVT)
01195   {
01196     if( EXTI_LineCmd == 0UL)
01197     {
01198       /* Clear EXTI line configuration */
01199       CLEAR_BIT(  *(__IO uint32_t *) (((uint32_t) &(EXTI_D1->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
01200     }
01201     else
01202     {
01203       SET_BIT(  *(__IO uint32_t *) (((uint32_t) &(EXTI_D1->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
01204     }
01205   }
01206 }
01207 
01208 #if defined(DUAL_CORE)
01209 /**
01210   * @brief  Configure the EXTI input event line for Domain D2
01211   * @param   EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
01212   *         (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
01213   * @param   EXTI_Mode: Specifies which EXTI line is used as interrupt or an event.
01214   *          This parameter can be one or a combination of the following values :
01215   *   @arg EXTI_MODE_IT :  Interrupt Mode selected
01216   *   @arg EXTI_MODE_EVT : Event Mode selected
01217   * @param   EXTI_LineCmd controls (Enable/Disable) the EXTI line.
01218 
01219   * @retval None
01220   */
01221 void HAL_EXTI_D2_EventInputConfig(uint32_t EXTI_Line , uint32_t EXTI_Mode,  uint32_t EXTI_LineCmd )
01222 {
01223   /* Check the parameter */
01224   assert_param(IS_EXTI_D2_LINE(EXTI_Line));
01225   assert_param(IS_EXTI_MODE_LINE(EXTI_Mode));
01226 
01227   if( (EXTI_Mode & EXTI_MODE_IT) == EXTI_MODE_IT)
01228   {
01229     if( EXTI_LineCmd == 0UL)
01230     {
01231     /* Clear EXTI line configuration */
01232      CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D2->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)),(uint32_t)(1UL << (EXTI_Line & 0x1FUL)) );
01233     }
01234     else
01235     {
01236      SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D2->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
01237     }
01238   }
01239 
01240   if( (EXTI_Mode & EXTI_MODE_EVT) == EXTI_MODE_EVT)
01241   {
01242     if( EXTI_LineCmd == 0UL)
01243     {
01244       /* Clear EXTI line configuration */
01245       CLEAR_BIT(  *(__IO uint32_t *) (((uint32_t) &(EXTI_D2->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
01246     }
01247     else
01248     {
01249       SET_BIT(  *(__IO uint32_t *) (((uint32_t) &(EXTI_D2->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
01250     }
01251   }
01252 }
01253 #endif /*DUAL_CORE*/
01254 
01255 /**
01256   * @brief  Configure the EXTI input event line for Domain D3
01257   * @param   EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
01258   *         (EXTI_LINE0...EXTI_LINE15),(EXTI_LINE19...EXTI_LINE21),EXTI_LINE25, EXTI_LINE34,
01259   *          EXTI_LINE35,EXTI_LINE41,(EXTI_LINE48...EXTI_LINE53)
01260   * @param   EXTI_LineCmd controls (Enable/Disable) the EXTI line.
01261   * @param   EXTI_ClearSrc: Specifies the clear source of D3 pending event.
01262   *          This parameter can be one of the following values :
01263   *   @arg BDMA_CH6_CLEAR : BDMA ch6 event selected as D3 domain pendclear source
01264   *   @arg BDMA_CH7_CLEAR : BDMA ch7 event selected as D3 domain pendclear source
01265   *   @arg LPTIM4_OUT_CLEAR : LPTIM4 out selected as D3 domain pendclear source
01266   *   @arg LPTIM5_OUT_CLEAR : LPTIM5 out selected as D3 domain pendclear source
01267   * @retval None
01268   */
01269 void HAL_EXTI_D3_EventInputConfig(uint32_t EXTI_Line, uint32_t EXTI_LineCmd , uint32_t EXTI_ClearSrc  )
01270 {
01271   __IO uint32_t *pRegv;
01272 
01273   /* Check the parameter */
01274   assert_param(IS_EXTI_D3_LINE(EXTI_Line));
01275   assert_param(IS_EXTI_D3_CLEAR(EXTI_ClearSrc));
01276 
01277   if( EXTI_LineCmd == 0UL)
01278   {
01279     /* Clear EXTI line configuration */
01280     CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->D3PMR1)) + ((EXTI_Line >> 5 ) * 0x20UL)),(uint32_t)(1UL << (EXTI_Line & 0x1FUL)) );
01281   }
01282   else
01283   {
01284     SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->D3PMR1)) +((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
01285   }
01286 
01287   if(((EXTI_Line>>4)%2UL) == 0UL)
01288   {
01289     pRegv = (__IO uint32_t *) (((uint32_t) &(EXTI->D3PCR1L)) + ((EXTI_Line >> 5 ) * 0x20UL));
01290   }
01291   else
01292   {
01293     pRegv = (__IO uint32_t *) (((uint32_t) &(EXTI->D3PCR1H)) + ((EXTI_Line >> 5 ) * 0x20UL));
01294   }
01295   MODIFY_REG(*pRegv, (uint32_t)(3UL << ((EXTI_Line*2UL) & 0x1FUL)), (uint32_t)(EXTI_ClearSrc << ((EXTI_Line*2UL) & 0x1FUL)));
01296 
01297 }
01298 
01299 
01300 
01301 /**
01302   * @}
01303   */
01304 
01305 /**
01306   * @}
01307   */
01308 
01309 /**
01310   * @}
01311   */
01312 
01313 /**
01314   * @}
01315   */
01316 
01317