Hopefully the last async eeprom write bug solved (missing wdt_reset)... Clear Mixes not working
This commit is contained in:
+5
-3
@@ -27,7 +27,7 @@
|
||||
|
||||
uint16_t eeprom_pointer;
|
||||
const char* eeprom_buffer_data;
|
||||
volatile size_t eeprom_buffer_size = 0;
|
||||
volatile int8_t eeprom_buffer_size = 0;
|
||||
|
||||
inline void eeprom_write_byte()
|
||||
{
|
||||
@@ -72,7 +72,9 @@ void eeWriteBlockCmp(const void *i_pointer_ram, void *i_pointer_eeprom, size_t s
|
||||
EECR |= (1<<EERIE);
|
||||
#endif
|
||||
|
||||
while (s_sync_write && eeprom_buffer_size > 0);
|
||||
if (s_sync_write) {
|
||||
while (eeprom_buffer_size > 0) wdt_reset();
|
||||
}
|
||||
}
|
||||
|
||||
#else
|
||||
@@ -235,7 +237,7 @@ bool keyState(EnumKeys enuk)
|
||||
#if defined (PCBV4)
|
||||
switch(enuk){
|
||||
case SW_ElevDR : return PINC & (1<<INP_C_ElevDR);
|
||||
|
||||
|
||||
case SW_AileDR : return PINC & (1<<INP_C_AileDR);
|
||||
|
||||
case SW_RuddDR : return PING & (1<<INP_G_RuddDR);
|
||||
|
||||
+6
-5
@@ -571,12 +571,13 @@ void RlcFile::nextRlcWriteStep()
|
||||
|
||||
void RlcFile::flush()
|
||||
{
|
||||
while (eeprom_buffer_size > 0);
|
||||
while (eeprom_buffer_size > 0) wdt_reset();
|
||||
|
||||
s_sync_write = true;
|
||||
while (theFile.m_write_len && !s_write_err)
|
||||
theFile.nextWriteStep();
|
||||
while (theFile.isWriting() && !s_write_err)
|
||||
theFile.nextRlcWriteStep();
|
||||
while (m_write_len && !s_write_err)
|
||||
nextWriteStep();
|
||||
while (isWriting() && !s_write_err)
|
||||
nextRlcWriteStep();
|
||||
s_sync_write = false;
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ void EeFsFormat();
|
||||
uint16_t EeFsGetFree();
|
||||
|
||||
#ifdef EEPROM_ASYNC_WRITE
|
||||
extern volatile size_t eeprom_buffer_size;
|
||||
extern volatile int8_t eeprom_buffer_size;
|
||||
#endif
|
||||
|
||||
class EFile
|
||||
|
||||
@@ -346,7 +346,7 @@ void menuProcTime(uint8_t event)
|
||||
|
||||
void menuProcTrainer(uint8_t event)
|
||||
{
|
||||
MENU("TRAINER", menuTabDiag, e_Trainer, 7, {0, 2, 2, 2, 2/*, 0, 0*/});
|
||||
MENU("TRAINER", menuTabDiag, e_Trainer, 7, {0, 2, 2, 2, 2, 0/*, 0*/});
|
||||
|
||||
int8_t sub = m_posVert;
|
||||
uint8_t subSub = m_posHorz;
|
||||
|
||||
+26
-16
@@ -632,8 +632,7 @@ void checkQuickSelect()
|
||||
lcd_clear();
|
||||
lcd_putsAtt(64-7*FW,0*FH,PSTR("LOADING"),DBLSIZE);
|
||||
|
||||
for(uint8_t i=0;i<sizeof(g_model.name);i++)
|
||||
lcd_putcAtt(FW*2+i*2*FW-i-2, 3*FH, g_model.name[i],DBLSIZE);
|
||||
putsModelName(2*FW, 3*FH, g_model.name, j, DBLSIZE);
|
||||
|
||||
refreshDiplay();
|
||||
lcdSetRefVolt(g_eeGeneral.contrast);
|
||||
@@ -677,6 +676,8 @@ void alert(const prog_char * s, bool defaults)
|
||||
BACKLIGHT_ON;
|
||||
else
|
||||
BACKLIGHT_OFF;
|
||||
|
||||
wdt_reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1579,13 +1580,23 @@ void perMain()
|
||||
g_menuStack[g_menuStackPtr](evt);
|
||||
refreshDiplay();
|
||||
|
||||
#if defined (PCBV4)
|
||||
// PPM signal on phono-jack. In or out? ...
|
||||
if(checkSlaveMode()) {
|
||||
PORTG |= (1<<OUT_G_SIM_CTL); // 1=ppm out
|
||||
}
|
||||
else{
|
||||
PORTG &= ~(1<<OUT_G_SIM_CTL); // 0=ppm in
|
||||
}
|
||||
#else
|
||||
// PPM signal on phono-jack. In or out? ...
|
||||
if(checkSlaveMode()) {
|
||||
PORTG &= ~(1<<OUT_G_SIM_CTL); // 0=ppm out
|
||||
}
|
||||
else{
|
||||
PORTG |= (1<<OUT_G_SIM_CTL); // 1=ppm-in
|
||||
}
|
||||
#endif
|
||||
|
||||
switch( get_tmr10ms() & 0x1f ) { //alle 10ms*32
|
||||
|
||||
@@ -1828,7 +1839,7 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer
|
||||
}
|
||||
}
|
||||
|
||||
#if defined (PCBV3)
|
||||
#if defined (PCBV3) && defined (BEEPSPKR)
|
||||
// G: use timer0 WGM mode tone generator for beeps
|
||||
if(beepOn)
|
||||
{
|
||||
@@ -1869,7 +1880,7 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer
|
||||
PORTE &= ~(1<<OUT_E_BUZZER);
|
||||
}
|
||||
#endif // BEEPSPKR
|
||||
#endif // PCBV3
|
||||
#endif // PCBV3 && BEEPSPKR
|
||||
|
||||
per10ms();
|
||||
|
||||
@@ -1905,25 +1916,25 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer
|
||||
// count delta values thus can range from about 1600 to 4400 counts (800us to 2200us),
|
||||
// corresponding to a PPM signal in the range 0.8ms to 2.2ms (1.5ms at center).
|
||||
// (The timer is free-running and is thus not reset to zero at each capture interval.)
|
||||
ISR(TIMER3_CAPT_vect, ISR_NOBLOCK) //capture ppm in 16MHz / 8 = 2MHz
|
||||
ISR(TIMER3_CAPT_vect) // G: High frequency noise can cause stack overflo with ISR_NOBLOCK
|
||||
{
|
||||
static uint16_t lastCapt;
|
||||
|
||||
uint16_t capture=ICR3;
|
||||
|
||||
cli(); // gruvin: are these global int disables really needed? Consult data sheet.
|
||||
// Prevent rentrance for this IRQ only
|
||||
#if defined (PCBV3)
|
||||
TIMSK3 &= ~(1<<ICIE3);
|
||||
#else
|
||||
ETIMSK &= ~(1<<TICIE3);
|
||||
#endif
|
||||
sei();
|
||||
sei(); // enable other interrupts
|
||||
|
||||
uint16_t val = (capture - lastCapt) / 2;
|
||||
|
||||
// G: We prcoess g_ppmInsright here to make servo movement as smooth as possible
|
||||
// G: We prcoess g_ppmIns immediately here, to make servo movement as smooth as possible
|
||||
// while under trainee control
|
||||
if (val>4000 && val < 16000) // G: Priorotise reset pulse. (Needed when less than 8 incoming pulses)
|
||||
if (val>4000 && val < 16000) // G: Prioritize reset pulse. (Needed when less than 8 incoming pulses)
|
||||
ppmInState = 1; // triggered
|
||||
else
|
||||
{
|
||||
@@ -1941,13 +1952,12 @@ ISR(TIMER3_CAPT_vect, ISR_NOBLOCK) //capture ppm in 16MHz / 8 = 2MHz
|
||||
|
||||
lastCapt = capture;
|
||||
|
||||
cli();
|
||||
cli(); // disable other interrupts for stack pops before this function's RETI
|
||||
#if defined (PCBV3)
|
||||
TIMSK3 |= (1<<ICIE3);
|
||||
#else
|
||||
ETIMSK |= (1<<TICIE3);
|
||||
#endif
|
||||
sei();
|
||||
}
|
||||
|
||||
#if defined (PCBV3)
|
||||
@@ -2085,9 +2095,9 @@ int main(void)
|
||||
DDRA = 0xff; PORTA = 0x00; // LCD data
|
||||
|
||||
#if defined (PCBV4)
|
||||
DDRB = 0b10010111; PORTB = 0b01101000; // 7:SPKR, 6:IDL2_S|PPM, 5:TrainSW, SDCARD[4:CS 3:MISO 2:MOSI 1:SCK], 0:PPM_OUT|IDL2_SW
|
||||
DDRB = 0b11000111; PORTB = 0b00111001; // 7:SPKR, 6:PPM_OUT, 5:TrainSW, 4:IDL2_SW, SDCARD[3:MISO 2:MOSI 1:SCK 0:CS]
|
||||
DDRC = 0x3f; PORTC = 0xc0; // 7:AilDR, 6:EleDR, LCD[5,4,3,2,1[, 0:BackLight
|
||||
DDRD = 0x01; PORTD = 0xfe; // 7/6:Spare3/4, 5:RENC2_PUSH, 4:RENC1_PUSH, 3:RENC2_B, 2:RENC2_A, 1:I2C_SDA, 0:I2C_SCL
|
||||
DDRD = 0x00; PORTD = 0xfc; // 7/6:Spare3/4, 5:RENC2_PUSH, 4:RENC1_PUSH, 3:RENC2_B, 2:RENC2_A, 1:I2C_SDA, 0:I2C_SCL
|
||||
DDRE = 0b00001010; PORTE = 0b11110101; // 7:PPM_IN, 6: RENC1_B, 5:RENC1_A, 4:USB_DNEG, 3:BUZZER, 2:USB_DPOS, 1:TELEM_TX, 0:TELEM_RX
|
||||
DDRF = 0x00; PORTF = 0x00; // 7-4:JTAG, 3:ADC_REF_1.2V input, 2-0:ADC_SPARE_2-0
|
||||
DDRG = 0b00010000; PORTG = 0xff; // 7-6:N/A, 5:GearSW, 4: Sim_Ctrl[out], 3:IDL1_Sw, 2:TCut_Sw, 1:RF_Power[in], 0: RudDr_Sw
|
||||
@@ -2161,16 +2171,16 @@ int main(void)
|
||||
// not here ... TIMSK1 |= (1<<OCIE1A); ... enable immediately before mainloop
|
||||
|
||||
// TCNT3 (2MHz) used for PPM_IN pulse width capture
|
||||
#if defined (PPMIN_MOD1) || defined (PCBV3)
|
||||
#if defined (PPMIN_MOD1) || (defined (PCBV3) && !defined (PCBV4))
|
||||
// Noise Canceller enabled, pos. edge, clock at 16MHz / 8 (2MHz)
|
||||
TCCR3B = (1<<ICNC3) | (1<<ICES3) | (0b010 << CS30);
|
||||
#else
|
||||
// Noise Canceller enabled, neg. edge, clock at 16MHz / 8 (2MHz)
|
||||
// Noise Canceller enabled, neg. edge, clock at 16MHz / 8 (2MHz) (Correct for PCB V4.x+ also)
|
||||
TCCR3B = (1<<ICNC3) | (0b010 << CS30);
|
||||
#endif
|
||||
|
||||
#if defined (PCBV3)
|
||||
TIMSK3 |= (1<<ICIE3); // Enable capture event interrupt
|
||||
TIMSK3 |= (1<<ICIE3); // Enable Timer 3 (PPM_IN) capture event interrupt
|
||||
#else
|
||||
ETIMSK |= (1<<TICIE3);
|
||||
#endif
|
||||
|
||||
+5
-3
@@ -175,7 +175,7 @@ extern uint16_t DEBUG2;
|
||||
# define OUT_B_Speaker 7
|
||||
# define OUT_B_PPM 6 // will be switched by TCNT1==OCR1B in hardware
|
||||
# define INP_B_Trainer 5
|
||||
# define INP_B_ID2 0
|
||||
# define INP_B_ID2 4
|
||||
|
||||
|
||||
#else // boards prior to v4 ...
|
||||
@@ -572,6 +572,9 @@ template<class t> inline int8_t sgn(t a){ return a>0 ? 1 : (a < 0 ? -1 : 0); }
|
||||
/// eeCheck ins EEPROM zurueckgeschrieben.
|
||||
void eeWriteBlockCmp(const void *i_pointer_ram, void *i_pointer_eeprom, size_t size);
|
||||
void eeDirty(uint8_t msk);
|
||||
#ifdef EEPROM_ASYNC_WRITE
|
||||
inline void eeFlush() { theFile.flush(); }
|
||||
#endif
|
||||
void eeCheck(bool immediately=false);
|
||||
//void eeWriteGeneral();
|
||||
void eeReadAll();
|
||||
@@ -684,7 +687,7 @@ inline void _beep(uint8_t b) {
|
||||
}
|
||||
|
||||
extern uint8_t toneFreq;
|
||||
#if defined (PCBV3)
|
||||
#if defined (PCBV3) && defined(BEEPSPKR)
|
||||
inline void _beepSpkr(uint8_t d, uint8_t f)
|
||||
{
|
||||
g_beepCnt=d;
|
||||
@@ -750,6 +753,5 @@ extern FATFS FATFS_Obj; // pers.cpp::resetTelemetry()
|
||||
extern FIL g_oLogFile; // pers.cpp::resetTelemetry()
|
||||
#endif
|
||||
|
||||
|
||||
#endif // gruvin9x_h
|
||||
/*eof*/
|
||||
|
||||
+23
-10
@@ -96,6 +96,11 @@ void menuProcModelSelect(uint8_t event) // TODO lignes sur tout du long
|
||||
int8_t subOld = m_posVert;
|
||||
if (!check_submenu_simple(event, MAX_MODELS-1)) return;
|
||||
|
||||
#ifdef EEPROM_ASYNC_WRITE
|
||||
// flush eeprom write so that it's possible to load model names
|
||||
eeFlush();
|
||||
#endif
|
||||
|
||||
lcd_puts_P( 9*FW, 0, PSTR("free"));
|
||||
lcd_outdezAtt( 17*FW, 0, EeFsGetFree(),0);
|
||||
|
||||
@@ -104,8 +109,6 @@ void menuProcModelSelect(uint8_t event) // TODO lignes sur tout du long
|
||||
int8_t sub = m_posVert;
|
||||
static uint8_t sel_editMode;
|
||||
|
||||
eeCheck(true); // force writing of current model data before this is changed
|
||||
|
||||
switch(event)
|
||||
{
|
||||
//case EVT_KEY_FIRST(KEY_MENU):
|
||||
@@ -114,6 +117,7 @@ void menuProcModelSelect(uint8_t event) // TODO lignes sur tout du long
|
||||
sel_editMode = false;
|
||||
beepKey();
|
||||
killEvents(event);
|
||||
eeCheck(true); // force writing of current model data before this is changed
|
||||
eeLoadModel(g_eeGeneral.currModel = m_posVert);
|
||||
STORE_GENERALVARS;
|
||||
break;
|
||||
@@ -125,6 +129,7 @@ void menuProcModelSelect(uint8_t event) // TODO lignes sur tout du long
|
||||
{
|
||||
killEvents(event);
|
||||
g_eeGeneral.currModel = m_posVert;
|
||||
eeCheck(true); // force writing of current model data before this is changed
|
||||
eeLoadModel(g_eeGeneral.currModel);
|
||||
STORE_GENERALVARS;
|
||||
beepWarn1();
|
||||
@@ -140,6 +145,7 @@ void menuProcModelSelect(uint8_t event) // TODO lignes sur tout du long
|
||||
case EVT_KEY_LONG(KEY_MENU):
|
||||
if(sel_editMode){
|
||||
// message(PSTR("Duplicating model"));
|
||||
eeCheck(true); // force writing of current model data before this is changed
|
||||
if (eeDuplicateModel(sub)) {
|
||||
beepKey();
|
||||
sel_editMode = false;
|
||||
@@ -152,10 +158,11 @@ void menuProcModelSelect(uint8_t event) // TODO lignes sur tout du long
|
||||
|
||||
case EVT_ENTRY:
|
||||
sel_editMode = false;
|
||||
m_posVert = g_eeGeneral.currModel;
|
||||
m_posVert = sub = g_eeGeneral.currModel;
|
||||
break;
|
||||
}
|
||||
if(sel_editMode && subOld!=sub){
|
||||
eeCheck(true); // force writing of current model data before this is changed
|
||||
#ifdef EEPROM_ASYNC_WRITE
|
||||
s_sync_write = true;
|
||||
#endif
|
||||
@@ -269,9 +276,14 @@ void menuProcModel(uint8_t _event)
|
||||
uint8_t event = (s_warning ? 0 : _event);
|
||||
|
||||
if (s_confirmation) {
|
||||
EFile::rm(FILE_MODEL(g_eeGeneral.currModel)); // delete file
|
||||
uint8_t i = g_eeGeneral.currModel;
|
||||
|
||||
#ifdef EEPROM_ASYNC_WRITE
|
||||
// flush eeprom write
|
||||
eeFlush();
|
||||
#endif
|
||||
EFile::rm(FILE_MODEL(i)); // delete file
|
||||
|
||||
uint8_t i = g_eeGeneral.currModel; // loop to find next available model
|
||||
while (!EFile::exists(FILE_MODEL(i))) {
|
||||
i--;
|
||||
if (i>MAX_MODELS) i=MAX_MODELS-1;
|
||||
@@ -285,6 +297,7 @@ void menuProcModel(uint8_t _event)
|
||||
eeLoadModel(i); // load default values
|
||||
s_confirmation = 0;
|
||||
chainMenu(menuProcModelSelect);
|
||||
return;
|
||||
}
|
||||
|
||||
MENU("SETUP", menuTabModel, e_Model, 11, {0,sizeof(g_model.name)-1,3,3,0,0,0,1,6,3/*, 0*/});
|
||||
@@ -1644,7 +1657,7 @@ void menuProcTelemetry(uint8_t event)
|
||||
case EVT_KEY_BREAK(KEY_UP):
|
||||
case EVT_KEY_BREAK(KEY_LEFT):
|
||||
case EVT_KEY_BREAK(KEY_RIGHT):
|
||||
if(s_editMode)
|
||||
if(s_editMode) // only fr-sky alarm fields have an edit mode
|
||||
FRSKY_setModelAlarms(); // update Fr-Sky module when edit mode exited
|
||||
}
|
||||
|
||||
@@ -1732,7 +1745,7 @@ void menuProcTelemetry(uint8_t event)
|
||||
#ifdef TEMPLATES
|
||||
void menuProcTemplates(uint8_t event)
|
||||
{
|
||||
SIMPLE_MENU("TEMPLATES", menuTabModel, e_Templates, NUM_TEMPLATES+2);
|
||||
SIMPLE_MENU("TEMPLATES", menuTabModel, e_Templates, 1+NUM_TEMPLATES+1);
|
||||
|
||||
uint8_t y = 0;
|
||||
uint8_t k = 0;
|
||||
@@ -1744,10 +1757,10 @@ void menuProcTemplates(uint8_t event)
|
||||
killEvents(event);
|
||||
//apply mixes or delete
|
||||
s_noHi = NO_HI_LEN;
|
||||
if(sub==NUM_TEMPLATES+1)
|
||||
clearMixes();
|
||||
else if((sub>=0) && (sub<(int8_t)NUM_TEMPLATES))
|
||||
if (sub>=0 && sub<(int8_t)NUM_TEMPLATES)
|
||||
applyTemplate(sub);
|
||||
if (sub==NUM_TEMPLATES)
|
||||
clearMixes();
|
||||
beepWarn1();
|
||||
break;
|
||||
}
|
||||
|
||||
+1
-2
@@ -312,7 +312,6 @@ bool eeDuplicateModel(uint8_t id)
|
||||
while((len=theFile2.read(buf, 15)))
|
||||
{
|
||||
theFile.write(buf, len);
|
||||
wdt_reset(); // TODO I don't know what it is
|
||||
if (errno() != 0) {
|
||||
return false;
|
||||
}
|
||||
@@ -373,7 +372,7 @@ void eeCheck(bool immediately)
|
||||
{
|
||||
#ifdef EEPROM_ASYNC_WRITE
|
||||
if (immediately) {
|
||||
theFile.flush();
|
||||
eeFlush();
|
||||
}
|
||||
if (s_eeDirtyMsk & EE_GENERAL) {
|
||||
s_eeDirtyMsk -= EE_GENERAL;
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@
|
||||
volatile unsigned char pinb=0, pinc=0xff, pind, pine=0xff, ping=0xff;
|
||||
unsigned char portb, dummyport;
|
||||
const char *eepromFile = "eeprom.bin";
|
||||
volatile size_t eeprom_buffer_size = 0;
|
||||
volatile int8_t eeprom_buffer_size = 0;
|
||||
|
||||
uint8_t eeprom[EESIZE];
|
||||
|
||||
|
||||
@@ -1,6 +0,0 @@
|
||||
//Automatically generated file (Makefile) - do not edit
|
||||
#define DATE_STR "2011-09-14"
|
||||
#define TIME_STR "11:11:34"
|
||||
#define TAG_VERS 2-bsongis
|
||||
#define SVN_VERS "open9x-r3"
|
||||
#define BUILD_NUM 841
|
||||
@@ -65,6 +65,7 @@ MixData* setDest(uint8_t dch)
|
||||
void clearMixes()
|
||||
{
|
||||
memset(g_model.mixData,0,sizeof(g_model.mixData)); //clear all mixes
|
||||
STORE_MODELVARS;
|
||||
}
|
||||
|
||||
void clearCurves()
|
||||
|
||||
Reference in New Issue
Block a user