From 699569ec99e6921cacf390964e7b62ef96ff1307 Mon Sep 17 00:00:00 2001 From: Steins7 Date: Tue, 16 Jul 2024 21:50:01 +0200 Subject: [PATCH] Add LSI configuration function to RCC --- drv/rcc.c | 10 ++++++++++ drv/rcc.h | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/drv/rcc.c b/drv/rcc.c index 73fe49b..56adbbc 100644 --- a/drv/rcc.c +++ b/drv/rcc.c @@ -60,6 +60,16 @@ void rcc_configure(enum RccPreset preset) regs->APB2ENR = apb2_enr; } +void rcc_configure_lsi(bool enable) +{ + regs->CSR.LSION = enable; + + //ensure LSI is enabled + if (enable) { + while (regs->CSR.LSIRDY != 0x1); + } +} + void rcc_enable(enum RccAhb ahb_mask, enum RccApb1 apb1_mask, enum RccApb2 apb2_mask) { diff --git a/drv/rcc.h b/drv/rcc.h index 770b7a0..f26ba01 100644 --- a/drv/rcc.h +++ b/drv/rcc.h @@ -112,6 +112,12 @@ struct RccClocks { */ void rcc_configure(enum RccPreset preset); +/** + * Configures the Low Speed Internal (LSI) oscillator for low power + * applications. + */ +void rcc_configure_lsi(bool enable); + /** * Enables peripherals on the different buses. The enums values can used as * masks to enable multiple peripherals at the same time. Invalid values will be