Fix "spontaneous heating" issue (WRITE bug) on STM32 (#13356)

Should fix "spontanous heating" problems due to order of operations error. Error occurs at least with ststm32 v5.1.0 in PlatformIO.
This commit is contained in:
pinchies 2019-03-11 09:25:54 +11:00 committed by Scott Lahteine
parent b824a517aa
commit 4c43e6c48b

View File

@ -30,7 +30,7 @@
#include <libmaple/gpio.h> #include <libmaple/gpio.h>
#define READ(IO) (PIN_MAP[IO].gpio_device->regs->IDR & (1U << PIN_MAP[IO].gpio_bit) ? HIGH : LOW) #define READ(IO) (PIN_MAP[IO].gpio_device->regs->IDR & (1U << PIN_MAP[IO].gpio_bit) ? HIGH : LOW)
#define WRITE(IO,V) (PIN_MAP[IO].gpio_device->regs->BSRR = (1U << PIN_MAP[IO].gpio_bit) << (16 * !(bool)V)) #define WRITE(IO,V) (PIN_MAP[IO].gpio_device->regs->BSRR = (1U << PIN_MAP[IO].gpio_bit) << (16 * !((bool)V)))
#define TOGGLE(IO) (PIN_MAP[IO].gpio_device->regs->ODR = PIN_MAP[IO].gpio_device->regs->ODR ^ (1U << PIN_MAP[IO].gpio_bit)) #define TOGGLE(IO) (PIN_MAP[IO].gpio_device->regs->ODR = PIN_MAP[IO].gpio_device->regs->ODR ^ (1U << PIN_MAP[IO].gpio_bit))
#define WRITE_VAR(IO,V) WRITE(IO,V) #define WRITE_VAR(IO,V) WRITE(IO,V)