diff options
author | Keith Packard <keithp@keithp.com> | 2015-12-17 19:27:42 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2016-04-13 06:17:06 -0700 |
commit | e3f0c5eb8e5d57cbd8882587477d1381e2a83226 (patch) | |
tree | 79821c10873606bdb611dc9c5c2671aebd2dc0ac /src/stm/stm32l.h | |
parent | 097c156b13ae975c742f294b46429e8ff14c365b (diff) |
altos: Add ao_gpi_set/clr_bits functions
These set or clear a group of bits in a single GPIO register all together.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/stm/stm32l.h')
-rw-r--r-- | src/stm/stm32l.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/stm/stm32l.h b/src/stm/stm32l.h index 01afedc6..0b6b2798 100644 --- a/src/stm/stm32l.h +++ b/src/stm/stm32l.h @@ -166,6 +166,16 @@ stm_gpio_set(struct stm_gpio *gpio, int pin, uint8_t value) { gpio->bsrr = ((uint32_t) (value ^ 1) << (pin + 16)) | ((uint32_t) value << pin); } +static inline void +stm_gpio_set_bits(struct stm_gpio *gpio, uint16_t bits) { + gpio->bsrr = bits; +} + +static inline void +stm_gpio_clr_bits(struct stm_gpio *gpio, uint16_t bits) { + gpio->bsrr = ((uint32_t) bits) << 16; +} + static inline uint8_t stm_gpio_get(struct stm_gpio *gpio, int pin) { return (gpio->idr >> pin) & 1; |