[Taranis] EEPROM is written 64bytes per main cycle, instead of completely written in one cycle
[Taranis] Channels count may go down to 4
This commit is contained in:
+1
-1
@@ -50,7 +50,7 @@ extern uint8_t s_eeDirtyMsk;
|
|||||||
extern tmr10ms_t s_eeDirtyTime10ms;
|
extern tmr10ms_t s_eeDirtyTime10ms;
|
||||||
|
|
||||||
void eeDirty(uint8_t msk);
|
void eeDirty(uint8_t msk);
|
||||||
void eeCheck(bool immediately=false);
|
void eeCheck(bool immediately);
|
||||||
void eeReadAll();
|
void eeReadAll();
|
||||||
bool eeModelExists(uint8_t id);
|
bool eeModelExists(uint8_t id);
|
||||||
void eeLoadModelName(uint8_t id, char *name);
|
void eeLoadModelName(uint8_t id, char *name);
|
||||||
|
|||||||
+8
-4
@@ -42,13 +42,14 @@
|
|||||||
uint8_t s_write_err = 0; // error reasons
|
uint8_t s_write_err = 0; // error reasons
|
||||||
RlcFile theFile; //used for any file operation
|
RlcFile theFile; //used for any file operation
|
||||||
EeFs eeFs;
|
EeFs eeFs;
|
||||||
#if defined(PCBTARANIS)
|
|
||||||
|
#if defined(CPUARM)
|
||||||
blkid_t freeBlocks = 0;
|
blkid_t freeBlocks = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
uint8_t s_sync_write = false;
|
||||||
|
|
||||||
#if !defined(CPUARM)
|
#if !defined(CPUARM)
|
||||||
uint8_t s_sync_write = false;
|
|
||||||
uint16_t eeprom_pointer;
|
uint16_t eeprom_pointer;
|
||||||
const char * eeprom_buffer_data;
|
const char * eeprom_buffer_data;
|
||||||
volatile int8_t eeprom_buffer_size = 0;
|
volatile int8_t eeprom_buffer_size = 0;
|
||||||
@@ -832,19 +833,22 @@ void RlcFile::nextRlcWriteStep()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(CPUARM)
|
|
||||||
void RlcFile::flush()
|
void RlcFile::flush()
|
||||||
{
|
{
|
||||||
|
#if !defined(CPUARM)
|
||||||
while (eeprom_buffer_size > 0) wdt_reset();
|
while (eeprom_buffer_size > 0) wdt_reset();
|
||||||
|
#endif
|
||||||
|
|
||||||
ENABLE_SYNC_WRITE(true);
|
ENABLE_SYNC_WRITE(true);
|
||||||
|
|
||||||
while (m_write_len && !s_write_err)
|
while (m_write_len && !s_write_err)
|
||||||
nextWriteStep();
|
nextWriteStep();
|
||||||
|
|
||||||
while (isWriting() && !s_write_err)
|
while (isWriting() && !s_write_err)
|
||||||
nextRlcWriteStep();
|
nextRlcWriteStep();
|
||||||
|
|
||||||
ENABLE_SYNC_WRITE(false);
|
ENABLE_SYNC_WRITE(false);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (EEPROM_PROGRESS_BAR)
|
#if defined (EEPROM_PROGRESS_BAR)
|
||||||
void RlcFile::DisplayProgressBar(uint8_t x)
|
void RlcFile::DisplayProgressBar(uint8_t x)
|
||||||
|
|||||||
@@ -148,14 +148,9 @@ class EFile
|
|||||||
#define ERR_FULL 1
|
#define ERR_FULL 1
|
||||||
extern uint8_t s_write_err; // error reasons
|
extern uint8_t s_write_err; // error reasons
|
||||||
|
|
||||||
#if defined(CPUARM)
|
|
||||||
#define ENABLE_SYNC_WRITE(val)
|
|
||||||
#define IS_SYNC_WRITE_ENABLE() true
|
|
||||||
#else
|
|
||||||
extern uint8_t s_sync_write;
|
extern uint8_t s_sync_write;
|
||||||
#define ENABLE_SYNC_WRITE(val) s_sync_write = val;
|
#define ENABLE_SYNC_WRITE(val) s_sync_write = val;
|
||||||
#define IS_SYNC_WRITE_ENABLE() s_sync_write
|
#define IS_SYNC_WRITE_ENABLE() s_sync_write
|
||||||
#endif
|
|
||||||
|
|
||||||
///deliver current errno, this is reset in open
|
///deliver current errno, this is reset in open
|
||||||
inline uint8_t write_errno() { return s_write_err; }
|
inline uint8_t write_errno() { return s_write_err; }
|
||||||
@@ -201,10 +196,8 @@ public:
|
|||||||
void nextRlcWriteStep();
|
void nextRlcWriteStep();
|
||||||
void writeRlc(uint8_t i_fileId, uint8_t typ, uint8_t *buf, uint16_t i_len, uint8_t sync_write);
|
void writeRlc(uint8_t i_fileId, uint8_t typ, uint8_t *buf, uint16_t i_len, uint8_t sync_write);
|
||||||
|
|
||||||
#if !defined(CPUARM)
|
|
||||||
// flush the current write operation if any
|
// flush the current write operation if any
|
||||||
void flush();
|
void flush();
|
||||||
#endif
|
|
||||||
|
|
||||||
// read from opened file and decode rlc-coded data
|
// read from opened file and decode rlc-coded data
|
||||||
uint16_t readRlc(uint8_t *buf, uint16_t i_len);
|
uint16_t readRlc(uint8_t *buf, uint16_t i_len);
|
||||||
@@ -216,11 +209,7 @@ public:
|
|||||||
|
|
||||||
extern RlcFile theFile; //used for any file operation
|
extern RlcFile theFile; //used for any file operation
|
||||||
|
|
||||||
#if defined(CPUARM)
|
|
||||||
#define eeFlush()
|
|
||||||
#else
|
|
||||||
inline void eeFlush() { theFile.flush(); }
|
inline void eeFlush() { theFile.flush(); }
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined (EEPROM_PROGRESS_BAR)
|
#if defined (EEPROM_PROGRESS_BAR)
|
||||||
#define DISPLAY_PROGRESS_BAR(x) theFile.DisplayProgressBar(x)
|
#define DISPLAY_PROGRESS_BAR(x) theFile.DisplayProgressBar(x)
|
||||||
|
|||||||
@@ -1235,9 +1235,9 @@ void menuModelSetup(uint8_t event)
|
|||||||
CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.channelsStart, 32-8-moduleData.channelsCount);
|
CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.channelsStart, 32-8-moduleData.channelsCount);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
CHECK_INCDEC_MODELVAR_ZERO(event, moduleData.channelsCount, min<int8_t>(MAX_CHANNELS(moduleIdx), 32-8-moduleData.channelsStart));
|
CHECK_INCDEC_MODELVAR(event, moduleData.channelsCount, -4, min<int8_t>(MAX_CHANNELS(moduleIdx), 32-8-moduleData.channelsStart));
|
||||||
if ((k == ITEM_MODEL_EXTERNAL_MODULE_CHANNELS && g_model.externalModule == MODULE_TYPE_PPM) || (k == ITEM_MODEL_TRAINER_CHANNELS))
|
if ((k == ITEM_MODEL_EXTERNAL_MODULE_CHANNELS && g_model.externalModule == MODULE_TYPE_PPM) || (k == ITEM_MODEL_TRAINER_CHANNELS))
|
||||||
moduleData.ppmFrameLength = moduleData.channelsCount * 4;
|
SET_DEFAULT_PPM_FRAME_LENGTH(moduleIdx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1383,7 +1383,8 @@ void menuModelSetup(uint8_t event)
|
|||||||
case 1:
|
case 1:
|
||||||
#if defined(PCBSKY9X)
|
#if defined(PCBSKY9X)
|
||||||
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.moduleData[0].channelsStart, 32-8-g_model.moduleData[0].channelsCount);
|
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.moduleData[0].channelsStart, 32-8-g_model.moduleData[0].channelsCount);
|
||||||
g_model.moduleData[0].ppmFrameLength = 4*(NUM_PORT1_CHANNELS()-8);
|
g_model.moduleData[0].ppmFrameLength = max((int8_t)0, g_model.moduleData[0].channelsCount) * 4;
|
||||||
|
SET_DEFAULT_PPM_FRAME_LENGTH(0);
|
||||||
#else
|
#else
|
||||||
CHECK_INCDEC_MODELVAR(event, g_model.ppmNCH, -2, 4);
|
CHECK_INCDEC_MODELVAR(event, g_model.ppmNCH, -2, 4);
|
||||||
g_model.ppmFrameLength = g_model.ppmNCH * 8;
|
g_model.ppmFrameLength = g_model.ppmNCH * 8;
|
||||||
@@ -1393,7 +1394,7 @@ void menuModelSetup(uint8_t event)
|
|||||||
case 2:
|
case 2:
|
||||||
if (IS_PPM_PROTOCOL(protocol)) {
|
if (IS_PPM_PROTOCOL(protocol)) {
|
||||||
CHECK_INCDEC_MODELVAR(event, g_model.moduleData[0].channelsCount, -4, min<int8_t>(8, 32-8-g_model.moduleData[0].channelsStart));
|
CHECK_INCDEC_MODELVAR(event, g_model.moduleData[0].channelsCount, -4, min<int8_t>(8, 32-8-g_model.moduleData[0].channelsStart));
|
||||||
g_model.moduleData[0].ppmFrameLength = 4*(NUM_PORT1_CHANNELS()-8);
|
SET_DEFAULT_PPM_FRAME_LENGTH(0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
REPEAT_LAST_CURSOR_MOVE();
|
REPEAT_LAST_CURSOR_MOVE();
|
||||||
@@ -1415,11 +1416,11 @@ void menuModelSetup(uint8_t event)
|
|||||||
switch (m_posHorz) {
|
switch (m_posHorz) {
|
||||||
case 0:
|
case 0:
|
||||||
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.moduleData[1].channelsStart, 32-8-g_model.moduleData[1].channelsCount);
|
CHECK_INCDEC_MODELVAR_ZERO(event, g_model.moduleData[1].channelsStart, 32-8-g_model.moduleData[1].channelsCount);
|
||||||
g_model.moduleData[1].ppmFrameLength = 4*(NUM_PORT2_CHANNELS()-8);
|
SET_DEFAULT_PPM_FRAME_LENGTH(1);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
CHECK_INCDEC_MODELVAR(event, g_model.moduleData[1].channelsCount, -4, min<int8_t>(8, 32-8-g_model.moduleData[1].channelsStart));
|
CHECK_INCDEC_MODELVAR(event, g_model.moduleData[1].channelsCount, -4, min<int8_t>(8, 32-8-g_model.moduleData[1].channelsStart));
|
||||||
g_model.moduleData[1].ppmFrameLength = 4*(NUM_PORT2_CHANNELS()-8);
|
SET_DEFAULT_PPM_FRAME_LENGTH(1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -228,6 +228,8 @@ PACK(typedef struct t_ModuleData {
|
|||||||
uint8_t ppmPulsePol;
|
uint8_t ppmPulsePol;
|
||||||
}) ModuleData;
|
}) ModuleData;
|
||||||
|
|
||||||
|
#define SET_DEFAULT_PPM_FRAME_LENGTH(idx) g_model.moduleData[idx].ppmFrameLength = 4 * max((int8_t)0, g_model.moduleData[idx].channelsCount)
|
||||||
|
|
||||||
#if defined(PCBTARANIS)
|
#if defined(PCBTARANIS)
|
||||||
enum ModuleIndex {
|
enum ModuleIndex {
|
||||||
INTERNAL_MODULE,
|
INTERNAL_MODULE,
|
||||||
|
|||||||
+6
-4
@@ -3602,16 +3602,18 @@ void perMain()
|
|||||||
if (Eeprom32_process_state != E32_IDLE)
|
if (Eeprom32_process_state != E32_IDLE)
|
||||||
ee32_process();
|
ee32_process();
|
||||||
else if (TIME_TO_WRITE())
|
else if (TIME_TO_WRITE())
|
||||||
eeCheck();
|
eeCheck(false);
|
||||||
#elif defined(CPUARM)
|
#elif defined(CPUARM)
|
||||||
if (TIME_TO_WRITE())
|
if (theFile.isWriting())
|
||||||
eeCheck();
|
theFile.nextWriteStep();
|
||||||
|
else if (TIME_TO_WRITE())
|
||||||
|
eeCheck(false);
|
||||||
#else
|
#else
|
||||||
if (!eeprom_buffer_size) {
|
if (!eeprom_buffer_size) {
|
||||||
if (theFile.isWriting())
|
if (theFile.isWriting())
|
||||||
theFile.nextWriteStep();
|
theFile.nextWriteStep();
|
||||||
else if (TIME_TO_WRITE())
|
else if (TIME_TO_WRITE())
|
||||||
eeCheck();
|
eeCheck(false);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -186,11 +186,11 @@ void setupPulsesPXX(unsigned int port)
|
|||||||
|
|
||||||
/* PPM */
|
/* PPM */
|
||||||
static uint32_t pass[NUM_MODULES] = { MODULES_INIT(0) };
|
static uint32_t pass[NUM_MODULES] = { MODULES_INIT(0) };
|
||||||
uint32_t sendUpperChannels = 0;
|
int sendUpperChannels = 0;
|
||||||
if (pass[port]++ & 0x01) {
|
if (pass[port]++ & 0x01) {
|
||||||
sendUpperChannels = g_model.moduleData[port].channelsCount;
|
sendUpperChannels = g_model.moduleData[port].channelsCount;
|
||||||
}
|
}
|
||||||
for (uint32_t i=0; i<8; i++) {
|
for (int i=0; i<8; i++) {
|
||||||
if (flag1 & PXX_SEND_FAILSAFE) {
|
if (flag1 & PXX_SEND_FAILSAFE) {
|
||||||
if (g_model.moduleData[port].failsafeMode == FAILSAFE_NOPULSES) {
|
if (g_model.moduleData[port].failsafeMode == FAILSAFE_NOPULSES) {
|
||||||
if (i < sendUpperChannels)
|
if (i < sendUpperChannels)
|
||||||
|
|||||||
Reference in New Issue
Block a user