aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/include/libmaple/rcc.h
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2012-02-02 07:01:41 -0500
committerMarti Bolivar <mbolivar@leaflabs.com>2012-04-11 16:56:54 -0400
commitc122d16c71d2aa04baa8b4b5a5df7faed93240fb (patch)
tree0a3966772ec4f927fdbb653bafdb40d033e6900c /libmaple/include/libmaple/rcc.h
parentfd03ab16e37437d99c76b0335305e0205fa5efbb (diff)
downloadlibrambutan-c122d16c71d2aa04baa8b4b5a5df7faed93240fb.tar.gz
librambutan-c122d16c71d2aa04baa8b4b5a5df7faed93240fb.zip
RCC: Add new mechanism for configuring the main PLL.
The new style for configuring the PLL is to initialize a (series-specific) struct rcc_pll_cfg, and pass a pointer to it to rcc_configure_pll(). After that's done, you can use rcc_turn_on_clk(RCC_CLK_PLL) to turn on the main PLL, and busy-wait until rcc_is_clk_ready(RCC_CLK_PLL) is true to make sure the new configuration took effect. - libmaple/rcc.h: -- Add struct rcc_pll_cfg, which specifies a PLL configuration. This specifies a PLL source and a void pointer to series-specific PLL configuration data. -- Add rcc_configure_pll(), which takes a pointer to struct rcc_pll_cfg, and configures the main PLL. It's up to each series to define this function. - stm32f1/rcc.h: Add struct stm32f1_rcc_pll_data, to store F1-specific PLL configuration state. - stm32f1/rcc.c: Add an implementation for rcc_configure_pll(). - stm32f2/rcc.h: Add struct stm32f2_rcc_pll_data, to store F2-specific PLL configuration data. - stm32f2/rcc.c: Add an implementation for rcc_configure_pll(). Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
Diffstat (limited to 'libmaple/include/libmaple/rcc.h')
-rw-r--r--libmaple/include/libmaple/rcc.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/libmaple/include/libmaple/rcc.h b/libmaple/include/libmaple/rcc.h
index 4a22b5e..2c8776b 100644
--- a/libmaple/include/libmaple/rcc.h
+++ b/libmaple/include/libmaple/rcc.h
@@ -80,12 +80,30 @@ typedef enum rcc_sysclk_src {
*/
/* Clock prescaler management. */
+
void rcc_set_prescaler(rcc_prescaler prescaler, uint32 divider);
/* SYSCLK. */
+
void rcc_switch_sysclk(rcc_sysclk_src sysclk_src);
+/* PLL configuration */
+
+/**
+ * @brief Specifies a configuration for the main PLL.
+ */
+typedef struct rcc_pll_cfg {
+ rcc_pllsrc pllsrc; /**< PLL source */
+ void *data; /**< Series-specific configuration
+ * data. See the <series/rcc.h> for your
+ * MCU for more information on what to put
+ * here. */
+} rcc_pll_cfg;
+
+void rcc_configure_pll(rcc_pll_cfg *pll_cfg);
+
/* System and secondary clock sources. */
+
void rcc_turn_on_clk(rcc_clk clock);
void rcc_turn_off_clk(rcc_clk clock);
int rcc_is_clk_ready(rcc_clk clock);