aboutsummaryrefslogtreecommitdiff
path: root/system-clock/include/clock.h
diff options
context:
space:
mode:
authorJosh Rahm <joshuarahm@gmail.com>2018-01-15 14:46:12 -0700
committerJosh Rahm <joshuarahm@gmail.com>2018-01-15 14:46:12 -0700
commit8e20f53dd3b33058508ff51bd19e49df19b06fb7 (patch)
tree9c8fa042aa57ebc94ad7e31519b243c3f00ff001 /system-clock/include/clock.h
parent178921510fb527ef294b29b690ec2ac1ac696d8e (diff)
downloadstm32l4-8e20f53dd3b33058508ff51bd19e49df19b06fb7.tar.gz
stm32l4-8e20f53dd3b33058508ff51bd19e49df19b06fb7.tar.bz2
stm32l4-8e20f53dd3b33058508ff51bd19e49df19b06fb7.zip
reorganize sources into src and include directories.
Diffstat (limited to 'system-clock/include/clock.h')
-rw-r--r--system-clock/include/clock.h61
1 files changed, 61 insertions, 0 deletions
diff --git a/system-clock/include/clock.h b/system-clock/include/clock.h
new file mode 100644
index 0000000..2ba6880
--- /dev/null
+++ b/system-clock/include/clock.h
@@ -0,0 +1,61 @@
+#ifndef CLOCK_H__
+#define CLOCK_H__
+
+#include <stdint.h>
+
+#define PERIPH_BASE ((uint32_t) 0x40000000)
+#define AHBPERIPH_BASE (PERIPH_BASE + 0x00020000)
+#define RCC_BASE (AHBPERIPH_BASE + 0x00001000)
+#define FLASH_R_BASE (AHBPERIPH_BASE + 0x00003C00)
+#define PWR_BASE (PERIPH_BASE + 0x7000)
+#define PWR_CSR_VOSF ((uint16_t)0x0010) /*!< Voltage Scaling select flag */
+
+
+#ifndef __IO
+#define __IO volatile
+#endif
+
+typedef struct {
+ __IO uint32_t cr;
+ __IO uint32_t csr;
+} pwr_t;
+
+typedef struct {
+ __IO uint32_t acr;
+ __IO uint32_t pecr;
+ __IO uint32_t pdkeyr;
+ __IO uint32_t pekeyr;
+ __IO uint32_t prgkeyr;
+ __IO uint32_t optkeyr;
+ __IO uint32_t sr;
+ __IO uint32_t obr;
+ __IO uint32_t wrpr;
+} flash_t;
+
+typedef struct {
+ __IO uint32_t cr;
+ __IO uint32_t icscr;
+ __IO uint32_t cfgr;
+ __IO uint32_t cir;
+ __IO uint32_t ahbrstr;
+ __IO uint32_t apb2rstr;
+ __IO uint32_t apb1rstr;
+ __IO uint32_t ahbenr;
+ __IO uint32_t apb2enr;
+ __IO uint32_t apb1enr;
+ __IO uint32_t ahblpenr;
+ __IO uint32_t apb2lpenr;
+ __IO uint32_t apb1lpenr;
+ __IO uint32_t csr;
+} rcc_t;
+
+#define RCC (*(rcc_t*) (RCC_BASE))
+#define FLASH (*(flash_t*) (FLASH_R_BASE))
+#define PWR (*(pwr_t*) (PWR_BASE))
+
+/*
+ * Sets the system clock to a full 80Mhz.
+ */
+int set_sys_clock();
+
+#endif /* CLOCK_H__ */