annotate Common/Drivers/STM32F4xx_HAL_DRIVER_v120/Src/stm32f4xx_hal_rcc_ex.c @ 75:2b3f8ed4a0b8

Update version info
author Ideenmodellierer
date Thu, 04 Oct 2018 20:41:21 +0200
parents 5f11787b4f42
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
38
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
1 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
2 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
3 * @file stm32f4xx_hal_rcc_ex.c
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
4 * @author MCD Application Team
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
5 * @version V1.2.0
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
6 * @date 26-December-2014
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
7 * @brief Extension RCC HAL module driver.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
8 * This file provides firmware functions to manage the following
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
9 * functionalities RCC extension peripheral:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
10 * + Extended Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
11 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
12 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
13 * @attention
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
14 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
15 * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
16 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
17 * Redistribution and use in source and binary forms, with or without modification,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
18 * are permitted provided that the following conditions are met:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
19 * 1. Redistributions of source code must retain the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
20 * this list of conditions and the following disclaimer.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
21 * 2. Redistributions in binary form must reproduce the above copyright notice,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
22 * this list of conditions and the following disclaimer in the documentation
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
23 * and/or other materials provided with the distribution.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
24 * 3. Neither the name of STMicroelectronics nor the names of its contributors
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
25 * may be used to endorse or promote products derived from this software
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
26 * without specific prior written permission.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
27 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
28 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
29 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
30 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
31 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
32 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
33 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
34 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
35 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
37 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
38 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
39 ******************************************************************************
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
40 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
41
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
42 /* Includes ------------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
43 #include "stm32f4xx_hal.h"
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
44
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
45 /** @addtogroup STM32F4xx_HAL_Driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
46 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
47 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
48
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
49 /** @defgroup RCCEx RCCEx
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
50 * @brief RCCEx HAL module driver
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
51 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
52 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
53
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
54 #ifdef HAL_RCC_MODULE_ENABLED
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
55
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
56 /* Private typedef -----------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
57 /* Private define ------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
58 /** @addtogroup RCCEx_Private_Constants
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
59 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
60 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
61 #define PLLI2S_TIMEOUT_VALUE 100 /* Timeout value fixed to 100 ms */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
62 #define PLLSAI_TIMEOUT_VALUE 100 /* Timeout value fixed to 100 ms */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
63 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
64 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
65 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
66 /* Private macro -------------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
67 /* Private variables ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
68 /* Private function prototypes -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
69 /* Private functions ---------------------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
70 /** @defgroup RCCEx_Exported_Functions RCCEx Exported Functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
71 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
72 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
73
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
74 /** @defgroup RCCEx_Exported_Functions_Group1 Extended Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
75 * @brief Extended Peripheral Control functions
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
76 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
77 @verbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
78 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
79 ##### Extended Peripheral Control functions #####
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
80 ===============================================================================
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
81 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
82 This subsection provides a set of functions allowing to control the RCC Clocks
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
83 frequencies.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
84 [..]
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
85 (@) Important note: Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
86 select the RTC clock source; in this case the Backup domain will be reset in
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
87 order to modify the RTC Clock source, as consequence RTC registers (including
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
88 the backup registers) and RCC_BDCR register are set to their reset values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
89
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
90 @endverbatim
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
91 * @{
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
92 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
93 #if defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx)|| defined(STM32F439xx)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
94 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
95 * @brief Initializes the RCC extended peripherals clocks according to the specified
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
96 * parameters in the RCC_PeriphCLKInitTypeDef.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
97 * @param PeriphClkInit: pointer to an RCC_PeriphCLKInitTypeDef structure that
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
98 * contains the configuration information for the Extended Peripherals
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
99 * clocks(I2S, SAI, LTDC RTC and TIM).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
100 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
101 * @note Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to select
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
102 * the RTC clock source; in this case the Backup domain will be reset in
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
103 * order to modify the RTC Clock source, as consequence RTC registers (including
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
104 * the backup registers) and RCC_BDCR register are set to their reset values.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
105 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
106 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
107 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
108 HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
109 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
110 uint32_t tickstart = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
111 uint32_t tmpreg = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
112
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
113 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
114 assert_param(IS_RCC_PERIPHCLOCK(PeriphClkInit->PeriphClockSelection));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
115
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
116 /*----------------------- SAI/I2S Configuration (PLLI2S) -------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
117
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
118 /*----------------------- Common configuration SAI/I2S ---------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
119 /* In Case of SAI or I2S Clock Configuration through PLLI2S, PLLI2SN division
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
120 factor is common parameters for both peripherals */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
121 if((((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_I2S) == RCC_PERIPHCLK_I2S) ||
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
122 (((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_SAI_PLLI2S) == RCC_PERIPHCLK_SAI_PLLI2S))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
123 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
124 /* check for Parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
125 assert_param(IS_RCC_PLLI2SN_VALUE(PeriphClkInit->PLLI2S.PLLI2SN));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
126
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
127 /* Disable the PLLI2S */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
128 __HAL_RCC_PLLI2S_DISABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
129 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
130 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
131 /* Wait till PLLI2S is disabled */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
132 while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLI2SRDY) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
133 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
134 if((HAL_GetTick() - tickstart ) > PLLI2S_TIMEOUT_VALUE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
135 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
136 /* return in case of Timeout detected */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
137 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
138 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
139 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
140
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
141 /*---------------------------- I2S configuration -------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
142 /* In Case of I2S Clock Configuration through PLLI2S, PLLI2SR must be added
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
143 only for I2S configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
144 if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_I2S) == (RCC_PERIPHCLK_I2S))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
145 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
146 /* check for Parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
147 assert_param(IS_RCC_PLLI2SR_VALUE(PeriphClkInit->PLLI2S.PLLI2SR));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
148 /* Configure the PLLI2S division factors */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
149 /* PLLI2S_VCO = f(VCO clock) = f(PLLI2S clock input) × (PLLI2SN/PLLM) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
150 /* I2SCLK = f(PLLI2S clock output) = f(VCO clock) / PLLI2SR */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
151 __HAL_RCC_PLLI2S_CONFIG(PeriphClkInit->PLLI2S.PLLI2SN , PeriphClkInit->PLLI2S.PLLI2SR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
152 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
153
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
154 /*---------------------------- SAI configuration -------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
155 /* In Case of SAI Clock Configuration through PLLI2S, PLLI2SQ and PLLI2S_DIVQ must
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
156 be added only for SAI configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
157 if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_SAI_PLLI2S) == (RCC_PERIPHCLK_SAI_PLLI2S))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
158 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
159 /* Check the PLLI2S division factors */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
160 assert_param(IS_RCC_PLLI2SQ_VALUE(PeriphClkInit->PLLI2S.PLLI2SQ));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
161 assert_param(IS_RCC_PLLI2S_DIVQ_VALUE(PeriphClkInit->PLLI2SDivQ));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
162
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
163 /* Read PLLI2SR value from PLLI2SCFGR register (this value is not need for SAI configuration) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
164 tmpreg = ((RCC->PLLI2SCFGR & RCC_PLLI2SCFGR_PLLI2SR) >> POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SR));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
165 /* Configure the PLLI2S division factors */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
166 /* PLLI2S_VCO Input = PLL_SOURCE/PLLM */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
167 /* PLLI2S_VCO Output = PLLI2S_VCO Input * PLLI2SN */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
168 /* SAI_CLK(first level) = PLLI2S_VCO Output/PLLI2SQ */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
169 __HAL_RCC_PLLI2S_SAICLK_CONFIG(PeriphClkInit->PLLI2S.PLLI2SN , PeriphClkInit->PLLI2S.PLLI2SQ , tmpreg);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
170 /* SAI_CLK_x = SAI_CLK(first level)/PLLI2SDIVQ */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
171 __HAL_RCC_PLLI2S_PLLSAICLKDIVQ_CONFIG(PeriphClkInit->PLLI2SDivQ);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
172 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
173
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
174 /* Enable the PLLI2S */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
175 __HAL_RCC_PLLI2S_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
176 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
177 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
178 /* Wait till PLLI2S is ready */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
179 while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLI2SRDY) == RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
180 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
181 if((HAL_GetTick() - tickstart ) > PLLI2S_TIMEOUT_VALUE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
182 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
183 /* return in case of Timeout detected */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
184 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
185 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
186 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
187 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
188
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
189 /*----------------------- SAI/LTDC Configuration (PLLSAI) ------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
190
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
191 /*----------------------- Common configuration SAI/LTDC --------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
192 /* In Case of SAI or LTDC Clock Configuration through PLLSAI, PLLSAIN division
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
193 factor is common parameters for both peripherals */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
194 if((((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_SAI_PLLSAI) == RCC_PERIPHCLK_SAI_PLLSAI) ||
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
195 (((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_LTDC) == RCC_PERIPHCLK_LTDC))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
196 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
197 /* Check the PLLSAI division factors */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
198 assert_param(IS_RCC_PLLSAIN_VALUE(PeriphClkInit->PLLSAI.PLLSAIN));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
199
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
200 /* Disable PLLSAI Clock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
201 __HAL_RCC_PLLSAI_DISABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
202 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
203 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
204 /* Wait till PLLSAI is disabled */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
205 while(__HAL_RCC_PLLSAI_GET_FLAG() != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
206 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
207 if((HAL_GetTick() - tickstart ) > PLLSAI_TIMEOUT_VALUE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
208 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
209 /* return in case of Timeout detected */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
210 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
211 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
212 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
213
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
214 /*---------------------------- SAI configuration -------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
215 /* In Case of SAI Clock Configuration through PLLSAI, PLLSAIQ and PLLSAI_DIVQ must
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
216 be added only for SAI configuration */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
217 if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_SAI_PLLSAI) == (RCC_PERIPHCLK_SAI_PLLSAI))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
218 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
219 assert_param(IS_RCC_PLLSAIQ_VALUE(PeriphClkInit->PLLSAI.PLLSAIQ));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
220 assert_param(IS_RCC_PLLSAI_DIVQ_VALUE(PeriphClkInit->PLLSAIDivQ));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
221
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
222 /* Read PLLSAIR value from PLLSAICFGR register (this value is not need for SAI configuration) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
223 tmpreg = ((RCC->PLLSAICFGR & RCC_PLLSAICFGR_PLLSAIR) >> POSITION_VAL(RCC_PLLSAICFGR_PLLSAIR));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
224 /* PLLSAI_VCO Input = PLL_SOURCE/PLLM */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
225 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
226 /* SAI_CLK(first level) = PLLSAI_VCO Output/PLLSAIQ */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
227 __HAL_RCC_PLLSAI_CONFIG(PeriphClkInit->PLLSAI.PLLSAIN , PeriphClkInit->PLLSAI.PLLSAIQ, tmpreg);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
228 /* SAI_CLK_x = SAI_CLK(first level)/PLLSAIDIVQ */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
229 __HAL_RCC_PLLSAI_PLLSAICLKDIVQ_CONFIG(PeriphClkInit->PLLSAIDivQ);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
230 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
231
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
232 /*---------------------------- LTDC configuration ------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
233 if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_LTDC) == (RCC_PERIPHCLK_LTDC))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
234 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
235 assert_param(IS_RCC_PLLSAIR_VALUE(PeriphClkInit->PLLSAI.PLLSAIR));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
236 assert_param(IS_RCC_PLLSAI_DIVR_VALUE(PeriphClkInit->PLLSAIDivR));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
237
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
238 /* Read PLLSAIR value from PLLSAICFGR register (this value is not need for SAI configuration) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
239 tmpreg = ((RCC->PLLSAICFGR & RCC_PLLSAICFGR_PLLSAIQ) >> POSITION_VAL(RCC_PLLSAICFGR_PLLSAIQ));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
240 /* PLLSAI_VCO Input = PLL_SOURCE/PLLM */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
241 /* PLLSAI_VCO Output = PLLSAI_VCO Input * PLLSAIN */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
242 /* LTDC_CLK(first level) = PLLSAI_VCO Output/PLLSAIR */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
243 __HAL_RCC_PLLSAI_CONFIG(PeriphClkInit->PLLSAI.PLLSAIN , tmpreg, PeriphClkInit->PLLSAI.PLLSAIR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
244 /* LTDC_CLK = LTDC_CLK(first level)/PLLSAIDIVR */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
245 __HAL_RCC_PLLSAI_PLLSAICLKDIVR_CONFIG(PeriphClkInit->PLLSAIDivR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
246 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
247 /* Enable PLLSAI Clock */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
248 __HAL_RCC_PLLSAI_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
249 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
250 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
251 /* Wait till PLLSAI is ready */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
252 while(__HAL_RCC_PLLSAI_GET_FLAG() == RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
253 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
254 if((HAL_GetTick() - tickstart ) > PLLSAI_TIMEOUT_VALUE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
255 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
256 /* return in case of Timeout detected */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
257 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
258 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
259 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
260 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
261
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
262
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
263 /*---------------------------- RTC configuration ---------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
264 if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_RTC) == (RCC_PERIPHCLK_RTC))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
265 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
266 /* Enable Power Clock*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
267 __HAL_RCC_PWR_CLK_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
268
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
269 /* Enable write access to Backup domain */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
270 PWR->CR |= PWR_CR_DBP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
271
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
272 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
273 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
274
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
275 while((PWR->CR & PWR_CR_DBP) == RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
276 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
277 if((HAL_GetTick() - tickstart ) > RCC_DBP_TIMEOUT_VALUE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
278 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
279 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
280 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
281 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
282
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
283 /* Reset the Backup domain only if the RTC Clock source selection is modified */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
284 if((RCC->BDCR & RCC_BDCR_RTCSEL) != (PeriphClkInit->RTCClockSelection & RCC_BDCR_RTCSEL))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
285 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
286 /* Store the content of BDCR register before the reset of Backup Domain */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
287 tmpreg = (RCC->BDCR & ~(RCC_BDCR_RTCSEL));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
288 /* RTC Clock selection can be changed only if the Backup Domain is reset */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
289 __HAL_RCC_BACKUPRESET_FORCE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
290 __HAL_RCC_BACKUPRESET_RELEASE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
291 /* Restore the Content of BDCR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
292 RCC->BDCR = tmpreg;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
293 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
294
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
295 /* If LSE is selected as RTC clock source, wait for LSE reactivation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
296 if(PeriphClkInit->RTCClockSelection == RCC_RTCCLKSOURCE_LSE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
297 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
298 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
299 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
300
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
301 /* Wait till LSE is ready */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
302 while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
303 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
304 if((HAL_GetTick() - tickstart ) > RCC_LSE_TIMEOUT_VALUE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
305 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
306 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
307 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
308 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
309 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
310 __HAL_RCC_RTC_CONFIG(PeriphClkInit->RTCClockSelection);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
311 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
312
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
313 /*---------------------------- TIM configuration ---------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
314 if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_TIM) == (RCC_PERIPHCLK_TIM))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
315 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
316 __HAL_RCC_TIMCLKPRESCALER(PeriphClkInit->TIMPresSelection);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
317 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
318 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
319 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
320
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
321 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
322 * @brief Configures the RCC_OscInitStruct according to the internal
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
323 * RCC configuration registers.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
324 * @param PeriphClkInit: pointer to an RCC_PeriphCLKInitTypeDef structure that
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
325 * will be configured.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
326 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
327 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
328 void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
329 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
330 uint32_t tempreg;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
331
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
332 /* Set all possible values for the extended clock type parameter------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
333 PeriphClkInit->PeriphClockSelection = RCC_PERIPHCLK_I2S | RCC_PERIPHCLK_SAI_PLLSAI | RCC_PERIPHCLK_SAI_PLLI2S | RCC_PERIPHCLK_LTDC | RCC_PERIPHCLK_TIM | RCC_PERIPHCLK_RTC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
334
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
335 /* Get the PLLI2S Clock configuration -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
336 PeriphClkInit->PLLI2S.PLLI2SN = (uint32_t)((RCC->PLLI2SCFGR & RCC_PLLI2SCFGR_PLLI2SN) >> POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SN));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
337 PeriphClkInit->PLLI2S.PLLI2SR = (uint32_t)((RCC->PLLI2SCFGR & RCC_PLLI2SCFGR_PLLI2SR) >> POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SR));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
338 PeriphClkInit->PLLI2S.PLLI2SQ = (uint32_t)((RCC->PLLI2SCFGR & RCC_PLLI2SCFGR_PLLI2SQ) >> POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SQ));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
339 /* Get the PLLSAI Clock configuration -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
340 PeriphClkInit->PLLSAI.PLLSAIN = (uint32_t)((RCC->PLLSAICFGR & RCC_PLLSAICFGR_PLLSAIN) >> POSITION_VAL(RCC_PLLSAICFGR_PLLSAIN));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
341 PeriphClkInit->PLLSAI.PLLSAIR = (uint32_t)((RCC->PLLSAICFGR & RCC_PLLSAICFGR_PLLSAIR) >> POSITION_VAL(RCC_PLLSAICFGR_PLLSAIR));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
342 PeriphClkInit->PLLSAI.PLLSAIQ = (uint32_t)((RCC->PLLSAICFGR & RCC_PLLSAICFGR_PLLSAIQ) >> POSITION_VAL(RCC_PLLSAICFGR_PLLSAIQ));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
343 /* Get the PLLSAI/PLLI2S division factors -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
344 PeriphClkInit->PLLI2SDivQ = (uint32_t)((RCC->DCKCFGR & RCC_DCKCFGR_PLLI2SDIVQ) >> POSITION_VAL(RCC_DCKCFGR_PLLI2SDIVQ));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
345 PeriphClkInit->PLLSAIDivQ = (uint32_t)((RCC->DCKCFGR & RCC_DCKCFGR_PLLSAIDIVQ) >> POSITION_VAL(RCC_DCKCFGR_PLLSAIDIVQ));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
346 PeriphClkInit->PLLSAIDivR = (uint32_t)(RCC->DCKCFGR & RCC_DCKCFGR_PLLSAIDIVR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
347 /* Get the RTC Clock configuration -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
348 tempreg = (RCC->CFGR & RCC_CFGR_RTCPRE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
349 PeriphClkInit->RTCClockSelection = (uint32_t)((tempreg) | (RCC->BDCR & RCC_BDCR_RTCSEL));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
350
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
351 if ((RCC->DCKCFGR & RCC_DCKCFGR_TIMPRE) == RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
352 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
353 PeriphClkInit->TIMPresSelection = RCC_TIMPRES_DESACTIVATED;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
354 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
355 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
356 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
357 PeriphClkInit->TIMPresSelection = RCC_TIMPRES_ACTIVATED;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
358 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
359 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
360 #endif /* STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
361
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
362 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx)|| defined(STM32F417xx) ||\
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
363 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
364 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
365 * @brief Initializes the RCC extended peripherals clocks according to the specified parameters in the
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
366 * RCC_PeriphCLKInitTypeDef.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
367 * @param PeriphClkInit: pointer to an RCC_PeriphCLKInitTypeDef structure that
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
368 * contains the configuration information for the Extended Peripherals clocks(I2S and RTC clocks).
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
369 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
370 * @note A caution to be taken when HAL_RCCEx_PeriphCLKConfig() is used to select RTC clock selection, in this case
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
371 * the Reset of Backup domain will be applied in order to modify the RTC Clock source as consequence all backup
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
372 * domain (RTC and RCC_BDCR register expect BKPSRAM) will be reset
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
373 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
374 * @retval HAL status
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
375 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
376 HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
377 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
378 uint32_t tickstart = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
379 uint32_t tmpreg = 0;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
380
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
381 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
382 assert_param(IS_RCC_PERIPHCLOCK(PeriphClkInit->PeriphClockSelection));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
383
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
384 /*---------------------------- I2S configuration ---------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
385 if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_I2S) == (RCC_PERIPHCLK_I2S))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
386 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
387 /* check for Parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
388 assert_param(IS_RCC_PLLI2SR_VALUE(PeriphClkInit->PLLI2S.PLLI2SR));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
389 assert_param(IS_RCC_PLLI2SN_VALUE(PeriphClkInit->PLLI2S.PLLI2SN));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
390 #if defined(STM32F411xE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
391 assert_param(IS_RCC_PLLI2SM_VALUE(PeriphClkInit->PLLI2S.PLLI2SM));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
392 #endif /* STM32F411xE */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
393 /* Disable the PLLI2S */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
394 __HAL_RCC_PLLI2S_DISABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
395 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
396 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
397 /* Wait till PLLI2S is disabled */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
398 while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLI2SRDY) != RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
399 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
400 if((HAL_GetTick() - tickstart ) > PLLI2S_TIMEOUT_VALUE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
401 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
402 /* return in case of Timeout detected */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
403 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
404 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
405 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
406
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
407 #if defined(STM32F411xE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
408 /* Configure the PLLI2S division factors */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
409 /* PLLI2S_VCO = f(VCO clock) = f(PLLI2S clock input) × (PLLI2SN/PLLI2SM) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
410 /* I2SCLK = f(PLLI2S clock output) = f(VCO clock) / PLLI2SR */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
411 __HAL_RCC_PLLI2S_I2SCLK_CONFIG(PeriphClkInit->PLLI2S.PLLI2SM, PeriphClkInit->PLLI2S.PLLI2SN, PeriphClkInit->PLLI2S.PLLI2SR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
412 #else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
413 /* Configure the PLLI2S division factors */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
414 /* PLLI2S_VCO = f(VCO clock) = f(PLLI2S clock input) × (PLLI2SN/PLLM) */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
415 /* I2SCLK = f(PLLI2S clock output) = f(VCO clock) / PLLI2SR */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
416 __HAL_RCC_PLLI2S_CONFIG(PeriphClkInit->PLLI2S.PLLI2SN , PeriphClkInit->PLLI2S.PLLI2SR);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
417 #endif /* STM32F411xE */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
418
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
419 /* Enable the PLLI2S */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
420 __HAL_RCC_PLLI2S_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
421 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
422 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
423 /* Wait till PLLI2S is ready */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
424 while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLI2SRDY) == RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
425 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
426 if((HAL_GetTick() - tickstart ) > PLLI2S_TIMEOUT_VALUE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
427 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
428 /* return in case of Timeout detected */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
429 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
430 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
431 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
432 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
433
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
434 /*---------------------------- RTC configuration ---------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
435 if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_RTC) == (RCC_PERIPHCLK_RTC))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
436 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
437 /* Enable Power Clock*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
438 __HAL_RCC_PWR_CLK_ENABLE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
439
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
440 /* Enable write access to Backup domain */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
441 PWR->CR |= PWR_CR_DBP;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
442
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
443 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
444 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
445
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
446 while((PWR->CR & PWR_CR_DBP) == RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
447 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
448 if((HAL_GetTick() - tickstart ) > RCC_DBP_TIMEOUT_VALUE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
449 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
450 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
451 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
452 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
453
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
454 /* Reset the Backup domain only if the RTC Clock source selection is modified */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
455 if((RCC->BDCR & RCC_BDCR_RTCSEL) != (PeriphClkInit->RTCClockSelection & RCC_BDCR_RTCSEL))
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
456 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
457 /* Store the content of BDCR register before the reset of Backup Domain */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
458 tmpreg = (RCC->BDCR & ~(RCC_BDCR_RTCSEL));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
459 /* RTC Clock selection can be changed only if the Backup Domain is reset */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
460 __HAL_RCC_BACKUPRESET_FORCE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
461 __HAL_RCC_BACKUPRESET_RELEASE();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
462 /* Restore the Content of BDCR register */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
463 RCC->BDCR = tmpreg;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
464 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
465
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
466 /* If LSE is selected as RTC clock source, wait for LSE reactivation */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
467 if(PeriphClkInit->RTCClockSelection == RCC_RTCCLKSOURCE_LSE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
468 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
469 /* Get tick */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
470 tickstart = HAL_GetTick();
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
471
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
472 /* Wait till LSE is ready */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
473 while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == RESET)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
474 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
475 if((HAL_GetTick() - tickstart ) > RCC_LSE_TIMEOUT_VALUE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
476 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
477 return HAL_TIMEOUT;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
478 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
479 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
480 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
481 __HAL_RCC_RTC_CONFIG(PeriphClkInit->RTCClockSelection);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
482 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
483
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
484 return HAL_OK;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
485 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
486
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
487 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
488 * @brief Configures the RCC_OscInitStruct according to the internal
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
489 * RCC configuration registers.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
490 * @param PeriphClkInit: pointer to an RCC_PeriphCLKInitTypeDef structure that
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
491 * will be configured.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
492 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
493 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
494 void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
495 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
496 uint32_t tempreg;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
497
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
498 /* Set all possible values for the extended clock type parameter------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
499 PeriphClkInit->PeriphClockSelection = RCC_PERIPHCLK_I2S | RCC_PERIPHCLK_RTC;
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
500
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
501 /* Get the PLLI2S Clock configuration -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
502 PeriphClkInit->PLLI2S.PLLI2SN = (uint32_t)((RCC->PLLI2SCFGR & RCC_PLLI2SCFGR_PLLI2SN) >> POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SN));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
503 PeriphClkInit->PLLI2S.PLLI2SR = (uint32_t)((RCC->PLLI2SCFGR & RCC_PLLI2SCFGR_PLLI2SR) >> POSITION_VAL(RCC_PLLI2SCFGR_PLLI2SR));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
504 #if defined(STM32F411xE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
505 PeriphClkInit->PLLI2S.PLLI2SM = (uint32_t)(RCC->PLLI2SCFGR & RCC_PLLI2SCFGR_PLLI2SM);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
506 #endif /* STM32F411xE */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
507 /* Get the RTC Clock configuration -----------------------------------------------*/
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
508 tempreg = (RCC->CFGR & RCC_CFGR_RTCPRE);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
509 PeriphClkInit->RTCClockSelection = (uint32_t)((tempreg) | (RCC->BDCR & RCC_BDCR_RTCSEL));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
510
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
511 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
512 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F401xC || STM32F401xE || STM32F411xE */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
513
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
514 #if defined(STM32F411xE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
515 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
516 * @brief Select LSE mode
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
517 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
518 * @note This mode is only available for STM32F411xx devices.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
519 *
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
520 * @param Mode: specifies the LSE mode.
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
521 * This parameter can be one of the following values:
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
522 * @arg RCC_LSE_LOWPOWER_MODE: LSE oscillator in low power mode selection
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
523 * @arg RCC_LSE_HIGHDRIVE_MODE: LSE oscillator in High Drive mode selection
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
524 * @retval None
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
525 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
526 void HAL_RCCEx_SelectLSEMode(uint8_t Mode)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
527 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
528 /* Check the parameters */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
529 assert_param(IS_RCC_LSE_MODE(Mode));
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
530 if(Mode == RCC_LSE_HIGHDRIVE_MODE)
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
531 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
532 SET_BIT(RCC->BDCR, RCC_BDCR_LSEMOD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
533 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
534 else
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
535 {
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
536 CLEAR_BIT(RCC->BDCR, RCC_BDCR_LSEMOD);
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
537 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
538 }
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
539
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
540 #endif /* STM32F411xE */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
541
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
542 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
543 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
544 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
545
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
546 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
547 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
548 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
549
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
550 #endif /* HAL_RCC_MODULE_ENABLED */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
551 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
552 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
553 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
554
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
555 /**
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
556 * @}
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
557 */
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
558
5f11787b4f42 include in ostc4 repository
heinrichsweikamp
parents:
diff changeset
559 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/