Merge pull request #6439 from DieHertz/bfdev-max7456-segfault-fix

Fixed init order of MAX7456 DisplayPort
This commit is contained in:
Michael Keller 2018-07-24 23:51:34 +12:00 committed by GitHub
commit 01ddbf2927
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 28 additions and 9 deletions

View File

@ -415,18 +415,18 @@ void max7456ReInit(void)
// Here we init only CS and try to init MAX for first time. // Here we init only CS and try to init MAX for first time.
// Also detect device type (MAX v.s. AT) // Also detect device type (MAX v.s. AT)
void max7456Init(const max7456Config_t *max7456Config, const vcdProfile_t *pVcdProfile, bool cpuOverclock) bool max7456Init(const max7456Config_t *max7456Config, const vcdProfile_t *pVcdProfile, bool cpuOverclock)
{ {
max7456HardwareReset(); max7456HardwareReset();
if (!max7456Config->csTag) { if (!max7456Config->csTag) {
return; return false;
} }
busdev->busdev_u.spi.csnPin = IOGetByTag(max7456Config->csTag); busdev->busdev_u.spi.csnPin = IOGetByTag(max7456Config->csTag);
if (!IOIsFreeOrPreinit(busdev->busdev_u.spi.csnPin)) { if (!IOIsFreeOrPreinit(busdev->busdev_u.spi.csnPin)) {
return; return false;
} }
IOInit(busdev->busdev_u.spi.csnPin, OWNER_OSD_CS, 0); IOInit(busdev->busdev_u.spi.csnPin, OWNER_OSD_CS, 0);
@ -489,6 +489,7 @@ void max7456Init(const max7456Config_t *max7456Config, const vcdProfile_t *pVcdP
#endif #endif
// Real init will be made later when driver detect idle. // Real init will be made later when driver detect idle.
return true;
} }
/** /**

View File

@ -31,7 +31,7 @@ extern uint16_t maxScreenSize;
struct vcdProfile_s; struct vcdProfile_s;
void max7456HardwareReset(void); void max7456HardwareReset(void);
struct max7456Config_s; struct max7456Config_s;
void max7456Init(const struct max7456Config_s *max7456Config, const struct vcdProfile_s *vcdProfile, bool cpuOverclock); bool max7456Init(const struct max7456Config_s *max7456Config, const struct vcdProfile_s *vcdProfile, bool cpuOverclock);
void max7456Invert(bool invert); void max7456Invert(bool invert);
void max7456Brightness(uint8_t black, uint8_t white); void max7456Brightness(uint8_t black, uint8_t white);
void max7456DrawScreen(void); void max7456DrawScreen(void);

View File

@ -265,7 +265,7 @@ void fcTasksInit(void)
#endif #endif
#ifdef USE_OSD_SLAVE #ifdef USE_OSD_SLAVE
setTaskEnabled(TASK_OSD_SLAVE, true); setTaskEnabled(TASK_OSD_SLAVE, osdSlaveInitialized());
#else #else
if (sensors(SENSOR_GYRO)) { if (sensors(SENSOR_GYRO)) {
rescheduleTask(TASK_GYROPID, gyro.targetLooptime); rescheduleTask(TASK_GYROPID, gyro.targetLooptime);
@ -319,7 +319,7 @@ void fcTasksInit(void)
setTaskEnabled(TASK_TRANSPONDER, feature(FEATURE_TRANSPONDER)); setTaskEnabled(TASK_TRANSPONDER, feature(FEATURE_TRANSPONDER));
#endif #endif
#ifdef USE_OSD #ifdef USE_OSD
setTaskEnabled(TASK_OSD, feature(FEATURE_OSD)); setTaskEnabled(TASK_OSD, feature(FEATURE_OSD) && osdInitialized());
#endif #endif
#ifdef USE_BST #ifdef USE_BST
setTaskEnabled(TASK_BST_MASTER_PROCESS, true); setTaskEnabled(TASK_BST_MASTER_PROCESS, true);

View File

@ -166,12 +166,18 @@ static const displayPortVTable_t max7456VTable = {
displayPort_t *max7456DisplayPortInit(const vcdProfile_t *vcdProfile) displayPort_t *max7456DisplayPortInit(const vcdProfile_t *vcdProfile)
{ {
displayInit(&max7456DisplayPort, &max7456VTable); if (
#ifdef USE_OSD_SLAVE #ifdef USE_OSD_SLAVE
max7456Init(max7456Config(), vcdProfile, false); !max7456Init(max7456Config(), vcdProfile, false)
#else #else
max7456Init(max7456Config(), vcdProfile, systemConfig()->cpu_overclock); !max7456Init(max7456Config(), vcdProfile, systemConfig()->cpu_overclock)
#endif #endif
) {
return NULL;
}
displayInit(&max7456DisplayPort, &max7456VTable);
resync(&max7456DisplayPort); resync(&max7456DisplayPort);
return &max7456DisplayPort; return &max7456DisplayPort;
} }

View File

@ -1131,6 +1131,11 @@ void osdInit(displayPort_t *osdDisplayPortToUse)
resumeRefreshAt = micros() + (4 * REFRESH_1S); resumeRefreshAt = micros() + (4 * REFRESH_1S);
} }
bool osdInitialized(void)
{
return osdDisplayPort;
}
void osdUpdateAlarms(void) void osdUpdateAlarms(void)
{ {
// This is overdone? // This is overdone?

View File

@ -201,6 +201,7 @@ extern timeUs_t resumeRefreshAt;
struct displayPort_s; struct displayPort_s;
void osdInit(struct displayPort_s *osdDisplayPort); void osdInit(struct displayPort_s *osdDisplayPort);
bool osdInitialized(void);
void osdResetAlarms(void); void osdResetAlarms(void);
void osdUpdate(timeUs_t currentTimeUs); void osdUpdate(timeUs_t currentTimeUs);
void osdStatSetState(uint8_t statIndex, bool enabled); void osdStatSetState(uint8_t statIndex, bool enabled);

View File

@ -120,6 +120,11 @@ void osdSlaveInit(displayPort_t *osdDisplayPortToUse)
displayResync(osdDisplayPort); displayResync(osdDisplayPort);
} }
bool osdSlaveInitialized(void)
{
return osdDisplayPort;
}
bool osdSlaveCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTimeUs) bool osdSlaveCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTimeUs)
{ {
UNUSED(currentTimeUs); UNUSED(currentTimeUs);

View File

@ -29,6 +29,7 @@ extern bool osdSlaveIsLocked;
// init // init
void osdSlaveInit(struct displayPort_s *osdDisplayPort); void osdSlaveInit(struct displayPort_s *osdDisplayPort);
bool osdSlaveInitialized(void);
// task api // task api
bool osdSlaveCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTimeUs); bool osdSlaveCheck(timeUs_t currentTimeUs, timeDelta_t currentDeltaTimeUs);