aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-04-25 22:08:30 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-04-25 22:08:30 -0400
commitd5ee5fef3e33c7fe634a0b416394be9a5aacaf60 (patch)
tree94f4e513fe2119489ab91a34bd2ad7a1622c695e
parent95af192c99459c56bb30763afd93582a524efc3a (diff)
downloadlibrambutan-d5ee5fef3e33c7fe634a0b416394be9a5aacaf60.tar.gz
librambutan-d5ee5fef3e33c7fe634a0b416394be9a5aacaf60.zip
Adding rcc_dev_clk(), an accessor for a peripheral's clock line.
-rw-r--r--libmaple/rcc.c23
-rw-r--r--libmaple/rcc.h8
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()