aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple
diff options
context:
space:
mode:
Diffstat (limited to 'libmaple')
-rw-r--r--libmaple/include/libmaple/rcc.h1
-rw-r--r--libmaple/rcc.c9
2 files changed, 10 insertions, 0 deletions
diff --git a/libmaple/include/libmaple/rcc.h b/libmaple/include/libmaple/rcc.h
index 2c8776b..9042391 100644
--- a/libmaple/include/libmaple/rcc.h
+++ b/libmaple/include/libmaple/rcc.h
@@ -106,6 +106,7 @@ void rcc_configure_pll(rcc_pll_cfg *pll_cfg);
void rcc_turn_on_clk(rcc_clk clock);
void rcc_turn_off_clk(rcc_clk clock);
+int rcc_is_clk_on(rcc_clk clock);
int rcc_is_clk_ready(rcc_clk clock);
/* Peripheral clock lines and clock domains. */
diff --git a/libmaple/rcc.c b/libmaple/rcc.c
index d42bbf1..91ce8e7 100644
--- a/libmaple/rcc.c
+++ b/libmaple/rcc.c
@@ -143,6 +143,15 @@ void rcc_turn_off_clk(rcc_clk clock) {
}
/**
+ * @brief Check if a clock is on.
+ * @param clock Clock to check.
+ * @return 1 if the clock is on, 0 if the clock is off.
+ */
+int rcc_is_clk_on(rcc_clk clock) {
+ return !!(*rcc_clk_reg(clock) & rcc_clk_on_mask(clock));
+}
+
+/**
* @brief Check if a clock source is ready.
*
* In general, it is not safe to rely on a clock source unless this