diff --git a/include/libopencm3/stm32/f7/rcc.h b/include/libopencm3/stm32/f7/rcc.h index 399be5f9..96c18d95 100644 --- a/include/libopencm3/stm32/f7/rcc.h +++ b/include/libopencm3/stm32/f7/rcc.h @@ -159,6 +159,7 @@ /* SWS: System clock switch status */ #define RCC_CFGR_SWS_SHIFT 2 +#define RCC_CFGR_SWS_MASK 0x3 #define RCC_CFGR_SWS_HSI 0x0 #define RCC_CFGR_SWS_HSE 0x1 #define RCC_CFGR_SWS_PLL 0x2 diff --git a/lib/stm32/f7/Makefile b/lib/stm32/f7/Makefile index 3145575d..1d245172 100644 --- a/lib/stm32/f7/Makefile +++ b/lib/stm32/f7/Makefile @@ -40,7 +40,9 @@ TGT_CFLAGS = -Os -g \ ARFLAGS = rcs -OBJS = gpio.o gpio_common_all.o gpio_common_f0234.o +OBJS = rcc.o gpio.o gpio_common_all.o gpio_common_f0234.o + +OBJS += rcc_common_all.o OBJS += rng_common_v1.o diff --git a/lib/stm32/f7/rcc.c b/lib/stm32/f7/rcc.c new file mode 100644 index 00000000..4698ac34 --- /dev/null +++ b/lib/stm32/f7/rcc.c @@ -0,0 +1,11 @@ +#include + +uint32_t rcc_ahb_frequency = 16000000; +uint32_t rcc_apb1_frequency = 16000000; +uint32_t rcc_apb2_frequency = 16000000; + +uint32_t rcc_system_clock_source(void) +{ + /* Return the clock source which is used as system clock. */ + return (RCC_CFGR >> RCC_CFGR_SWS_SHIFT) & RCC_CFGR_SWS_MASK; +}