Merge remote-tracking branch 'upstream/master' into abo_RTH_sanity_fix
[inav.git] / src / main / drivers / rcc.h
blob2f8c8928bf4b82e21f0c28491f0e2d90a9f5d523
1 #pragma once
3 #include "rcc_types.h"
5 enum rcc_reg {
6 RCC_EMPTY = 0, // make sure that default value (0) does not enable anything
8 RCC_AHB,
9 RCC_APB2,
10 RCC_APB1,
11 RCC_AHB1,
12 RCC_AHB2,
13 RCC_APB1L,
14 RCC_APB1H,
15 RCC_AHB3,
16 RCC_APB3,
17 RCC_AHB4,
18 RCC_APB4
21 #define RCC_ENCODE(reg, mask) (((reg) << 5) | LOG2_32BIT(mask))
22 #define RCC_AHB(periph) RCC_ENCODE(RCC_AHB, RCC_AHBENR_ ## periph ## EN)
23 #define RCC_AHB1(periph) RCC_ENCODE(RCC_AHB1, RCC_AHB1ENR_ ## periph ## EN)
24 #define RCC_APB1(periph) RCC_ENCODE(RCC_APB1, RCC_APB1ENR_ ## periph ## EN)
25 #define RCC_APB2(periph) RCC_ENCODE(RCC_APB2, RCC_APB2ENR_ ## periph ## EN)
27 #ifdef STM32H7
28 #define RCC_AHB2(periph) RCC_ENCODE(RCC_AHB2, RCC_AHB2ENR_ ## periph ## EN)
29 #define RCC_AHB3(periph) RCC_ENCODE(RCC_AHB3, RCC_AHB3ENR_ ## periph ## EN)
30 #define RCC_AHB4(periph) RCC_ENCODE(RCC_AHB4, RCC_AHB4ENR_ ## periph ## EN)
31 #define RCC_APB1L(periph) RCC_ENCODE(RCC_APB1L, RCC_APB1LENR_ ## periph ## EN)
32 #define RCC_APB1H(periph) RCC_ENCODE(RCC_APB1H, RCC_APB1HENR_ ## periph ## EN)
33 #define RCC_APB3(periph) RCC_ENCODE(RCC_APB3, RCC_APB3ENR_ ## periph ## EN)
34 #define RCC_APB4(periph) RCC_ENCODE(RCC_APB4, RCC_APB4ENR_ ## periph ## EN)
35 #endif
37 void RCC_ClockCmd(rccPeriphTag_t periphTag, FunctionalState NewState);
38 void RCC_ResetCmd(rccPeriphTag_t periphTag, FunctionalState NewState);