diff options
-rw-r--r-- | libmaple/rcc.c | 23 | ||||
-rw-r--r-- | libmaple/rcc.h | 8 |
2 files changed, 23 insertions, 8 deletions
diff --git a/libmaple/rcc.c b/libmaple/rcc.c index 78abbcf..efb2599 100644 --- a/libmaple/rcc.c +++ b/libmaple/rcc.c @@ -32,14 +32,12 @@ #include "rcc.h" #include "bitband.h" -enum { - APB1, - APB2, - AHB -}; +#define APB1 RCC_APB1 +#define APB2 RCC_APB2 +#define AHB RCC_AHB struct rcc_dev_info { - const uint8 clk_domain; + const rcc_clk_domain clk_domain; const uint8 line_num; }; @@ -149,7 +147,7 @@ void rcc_clk_enable(rcc_clk_id device) { [AHB] = &RCC_BASE->AHBENR, }; - uint8 clk_domain = rcc_dev_table[device].clk_domain; + rcc_clk_domain clk_domain = rcc_dev_clk(device); __io uint32* enr = (__io uint32*)enable_regs[clk_domain]; uint8 lnum = rcc_dev_table[device].line_num; @@ -166,7 +164,7 @@ void rcc_reset_dev(rcc_clk_id device) { [APB2] = &RCC_BASE->APB2RSTR, }; - uint8 clk_domain = rcc_dev_table[device].clk_domain; + rcc_clk_domain clk_domain = rcc_dev_clk(device); __io void* addr = (__io void*)reset_regs[clk_domain]; uint8 lnum = rcc_dev_table[device].line_num; @@ -175,6 +173,15 @@ void rcc_reset_dev(rcc_clk_id device) { } /** + * @brief Get a device's clock domain + * @param device Device whose clock domain to return + * @return Device's clock source + */ +rcc_clk_domain rcc_dev_clk(rcc_clk_id device) { + return rcc_dev_table[device].clk_domain; +} + +/** * @brief Set the divider on a device prescaler * @param prescaler prescaler to set * @param divider prescaler divider diff --git a/libmaple/rcc.h b/libmaple/rcc.h index 91f77d0..08f8977 100644 --- a/libmaple/rcc.h +++ b/libmaple/rcc.h @@ -484,6 +484,14 @@ void rcc_clk_init(rcc_sysclk_src sysclk_src, void rcc_clk_enable(rcc_clk_id device); void rcc_reset_dev(rcc_clk_id device); +typedef enum rcc_clk_domain { + RCC_APB1, + RCC_APB2, + RCC_AHB +} rcc_clk_domain; + +rcc_clk_domain rcc_dev_clk(rcc_clk_id device); + /** * Prescaler identifiers * @see rcc_set_prescaler() |