From e3f0c5eb8e5d57cbd8882587477d1381e2a83226 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 17 Dec 2015 19:27:42 -0800 Subject: 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 --- src/stm/stm32l.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/stm/stm32l.h') 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; -- cgit v1.2.3