1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-17 21:35:44 +03:00

MAX7456: Support delayed initialization

This allows the init sequence to correctly determine and store that
the selected display device after autoselection was MAX7456 but it
hasn't been yet initialized, and allows us to properly transmit this
information to the configurator.

This also lets the display subsystem initialize the MAX7456 at any
time, so for example in flight controllers that require battery power
in order to turn on the MAX7456, the user can plug the battery after
powering the system up via USB and the MAX7456 will be detected shortly
after without having to reboot.
This commit is contained in:
Alberto García Hierro 2020-06-24 23:56:32 +01:00
parent d85b372ae7
commit db0e1e7788
3 changed files with 44 additions and 14 deletions

View file

@ -450,7 +450,7 @@ void max7456PreInit(const max7456Config_t *max7456Config)
// Here we init only CS and try to init MAX for first time.
// Also detect device type (MAX v.s. AT)
bool max7456Init(const max7456Config_t *max7456Config, const vcdProfile_t *pVcdProfile, bool cpuOverclock)
max7456InitStatus_e max7456Init(const max7456Config_t *max7456Config, const vcdProfile_t *pVcdProfile, bool cpuOverclock)
{
max7456DeviceDetected = false;
@ -462,13 +462,13 @@ bool max7456Init(const max7456Config_t *max7456Config, const vcdProfile_t *pVcdP
max7456HardwareReset();
if (!max7456Config->csTag || !max7456Config->spiDevice) {
return false;
return MAX7456_INIT_NOT_CONFIGURED;
}
busdev->busdev_u.spi.csnPin = IOGetByTag(max7456Config->csTag);
if (!IOIsFreeOrPreinit(busdev->busdev_u.spi.csnPin)) {
return false;
return MAX7456_INIT_NOT_CONFIGURED;
}
IOInit(busdev->busdev_u.spi.csnPin, OWNER_OSD_CS, 0);
@ -492,7 +492,7 @@ bool max7456Init(const max7456Config_t *max7456Config, const vcdProfile_t *pVcdP
if (osdm != 0x1B) {
IOConfigGPIO(busdev->busdev_u.spi.csnPin, IOCFG_IPU);
return false;
return MAX7456_INIT_NOT_FOUND;
}
// At this point, we can claim the ownership of the CS pin
@ -560,7 +560,7 @@ bool max7456Init(const max7456Config_t *max7456Config, const vcdProfile_t *pVcdP
#endif
// Real init will be made later when driver detect idle.
return true;
return MAX7456_INIT_OK;
}
/**