Device update through S.PORT port now OK

This commit is contained in:
Bertrand Songis
2019-02-20 18:04:18 +01:00
parent 1cef3ccf90
commit 6685dcfdcd
2 changed files with 7 additions and 12 deletions
+6 -11
View File
@@ -72,21 +72,21 @@ void DeviceFirmwareUpdate::startup()
switch(module) { switch(module) {
case INTERNAL_MODULE: case INTERNAL_MODULE:
#if defined(INTMODULE_USART) #if defined(INTMODULE_USART)
return intmoduleSerialStart(57600); intmoduleSerialStart(57600);
break;
#endif #endif
default: default:
return telemetryInit(PROTOCOL_TELEMETRY_FRSKY_SPORT); telemetryInit(PROTOCOL_TELEMETRY_FRSKY_SPORT);
break;
} }
#if defined(PCBTARANIS) || defined(PCBHORUS)
if (module == INTERNAL_MODULE) if (module == INTERNAL_MODULE)
INTERNAL_MODULE_ON(); INTERNAL_MODULE_ON();
else if (module == EXTERNAL_MODULE) else if (module == EXTERNAL_MODULE)
EXTERNAL_MODULE_ON(); EXTERNAL_MODULE_ON();
else else
SPORT_UPDATE_POWER_ON(); SPORT_UPDATE_POWER_ON();
#endif
watchdogSuspend(50); watchdogSuspend(50);
RTOS_WAIT_MS(50); RTOS_WAIT_MS(50);
@@ -117,7 +117,7 @@ bool DeviceFirmwareUpdate::waitState(State state, uint32_t timeout)
uint8_t len = 0; uint8_t len = 0;
while (len < 10) { while (len < 10) {
uint32_t elapsed = 0; uint32_t elapsed = 0;
while (!intmoduleFifo.pop(frame[len])) { while (!readByte(frame[len])) {
RTOS_WAIT_MS(1); RTOS_WAIT_MS(1);
if (elapsed++ >= timeout) { if (elapsed++ >= timeout) {
return false; return false;
@@ -275,9 +275,9 @@ void DeviceFirmwareUpdate::flashFile(const char * filename)
{ {
pausePulses(); pausePulses();
#if defined(PCBTARANIS) || defined(PCBHORUS)
uint8_t intPwr = IS_INTERNAL_MODULE_ON(); uint8_t intPwr = IS_INTERNAL_MODULE_ON();
uint8_t extPwr = IS_EXTERNAL_MODULE_ON(); uint8_t extPwr = IS_EXTERNAL_MODULE_ON();
INTERNAL_MODULE_OFF(); INTERNAL_MODULE_OFF();
EXTERNAL_MODULE_OFF(); EXTERNAL_MODULE_OFF();
SPORT_UPDATE_POWER_OFF(); SPORT_UPDATE_POWER_OFF();
@@ -285,7 +285,6 @@ void DeviceFirmwareUpdate::flashFile(const char * filename)
/* wait 2s off */ /* wait 2s off */
watchdogSuspend(2000); watchdogSuspend(2000);
RTOS_WAIT_MS(2000); RTOS_WAIT_MS(2000);
#endif
startup(); startup();
@@ -302,20 +301,16 @@ void DeviceFirmwareUpdate::flashFile(const char * filename)
POPUP_INFORMATION(STR_FIRMWARE_UPDATE_SUCCESS); POPUP_INFORMATION(STR_FIRMWARE_UPDATE_SUCCESS);
} }
#if defined(PCBTARANIS) || defined(PCBHORUS)
INTERNAL_MODULE_OFF(); INTERNAL_MODULE_OFF();
EXTERNAL_MODULE_OFF(); EXTERNAL_MODULE_OFF();
SPORT_UPDATE_POWER_OFF(); SPORT_UPDATE_POWER_OFF();
#endif
waitState(SPORT_IDLE, 500); // Clear the fifo waitState(SPORT_IDLE, 500); // Clear the fifo
#if defined(PCBTARANIS) || defined(PCBHORUS)
if (intPwr) if (intPwr)
INTERNAL_MODULE_ON(); INTERNAL_MODULE_ON();
if (extPwr) if (extPwr)
EXTERNAL_MODULE_ON(); EXTERNAL_MODULE_ON();
#endif
state = SPORT_IDLE; state = SPORT_IDLE;
+1 -1
View File
@@ -66,7 +66,7 @@ class DeviceFirmwareUpdate {
void flashFile(const char * filename); void flashFile(const char * filename);
protected: protected:
uint8_t state = SPORT_IDLE; uint8_t state = SPORT_IDLE;
uint32_t address = 0; uint32_t address = 0;
ModuleIndex module; ModuleIndex module;
uint8_t frame[12]; uint8_t frame[12];