From 8b99e49670068e4c464fa23fac7f54b2067b88cc 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/ao_arch_funcs.h | 5 +++++ src/stm/stm32l.h | 10 ++++++++++ 2 files changed, 15 insertions(+) (limited to 'src/stm') diff --git a/src/stm/ao_arch_funcs.h b/src/stm/ao_arch_funcs.h index 42f1a2e5..ce59acaa 100644 --- a/src/stm/ao_arch_funcs.h +++ b/src/stm/ao_arch_funcs.h @@ -149,6 +149,11 @@ ao_spi_try_get_mask(struct stm_gpio *reg, uint16_t mask, uint8_t bus, uint32_t s #define ao_gpio_get(port, bit, pin) stm_gpio_get(port, bit) +#define ao_gpio_set_bits(port, bits) stm_gpio_set_bits(port, bits) + +#define ao_gpio_clr_bits(port, bits) stm_gpio_clr_bits(port, bits); + + #define ao_enable_output(port,bit,pin,v) do { \ ao_enable_port(port); \ ao_gpio_set(port, bit, pin, v); \ diff --git a/src/stm/stm32l.h b/src/stm/stm32l.h index 799cccbd..0d1edd2e 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