|
36 | 36 |
|
37 | 37 | /*** RCC ***/ |
38 | 38 | #define RCC_BASE (0x40021000) |
39 | | -#define RCC_CR (*(volatile uint32_t *)(RCC_BASE + 0x00)) /* RM0444 - 5.4.1 */ |
40 | | -#define RCC_CFGR (*(volatile uint32_t *)(RCC_BASE + 0x08)) /* RM0444 - 5.4.3 */ |
41 | | -#define APB1_CLOCK_ER (*(volatile uint32_t *)(RCC_BASE + 0x3C)) |
42 | | -#define APB2_CLOCK_ER (*(volatile uint32_t *)(RCC_BASE + 0x40)) |
43 | | - |
| 39 | +#define RCC_CR (*(volatile uint32_t *)(RCC_BASE + 0x00)) /* RM0490 - 5.4.1 */ |
| 40 | +#define RCC_CFGR (*(volatile uint32_t *)(RCC_BASE + 0x08)) /* RM0490 - 5.4.3 */ |
| 41 | +#define APB1_CLOCK_ER (*(volatile uint32_t *)(RCC_BASE + 0x3C)) /* RM0490 - 5.4.13 */ |
| 42 | +#define APB2_CLOCK_ER (*(volatile uint32_t *)(RCC_BASE + 0x40)) /* RM0490 - 5.4.14 */ |
44 | 43 |
|
45 | 44 | #define RCC_CR_HSIRDY (1 << 10) |
46 | 45 | #define RCC_CR_HSION (1 << 8) |
|
56 | 55 | #define RCC_CR_HSIDIV_64 (6ul << RCC_CR_HSIDIV_SHIFT) |
57 | 56 | #define RCC_CR_HSIDIV_128 (7ul << RCC_CR_HSIDIV_SHIFT) |
58 | 57 |
|
59 | | - |
60 | 58 | #define RCC_CFGR_SW_HSISYS 0x0 |
61 | | -#define RCC_CFGR_SW_PLL 0x2 |
62 | | -#define RCC_PLLCFGR_PLLR_EN (1 << 28) /* RM0444 - 5.4.3 */ |
63 | | - |
64 | | -#define RCC_PLLCFGR_PLLSRC_HSI16 2 |
65 | | - |
66 | 59 |
|
67 | 60 | /*** APB PRESCALER ***/ |
68 | 61 | #define RCC_PRESCALER_DIV_NONE 0 |
69 | 62 |
|
70 | 63 | /*** FLASH ***/ |
71 | 64 | #define PWR_APB1_CLOCK_ER_VAL (1 << 28) |
72 | | -#define SYSCFG_APB2_CLOCK_ER_VAL (1 << 0) /* RM0444 - 5.4.15 - RCC_APBENR2 - SYSCFGEN */ |
| 65 | +#define SYSCFG_APB2_CLOCK_ER_VAL (1 << 0) /* RM0490 - 5.4.14 - RCC_APBENR2 - SYSCFGEN */ |
73 | 66 |
|
74 | 67 | #define FLASH_BASE (0x40022000) /*FLASH_R_BASE = 0x40000000UL + 0x00020000UL + 0x00002000UL */ |
75 | 68 | #define FLASH_ACR (*(volatile uint32_t *)(FLASH_BASE + 0x00)) /* RM0490 - 3.7.1 - FLASH_ACR */ |
@@ -230,26 +223,18 @@ static void clock_pll_off(void) |
230 | 223 | DMB(); |
231 | 224 | } |
232 | 225 |
|
233 | | -/* This implementation will setup HSI RC 48 MHz as System Clock Source, set |
234 | | - * flash wait state to 1, and set all peripherals to 16MHz (div4) |
235 | | - */ |
| 226 | +/* This implementation will setup HSI RC 48 MHz as System Clock Source and set |
| 227 | + * flash wait state to 1 */ |
236 | 228 | static void clock_pll_on(int powersave) |
237 | 229 | { |
238 | 230 | uint32_t reg32; |
239 | | - uint32_t cpu_freq, plln, pllm, pllq, pllp, pllr, hpre, ppre, flash_waitstates; |
| 231 | + uint32_t cpu_freq, flash_waitstates; |
240 | 232 |
|
241 | 233 | /* Enable Power controller */ |
242 | 234 | APB1_CLOCK_ER |= PWR_APB1_CLOCK_ER_VAL; |
243 | 235 |
|
244 | 236 | /* Select clock parameters (CPU Speed = 48MHz) */ |
245 | 237 | cpu_freq = 48000000; |
246 | | - pllm = 4; |
247 | | - plln = 80; |
248 | | - pllp = 10; |
249 | | - pllq = 5; |
250 | | - pllr = 5; |
251 | | - hpre = RCC_PRESCALER_DIV_NONE; |
252 | | - ppre = RCC_PRESCALER_DIV_NONE; |
253 | 238 | flash_waitstates = 1; |
254 | 239 |
|
255 | 240 | flash_set_waitstates(flash_waitstates); |
|
0 commit comments