5 * th9x - http://code.google.com/p/th9x
6 * er9x - http://code.google.com/p/er9x
7 * gruvin9x - http://code.google.com/p/gruvin9x
9 * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License version 2 as
13 * published by the Free Software Foundation.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
21 #ifndef _FRSKY_FIRMWARE_UPDATE_H_
22 #define _FRSKY_FIRMWARE_UPDATE_H_
24 #include "dataconstants.h"
25 #include "definitions.h"
26 #include "frsky_pxx2.h"
29 enum FrskyFirmwareProductFamily
{
30 FIRMWARE_FAMILY_INTERNAL_MODULE
,
31 FIRMWARE_FAMILY_EXTERNAL_MODULE
,
32 FIRMWARE_FAMILY_RECEIVER
,
33 FIRMWARE_FAMILY_SENSOR
,
34 FIRMWARE_FAMILY_BLUETOOTH_CHIP
,
35 FIRMWARE_FAMILY_POWER_MANAGEMENT_UNIT
,
38 enum FrskyFirmwareProductId
{
40 FIRMWARE_ID_XJT
= 0x01,
41 FIRMWARE_ID_ISRM
= 0x02,
44 PACK(struct FrSkyFirmwareInformation
{
46 uint8_t headerVersion
;
47 uint8_t firmwareVersionMajor
;
48 uint8_t firmwareVersionMinor
;
49 uint8_t firmwareVersionRevision
;
51 uint8_t productFamily
;
56 const char * readFrSkyFirmwareInformation(const char * filename
, FrSkyFirmwareInformation
& data
);
58 class FrskyDeviceFirmwareUpdate
{
72 FrskyDeviceFirmwareUpdate(ModuleIndex module
):
76 const char * flashFirmware(const char * filename
);
79 uint8_t state
= SPORT_IDLE
;
84 void startFrame(uint8_t command
);
87 bool readBuffer(uint8_t * buffer
, uint8_t count
, uint32_t timeout
);
88 const uint8_t * readFullDuplexFrame(ModuleFifo
& fifo
, uint32_t timeout
);
89 const uint8_t * readHalfDuplexFrame(uint32_t timeout
);
90 const uint8_t * readFrame(uint32_t timeout
);
91 bool waitState(State state
, uint32_t timeout
);
92 void processFrame(const uint8_t * frame
);
94 const char * doFlashFirmware(const char * filename
);
95 const char * sendPowerOn();
96 const char * sendReqVersion();
97 const char * uploadFileNormal(const char * filename
, FIL
* file
);
98 const char * uploadFileToHorusXJT(const char * filename
, FIL
* file
);
99 const char * endTransfer();
102 class FrskyChipFirmwareUpdate
{
104 FrskyChipFirmwareUpdate()
108 const char * flashFirmware(const char * filename
, bool wait
= true);
113 void sendByte(uint8_t byte
, bool crc
= true);
114 const char * waitAnswer(uint8_t & status
);
115 const char * startBootloader();
116 const char * sendUpgradeCommand(char command
, uint32_t packetsCount
);
117 const char * sendUpgradeData(uint32_t index
, uint8_t * data
);
119 const char * doFlashFirmware(const char * filename
);
122 #endif // _FRSKY_FIRMWARE_UPDATE_H_