summaryrefslogtreecommitdiff
path: root/syscfg
diff options
context:
space:
mode:
Diffstat (limited to 'syscfg')
-rw-r--r--syscfg/SConscript23
-rw-r--r--syscfg/stm32_syscfg.h (renamed from syscfg/syscfg.h)37
2 files changed, 40 insertions, 20 deletions
diff --git a/syscfg/SConscript b/syscfg/SConscript
new file mode 100644
index 0000000..190bacb
--- /dev/null
+++ b/syscfg/SConscript
@@ -0,0 +1,23 @@
+Import('env')
+
+headers = []
+instances = []
+sources = []
+aliases = {}
+
+periph = env['PLATFORM_SPEC'].get('periph', {})
+
+if 'stm32_syscfg' in periph:
+ headers.append('stm32_syscfg.h')
+ for name, data in periph['stm32_syscfg'].items():
+ # allow overrides, but default to family for syscfg, it's a little special
+ ptype = data.get('type', env['PLATFORM_SPEC']['meta']['family'])
+ instances.append({
+ 'type': 'STM32_SYSCFG_t<STM32_SYSCFG_reg_%s_t>' % ptype,
+ 'name': name,
+ 'args': [data['offset']],
+ })
+
+env.Jinja2('syscfg.h', '../templates/periph_instances.h.j2', headers = headers, instances = instances, aliases = aliases)
+
+Return('sources')
diff --git a/syscfg/syscfg.h b/syscfg/stm32_syscfg.h
index 0006f7b..cb3c505 100644
--- a/syscfg/syscfg.h
+++ b/syscfg/stm32_syscfg.h
@@ -1,29 +1,25 @@
-#ifndef SYSCFG_H
-#define SYSCFG_H
+#pragma once
-#include <stdint.h>
+#include <mmio/mmio.h>
-#if defined(STM32L0)
+struct STM32_SYSCFG_reg_f4_t {
+ volatile uint32_t MEMRMP;
+ volatile uint32_t PMC;
+ volatile uint32_t EXTICR[4];
+ volatile uint32_t CMPCR;
+};
-struct SYSCFG_t {
+
+struct STM32_SYSCFG_reg_l0_t {
volatile uint32_t CFGR1;
volatile uint32_t CFGR2;
- volatile uint32_t EXTICR1;
- volatile uint32_t EXTICR2;
- volatile uint32_t EXTICR3;
- volatile uint32_t EXTICR4;
+ volatile uint32_t EXTICR[4];
volatile uint32_t COMP1_CTRL;
volatile uint32_t COMP2_CTRL;
volatile uint32_t CFGR3;
};
-static SYSCFG_t& SYSCFG = *(SYSCFG_t*)0x40010000;
-
-#endif
-
-#if defined(STM32WB)
-
-struct SYSCFG_t {
+struct STM32_SYSCFG_reg_wb_t {
volatile uint32_t MEMRMP;
volatile uint32_t CFGR1;
volatile uint32_t EXTICR[4];
@@ -40,8 +36,9 @@ struct SYSCFG_t {
volatile uint32_t SIPCR;
};
-static SYSCFG_t& SYSCFG = *(SYSCFG_t*)0x40010000;
-#endif
-
-#endif
+template <typename T>
+class STM32_SYSCFG_t : public mmio_ptr<T> {
+ public:
+ using mmio_ptr<T>::ptr;
+};