You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

1290 lines
41 KiB

  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
  7. *
  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
  19. @endverbatim
  20. ******************************************************************************
  21. * @attention
  22. *
  23. * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
  24. * All rights reserved.</center></h2>
  25. *
  26. * This software component is licensed by ST under BSD 3-Clause license,
  27. * the "License"; You may not use this file except in compliance with the
  28. * License. You may obtain a copy of the License at:
  29. * opensource.org/licenses/BSD-3-Clause
  30. *
  31. ******************************************************************************
  32. */
  33. /* Includes ------------------------------------------------------------------*/
  34. #include "stm32h7xx_hal.h"
  35. /** @addtogroup STM32H7xx_HAL_Driver
  36. * @{
  37. */
  38. /** @defgroup HAL HAL
  39. * @brief HAL module driver.
  40. * @{
  41. */
  42. /* Private typedef -----------------------------------------------------------*/
  43. /* Private define ------------------------------------------------------------*/
  44. /**
  45. * @brief STM32H7xx HAL Driver version number V1.7.0
  46. */
  47. #define __STM32H7xx_HAL_VERSION_MAIN (0x01UL) /*!< [31:24] main version */
  48. #define __STM32H7xx_HAL_VERSION_SUB1 (0x07UL) /*!< [23:16] sub1 version */
  49. #define __STM32H7xx_HAL_VERSION_SUB2 (0x00UL) /*!< [15:8] sub2 version */
  50. #define __STM32H7xx_HAL_VERSION_RC (0x00UL) /*!< [7:0] release candidate */
  51. #define __STM32H7xx_HAL_VERSION ((__STM32H7xx_HAL_VERSION_MAIN << 24)\
  52. |(__STM32H7xx_HAL_VERSION_SUB1 << 16)\
  53. |(__STM32H7xx_HAL_VERSION_SUB2 << 8 )\
  54. |(__STM32H7xx_HAL_VERSION_RC))
  55. #define IDCODE_DEVID_MASK ((uint32_t)0x00000FFF)
  56. #define VREFBUF_TIMEOUT_VALUE (uint32_t)10 /* 10 ms */
  57. /* Private macro -------------------------------------------------------------*/
  58. /* Private variables ---------------------------------------------------------*/
  59. /* Exported variables --------------------------------------------------------*/
  60. /** @defgroup HAL_Exported_Variables HAL Exported Variables
  61. * @{
  62. */
  63. __IO uint32_t uwTick;
  64. uint32_t uwTickPrio = (1UL << __NVIC_PRIO_BITS); /* Invalid PRIO */
  65. HAL_TickFreqTypeDef uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */
  66. /**
  67. * @}
  68. */
  69. /* Private function prototypes -----------------------------------------------*/
  70. /* Private functions ---------------------------------------------------------*/
  71. /** @defgroup HAL_Private_Functions HAL Private Functions
  72. * @{
  73. */
  74. /** @defgroup HAL_Group1 Initialization and de-initialization Functions
  75. * @brief Initialization and de-initialization functions
  76. *
  77. @verbatim
  78. ===============================================================================
  79. ##### Initialization and de-initialization functions #####
  80. ===============================================================================
  81. [..] This section provides functions allowing to:
  82. (+) Initializes the Flash interface the NVIC allocation and initial clock
  83. configuration. It initializes the systick also when timeout is needed
  84. and the backup domain when enabled.
  85. (+) De-Initializes common part of the HAL.
  86. (+) Configure The time base source to have 1ms time base with a dedicated
  87. Tick interrupt priority.
  88. (++) SysTick timer is used by default as source of time base, but user
  89. can eventually implement his proper time base source (a general purpose
  90. timer for example or other time source), keeping in mind that Time base
  91. duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
  92. handled in milliseconds basis.
  93. (++) Time base configuration function (HAL_InitTick ()) is called automatically
  94. at the beginning of the program after reset by HAL_Init() or at any time
  95. when clock is configured, by HAL_RCC_ClockConfig().
  96. (++) Source of time base is configured to generate interrupts at regular
  97. time intervals. Care must be taken if HAL_Delay() is called from a
  98. peripheral ISR process, the Tick interrupt line must have higher priority
  99. (numerically lower) than the peripheral interrupt. Otherwise the caller
  100. ISR process will be blocked.
  101. (++) functions affecting time base configurations are declared as __weak
  102. to make override possible in case of other implementations in user file.
  103. @endverbatim
  104. * @{
  105. */
  106. /**
  107. * @brief This function is used to initialize the HAL Library; it must be the first
  108. * instruction to be executed in the main program (before to call any other
  109. * HAL function), it performs the following:
  110. * Configures the SysTick to generate an interrupt each 1 millisecond,
  111. * which is clocked by the HSI (at this stage, the clock is not yet
  112. * configured and thus the system is running from the internal HSI at 16 MHz).
  113. * Set NVIC Group Priority to 4.
  114. * Calls the HAL_MspInit() callback function defined in user file
  115. * "stm32h7xx_hal_msp.c" to do the global low level hardware initialization
  116. *
  117. * @note SysTick is used as time base for the HAL_Delay() function, the application
  118. * need to ensure that the SysTick time base is always set to 1 millisecond
  119. * to have correct HAL operation.
  120. * @retval HAL status
  121. */
  122. HAL_StatusTypeDef HAL_Init(void)
  123. {
  124. #if defined(DUAL_CORE) && defined(CORE_CM4)
  125. /* Configure Cortex-M4 Instruction cache through ART accelerator */
  126. __HAL_RCC_ART_CLK_ENABLE(); /* Enable the Cortex-M4 ART Clock */
  127. __HAL_ART_CONFIG_BASE_ADDRESS(0x08100000UL); /* Configure the Cortex-M4 ART Base address to the Flash Bank 2 : */
  128. __HAL_ART_ENABLE(); /* Enable the Cortex-M4 ART */
  129. #endif /* DUAL_CORE && CORE_CM4 */
  130. /* Set Interrupt Group Priority */
  131. HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
  132. /* Update the SystemCoreClock global variable */
  133. #if defined(RCC_D1CFGR_D1CPRE)
  134. SystemCoreClock = HAL_RCC_GetSysClockFreq() >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_D1CPRE)>> RCC_D1CFGR_D1CPRE_Pos]) & 0x1FU);
  135. #else
  136. SystemCoreClock = HAL_RCC_GetSysClockFreq() >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_CDCPRE)>> RCC_CDCFGR1_CDCPRE_Pos]) & 0x1FU);
  137. #endif
  138. /* Update the SystemD2Clock global variable */
  139. #if defined(RCC_D1CFGR_HPRE)
  140. SystemD2Clock = (SystemCoreClock >> ((D1CorePrescTable[(RCC->D1CFGR & RCC_D1CFGR_HPRE)>> RCC_D1CFGR_HPRE_Pos]) & 0x1FU));
  141. #else
  142. SystemD2Clock = (SystemCoreClock >> ((D1CorePrescTable[(RCC->CDCFGR1 & RCC_CDCFGR1_HPRE)>> RCC_CDCFGR1_HPRE_Pos]) & 0x1FU));
  143. #endif
  144. /* Use systick as time base source and configure 1ms tick (default clock after Reset is HSI) */
  145. if(HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK)
  146. {
  147. return HAL_ERROR;
  148. }
  149. /* Init the low level hardware */
  150. HAL_MspInit();
  151. /* Return function status */
  152. return HAL_OK;
  153. }
  154. /**
  155. * @brief This function de-Initializes common part of the HAL and stops the systick.
  156. * This function is optional.
  157. * @retval HAL status
  158. */
  159. HAL_StatusTypeDef HAL_DeInit(void)
  160. {
  161. /* Reset of all peripherals */
  162. __HAL_RCC_AHB3_FORCE_RESET();
  163. __HAL_RCC_AHB3_RELEASE_RESET();
  164. __HAL_RCC_AHB1_FORCE_RESET();
  165. __HAL_RCC_AHB1_RELEASE_RESET();
  166. __HAL_RCC_AHB2_FORCE_RESET();
  167. __HAL_RCC_AHB2_RELEASE_RESET();
  168. __HAL_RCC_AHB4_FORCE_RESET();
  169. __HAL_RCC_AHB4_RELEASE_RESET();
  170. __HAL_RCC_APB3_FORCE_RESET();
  171. __HAL_RCC_APB3_RELEASE_RESET();
  172. __HAL_RCC_APB1L_FORCE_RESET();
  173. __HAL_RCC_APB1L_RELEASE_RESET();
  174. __HAL_RCC_APB1H_FORCE_RESET();
  175. __HAL_RCC_APB1H_RELEASE_RESET();
  176. __HAL_RCC_APB2_FORCE_RESET();
  177. __HAL_RCC_APB2_RELEASE_RESET();
  178. __HAL_RCC_APB4_FORCE_RESET();
  179. __HAL_RCC_APB4_RELEASE_RESET();
  180. /* De-Init the low level hardware */
  181. HAL_MspDeInit();
  182. /* Return function status */
  183. return HAL_OK;
  184. }
  185. /**
  186. * @brief Initializes the MSP.
  187. * @retval None
  188. */
  189. __weak void HAL_MspInit(void)
  190. {
  191. /* NOTE : This function Should not be modified, when the callback is needed,
  192. the HAL_MspInit could be implemented in the user file
  193. */
  194. }
  195. /**
  196. * @brief DeInitializes the MSP.
  197. * @retval None
  198. */
  199. __weak void HAL_MspDeInit(void)
  200. {
  201. /* NOTE : This function Should not be modified, when the callback is needed,
  202. the HAL_MspDeInit could be implemented in the user file
  203. */
  204. }
  205. /**
  206. * @brief This function configures the source of the time base.
  207. * The time source is configured to have 1ms time base with a dedicated
  208. * Tick interrupt priority.
  209. * @note This function is called automatically at the beginning of program after
  210. * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig().
  211. * @note In the default implementation, SysTick timer is the source of time base.
  212. * It is used to generate interrupts at regular time intervals.
  213. * Care must be taken if HAL_Delay() is called from a peripheral ISR process,
  214. * The the SysTick interrupt must have higher priority (numerically lower)
  215. * than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
  216. * The function is declared as __weak to be overwritten in case of other
  217. * implementation in user file.
  218. * @param TickPriority: Tick interrupt priority.
  219. * @retval HAL status
  220. */
  221. __weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
  222. {
  223. /* Check uwTickFreq for MisraC 2012 (even if uwTickFreq is a enum type that don't take the value zero)*/
  224. if((uint32_t)uwTickFreq == 0UL)
  225. {
  226. return HAL_ERROR;
  227. }
  228. #if defined(DUAL_CORE)
  229. if (HAL_GetCurrentCPUID() == CM7_CPUID)
  230. {
  231. /* Cortex-M7 detected */
  232. /* Configure the SysTick to have interrupt in 1ms time basis*/
  233. if (HAL_SYSTICK_Config(SystemCoreClock / (1000UL / (uint32_t)uwTickFreq)) > 0U)
  234. {
  235. return HAL_ERROR;
  236. }
  237. }
  238. else
  239. {
  240. /* Cortex-M4 detected */
  241. /* Configure the SysTick to have interrupt in 1ms time basis*/
  242. if (HAL_SYSTICK_Config(HAL_RCC_GetHCLKFreq() / (1000UL / (uint32_t)uwTickFreq)) > 0U)
  243. {
  244. return HAL_ERROR;
  245. }
  246. }
  247. #else
  248. /* Configure the SysTick to have interrupt in 1ms time basis*/
  249. if (HAL_SYSTICK_Config(SystemCoreClock / (1000UL / (uint32_t)uwTickFreq)) > 0U)
  250. {
  251. return HAL_ERROR;
  252. }
  253. #endif
  254. /* Configure the SysTick IRQ priority */
  255. if (TickPriority < (1UL << __NVIC_PRIO_BITS))
  256. {
  257. HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
  258. uwTickPrio = TickPriority;
  259. }
  260. else
  261. {
  262. return HAL_ERROR;
  263. }
  264. /* Return function status */
  265. return HAL_OK;
  266. }
  267. /**
  268. * @}
  269. */
  270. /** @defgroup HAL_Group2 HAL Control functions
  271. * @brief HAL Control functions
  272. *
  273. @verbatim
  274. ===============================================================================
  275. ##### HAL Control functions #####
  276. ===============================================================================
  277. [..] This section provides functions allowing to:
  278. (+) Provide a tick value in millisecond
  279. (+) Provide a blocking delay in millisecond
  280. (+) Suspend the time base source interrupt
  281. (+) Resume the time base source interrupt
  282. (+) Get the HAL API driver version
  283. (+) Get the device identifier
  284. (+) Get the device revision identifier
  285. (+) Enable/Disable Debug module during SLEEP mode
  286. (+) Enable/Disable Debug module during STOP mode
  287. (+) Enable/Disable Debug module during STANDBY mode
  288. @endverbatim
  289. * @{
  290. */
  291. /**
  292. * @brief This function is called to increment a global variable "uwTick"
  293. * used as application time base.
  294. * @note In the default implementation, this variable is incremented each 1ms
  295. * in Systick ISR.
  296. * @note This function is declared as __weak to be overwritten in case of other
  297. * implementations in user file.
  298. * @retval None
  299. */
  300. __weak void HAL_IncTick(void)
  301. {
  302. uwTick += (uint32_t)uwTickFreq;
  303. }
  304. /**
  305. * @brief Provides a tick value in millisecond.
  306. * @note This function is declared as __weak to be overwritten in case of other
  307. * implementations in user file.
  308. * @retval tick value
  309. */
  310. __weak uint32_t HAL_GetTick(void)
  311. {
  312. return uwTick;
  313. }
  314. /**
  315. * @brief This function returns a tick priority.
  316. * @retval tick priority
  317. */
  318. uint32_t HAL_GetTickPrio(void)
  319. {
  320. return uwTickPrio;
  321. }
  322. /**
  323. * @brief Set new tick Freq.
  324. * @retval Status
  325. */
  326. HAL_StatusTypeDef HAL_SetTickFreq(HAL_TickFreqTypeDef Freq)
  327. {
  328. HAL_StatusTypeDef status = HAL_OK;
  329. HAL_TickFreqTypeDef prevTickFreq;
  330. assert_param(IS_TICKFREQ(Freq));
  331. if (uwTickFreq != Freq)
  332. {
  333. /* Back up uwTickFreq frequency */
  334. prevTickFreq = uwTickFreq;
  335. /* Update uwTickFreq global variable used by HAL_InitTick() */
  336. uwTickFreq = Freq;
  337. /* Apply the new tick Freq */
  338. status = HAL_InitTick(uwTickPrio);
  339. if (status != HAL_OK)
  340. {
  341. /* Restore previous tick frequency */
  342. uwTickFreq = prevTickFreq;
  343. }
  344. }
  345. return status;
  346. }
  347. /**
  348. * @brief Return tick frequency.
  349. * @retval tick period in Hz
  350. */
  351. HAL_TickFreqTypeDef HAL_GetTickFreq(void)
  352. {
  353. return uwTickFreq;
  354. }
  355. /**
  356. * @brief This function provides minimum delay (in milliseconds) based
  357. * on variable incremented.
  358. * @note In the default implementation , SysTick timer is the source of time base.
  359. * It is used to generate interrupts at regular time intervals where uwTick
  360. * is incremented.
  361. * @note This function is declared as __weak to be overwritten in case of other
  362. * implementations in user file.
  363. * @param Delay specifies the delay time length, in milliseconds.
  364. * @retval None
  365. */
  366. __weak void HAL_Delay(uint32_t Delay)
  367. {
  368. uint32_t tickstart = HAL_GetTick();
  369. uint32_t wait = Delay;
  370. /* Add a freq to guarantee minimum wait */
  371. if (wait < HAL_MAX_DELAY)
  372. {
  373. wait += (uint32_t)(uwTickFreq);
  374. }
  375. while ((HAL_GetTick() - tickstart) < wait)
  376. {
  377. }
  378. }
  379. /**
  380. * @brief Suspend Tick increment.
  381. * @note In the default implementation , SysTick timer is the source of time base. It is
  382. * used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
  383. * is called, the the SysTick interrupt will be disabled and so Tick increment
  384. * is suspended.
  385. * @note This function is declared as __weak to be overwritten in case of other
  386. * implementations in user file.
  387. * @retval None
  388. */
  389. __weak void HAL_SuspendTick(void)
  390. {
  391. /* Disable SysTick Interrupt */
  392. SysTick->CTRL &= ~SysTick_CTRL_TICKINT_Msk;
  393. }
  394. /**
  395. * @brief Resume Tick increment.
  396. * @note In the default implementation , SysTick timer is the source of time base. It is
  397. * used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
  398. * is called, the the SysTick interrupt will be enabled and so Tick increment
  399. * is resumed.
  400. * @note This function is declared as __weak to be overwritten in case of other
  401. * implementations in user file.
  402. * @retval None
  403. */
  404. __weak void HAL_ResumeTick(void)
  405. {
  406. /* Enable SysTick Interrupt */
  407. SysTick->CTRL |= SysTick_CTRL_TICKINT_Msk;
  408. }
  409. /**
  410. * @brief Returns the HAL revision
  411. * @retval version : 0xXYZR (8bits for each decimal, R for RC)
  412. */
  413. uint32_t HAL_GetHalVersion(void)
  414. {
  415. return __STM32H7xx_HAL_VERSION;
  416. }
  417. /**
  418. * @brief Returns the device revision identifier.
  419. * @retval Device revision identifier
  420. */
  421. uint32_t HAL_GetREVID(void)
  422. {
  423. return((DBGMCU->IDCODE) >> 16);
  424. }
  425. /**
  426. * @brief Returns the device identifier.
  427. * @retval Device identifier
  428. */
  429. uint32_t HAL_GetDEVID(void)
  430. {
  431. return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
  432. }
  433. /**
  434. * @brief Return the first word of the unique device identifier (UID based on 96 bits)
  435. * @retval Device identifier
  436. */
  437. uint32_t HAL_GetUIDw0(void)
  438. {
  439. return(READ_REG(*((uint32_t *)UID_BASE)));
  440. }
  441. /**
  442. * @brief Return the second word of the unique device identifier (UID based on 96 bits)
  443. * @retval Device identifier
  444. */
  445. uint32_t HAL_GetUIDw1(void)
  446. {
  447. return(READ_REG(*((uint32_t *)(UID_BASE + 4U))));
  448. }
  449. /**
  450. * @brief Return the third word of the unique device identifier (UID based on 96 bits)
  451. * @retval Device identifier
  452. */
  453. uint32_t HAL_GetUIDw2(void)
  454. {
  455. return(READ_REG(*((uint32_t *)(UID_BASE + 8U))));
  456. }
  457. /**
  458. * @brief Configure the internal voltage reference buffer voltage scale.
  459. * @param VoltageScaling specifies the output voltage to achieve
  460. * This parameter can be one of the following values:
  461. * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE0: VREF_OUT1 around 2.048 V.
  462. * This requires VDDA equal to or higher than 2.4 V.
  463. * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE1: VREF_OUT2 around 2.5 V.
  464. * This requires VDDA equal to or higher than 2.8 V.
  465. * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE2: VREF_OUT3 around 1.5 V.
  466. * This requires VDDA equal to or higher than 1.8 V.
  467. * @arg SYSCFG_VREFBUF_VOLTAGE_SCALE3: VREF_OUT4 around 1.8 V.
  468. * This requires VDDA equal to or higher than 2.1 V.
  469. * @retval None
  470. */
  471. void HAL_SYSCFG_VREFBUF_VoltageScalingConfig(uint32_t VoltageScaling)
  472. {
  473. /* Check the parameters */
  474. assert_param(IS_SYSCFG_VREFBUF_VOLTAGE_SCALE(VoltageScaling));
  475. MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_VRS, VoltageScaling);
  476. }
  477. /**
  478. * @brief Configure the internal voltage reference buffer high impedance mode.
  479. * @param Mode specifies the high impedance mode
  480. * This parameter can be one of the following values:
  481. * @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_DISABLE: VREF+ pin is internally connect to VREFINT output.
  482. * @arg SYSCFG_VREFBUF_HIGH_IMPEDANCE_ENABLE: VREF+ pin is high impedance.
  483. * @retval None
  484. */
  485. void HAL_SYSCFG_VREFBUF_HighImpedanceConfig(uint32_t Mode)
  486. {
  487. /* Check the parameters */
  488. assert_param(IS_SYSCFG_VREFBUF_HIGH_IMPEDANCE(Mode));
  489. MODIFY_REG(VREFBUF->CSR, VREFBUF_CSR_HIZ, Mode);
  490. }
  491. /**
  492. * @brief Tune the Internal Voltage Reference buffer (VREFBUF).
  493. * @retval None
  494. */
  495. void HAL_SYSCFG_VREFBUF_TrimmingConfig(uint32_t TrimmingValue)
  496. {
  497. /* Check the parameters */
  498. assert_param(IS_SYSCFG_VREFBUF_TRIMMING(TrimmingValue));
  499. MODIFY_REG(VREFBUF->CCR, VREFBUF_CCR_TRIM, TrimmingValue);
  500. }
  501. /**
  502. * @brief Enable the Internal Voltage Reference buffer (VREFBUF).
  503. * @retval HAL_OK/HAL_TIMEOUT
  504. */
  505. HAL_StatusTypeDef HAL_SYSCFG_EnableVREFBUF(void)
  506. {
  507. uint32_t tickstart;
  508. SET_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR);
  509. /* Get Start Tick*/
  510. tickstart = HAL_GetTick();
  511. /* Wait for VRR bit */
  512. while(READ_BIT(VREFBUF->CSR, VREFBUF_CSR_VRR) == 0UL)
  513. {
  514. if((HAL_GetTick() - tickstart) > VREFBUF_TIMEOUT_VALUE)
  515. {
  516. return HAL_TIMEOUT;
  517. }
  518. }
  519. return HAL_OK;
  520. }
  521. /**
  522. * @brief Disable the Internal Voltage Reference buffer (VREFBUF).
  523. *
  524. * @retval None
  525. */
  526. void HAL_SYSCFG_DisableVREFBUF(void)
  527. {
  528. CLEAR_BIT(VREFBUF->CSR, VREFBUF_CSR_ENVR);
  529. }
  530. #if defined(SYSCFG_PMCR_EPIS_SEL)
  531. /**
  532. * @brief Ethernet PHY Interface Selection either MII or RMII
  533. * @param SYSCFG_ETHInterface: Selects the Ethernet PHY interface
  534. * This parameter can be one of the following values:
  535. * @arg SYSCFG_ETH_MII : Select the Media Independent Interface
  536. * @arg SYSCFG_ETH_RMII: Select the Reduced Media Independent Interface
  537. * @retval None
  538. */
  539. void HAL_SYSCFG_ETHInterfaceSelect(uint32_t SYSCFG_ETHInterface)
  540. {
  541. /* Check the parameter */
  542. assert_param(IS_SYSCFG_ETHERNET_CONFIG(SYSCFG_ETHInterface));
  543. MODIFY_REG(SYSCFG->PMCR, SYSCFG_PMCR_EPIS_SEL, (uint32_t)(SYSCFG_ETHInterface));
  544. }
  545. #endif /* SYSCFG_PMCR_EPIS_SEL */
  546. /**
  547. * @brief Analog Switch control for dual analog pads.
  548. * @param SYSCFG_AnalogSwitch: Selects the analog pad
  549. * This parameter can be one or a combination of the following values:
  550. * @arg SYSCFG_SWITCH_PA0 : Select PA0 analog switch
  551. * @arg SYSCFG_SWITCH_PA1: Select PA1 analog switch
  552. * @arg SYSCFG_SWITCH_PC2 : Select PC2 analog switch
  553. * @arg SYSCFG_SWITCH_PC3: Select PC3 analog switch
  554. * @param SYSCFG_SwitchState: Open or Close the analog switch between dual pads (PXn and PXn_C)
  555. * This parameter can be one or a combination of the following values:
  556. * @arg SYSCFG_SWITCH_PA0_OPEN
  557. * @arg SYSCFG_SWITCH_PA0_CLOSE
  558. * @arg SYSCFG_SWITCH_PA1_OPEN
  559. * @arg SYSCFG_SWITCH_PA1_CLOSE
  560. * @arg SYSCFG_SWITCH_PC2_OPEN
  561. * @arg SYSCFG_SWITCH_PC2_CLOSE
  562. * @arg SYSCFG_SWITCH_PC3_OPEN
  563. * @arg SYSCFG_SWITCH_PC3_CLOSE
  564. * @retval None
  565. */
  566. void HAL_SYSCFG_AnalogSwitchConfig(uint32_t SYSCFG_AnalogSwitch , uint32_t SYSCFG_SwitchState )
  567. {
  568. /* Check the parameter */
  569. assert_param(IS_SYSCFG_ANALOG_SWITCH(SYSCFG_AnalogSwitch));
  570. assert_param(IS_SYSCFG_SWITCH_STATE(SYSCFG_SwitchState));
  571. MODIFY_REG(SYSCFG->PMCR, (uint32_t) SYSCFG_AnalogSwitch, (uint32_t)(SYSCFG_SwitchState));
  572. }
  573. #if defined(SYSCFG_PMCR_BOOSTEN)
  574. /**
  575. * @brief Enables the booster to reduce the total harmonic distortion of the analog
  576. * switch when the supply voltage is lower than 2.7 V.
  577. * @note Activating the booster allows to guaranty the analog switch AC performance
  578. * when the supply voltage is below 2.7 V: in this case, the analog switch
  579. * performance is the same on the full voltage range
  580. * @retval None
  581. */
  582. void HAL_SYSCFG_EnableBOOST(void)
  583. {
  584. SET_BIT(SYSCFG->PMCR, SYSCFG_PMCR_BOOSTEN) ;
  585. }
  586. /**
  587. * @brief Disables the booster
  588. * @note Activating the booster allows to guaranty the analog switch AC performance
  589. * when the supply voltage is below 2.7 V: in this case, the analog switch
  590. * performance is the same on the full voltage range
  591. * @retval None
  592. */
  593. void HAL_SYSCFG_DisableBOOST(void)
  594. {
  595. CLEAR_BIT(SYSCFG->PMCR, SYSCFG_PMCR_BOOSTEN) ;
  596. }
  597. #endif /* SYSCFG_PMCR_BOOSTEN */
  598. #if defined (SYSCFG_UR2_BOOT_ADD0) || defined (SYSCFG_UR2_BCM7_ADD0)
  599. /**
  600. * @brief BootCM7 address 0 configuration
  601. * @param BootRegister :Specifies the Boot Address register (Address0 or Address1)
  602. * This parameter can be one of the following values:
  603. * @arg SYSCFG_BOOT_ADDR0 : Select the boot address0
  604. * @arg SYSCFG_BOOT_ADDR1: Select the boot address1
  605. * @param BootAddress :Specifies the CM7 Boot Address to be loaded in Address0 or Address1
  606. * @retval None
  607. */
  608. void HAL_SYSCFG_CM7BootAddConfig(uint32_t BootRegister, uint32_t BootAddress)
  609. {
  610. /* Check the parameters */
  611. assert_param(IS_SYSCFG_BOOT_REGISTER(BootRegister));
  612. assert_param(IS_SYSCFG_BOOT_ADDRESS(BootAddress));
  613. if ( BootRegister == SYSCFG_BOOT_ADDR0 )
  614. {
  615. /* Configure CM7 BOOT ADD0 */
  616. #if defined(DUAL_CORE)
  617. MODIFY_REG(SYSCFG->UR2, SYSCFG_UR2_BCM7_ADD0, ((BootAddress >> 16) << SYSCFG_UR2_BCM7_ADD0_Pos));
  618. #else
  619. MODIFY_REG(SYSCFG->UR2, SYSCFG_UR2_BOOT_ADD0, ((BootAddress >> 16) << SYSCFG_UR2_BOOT_ADD0_Pos));
  620. #endif /*DUAL_CORE*/
  621. }
  622. else
  623. {
  624. /* Configure CM7 BOOT ADD1 */
  625. #if defined(DUAL_CORE)
  626. MODIFY_REG(SYSCFG->UR3, SYSCFG_UR3_BCM7_ADD1, (BootAddress >> 16));
  627. #else
  628. MODIFY_REG(SYSCFG->UR3, SYSCFG_UR3_BOOT_ADD1, (BootAddress >> 16));
  629. #endif /*DUAL_CORE*/
  630. }
  631. }
  632. #endif /* SYSCFG_UR2_BOOT_ADD0 || SYSCFG_UR2_BCM7_ADD0 */
  633. #if defined(DUAL_CORE)
  634. /**
  635. * @brief BootCM4 address 0 configuration
  636. * @param BootRegister :Specifies the Boot Address register (Address0 or Address1)
  637. * This parameter can be one of the following values:
  638. * @arg SYSCFG_BOOT_ADDR0 : Select the boot address0
  639. * @arg SYSCFG_BOOT_ADDR1: Select the boot address1
  640. * @param BootAddress :Specifies the CM4 Boot Address to be loaded in Address0 or Address1
  641. * @retval None
  642. */
  643. void HAL_SYSCFG_CM4BootAddConfig(uint32_t BootRegister, uint32_t BootAddress)
  644. {
  645. /* Check the parameters */
  646. assert_param(IS_SYSCFG_BOOT_REGISTER(BootRegister));
  647. assert_param(IS_SYSCFG_BOOT_ADDRESS(BootAddress));
  648. if ( BootRegister == SYSCFG_BOOT_ADDR0 )
  649. {
  650. /* Configure CM4 BOOT ADD0 */
  651. MODIFY_REG(SYSCFG->UR3, SYSCFG_UR3_BCM4_ADD0, ((BootAddress >> 16)<< SYSCFG_UR3_BCM4_ADD0_Pos));
  652. }
  653. else
  654. {
  655. /* Configure CM4 BOOT ADD1 */
  656. MODIFY_REG(SYSCFG->UR4, SYSCFG_UR4_BCM4_ADD1, (BootAddress >> 16));
  657. }
  658. }
  659. /**
  660. * @brief Enables the Cortex-M7 boot
  661. * @retval None
  662. */
  663. void HAL_SYSCFG_EnableCM7BOOT(void)
  664. {
  665. SET_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM7);
  666. }
  667. /**
  668. * @brief Disables the Cortex-M7 boot
  669. * @note Disabling the boot will gate the CPU clock
  670. * @retval None
  671. */
  672. void HAL_SYSCFG_DisableCM7BOOT(void)
  673. {
  674. CLEAR_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM7) ;
  675. }
  676. /**
  677. * @brief Enables the Cortex-M4 boot
  678. * @retval None
  679. */
  680. void HAL_SYSCFG_EnableCM4BOOT(void)
  681. {
  682. SET_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM4);
  683. }
  684. /**
  685. * @brief Disables the Cortex-M4 boot
  686. * @note Disabling the boot will gate the CPU clock
  687. * @retval None
  688. */
  689. void HAL_SYSCFG_DisableCM4BOOT(void)
  690. {
  691. CLEAR_BIT(SYSCFG->UR1, SYSCFG_UR1_BCM4);
  692. }
  693. #endif /*DUAL_CORE*/
  694. /**
  695. * @brief Enables the I/O Compensation Cell.
  696. * @note The I/O compensation cell can be used only when the device supply
  697. * voltage ranges from 2.4 to 3.6 V.
  698. * @retval None
  699. */
  700. void HAL_EnableCompensationCell(void)
  701. {
  702. SET_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_EN) ;
  703. }
  704. /**
  705. * @brief Power-down the I/O Compensation Cell.
  706. * @note The I/O compensation cell can be used only when the device supply
  707. * voltage ranges from 2.4 to 3.6 V.
  708. * @retval None
  709. */
  710. void HAL_DisableCompensationCell(void)
  711. {
  712. CLEAR_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_EN);
  713. }
  714. /**
  715. * @brief To Enable optimize the I/O speed when the product voltage is low.
  716. * @note This bit is active only if PRODUCT_BELOW_25V user option bit is set. It must be
  717. * used only if the product supply voltage is below 2.5 V. Setting this bit when VDD is
  718. * higher than 2.5 V might be destructive.
  719. * @retval None
  720. */
  721. void HAL_SYSCFG_EnableIOSpeedOptimize(void)
  722. {
  723. #if defined(SYSCFG_CCCSR_HSLV)
  724. SET_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_HSLV);
  725. #else
  726. SET_BIT(SYSCFG->CCCSR, (SYSCFG_CCCSR_HSLV0| SYSCFG_CCCSR_HSLV1 | SYSCFG_CCCSR_HSLV2 | SYSCFG_CCCSR_HSLV3));
  727. #endif /* SYSCFG_CCCSR_HSLV */
  728. }
  729. /**
  730. * @brief To Disable optimize the I/O speed when the product voltage is low.
  731. * @note This bit is active only if PRODUCT_BELOW_25V user option bit is set. It must be
  732. * used only if the product supply voltage is below 2.5 V. Setting this bit when VDD is
  733. * higher than 2.5 V might be destructive.
  734. * @retval None
  735. */
  736. void HAL_SYSCFG_DisableIOSpeedOptimize(void)
  737. {
  738. #if defined(SYSCFG_CCCSR_HSLV)
  739. CLEAR_BIT(SYSCFG->CCCSR, SYSCFG_CCCSR_HSLV);
  740. #else
  741. CLEAR_BIT(SYSCFG->CCCSR, (SYSCFG_CCCSR_HSLV0| SYSCFG_CCCSR_HSLV1 | SYSCFG_CCCSR_HSLV2 | SYSCFG_CCCSR_HSLV3));
  742. #endif /* SYSCFG_CCCSR_HSLV */
  743. }
  744. /**
  745. * @brief Code selection for the I/O Compensation cell
  746. * @param SYSCFG_CompCode: Selects the code to be applied for the I/O compensation cell
  747. * This parameter can be one of the following values:
  748. * @arg SYSCFG_CELL_CODE : Select Code from the cell (available in the SYSCFG_CCVR)
  749. * @arg SYSCFG_REGISTER_CODE: Select Code from the SYSCFG compensation cell code register (SYSCFG_CCCR)
  750. * @retval None
  751. */
  752. void HAL_SYSCFG_CompensationCodeSelect(uint32_t SYSCFG_CompCode)
  753. {
  754. /* Check the parameter */
  755. assert_param(IS_SYSCFG_CODE_SELECT(SYSCFG_CompCode));
  756. MODIFY_REG(SYSCFG->CCCSR, SYSCFG_CCCSR_CS, (uint32_t)(SYSCFG_CompCode));
  757. }
  758. /**
  759. * @brief Code selection for the I/O Compensation cell
  760. * @param SYSCFG_PMOSCode: PMOS compensation code
  761. * This code is applied to the I/O compensation cell when the CS bit of the
  762. * SYSCFG_CMPCR is set
  763. * @param SYSCFG_NMOSCode: NMOS compensation code
  764. * This code is applied to the I/O compensation cell when the CS bit of the
  765. * SYSCFG_CMPCR is set
  766. * @retval None
  767. */
  768. void HAL_SYSCFG_CompensationCodeConfig(uint32_t SYSCFG_PMOSCode, uint32_t SYSCFG_NMOSCode )
  769. {
  770. /* Check the parameter */
  771. assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_PMOSCode));
  772. assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_NMOSCode));
  773. MODIFY_REG(SYSCFG->CCCR, SYSCFG_CCCR_NCC|SYSCFG_CCCR_PCC, (((uint32_t)(SYSCFG_PMOSCode)<< 4)|(uint32_t)(SYSCFG_NMOSCode)) );
  774. }
  775. #if defined(SYSCFG_CCCR_NCC_MMC)
  776. /**
  777. * @brief Code selection for the I/O Compensation cell
  778. * @param SYSCFG_PMOSCode: VDDMMC PMOS compensation code
  779. * This code is applied to the I/O compensation cell when the CS bit of the
  780. * SYSCFG_CMPCR is set
  781. * @param SYSCFG_NMOSCode: VDDMMC NMOS compensation code
  782. * This code is applied to the I/O compensation cell when the CS bit of the
  783. * SYSCFG_CMPCR is set
  784. * @retval None
  785. */
  786. void HAL_SYSCFG_VDDMMC_CompensationCodeConfig(uint32_t SYSCFG_PMOSCode, uint32_t SYSCFG_NMOSCode )
  787. {
  788. /* Check the parameter */
  789. assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_PMOSCode));
  790. assert_param(IS_SYSCFG_CODE_CONFIG(SYSCFG_NMOSCode));
  791. MODIFY_REG(SYSCFG->CCCR, (SYSCFG_CCCR_NCC_MMC | SYSCFG_CCCR_PCC_MMC), (((uint32_t)(SYSCFG_PMOSCode)<< 4)|(uint32_t)(SYSCFG_NMOSCode)) );
  792. }
  793. #endif /* SYSCFG_CCCR_NCC_MMC */
  794. /**
  795. * @brief Enable the Debug Module during Domain1/CDomain SLEEP mode
  796. * @retval None
  797. */
  798. void HAL_EnableDBGSleepMode(void)
  799. {
  800. SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD1);
  801. }
  802. /**
  803. * @brief Disable the Debug Module during Domain1/CDomain SLEEP mode
  804. * @retval None
  805. */
  806. void HAL_DisableDBGSleepMode(void)
  807. {
  808. CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD1);
  809. }
  810. /**
  811. * @brief Enable the Debug Module during Domain1/CDomain STOP mode
  812. * @retval None
  813. */
  814. void HAL_EnableDBGStopMode(void)
  815. {
  816. SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD1);
  817. }
  818. /**
  819. * @brief Disable the Debug Module during Domain1/CDomain STOP mode
  820. * @retval None
  821. */
  822. void HAL_DisableDBGStopMode(void)
  823. {
  824. CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD1);
  825. }
  826. /**
  827. * @brief Enable the Debug Module during Domain1/CDomain STANDBY mode
  828. * @retval None
  829. */
  830. void HAL_EnableDBGStandbyMode(void)
  831. {
  832. SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD1);
  833. }
  834. /**
  835. * @brief Disable the Debug Module during Domain1/CDomain STANDBY mode
  836. * @retval None
  837. */
  838. void HAL_DisableDBGStandbyMode(void)
  839. {
  840. CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD1);
  841. }
  842. #if defined(DUAL_CORE)
  843. /**
  844. * @brief Enable the Debug Module during Domain1 SLEEP mode
  845. * @retval None
  846. */
  847. void HAL_EnableDomain2DBGSleepMode(void)
  848. {
  849. SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD2);
  850. }
  851. /**
  852. * @brief Disable the Debug Module during Domain2 SLEEP mode
  853. * @retval None
  854. */
  855. void HAL_DisableDomain2DBGSleepMode(void)
  856. {
  857. CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEPD2);
  858. }
  859. /**
  860. * @brief Enable the Debug Module during Domain2 STOP mode
  861. * @retval None
  862. */
  863. void HAL_EnableDomain2DBGStopMode(void)
  864. {
  865. SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD2);
  866. }
  867. /**
  868. * @brief Disable the Debug Module during Domain2 STOP mode
  869. * @retval None
  870. */
  871. void HAL_DisableDomain2DBGStopMode(void)
  872. {
  873. CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD2);
  874. }
  875. /**
  876. * @brief Enable the Debug Module during Domain2 STANDBY mode
  877. * @retval None
  878. */
  879. void HAL_EnableDomain2DBGStandbyMode(void)
  880. {
  881. SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD2);
  882. }
  883. /**
  884. * @brief Disable the Debug Module during Domain2 STANDBY mode
  885. * @retval None
  886. */
  887. void HAL_DisableDomain2DBGStandbyMode(void)
  888. {
  889. CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD2);
  890. }
  891. #endif /*DUAL_CORE*/
  892. /**
  893. * @brief Enable the Debug Module during Domain3/SRDomain STOP mode
  894. * @retval None
  895. */
  896. void HAL_EnableDomain3DBGStopMode(void)
  897. {
  898. SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD3);
  899. }
  900. /**
  901. * @brief Disable the Debug Module during Domain3/SRDomain STOP mode
  902. * @retval None
  903. */
  904. void HAL_DisableDomain3DBGStopMode(void)
  905. {
  906. CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOPD3);
  907. }
  908. /**
  909. * @brief Enable the Debug Module during Domain3/SRDomain STANDBY mode
  910. * @retval None
  911. */
  912. void HAL_EnableDomain3DBGStandbyMode(void)
  913. {
  914. SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD3);
  915. }
  916. /**
  917. * @brief Disable the Debug Module during Domain3/SRDomain STANDBY mode
  918. * @retval None
  919. */
  920. void HAL_DisableDomain3DBGStandbyMode(void)
  921. {
  922. CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBYD3);
  923. }
  924. /**
  925. * @brief Set the FMC Memory Mapping Swapping config.
  926. * @param BankMapConfig: Defines the FMC Bank mapping configuration. This parameter can be
  927. FMC_SWAPBMAP_DISABLE, FMC_SWAPBMAP_SDRAM_SRAM, FMC_SWAPBMAP_SDRAMB2
  928. * @retval HAL state
  929. */
  930. void HAL_SetFMCMemorySwappingConfig(uint32_t BankMapConfig)
  931. {
  932. /* Check the parameter */
  933. assert_param(IS_FMC_SWAPBMAP_MODE(BankMapConfig));
  934. MODIFY_REG(FMC_Bank1_R->BTCR[0], FMC_BCR1_BMAP, BankMapConfig);
  935. }
  936. /**
  937. * @brief Get FMC Bank mapping mode.
  938. * @retval The FMC Bank mapping mode. This parameter can be
  939. FMC_SWAPBMAP_DISABLE, FMC_SWAPBMAP_SDRAM_SRAM, FMC_SWAPBMAP_SDRAMB2
  940. */
  941. uint32_t HAL_GetFMCMemorySwappingConfig(void)
  942. {
  943. return READ_BIT(FMC_Bank1_R->BTCR[0], FMC_BCR1_BMAP);
  944. }
  945. /**
  946. * @brief Configure the EXTI input event line edge
  947. * @note No edge configuration for direct lines but for configurable lines:(EXTI_LINE0..EXTI_LINE21),
  948. * EXTI_LINE49,EXTI_LINE51,EXTI_LINE82,EXTI_LINE84,EXTI_LINE85 and EXTI_LINE86.
  949. * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
  950. * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
  951. * @param EXTI_Edge: Specifies EXTI line Edge used.
  952. * This parameter can be one of the following values :
  953. * @arg EXTI_RISING_EDGE : Configurable line, with Rising edge trigger detection
  954. * @arg EXTI_FALLING_EDGE: Configurable line, with Falling edge trigger detection
  955. * @retval None
  956. */
  957. void HAL_EXTI_EdgeConfig(uint32_t EXTI_Line , uint32_t EXTI_Edge )
  958. {
  959. /* Check the parameter */
  960. assert_param(IS_HAL_EXTI_CONFIG_LINE(EXTI_Line));
  961. assert_param(IS_EXTI_EDGE_LINE(EXTI_Edge));
  962. /* Clear Rising Falling edge configuration */
  963. CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->FTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
  964. CLEAR_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI->RTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
  965. if( (EXTI_Edge & EXTI_RISING_EDGE) == EXTI_RISING_EDGE)
  966. {
  967. SET_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI->RTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
  968. }
  969. if( (EXTI_Edge & EXTI_FALLING_EDGE) == EXTI_FALLING_EDGE)
  970. {
  971. SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->FTSR1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
  972. }
  973. }
  974. /**
  975. * @brief Generates a Software interrupt on selected EXTI line.
  976. * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
  977. * (EXTI_LINE0..EXTI_LINE21),EXTI_LINE49,EXTI_LINE51,EXTI_LINE82,EXTI_LINE84,EXTI_LINE85 and EXTI_LINE86.
  978. * @retval None
  979. */
  980. void HAL_EXTI_GenerateSWInterrupt(uint32_t EXTI_Line)
  981. {
  982. /* Check the parameters */
  983. assert_param(IS_HAL_EXTI_CONFIG_LINE(EXTI_Line));
  984. SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->SWIER1)) + ((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
  985. }
  986. /**
  987. * @brief Clears the EXTI's line pending flags for Domain D1
  988. * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
  989. * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
  990. * @retval None
  991. */
  992. void HAL_EXTI_D1_ClearFlag(uint32_t EXTI_Line)
  993. {
  994. /* Check the parameters */
  995. assert_param(IS_EXTI_D1_LINE(EXTI_Line));
  996. WRITE_REG(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->PR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
  997. }
  998. #if defined(DUAL_CORE)
  999. /**
  1000. * @brief Clears the EXTI's line pending flags for Domain D2
  1001. * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
  1002. * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
  1003. * @retval None
  1004. */
  1005. void HAL_EXTI_D2_ClearFlag(uint32_t EXTI_Line)
  1006. {
  1007. /* Check the parameters */
  1008. assert_param(IS_EXTI_D2_LINE(EXTI_Line));
  1009. WRITE_REG(*(__IO uint32_t *) (((uint32_t) &(EXTI_D2->PR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
  1010. }
  1011. #endif /*DUAL_CORE*/
  1012. /**
  1013. * @brief Configure the EXTI input event line for Domain D1
  1014. * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
  1015. * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
  1016. * @param EXTI_Mode: Specifies which EXTI line is used as interrupt or an event.
  1017. * This parameter can be one or a combination of the following values :
  1018. * @arg EXTI_MODE_IT : Interrupt Mode selected
  1019. * @arg EXTI_MODE_EVT : Event Mode selected
  1020. * @param EXTI_LineCmd controls (Enable/Disable) the EXTI line.
  1021. * @retval None
  1022. */
  1023. void HAL_EXTI_D1_EventInputConfig(uint32_t EXTI_Line , uint32_t EXTI_Mode, uint32_t EXTI_LineCmd )
  1024. {
  1025. /* Check the parameter */
  1026. assert_param(IS_EXTI_D1_LINE(EXTI_Line));
  1027. assert_param(IS_EXTI_MODE_LINE(EXTI_Mode));
  1028. if( (EXTI_Mode & EXTI_MODE_IT) == EXTI_MODE_IT)
  1029. {
  1030. if( EXTI_LineCmd == 0UL)
  1031. {
  1032. /* Clear EXTI line configuration */
  1033. CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)),(uint32_t)(1UL << (EXTI_Line & 0x1FUL)) );
  1034. }
  1035. else
  1036. {
  1037. SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D1->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
  1038. }
  1039. }
  1040. if( (EXTI_Mode & EXTI_MODE_EVT) == EXTI_MODE_EVT)
  1041. {
  1042. if( EXTI_LineCmd == 0UL)
  1043. {
  1044. /* Clear EXTI line configuration */
  1045. CLEAR_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI_D1->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
  1046. }
  1047. else
  1048. {
  1049. SET_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI_D1->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
  1050. }
  1051. }
  1052. }
  1053. #if defined(DUAL_CORE)
  1054. /**
  1055. * @brief Configure the EXTI input event line for Domain D2
  1056. * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
  1057. * (EXTI_LINE0....EXTI_LINE87)excluding :line45, line81,line83 which are reserved
  1058. * @param EXTI_Mode: Specifies which EXTI line is used as interrupt or an event.
  1059. * This parameter can be one or a combination of the following values :
  1060. * @arg EXTI_MODE_IT : Interrupt Mode selected
  1061. * @arg EXTI_MODE_EVT : Event Mode selected
  1062. * @param EXTI_LineCmd controls (Enable/Disable) the EXTI line.
  1063. * @retval None
  1064. */
  1065. void HAL_EXTI_D2_EventInputConfig(uint32_t EXTI_Line , uint32_t EXTI_Mode, uint32_t EXTI_LineCmd )
  1066. {
  1067. /* Check the parameter */
  1068. assert_param(IS_EXTI_D2_LINE(EXTI_Line));
  1069. assert_param(IS_EXTI_MODE_LINE(EXTI_Mode));
  1070. if( (EXTI_Mode & EXTI_MODE_IT) == EXTI_MODE_IT)
  1071. {
  1072. if( EXTI_LineCmd == 0UL)
  1073. {
  1074. /* Clear EXTI line configuration */
  1075. CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D2->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)),(uint32_t)(1UL << (EXTI_Line & 0x1FUL)) );
  1076. }
  1077. else
  1078. {
  1079. SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI_D2->IMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
  1080. }
  1081. }
  1082. if( (EXTI_Mode & EXTI_MODE_EVT) == EXTI_MODE_EVT)
  1083. {
  1084. if( EXTI_LineCmd == 0UL)
  1085. {
  1086. /* Clear EXTI line configuration */
  1087. CLEAR_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI_D2->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
  1088. }
  1089. else
  1090. {
  1091. SET_BIT( *(__IO uint32_t *) (((uint32_t) &(EXTI_D2->EMR1)) + ((EXTI_Line >> 5 ) * 0x10UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
  1092. }
  1093. }
  1094. }
  1095. #endif /*DUAL_CORE*/
  1096. /**
  1097. * @brief Configure the EXTI input event line for Domain D3
  1098. * @param EXTI_Line: Specifies the EXTI LINE, it can be one of the following values,
  1099. * (EXTI_LINE0...EXTI_LINE15),(EXTI_LINE19...EXTI_LINE21),EXTI_LINE25, EXTI_LINE34,
  1100. * EXTI_LINE35,EXTI_LINE41,(EXTI_LINE48...EXTI_LINE53)
  1101. * @param EXTI_LineCmd controls (Enable/Disable) the EXTI line.
  1102. * @param EXTI_ClearSrc: Specifies the clear source of D3 pending event.
  1103. * This parameter can be one of the following values :
  1104. * @arg BDMA_CH6_CLEAR : BDMA ch6 event selected as D3 domain pendclear source
  1105. * @arg BDMA_CH7_CLEAR : BDMA ch7 event selected as D3 domain pendclear source
  1106. * @arg LPTIM4_OUT_CLEAR : LPTIM4 out selected as D3 domain pendclear source
  1107. * @arg LPTIM5_OUT_CLEAR : LPTIM5 out selected as D3 domain pendclear source
  1108. * @retval None
  1109. */
  1110. void HAL_EXTI_D3_EventInputConfig(uint32_t EXTI_Line, uint32_t EXTI_LineCmd , uint32_t EXTI_ClearSrc )
  1111. {
  1112. __IO uint32_t *pRegv;
  1113. /* Check the parameter */
  1114. assert_param(IS_EXTI_D3_LINE(EXTI_Line));
  1115. assert_param(IS_EXTI_D3_CLEAR(EXTI_ClearSrc));
  1116. if( EXTI_LineCmd == 0UL)
  1117. {
  1118. /* Clear EXTI line configuration */
  1119. CLEAR_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->D3PMR1)) + ((EXTI_Line >> 5 ) * 0x20UL)),(uint32_t)(1UL << (EXTI_Line & 0x1FUL)) );
  1120. }
  1121. else
  1122. {
  1123. SET_BIT(*(__IO uint32_t *) (((uint32_t) &(EXTI->D3PMR1)) +((EXTI_Line >> 5 ) * 0x20UL)), (uint32_t)(1UL << (EXTI_Line & 0x1FUL)));
  1124. }
  1125. if(((EXTI_Line>>4)%2UL) == 0UL)
  1126. {
  1127. pRegv = (__IO uint32_t *) (((uint32_t) &(EXTI->D3PCR1L)) + ((EXTI_Line >> 5 ) * 0x20UL));
  1128. }
  1129. else
  1130. {
  1131. pRegv = (__IO uint32_t *) (((uint32_t) &(EXTI->D3PCR1H)) + ((EXTI_Line >> 5 ) * 0x20UL));
  1132. }
  1133. MODIFY_REG(*pRegv, (uint32_t)(3UL << ((EXTI_Line*2UL) & 0x1FUL)), (uint32_t)(EXTI_ClearSrc << ((EXTI_Line*2UL) & 0x1FUL)));
  1134. }
  1135. /**
  1136. * @}
  1137. */
  1138. /**
  1139. * @}
  1140. */
  1141. /**
  1142. * @}
  1143. */
  1144. /**
  1145. * @}
  1146. */
  1147. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/