NavHAL 0.1.0
NAVRobotec's architecture-agnostic HAL for embedded systems.
Loading...
Searching...
No Matches
rcc_reg.h
Go to the documentation of this file.
1
13
14#ifndef CORTEX_M4_RCC_REG_H
15#define CORTEX_M4_RCC_REG_H
16
17#include "common/hal_types.h"
18#include <stdint.h>
19
23typedef struct {
24 __IO uint32_t CR;
25 __IO uint32_t PLLCFGR;
26 __IO uint32_t CFGR;
27 __IO uint32_t CIR;
28 __IO uint32_t AHB1RSTR;
29 __IO uint32_t AHB2RSTR;
30 __IO uint32_t RESERVED_18;
31 __IO uint32_t RESERVED_1C;
32 __IO uint32_t APB1RSTR;
33 __IO uint32_t APB2RSTR;
34 __IO uint32_t RESERVED_28;
35 __IO uint32_t RESERVED_2C;
36 __IO uint32_t AHB1ENR;
37 __IO uint32_t AHB2ENR;
38 __IO uint32_t RESERVED_38;
39 __IO uint32_t RESERVED_3C;
40 __IO uint32_t APB1ENR;
41 __IO uint32_t APB2ENR;
42 __IO uint32_t RESERVED_48;
43 __IO uint32_t RESERVED_4C;
44 __IO uint32_t AHB1LPENR;
45 __IO uint32_t AHB2LPENR;
46 __IO uint32_t RESERVED_58;
47 __IO uint32_t RESERVED_5C;
48 __IO uint32_t APB1LPENR;
49 __IO uint32_t APB2LPENR;
50 __IO uint32_t RESERVED_68;
51 __IO uint32_t RESERVED_6C;
52 __IO uint32_t BDCR;
53 __IO uint32_t CSR;
54 __IO uint32_t RESERVED_78;
55 __IO uint32_t RESERVED_7C;
56 __IO uint32_t SSCGR;
57 __IO uint32_t PLLI2SCFGR;
58 __IO uint32_t RESERVED_88;
59 __IO uint32_t DCKCFGR;
61
63#define RCC_BASE_ADDR 0x40023800
64
66#define RCC ((RCC_Typedef *)RCC_BASE_ADDR)
67
69#define RCC_ON 0x1
71#define RCC_OFF 0x0
72
73/* RCC_CR bit positions */
74#define RCC_CR_HSE_ON_BIT 16
75#define RCC_CR_HSE_READY_BIT 17
76#define RCC_CR_HSI_ON_BIT 0
77#define RCC_CR_HSI_READY_BIT 1
78#define RCC_CR_PLL_ON_BIT 24
79#define RCC_CR_PLL_READY_BIT 25
80
81/* RCC_CR masks */
82#define RCC_CR_HSEON (1 << RCC_CR_HSE_ON_BIT)
83#define RCC_CR_HSERDY (1 << RCC_CR_HSE_READY_BIT)
84#define RCC_CR_HSION (1 << RCC_CR_HSI_ON_BIT)
85#define RCC_CR_HSIRDY (1 << RCC_CR_HSI_READY_BIT)
86#define RCC_CR_PLLON (1 << RCC_CR_PLL_ON_BIT)
87#define RCC_CR_PLLRDY (1 << RCC_CR_PLL_READY_BIT)
88
89/* RCC_PLLCFGR bit positions */
90#define RCC_PLLCFGR_SRC_BIT 22
91#define RCC_PLLCFGR_PLLM_BIT 0
92#define RCC_PLLCFGR_PLLN_BIT 6
93#define RCC_PLLCFGR_PLLP_BIT 16
94#define RCC_PLLCFGR_PLLQ_BIT 24
95
96/* RCC_PLLCFGR masks */
97#define RCC_PLLCFGR_SRC (1 << RCC_PLLCFGR_SRC_BIT)
98#define RCC_PLLCFGR_PLLM(m) (((m) & 0x3F) << RCC_PLLCFGR_PLLM_BIT)
99#define RCC_PLLCFGR_PLLN(n) (((n) & 0x1FF) << RCC_PLLCFGR_PLLN_BIT)
100#define RCC_PLLCFGR_PLLP(p) ((((p) >> 1) - 1) << RCC_PLLCFGR_PLLP_BIT)
101#define RCC_PLLCFGR_PLLQ(q) (((q) & 0x0F) << RCC_PLLCFGR_PLLQ_BIT)
102
103/* RCC_CFGR bit positions */
104#define RCC_CFGR_HPRE_BIT 4
105#define RCC_CFGR_PPRE1_BIT 10
106#define RCC_CFGR_PPRE2_BIT 13
107#define RCC_CFGR_SW_BIT 0
108#define RCC_CFGR_SWS_BIT 2
109
110/* RCC_CFGR masks */
111#define RCC_CFGR_HPRE_MASK (0xF << RCC_CFGR_HPRE_BIT)
112#define RCC_CFGR_PPRE1_MASK (0x7 << RCC_CFGR_PPRE1_BIT)
113#define RCC_CFGR_PPRE2_MASK (0x7 << RCC_CFGR_PPRE2_BIT)
114
129
140
141#define RCC_CFGR_HPRE_DIV(n) (n << RCC_CFGR_HPRE_BIT)
142#define RCC_CFGR_PPRE1_DIV(n) (n << RCC_CFGR_PPRE1_BIT)
143#define RCC_CFGR_PPRE2_DIV(n) (n << RCC_CFGR_PPRE2_BIT)
144
145/* Common predefined prescaler values */
146#define RCC_CFGR_HPRE_DIV1 0x0
147#define RCC_CFGR_PPRE1_DIV4 0x5
148#define RCC_CFGR_PPRE2_DIV2 0x4
149
150#endif // !CORTEX_M4_RCC_REG_H
Hardware Abstraction Layer (HAL) common type definitions.
#define __IO
Definition hal_types.h:20
#define RCC_CFGR_HPRE_DIV1
Definition rcc_reg.h:146
rcc_cfgr_ppre_div_t
APB prescaler division factors.
Definition rcc_reg.h:133
@ RCC_CFGR_PPRE_DIV1
Definition rcc_reg.h:134
@ RCC_CFGR_PPRE_DIV2
Definition rcc_reg.h:135
@ RCC_CFGR_PPRE_DIV16
Definition rcc_reg.h:138
@ RCC_CFGR_PPRE_DIV8
Definition rcc_reg.h:137
@ RCC_CFGR_PPRE_DIV4
Definition rcc_reg.h:136
rcc_cfgr_hpre_div_t
AHB prescaler division factors.
Definition rcc_reg.h:118
@ RCC_CFGR_HPRE_DIV16
Definition rcc_reg.h:123
@ RCC_CFGR_HPRE_DIV8
Definition rcc_reg.h:122
@ RCC_CFGR_HPRE_DIV64
Definition rcc_reg.h:124
@ RCC_CFGR_HPRE_DIV2
Definition rcc_reg.h:120
@ RCC_CFGR_HPRE_DIV128
Definition rcc_reg.h:125
@ RCC_CFGR_HPRE_DIV4
Definition rcc_reg.h:121
@ RCC_CFGR_HPRE_DIV256
Definition rcc_reg.h:126
@ RCC_CFGR_HPRE_DIV512
Definition rcc_reg.h:127
RCC register map structure.
Definition rcc_reg.h:23
__IO uint32_t APB1RSTR
Definition rcc_reg.h:32
__IO uint32_t PLLI2SCFGR
Definition rcc_reg.h:57
__IO uint32_t RESERVED_18
Definition rcc_reg.h:30
__IO uint32_t SSCGR
Definition rcc_reg.h:56
__IO uint32_t PLLCFGR
Definition rcc_reg.h:25
__IO uint32_t CR
Definition rcc_reg.h:24
__IO uint32_t CSR
Definition rcc_reg.h:53
__IO uint32_t AHB1LPENR
Definition rcc_reg.h:44
__IO uint32_t APB2ENR
Definition rcc_reg.h:41
__IO uint32_t RESERVED_58
Definition rcc_reg.h:46
__IO uint32_t BDCR
Definition rcc_reg.h:52
__IO uint32_t CFGR
Definition rcc_reg.h:26
__IO uint32_t RESERVED_88
Definition rcc_reg.h:58
__IO uint32_t RESERVED_28
Definition rcc_reg.h:34
__IO uint32_t RESERVED_2C
Definition rcc_reg.h:35
__IO uint32_t AHB2ENR
Definition rcc_reg.h:37
__IO uint32_t RESERVED_78
Definition rcc_reg.h:54
__IO uint32_t RESERVED_48
Definition rcc_reg.h:42
__IO uint32_t RESERVED_6C
Definition rcc_reg.h:51
__IO uint32_t DCKCFGR
Definition rcc_reg.h:59
__IO uint32_t AHB1ENR
Definition rcc_reg.h:36
__IO uint32_t RESERVED_7C
Definition rcc_reg.h:55
__IO uint32_t APB2LPENR
Definition rcc_reg.h:49
__IO uint32_t RESERVED_5C
Definition rcc_reg.h:47
__IO uint32_t APB1ENR
Definition rcc_reg.h:40
__IO uint32_t AHB2RSTR
Definition rcc_reg.h:29
__IO uint32_t RESERVED_38
Definition rcc_reg.h:38
__IO uint32_t RESERVED_3C
Definition rcc_reg.h:39
__IO uint32_t RESERVED_1C
Definition rcc_reg.h:31
__IO uint32_t CIR
Definition rcc_reg.h:27
__IO uint32_t AHB2LPENR
Definition rcc_reg.h:45
__IO uint32_t AHB1RSTR
Definition rcc_reg.h:28
__IO uint32_t APB1LPENR
Definition rcc_reg.h:48
__IO uint32_t RESERVED_68
Definition rcc_reg.h:50
__IO uint32_t APB2RSTR
Definition rcc_reg.h:33
__IO uint32_t RESERVED_4C
Definition rcc_reg.h:43