summaryrefslogtreecommitdiff
path: root/src/stm/stm32l.h
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2017-04-03 11:37:21 -0700
committerKeith Packard <keithp@keithp.com>2017-04-03 11:37:21 -0700
commit0197157a295d848bac65cf7f4457dd5a99af24e3 (patch)
treeb165631d389e80f72e2956e2dc283ac218237e23 /src/stm/stm32l.h
parent89c8e0299504e66fc416a778055958cff467e008 (diff)
stm: Add a few more GPIO functions to make dealing with the 1802 easier
ao_gpio_set_mask and ao_gpio_get_all Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/stm/stm32l.h')
-rw-r--r--src/stm/stm32l.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/stm/stm32l.h b/src/stm/stm32l.h
index a20efa8a..4f966e3e 100644
--- a/src/stm/stm32l.h
+++ b/src/stm/stm32l.h
@@ -168,6 +168,12 @@ stm_gpio_set(struct stm_gpio *gpio, int pin, uint8_t value) {
}
static inline void
+stm_gpio_set_mask(struct stm_gpio *gpio, uint16_t bits, uint16_t mask) {
+ /* Use the bit set/reset register to do this atomically */
+ gpio->bsrr = ((uint32_t) (~bits & mask) << 16) | ((uint32_t) (bits & mask));
+}
+
+static inline void
stm_gpio_set_bits(struct stm_gpio *gpio, uint16_t bits) {
gpio->bsrr = bits;
}