From 382da37cda44204331d57939c596d768cbd0e188 Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Mon, 26 Mar 2012 15:19:53 -0400 Subject: RCC: Add rcc_is_clk_on(). This is a convenience function for checking if a clock line is on. Signed-off-by: Marti Bolivar --- libmaple/include/libmaple/rcc.h | 1 + libmaple/rcc.c | 9 +++++++++ 2 files changed, 10 insertions(+) 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 @@ -142,6 +142,15 @@ void rcc_turn_off_clk(rcc_clk clock) { *rcc_clk_reg(clock) &= ~rcc_clk_on_mask(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. * -- cgit v1.2.3