|
1 | | -/** |
2 | | - ****************************************************************************** |
3 | | - * @file clock.c |
4 | | - * @author WI6LABS |
5 | | - * @version V1.0.0 |
6 | | - * @date 01-August-2016 |
7 | | - * @brief provide clock services for time purpose |
8 | | - * |
9 | | - ****************************************************************************** |
10 | | - * @attention |
11 | | - * |
12 | | - * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
13 | | - * |
14 | | - * Redistribution and use in source and binary forms, with or without modification, |
15 | | - * are permitted provided that the following conditions are met: |
16 | | - * 1. Redistributions of source code must retain the above copyright notice, |
17 | | - * this list of conditions and the following disclaimer. |
18 | | - * 2. Redistributions in binary form must reproduce the above copyright notice, |
19 | | - * this list of conditions and the following disclaimer in the documentation |
20 | | - * and/or other materials provided with the distribution. |
21 | | - * 3. Neither the name of STMicroelectronics nor the names of its contributors |
22 | | - * may be used to endorse or promote products derived from this software |
23 | | - * without specific prior written permission. |
24 | | - * |
25 | | - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
26 | | - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
27 | | - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
28 | | - * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
29 | | - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
30 | | - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
31 | | - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
32 | | - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
33 | | - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
34 | | - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
35 | | - * |
36 | | - ****************************************************************************** |
37 | | - */ |
| 1 | +/* |
| 2 | + ******************************************************************************* |
| 3 | + * Copyright (c) 2016-2021, STMicroelectronics |
| 4 | + * All rights reserved. |
| 5 | + * |
| 6 | + * This software component is licensed by ST under BSD 3-Clause license, |
| 7 | + * the "License"; You may not use this file except in compliance with the |
| 8 | + * License. You may obtain a copy of the License at: |
| 9 | + * opensource.org/licenses/BSD-3-Clause |
| 10 | + * |
| 11 | + ******************************************************************************* |
| 12 | + */ |
38 | 13 | #include "backup.h" |
39 | 14 | #include "clock.h" |
| 15 | +#include "otp.h" |
40 | 16 | #include "stm32yyxx_ll_cortex.h" |
| 17 | +#include "stm32yyxx_ll_rcc.h" |
41 | 18 |
|
42 | 19 | #ifdef __cplusplus |
43 | 20 | extern "C" { |
@@ -160,6 +137,18 @@ void enableClock(sourceClock_t source) |
160 | 137 | } |
161 | 138 | } |
162 | 139 |
|
| 140 | +void configHSECapacitorTuning(void) |
| 141 | +{ |
| 142 | +#if defined(OTP_AREA_BASE) && defined(STM32WBxx) |
| 143 | + OTP_BT_t *p_otp; |
| 144 | + /* Read HSE_Tuning from OTP with index 0 */ |
| 145 | + p_otp = (OTP_BT_t *) OTP_Read(0); |
| 146 | + if ((p_otp) && (!LL_RCC_HSE_IsReady())) { |
| 147 | + LL_RCC_HSE_SetCapacitorTuning(p_otp->hse_tuning); |
| 148 | + } |
| 149 | +#endif |
| 150 | +} |
| 151 | + |
163 | 152 | #ifdef __cplusplus |
164 | 153 | } |
165 | 154 | #endif |
|
0 commit comments