Blackbox device type 'file' (SITL) considered working when file handler is available
[inav.git] / src / main / drivers / rcc.h
blob8e97286b3e8d10b128a5ec357e825b5ff2a35a3a
1 #pragma once
3 #include "rcc_types.h"
4 #include "rcc_at32f43x_periph.h"
6 enum rcc_reg {
7 RCC_EMPTY = 0, // make sure that default value (0) does not enable anything
8 RCC_AHB, //0x20
9 RCC_APB2, //0x40 CRM->apb2en
10 RCC_APB1, //0x60 CRM->apb1en end AT32
11 RCC_AHB1, //0x80
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))
23 #ifdef AT32F43x
25 #define RCC_AHB1(periph) RCC_ENCODE(RCC_AHB1, CRM_AHB1_ ## periph ## _PER_MASK)
26 #define RCC_AHB2(periph) RCC_ENCODE(RCC_AHB2, CRM_AHB2_ ## periph ## _PER_MASK)
27 #define RCC_AHB3(periph) RCC_ENCODE(RCC_AHB3, CRM_AHB3_ ## periph ## _PER_MASK)
28 #define RCC_APB1(periph) RCC_ENCODE(RCC_APB1, CRM_APB1_ ## periph ## _PER_MASK)
29 #define RCC_APB2(periph) RCC_ENCODE(RCC_APB2, CRM_APB2_ ## periph ## _PER_MASK)
31 #else
32 #define RCC_AHB(periph) RCC_ENCODE(RCC_AHB, RCC_AHBENR_ ## periph ## EN)
33 #define RCC_AHB1(periph) RCC_ENCODE(RCC_AHB1, RCC_AHB1ENR_ ## periph ## EN)
34 #define RCC_APB1(periph) RCC_ENCODE(RCC_APB1, RCC_APB1ENR_ ## periph ## EN)
35 #define RCC_APB2(periph) RCC_ENCODE(RCC_APB2, RCC_APB2ENR_ ## periph ## EN)
36 #endif
38 #ifdef STM32H7
39 #define RCC_AHB2(periph) RCC_ENCODE(RCC_AHB2, RCC_AHB2ENR_ ## periph ## EN)
40 #define RCC_AHB3(periph) RCC_ENCODE(RCC_AHB3, RCC_AHB3ENR_ ## periph ## EN)
41 #define RCC_AHB4(periph) RCC_ENCODE(RCC_AHB4, RCC_AHB4ENR_ ## periph ## EN)
42 #define RCC_APB1L(periph) RCC_ENCODE(RCC_APB1L, RCC_APB1LENR_ ## periph ## EN)
43 #define RCC_APB1H(periph) RCC_ENCODE(RCC_APB1H, RCC_APB1HENR_ ## periph ## EN)
44 #define RCC_APB3(periph) RCC_ENCODE(RCC_APB3, RCC_APB3ENR_ ## periph ## EN)
45 #define RCC_APB4(periph) RCC_ENCODE(RCC_APB4, RCC_APB4ENR_ ## periph ## EN)
46 #endif
48 void RCC_ClockCmd(rccPeriphTag_t periphTag, FunctionalState NewState);
49 void RCC_ResetCmd(rccPeriphTag_t periphTag, FunctionalState NewState);