mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 01:05:27 +03:00
Fix IOToggle. The F1 and F3 implementation didn't work because mask is 16 bits and not 32.
This commit is contained in:
parent
4fcdc5b346
commit
708638f87b
1 changed files with 7 additions and 13 deletions
|
@ -171,16 +171,8 @@ void IOToggle(IO_t io)
|
|||
{
|
||||
if (!io)
|
||||
return;
|
||||
// check pin state and use BSRR accordinly to avoid race condition
|
||||
uint16_t mask = IO_Pin(io);
|
||||
#if defined(STM32F40_41xxx) || defined(STM32F411xE)
|
||||
IO_GPIO(io)->ODR ^= mask;
|
||||
#else
|
||||
if (IO_GPIO(io)->ODR & mask)
|
||||
mask <<= 16; // bit is set, shift mask to reset half
|
||||
|
||||
IO_GPIO(io)->BSRR = mask;
|
||||
#endif
|
||||
}
|
||||
|
||||
// claim IO pin, set owner and resources
|
||||
|
@ -275,13 +267,15 @@ ioRec_t ioRecs[DEFIO_IO_USED_COUNT];
|
|||
void IOInitGlobal(void) {
|
||||
ioRec_t *ioRec = ioRecs;
|
||||
|
||||
for (unsigned port = 0; port < ARRAYLEN(ioDefUsedMask); port++)
|
||||
for (unsigned pin = 0; pin < sizeof(ioDefUsedMask[0]) * 8; pin++)
|
||||
for (unsigned port = 0; port < ARRAYLEN(ioDefUsedMask); port++) {
|
||||
for (unsigned pin = 0; pin < sizeof(ioDefUsedMask[0]) * 8; pin++) {
|
||||
if (ioDefUsedMask[port] & (1 << pin)) {
|
||||
ioRec->gpio = (GPIO_TypeDef *)(GPIOA_BASE + (port << 10)); // ports are 0x400 apart
|
||||
ioRec->pin = 1 << pin;
|
||||
ioRec++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
IO_t IOGetByTag(ioTag_t tag)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue