mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-17 21:35:44 +03:00
Fix GPIO AF settings being overridden by timerInit(). (#12886)
This commit is contained in:
parent
7d1007ea03
commit
646de8c57d
6 changed files with 33 additions and 8 deletions
|
@ -671,6 +671,10 @@ _TIM_IRQ_HANDLER(TMR20_CH_IRQnHandler, 20);
|
|||
#endif
|
||||
|
||||
|
||||
void timerIOInit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void timerInit(void)
|
||||
{
|
||||
memset(timerConfig, 0, sizeof(timerConfig));
|
||||
|
|
|
@ -1028,14 +1028,6 @@ void timerInit(void)
|
|||
RCC_ClockCmd(timerRCC(TIMER_HARDWARE[i].tim), ENABLE);
|
||||
}
|
||||
|
||||
#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7)
|
||||
for (unsigned timerIndex = 0; timerIndex < TIMER_CHANNEL_COUNT; timerIndex++) {
|
||||
const timerHardware_t *timerHardwarePtr = &TIMER_HARDWARE[timerIndex];
|
||||
// XXX IOConfigGPIOAF in timerInit should eventually go away.
|
||||
IOConfigGPIOAF(IOGetByTag(timerHardwarePtr->tag), IOCFG_AF_PP, timerHardwarePtr->alternateFunction);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* enable the timer peripherals */
|
||||
for (unsigned i = 0; i < TIMER_CHANNEL_COUNT; i++) {
|
||||
RCC_ClockCmd(timerRCC(TIMER_HARDWARE[i].tim), ENABLE);
|
||||
|
@ -1051,6 +1043,17 @@ void timerInit(void)
|
|||
}
|
||||
}
|
||||
|
||||
void timerIOInit(void)
|
||||
{
|
||||
#if defined(STM32F4) || defined(STM32F7) || defined(STM32H7)
|
||||
for (unsigned timerIndex = 0; timerIndex < TIMER_CHANNEL_COUNT; timerIndex++) {
|
||||
const timerHardware_t *timerHardwarePtr = &TIMER_HARDWARE[timerIndex];
|
||||
// XXX IOConfigGPIOAF in timerInit should eventually go away.
|
||||
IOConfigGPIOAF(IOGetByTag(timerHardwarePtr->tag), IOCFG_AF_PP, timerHardwarePtr->alternateFunction);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
// finish configuring timers after allocation phase
|
||||
// start timers
|
||||
// TODO - Work in progress - initialization routine must be modified/verified to start correctly without timers
|
||||
|
|
|
@ -851,6 +851,10 @@ void timerInit(void)
|
|||
}
|
||||
}
|
||||
|
||||
void timerIOInit(void)
|
||||
{
|
||||
// No-op
|
||||
}
|
||||
// finish configuring timers after allocation phase
|
||||
// start timers
|
||||
// TODO - Work in progress - initialization routine must be modified/verified to start correctly without timers
|
||||
|
|
|
@ -127,6 +127,7 @@ void timerConfigure(const timerHardware_t *timHw, uint16_t period, uint32_t hz);
|
|||
// Initialisation
|
||||
//
|
||||
void timerInit(void);
|
||||
void timerIOInit(void);
|
||||
void timerStart(void);
|
||||
|
||||
//
|
||||
|
|
|
@ -271,6 +271,15 @@ void init(void)
|
|||
// initialize IO (needed for all IO operations)
|
||||
IOInitGlobal();
|
||||
|
||||
#ifdef USE_TIMER
|
||||
// timerIOInit blindly reconfigures GPIO AF for all pins in the fullTimerHardware array regardless
|
||||
// of if the timer pin is used already by something else.
|
||||
// If it is called AFTER the SPI initilisation, any AF settings for the SPI are overridden by timer
|
||||
// AF, making the SPI hang when it's used.
|
||||
// To work-around this issue init timer AF before other AF, such as SPI/QSPI/OSPI/etc.
|
||||
timerIOInit();
|
||||
#endif
|
||||
|
||||
#ifdef USE_HARDWARE_REVISION_DETECTION
|
||||
detectHardwareRevision();
|
||||
#endif
|
||||
|
|
|
@ -358,6 +358,10 @@ void timerInit(void)
|
|||
printf("[timer]Init...\n");
|
||||
}
|
||||
|
||||
void timerIOInit(void)
|
||||
{
|
||||
}
|
||||
|
||||
void timerStart(void)
|
||||
{
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue