Exclude SWD pins from being initialised as pull up if unused.

This commit is contained in:
mikeller 2020-01-28 00:00:04 +13:00 committed by Michael Keller
parent 0c6b965898
commit cd27b63b89
6 changed files with 24 additions and 8 deletions

View File

@ -108,4 +108,5 @@ const char * const ownerNames[OWNER_TOTAL_COUNT] = {
"PULLUP", "PULLUP",
"PULLDOWN", "PULLDOWN",
"DSHOT_BITBANG", "DSHOT_BITBANG",
"SWD",
}; };

View File

@ -106,6 +106,7 @@ typedef enum {
OWNER_PULLUP, OWNER_PULLUP,
OWNER_PULLDOWN, OWNER_PULLDOWN,
OWNER_DSHOT_BITBANG, OWNER_DSHOT_BITBANG,
OWNER_SWD,
OWNER_TOTAL_COUNT OWNER_TOTAL_COUNT
} resourceOwner_e; } resourceOwner_e;

View File

@ -273,14 +273,14 @@ void initialiseMemorySections(void)
#endif #endif
} }
static void initializeUnusedPin(IO_t io) static void unusedPinInit(IO_t io)
{ {
if (IOGetOwner(io) == OWNER_FREE) { if (IOGetOwner(io) == OWNER_FREE) {
IOConfigGPIO(io, IOCFG_IPU); IOConfigGPIO(io, IOCFG_IPU);
} }
} }
void initializeUnusedPins(void) void unusedPinsInit(void)
{ {
IOTraversePins(initializeUnusedPin); IOTraversePins(unusedPinInit);
} }

View File

@ -83,4 +83,4 @@ typedef void extiCallbackHandlerFunc(void);
void registerExtiCallbackHandler(IRQn_Type irqn, extiCallbackHandlerFunc *fn);void unregisterExtiCallbackHandler(IRQn_Type irqn, extiCallbackHandlerFunc *fn); void registerExtiCallbackHandler(IRQn_Type irqn, extiCallbackHandlerFunc *fn);void unregisterExtiCallbackHandler(IRQn_Type irqn, extiCallbackHandlerFunc *fn);
void initializeUnusedPins(void); void unusedPinsInit(void);

View File

@ -285,13 +285,25 @@ static void configureSPIAndQuadSPI(void)
} }
#ifdef USE_SDCARD #ifdef USE_SDCARD
void sdCardAndFSInit() static void sdCardAndFSInit()
{ {
sdcard_init(sdcardConfig()); sdcard_init(sdcardConfig());
afatfs_init(); afatfs_init();
} }
#endif #endif
static void swdPinsInit(void)
{
IO_t io = IOGetByTag(DEFIO_TAG_E(PA13)); // SWDIO
if (IOGetOwner(io) == OWNER_FREE) {
IOInit(io, OWNER_SWD, 0);
}
io = IOGetByTag(DEFIO_TAG_E(PA14)); // SWCLK
if (IOGetOwner(io) == OWNER_FREE) {
IOInit(io, OWNER_SWD, 0);
}
}
void init(void) void init(void)
{ {
#ifdef SERIAL_PORT_COUNT #ifdef SERIAL_PORT_COUNT
@ -1006,7 +1018,9 @@ void init(void)
motorEnable(); motorEnable();
#endif #endif
initializeUnusedPins(); swdPinsInit();
unusedPinsInit();
tasksInit(); tasksInit();

View File

@ -593,7 +593,7 @@ void spektrumBind(rxConfig_t *rxConfig)
printf("spektrumBind\n"); printf("spektrumBind\n");
} }
void initializeUnusedPins(void) void unusedPinsInit(void)
{ {
printf("initializeUnusedPins\n"); printf("unusedPinsInit\n");
} }