2021-08-08 18:03:25 +00:00
|
|
|
#pragma once
|
|
|
|
|
2023-09-19 14:22:21 +00:00
|
|
|
#include <stm32wbxx_ll_rcc.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
|
2022-09-14 16:11:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2022-09-28 16:37:24 +00:00
|
|
|
typedef enum {
|
|
|
|
FuriHalClockMcoLse,
|
|
|
|
FuriHalClockMcoSysclk,
|
|
|
|
FuriHalClockMcoMsi100k,
|
|
|
|
FuriHalClockMcoMsi200k,
|
|
|
|
FuriHalClockMcoMsi400k,
|
|
|
|
FuriHalClockMcoMsi800k,
|
|
|
|
FuriHalClockMcoMsi1m,
|
|
|
|
FuriHalClockMcoMsi2m,
|
|
|
|
FuriHalClockMcoMsi4m,
|
|
|
|
FuriHalClockMcoMsi8m,
|
|
|
|
FuriHalClockMcoMsi16m,
|
|
|
|
FuriHalClockMcoMsi24m,
|
|
|
|
FuriHalClockMcoMsi32m,
|
|
|
|
FuriHalClockMcoMsi48m,
|
|
|
|
} FuriHalClockMcoSourceId;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
FuriHalClockMcoDiv1 = LL_RCC_MCO1_DIV_1,
|
|
|
|
FuriHalClockMcoDiv2 = LL_RCC_MCO1_DIV_2,
|
|
|
|
FuriHalClockMcoDiv4 = LL_RCC_MCO1_DIV_4,
|
|
|
|
FuriHalClockMcoDiv8 = LL_RCC_MCO1_DIV_8,
|
|
|
|
FuriHalClockMcoDiv16 = LL_RCC_MCO1_DIV_16,
|
|
|
|
} FuriHalClockMcoDivisorId;
|
|
|
|
|
2022-04-13 20:50:25 +00:00
|
|
|
/** Early initialization */
|
2024-03-19 14:43:52 +00:00
|
|
|
void furi_hal_clock_init_early(void);
|
2022-04-13 20:50:25 +00:00
|
|
|
|
|
|
|
/** Early deinitialization */
|
2024-03-19 14:43:52 +00:00
|
|
|
void furi_hal_clock_deinit_early(void);
|
2022-04-13 20:50:25 +00:00
|
|
|
|
2021-08-08 18:03:25 +00:00
|
|
|
/** Initialize clocks */
|
2024-03-19 14:43:52 +00:00
|
|
|
void furi_hal_clock_init(void);
|
2021-08-08 18:03:25 +00:00
|
|
|
|
2023-09-19 14:22:21 +00:00
|
|
|
/** Switch clock from HSE to HSI */
|
2024-03-19 14:43:52 +00:00
|
|
|
void furi_hal_clock_switch_hse2hsi(void);
|
2023-09-19 14:22:21 +00:00
|
|
|
|
|
|
|
/** Switch clock from HSI to HSE */
|
2024-03-19 14:43:52 +00:00
|
|
|
void furi_hal_clock_switch_hsi2hse(void);
|
2023-09-19 14:22:21 +00:00
|
|
|
|
|
|
|
/** Switch clock from HSE to PLL
|
|
|
|
*
|
|
|
|
* @return true if changed, false if failed or not possible at this moment
|
|
|
|
*/
|
2024-03-19 14:43:52 +00:00
|
|
|
bool furi_hal_clock_switch_hse2pll(void);
|
2021-08-08 18:03:25 +00:00
|
|
|
|
2023-09-19 14:22:21 +00:00
|
|
|
/** Switch clock from PLL to HSE
|
|
|
|
*
|
|
|
|
* @return true if changed, false if failed or not possible at this moment
|
|
|
|
*/
|
2024-03-19 14:43:52 +00:00
|
|
|
bool furi_hal_clock_switch_pll2hse(void);
|
2022-04-21 13:15:19 +00:00
|
|
|
|
|
|
|
/** Stop SysTick counter without resetting */
|
2024-03-19 14:43:52 +00:00
|
|
|
void furi_hal_clock_suspend_tick(void);
|
2022-04-21 13:15:19 +00:00
|
|
|
|
|
|
|
/** Continue SysTick counter operation */
|
2024-03-19 14:43:52 +00:00
|
|
|
void furi_hal_clock_resume_tick(void);
|
2022-09-14 16:11:38 +00:00
|
|
|
|
2022-09-28 16:37:24 +00:00
|
|
|
/** Enable clock output on MCO pin
|
|
|
|
*
|
|
|
|
* @param source MCO clock source
|
|
|
|
* @param div MCO clock division
|
|
|
|
*/
|
|
|
|
void furi_hal_clock_mco_enable(FuriHalClockMcoSourceId source, FuriHalClockMcoDivisorId div);
|
|
|
|
|
|
|
|
/** Disable clock output on MCO pin */
|
2024-03-19 14:43:52 +00:00
|
|
|
void furi_hal_clock_mco_disable(void);
|
2022-09-28 16:37:24 +00:00
|
|
|
|
2022-09-14 16:11:38 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|