mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 21:05:35 +03:00
Add unused pin state traverse and initialization facility
This commit is contained in:
parent
e02716a8a4
commit
a88d5470eb
4 changed files with 26 additions and 0 deletions
|
@ -471,3 +471,9 @@ IO_t IOGetByTag(ioTag_t tag)
|
|||
return ioRecs + offset;
|
||||
}
|
||||
|
||||
void IOTraversePins(IOTraverseFuncPtr_t fnPtr)
|
||||
{
|
||||
for (int i = 0; i < DEFIO_IO_USED_COUNT; i++) {
|
||||
fnPtr(&ioRecs[i]);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -127,3 +127,7 @@ void IOConfigGPIOAF(IO_t io, ioConfig_t cfg, uint8_t af);
|
|||
#endif
|
||||
|
||||
void IOInitGlobal(void);
|
||||
|
||||
typedef void (*IOTraverseFuncPtr_t)(IO_t io);
|
||||
|
||||
void IOTraversePins(IOTraverseFuncPtr_t func);
|
||||
|
|
|
@ -26,10 +26,13 @@
|
|||
|
||||
#include "build/atomic.h"
|
||||
|
||||
#include "drivers/io.h"
|
||||
#include "drivers/light_led.h"
|
||||
#include "drivers/nvic.h"
|
||||
#include "drivers/resource.h"
|
||||
#include "drivers/sound_beeper.h"
|
||||
|
||||
|
||||
#include "system.h"
|
||||
|
||||
#if defined(STM32F3) || defined(STM32F4) || defined(STM32F7) || defined(STM32H7)
|
||||
|
@ -269,3 +272,15 @@ void initialiseMemorySections(void)
|
|||
memcpy(&_sfastram_data, &_sfastram_idata, (size_t) (&_efastram_data - &_sfastram_data));
|
||||
#endif
|
||||
}
|
||||
|
||||
static void initializeUnusedPin(IO_t io)
|
||||
{
|
||||
if (IOGetOwner(io) == OWNER_FREE) {
|
||||
IOConfigGPIO(io, IOCFG_IPU);
|
||||
}
|
||||
}
|
||||
|
||||
void initializeUnusedPins(void)
|
||||
{
|
||||
IOTraversePins(initializeUnusedPin);
|
||||
}
|
||||
|
|
|
@ -83,3 +83,4 @@ typedef void extiCallbackHandlerFunc(void);
|
|||
|
||||
void registerExtiCallbackHandler(IRQn_Type irqn, extiCallbackHandlerFunc *fn);void unregisterExtiCallbackHandler(IRQn_Type irqn, extiCallbackHandlerFunc *fn);
|
||||
|
||||
void initializeUnusedPins(void);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue