diff options
author | Keith Packard <keithp@keithp.com> | 2015-12-17 19:27:42 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2015-12-23 23:12:18 -0800 |
commit | 8b99e49670068e4c464fa23fac7f54b2067b88cc (patch) | |
tree | cbe3d2f2f3788fedde026495d250b2663a7fe8c5 /src/stm/stm32l.h | |
parent | a1b760d0a01e7087bcc214fcd395541fbf268fe8 (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 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; |