summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2014-05-12 22:56:38 -0700
committerKeith Packard <keithp@keithp.com>2014-05-12 22:56:38 -0700
commita25c34ef0a92beaa0695e0d0020eda5e26b309e2 (patch)
tree4aedbd7aff77f8933250e7e8e9fe7486cd4fd3b7
parent530894f508874f4cb3db644ca9ca679ed704f964 (diff)
altos/stm: Use #define'd constants for GPIO register addresses
This lets the compiler short-circuit the tests in ao_enable_gpio and ao_disable_gpio to save a bit of code space and time. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src/stm/stm32l.h27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/stm/stm32l.h b/src/stm/stm32l.h
index 9226e9cb..799cccbd 100644
--- a/src/stm/stm32l.h
+++ b/src/stm/stm32l.h
@@ -176,12 +176,27 @@ stm_gpio_get_all(struct stm_gpio *gpio) {
return gpio->idr;
}
-extern struct stm_gpio stm_gpioa;
-extern struct stm_gpio stm_gpiob;
-extern struct stm_gpio stm_gpioc;
-extern struct stm_gpio stm_gpiod;
-extern struct stm_gpio stm_gpioe;
-extern struct stm_gpio stm_gpioh;
+/*
+ * We can't define these in registers.ld or our fancy
+ * ao_enable_gpio macro will expand into a huge pile of code
+ * as the compiler won't do correct constant folding and
+ * dead-code elimination
+
+ extern struct stm_gpio stm_gpioa;
+ extern struct stm_gpio stm_gpiob;
+ extern struct stm_gpio stm_gpioc;
+ extern struct stm_gpio stm_gpiod;
+ extern struct stm_gpio stm_gpioe;
+ extern struct stm_gpio stm_gpioh;
+
+*/
+
+#define stm_gpioh (*((struct stm_gpio *) 0x40021400))
+#define stm_gpioe (*((struct stm_gpio *) 0x40021000))
+#define stm_gpiod (*((struct stm_gpio *) 0x40020c00))
+#define stm_gpioc (*((struct stm_gpio *) 0x40020800))
+#define stm_gpiob (*((struct stm_gpio *) 0x40020400))
+#define stm_gpioa (*((struct stm_gpio *) 0x40020000))
struct stm_usart {
vuint32_t sr; /* status register */