S.PORT Flash fix

This commit is contained in:
Bertrand Songis
2019-06-06 17:04:08 +02:00
parent 1203557739
commit 5ae3eae1d4
5 changed files with 30 additions and 5 deletions
+13 -5
View File
@@ -165,6 +165,8 @@ const uint8_t * FrskyDeviceFirmwareUpdate::readHalfDuplexFrame(uint32_t timeout)
const uint8_t * FrskyDeviceFirmwareUpdate::readFrame(uint32_t timeout) const uint8_t * FrskyDeviceFirmwareUpdate::readFrame(uint32_t timeout)
{ {
RTOS_WAIT_MS(1);
switch(module) { switch(module) {
#if defined(INTMODULE_USART) #if defined(INTMODULE_USART)
case INTERNAL_MODULE: case INTERNAL_MODULE:
@@ -238,7 +240,10 @@ void FrskyDeviceFirmwareUpdate::sendFrame()
const char * FrskyDeviceFirmwareUpdate::sendPowerOn() const char * FrskyDeviceFirmwareUpdate::sendPowerOn()
{ {
state = SPORT_POWERUP_REQ; state = SPORT_POWERUP_REQ;
waitState(SPORT_IDLE, 50); // Wait 50ms and clear the fifo
RTOS_WAIT_MS(50);
telemetryClearFifo();
for (int i=0; i<10; i++) { for (int i=0; i<10; i++) {
// max 10 attempts // max 10 attempts
startFrame(PRIM_REQ_POWERUP); startFrame(PRIM_REQ_POWERUP);
@@ -268,7 +273,9 @@ const char * FrskyDeviceFirmwareUpdate::sendPowerOn()
const char * FrskyDeviceFirmwareUpdate::sendReqVersion() const char * FrskyDeviceFirmwareUpdate::sendReqVersion()
{ {
waitState(SPORT_IDLE, 20); // Clear the fifo RTOS_WAIT_MS(20);
telemetryClearFifo();
state = SPORT_VERSION_REQ; state = SPORT_VERSION_REQ;
for (int i=0; i<10; i++) { for (int i=0; i<10; i++) {
// max 10 attempts // max 10 attempts
@@ -299,7 +306,9 @@ const char * FrskyDeviceFirmwareUpdate::uploadFile(const char * filename)
} }
} }
waitState(SPORT_IDLE, 200); // Clear the fifo RTOS_WAIT_MS(200);
telemetryClearFifo();
state = SPORT_DATA_TRANSFER; state = SPORT_DATA_TRANSFER;
startFrame(PRIM_CMD_DOWNLOAD); startFrame(PRIM_CMD_DOWNLOAD);
sendFrame(); sendFrame();
@@ -385,11 +394,10 @@ void FrskyDeviceFirmwareUpdate::flashFirmware(const char * filename)
EXTERNAL_MODULE_OFF(); EXTERNAL_MODULE_OFF();
SPORT_UPDATE_POWER_OFF(); SPORT_UPDATE_POWER_OFF();
waitState(SPORT_IDLE, 500); // Clear the fifo
/* wait 2s off */ /* wait 2s off */
watchdogSuspend(2000); watchdogSuspend(2000);
RTOS_WAIT_MS(2000); RTOS_WAIT_MS(2000);
telemetryClearFifo();
if (intPwr) { if (intPwr) {
INTERNAL_MODULE_ON(); INTERNAL_MODULE_ON();
+1
View File
@@ -600,6 +600,7 @@ void telemetryPortSetDirectionOutput(void);
void sportSendByte(uint8_t byte); void sportSendByte(uint8_t byte);
void sportSendBuffer(const uint8_t * buffer, uint32_t count); void sportSendBuffer(const uint8_t * buffer, uint32_t count);
uint8_t telemetryGetByte(uint8_t * byte); uint8_t telemetryGetByte(uint8_t * byte);
void telemetryClearFifo();
extern uint32_t telemetryErrors; extern uint32_t telemetryErrors;
// Sport update driver // Sport update driver
@@ -235,3 +235,13 @@ uint8_t telemetryGetByte(uint8_t * byte)
return telemetryNoDMAFifo.pop(*byte); return telemetryNoDMAFifo.pop(*byte);
#endif #endif
} }
void telemetryClearFifo()
{
#if defined(PCBX12S)
telemetryDMAFifo.clear();
#endif
telemetryNoDMAFifo.clear();
}
+1
View File
@@ -696,6 +696,7 @@ void telemetryPortSetDirectionOutput(void);
void sportSendByte(uint8_t byte); void sportSendByte(uint8_t byte);
void sportSendBuffer(const uint8_t * buffer, uint32_t count); void sportSendBuffer(const uint8_t * buffer, uint32_t count);
uint8_t telemetryGetByte(uint8_t * byte); uint8_t telemetryGetByte(uint8_t * byte);
void telemetryClearFifo();
extern uint32_t telemetryErrors; extern uint32_t telemetryErrors;
// PCBREV driver // PCBREV driver
@@ -198,3 +198,8 @@ uint8_t telemetryGetByte(uint8_t * byte)
return telemetryFifo.pop(*byte); return telemetryFifo.pop(*byte);
#endif #endif
} }
void telemetryClearFifo()
{
telemetryFifo.clear();
}