diff options
author | Marti Bolivar <mbolivar@leaflabs.com> | 2012-03-26 15:19:53 -0400 |
---|---|---|
committer | Marti Bolivar <mbolivar@leaflabs.com> | 2012-04-11 16:56:54 -0400 |
commit | 382da37cda44204331d57939c596d768cbd0e188 (patch) | |
tree | 1b3cd9ed2fecc4849440bd4070e6f07d10ee0070 /libmaple | |
parent | 117a6f118adb4540866beb5aba8afd8f98da139e (diff) | |
download | librambutan-382da37cda44204331d57939c596d768cbd0e188.tar.gz librambutan-382da37cda44204331d57939c596d768cbd0e188.zip |
RCC: Add rcc_is_clk_on().
This is a convenience function for checking if a clock line is on.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'libmaple')
-rw-r--r-- | libmaple/include/libmaple/rcc.h | 1 | ||||
-rw-r--r-- | libmaple/rcc.c | 9 |
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 |