Filesystem marked as dirty on unexpected shutdown (v4.1 / ersky9x). By Michal, Thanks!
Protocol FAAST (FUTABA) removed. I will add later a configuration parameter. PPMsim ported from er9x
This commit is contained in:
@@ -89,9 +89,6 @@ SDCARD = NO
|
|||||||
# PXX (FrSky PCM) protocol
|
# PXX (FrSky PCM) protocol
|
||||||
PXX = NO
|
PXX = NO
|
||||||
|
|
||||||
# PPM16
|
|
||||||
PPM16 = NO
|
|
||||||
|
|
||||||
# DSM2 (Spektrum) protocol
|
# DSM2 (Spektrum) protocol
|
||||||
DSM2 = NO
|
DSM2 = NO
|
||||||
|
|
||||||
@@ -389,10 +386,6 @@ ifeq ($(PXX), YES)
|
|||||||
CPPDEFS += -DPXX
|
CPPDEFS += -DPXX
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(PPM16), YES)
|
|
||||||
CPPDEFS += -DPPM16
|
|
||||||
endif
|
|
||||||
|
|
||||||
ifeq ($(DSM2), SERIAL)
|
ifeq ($(DSM2), SERIAL)
|
||||||
CPPDEFS += -DDSM2 -DDSM2_SERIAL
|
CPPDEFS += -DDSM2 -DDSM2_SERIAL
|
||||||
endif
|
endif
|
||||||
|
|||||||
+13
-12
@@ -550,7 +550,7 @@ void menuProcModel(uint8_t event)
|
|||||||
lcd_outdezNAtt(7*FW,0,g_eeGeneral.currModel+1,INVERS+LEADING0,2);
|
lcd_outdezNAtt(7*FW,0,g_eeGeneral.currModel+1,INVERS+LEADING0,2);
|
||||||
|
|
||||||
uint8_t protocol = g_model.protocol;
|
uint8_t protocol = g_model.protocol;
|
||||||
MENU(STR_MENUSETUP, menuTabModel, e_Model, ((protocol==PROTO_PPM||protocol==PROTO_FAAST||IS_DSM2_PROTOCOL(protocol)||IS_PXX_PROTOCOL(protocol)) ? 12 : 11), {0,ZCHAR|(sizeof(g_model.name)-1),2,2,0,0,0,0,0,NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1,2,1});
|
MENU(STR_MENUSETUP, menuTabModel, e_Model, ((protocol<=PROTO_PPMSIM||IS_DSM2_PROTOCOL(protocol)||IS_PXX_PROTOCOL(protocol)) ? 12 : 11), {0,ZCHAR|(sizeof(g_model.name)-1),2,2,0,0,0,0,0,NUM_STICKS+NUM_POTS+NUM_ROTARY_ENCODERS-1,1,2});
|
||||||
|
|
||||||
uint8_t sub = m_posVert - 1;
|
uint8_t sub = m_posVert - 1;
|
||||||
|
|
||||||
@@ -657,23 +657,21 @@ void menuProcModel(uint8_t event)
|
|||||||
lcd_putsLeft(y, STR_PROTO);
|
lcd_putsLeft(y, STR_PROTO);
|
||||||
lcd_putsiAtt(MODEL_PARAM_OFS, y, STR_VPROTOS, protocol,
|
lcd_putsiAtt(MODEL_PARAM_OFS, y, STR_VPROTOS, protocol,
|
||||||
(attr && m_posHorz==0 ? (s_editMode>0 ? BLINK|INVERS : INVERS):0));
|
(attr && m_posHorz==0 ? (s_editMode>0 ? BLINK|INVERS : INVERS):0));
|
||||||
if (protocol == PROTO_PPM || protocol == PROTO_FAAST) {
|
if (protocol <= PROTO_PPMSIM) {
|
||||||
lcd_putsiAtt(MODEL_PARAM_OFS+4*FW, y, STR_NCHANNELS, g_model.ppmNCH+2, (attr && m_posHorz==1) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
lcd_putsiAtt(MODEL_PARAM_OFS+7*FW, y, STR_NCHANNELS, g_model.ppmNCH+2, (attr && m_posHorz==1) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
||||||
lcd_puts(MODEL_PARAM_OFS+11*FW, y, PSTR("u"));
|
|
||||||
lcd_outdezAtt(MODEL_PARAM_OFS+11*FW, y, (g_model.ppmDelay*50)+300, ((attr && m_posHorz==2) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0));
|
|
||||||
}
|
}
|
||||||
#ifdef DSM2
|
#ifdef DSM2
|
||||||
else if (protocol == PROTO_DSM2) {
|
else if (protocol == PROTO_DSM2) {
|
||||||
if (m_posHorz > 1) m_posHorz = 1;
|
if (m_posHorz > 1) m_posHorz = 1;
|
||||||
int8_t x = limit((int8_t)0, (int8_t)g_model.ppmNCH, (int8_t)2);
|
int8_t x = limit((int8_t)0, (int8_t)g_model.ppmNCH, (int8_t)2);
|
||||||
g_model.ppmNCH = x;
|
g_model.ppmNCH = x;
|
||||||
lcd_putsiAtt(MODEL_PARAM_OFS+5*FW, y, STR_DSM2MODE, x, (attr && m_posHorz==1) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
lcd_putsiAtt(MODEL_PARAM_OFS+7*FW, y, STR_DSM2MODE, x, (attr && m_posHorz==1) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
else if (attr) {
|
else if (attr) {
|
||||||
m_posHorz = 0;
|
m_posHorz = 0;
|
||||||
}
|
}
|
||||||
if (attr && (s_editMode>0 || p1valdiff || (protocol!=PROTO_PPM && protocol!=PROTO_FAAST && protocol!=PROTO_DSM2))) { // TODO avoid DSM2 when not defined
|
if (attr && (s_editMode>0 || p1valdiff || (protocol>PROTO_PPMSIM && !IS_DSM2_PROTOCOL(protocol)))) {
|
||||||
switch (m_posHorz) {
|
switch (m_posHorz) {
|
||||||
case 0:
|
case 0:
|
||||||
CHECK_INCDEC_MODELVAR(event, g_model.protocol,0, PROTO_MAX-1);
|
CHECK_INCDEC_MODELVAR(event, g_model.protocol,0, PROTO_MAX-1);
|
||||||
@@ -686,25 +684,28 @@ void menuProcModel(uint8_t event)
|
|||||||
#endif
|
#endif
|
||||||
CHECK_INCDEC_MODELVAR(event, g_model.ppmNCH, -2, 4);
|
CHECK_INCDEC_MODELVAR(event, g_model.ppmNCH, -2, 4);
|
||||||
break;
|
break;
|
||||||
case 2:
|
|
||||||
CHECK_INCDEC_MODELVAR(event, g_model.ppmDelay, -4, 10);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ITEM_MODEL_PROTOCOL_PARAMS:
|
case ITEM_MODEL_PROTOCOL_PARAMS:
|
||||||
if (protocol == PROTO_PPM || protocol == PROTO_FAAST) {
|
if (protocol <= PROTO_PPMSIM) {
|
||||||
lcd_putsLeft( y, STR_PPMFRAME);
|
lcd_putsLeft( y, STR_PPMFRAME);
|
||||||
lcd_puts(MODEL_PARAM_OFS+3*FW, y, STR_MS);
|
lcd_puts(MODEL_PARAM_OFS+3*FW, y, STR_MS);
|
||||||
lcd_outdezAtt(MODEL_PARAM_OFS, y, (int16_t)g_model.ppmFrameLength*5 + 225, ((attr && m_posHorz==0) ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0) | PREC1|LEFT);
|
lcd_outdezAtt(MODEL_PARAM_OFS, y, (int16_t)g_model.ppmFrameLength*5 + 225, ((attr && m_posHorz==0) ? (s_editMode>0 ? BLINK|INVERS : INVERS) : 0) | PREC1|LEFT);
|
||||||
lcd_putsiAtt(MODEL_PARAM_OFS+6*FW, y, STR_POSNEG, g_model.pulsePol, (attr && m_posHorz==1) ? INVERS : 0);
|
lcd_puts(MODEL_PARAM_OFS+8*FW+2, y, PSTR("us"));
|
||||||
|
lcd_outdezAtt(MODEL_PARAM_OFS+8*FW+2, y, (g_model.ppmDelay*50)+300, ((attr && m_posHorz==1) ? ((s_editMode>0) ? BLINK|INVERS : INVERS) : 0));
|
||||||
|
lcd_putcAtt(MODEL_PARAM_OFS+11*FW, y, g_model.pulsePol ? '-' : '+', (attr && m_posHorz==2) ? INVERS : 0);
|
||||||
|
|
||||||
if(attr && (s_editMode>0 || p1valdiff)) {
|
if(attr && (s_editMode>0 || p1valdiff)) {
|
||||||
switch (m_posHorz) {
|
switch (m_posHorz) {
|
||||||
case 0:
|
case 0:
|
||||||
CHECK_INCDEC_MODELVAR(event, g_model.ppmFrameLength, -20, 20);
|
CHECK_INCDEC_MODELVAR(event, g_model.ppmFrameLength, -20, 20);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
|
CHECK_INCDEC_MODELVAR(event, g_model.ppmDelay, -4, 10);
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
CHECK_INCDEC_MODELVAR(event, g_model.pulsePol, 0, 1);
|
CHECK_INCDEC_MODELVAR(event, g_model.pulsePol, 0, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-4
@@ -140,7 +140,7 @@ PACK(typedef struct t_EEGeneral {
|
|||||||
int8_t beeperLength:3;
|
int8_t beeperLength:3;
|
||||||
uint8_t hapticStrength:3;
|
uint8_t hapticStrength:3;
|
||||||
uint8_t gpsFormat:1;
|
uint8_t gpsFormat:1;
|
||||||
uint8_t spare4:1;
|
uint8_t unexpectedShutdown:1;
|
||||||
uint8_t speakerPitch;
|
uint8_t speakerPitch;
|
||||||
|
|
||||||
EXTRA_ARM_FIELDS
|
EXTRA_ARM_FIELDS
|
||||||
@@ -506,11 +506,10 @@ PACK(typedef struct t_TimerData {
|
|||||||
|
|
||||||
enum Protocols {
|
enum Protocols {
|
||||||
PROTO_PPM,
|
PROTO_PPM,
|
||||||
|
PROTO_PPM16,
|
||||||
|
PROTO_PPMSIM,
|
||||||
PROTO_PXX,
|
PROTO_PXX,
|
||||||
PROTO_DSM2,
|
PROTO_DSM2,
|
||||||
PROTO_PPM16,
|
|
||||||
PROTO_FAAST,
|
|
||||||
PROTO_PPMSIM,
|
|
||||||
PROTO_MAX
|
PROTO_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
+15
-3
@@ -2527,13 +2527,16 @@ int main(void)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PCBV4)
|
#if defined(PCBV4)
|
||||||
if (MCUSR != (1 << PORF))
|
if (MCUSR != (1 << PORF) && !g_eeGeneral.unexpectedShutdown)
|
||||||
#elif defined(PCBSTD)
|
#elif defined(PCBSTD)
|
||||||
if (MCUCSR != (1 << PORF))
|
if (MCUCSR != (1 << PORF))
|
||||||
|
#else
|
||||||
|
if (!g_eeGeneral.unexpectedShutdown)
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
#ifdef SPLASH
|
#ifdef SPLASH
|
||||||
if (g_model.protocol != PROTO_FAAST && g_model.protocol != PROTO_DSM2)
|
// TODO rather use another Model Parameter
|
||||||
|
if (g_model.protocol != PROTO_DSM2)
|
||||||
doSplash();
|
doSplash();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -2548,6 +2551,13 @@ int main(void)
|
|||||||
checkAlarm();
|
checkAlarm();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(PCBARM) || defined(PCBV4)
|
||||||
|
if (!g_eeGeneral.unexpectedShutdown) {
|
||||||
|
g_eeGeneral.unexpectedShutdown = 1;
|
||||||
|
eeDirty(EE_GENERAL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
clearKeyEvents(); //make sure no keys are down before proceeding
|
clearKeyEvents(); //make sure no keys are down before proceeding
|
||||||
|
|
||||||
lcdSetRefVolt(g_eeGeneral.contrast);
|
lcdSetRefVolt(g_eeGeneral.contrast);
|
||||||
@@ -2630,6 +2640,8 @@ int main(void)
|
|||||||
// Time to switch off
|
// Time to switch off
|
||||||
lcd_clear() ;
|
lcd_clear() ;
|
||||||
displayPopup(STR_SHUTDOWN);
|
displayPopup(STR_SHUTDOWN);
|
||||||
|
g_eeGeneral.unexpectedShutdown=0;
|
||||||
|
eeDirty(EE_GENERAL);
|
||||||
eeCheck(true);
|
eeCheck(true);
|
||||||
lcd_clear() ;
|
lcd_clear() ;
|
||||||
refreshDisplay() ;
|
refreshDisplay() ;
|
||||||
|
|||||||
+19
-10
@@ -55,7 +55,7 @@ inline void DSM2_EnableTXD(void)
|
|||||||
|
|
||||||
void set_timer3_capture( void ) ;
|
void set_timer3_capture( void ) ;
|
||||||
void set_timer3_ppm( void ) ;
|
void set_timer3_ppm( void ) ;
|
||||||
void setupPulsesPPM16( void ) ;
|
void setupPulsesPPM16( uint8_t proto ) ;
|
||||||
|
|
||||||
void startPulses()
|
void startPulses()
|
||||||
{
|
{
|
||||||
@@ -583,7 +583,6 @@ void setupPulses()
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(PPM16)
|
|
||||||
case PROTO_PPM16 :
|
case PROTO_PPM16 :
|
||||||
TCCR1B = 0 ; // Stop counter
|
TCCR1B = 0 ; // Stop counter
|
||||||
OCR1A = 40000 ; // Next frame starts in 20 mS
|
OCR1A = 40000 ; // Next frame starts in 20 mS
|
||||||
@@ -595,12 +594,24 @@ void setupPulses()
|
|||||||
TIMSK |= 0x10 ; // Enable COMPA
|
TIMSK |= 0x10 ; // Enable COMPA
|
||||||
TCCR1A = (0<<WGM10) ;
|
TCCR1A = (0<<WGM10) ;
|
||||||
TCCR1B = (1 << WGM12) | (2<<CS10) ; // CTC OCRA, 16MHz / 8
|
TCCR1B = (1 << WGM12) | (2<<CS10) ; // CTC OCRA, 16MHz / 8
|
||||||
setupPulsesPPM16();
|
setupPulsesPPM16(PROTO_PPM16);
|
||||||
|
OCR3A = 50000 ;
|
||||||
|
OCR3B = 5000 ;
|
||||||
|
set_timer3_ppm() ;
|
||||||
|
break ;
|
||||||
|
|
||||||
|
case PROTO_PPMSIM :
|
||||||
|
TCCR1B = 0 ; // Stop counter
|
||||||
|
TCNT1 = 0 ;
|
||||||
|
TIMSK &= ~0x3C ; // All interrupts off
|
||||||
|
ETIMSK &= ~(1<<OCIE1C) ; // COMPC1 off
|
||||||
|
TIFR = 0x3C ; // Clear all pending interrupts
|
||||||
|
ETIFR = 0x3F ; // Clear all pending interrupts
|
||||||
|
setupPulsesPPM16(PROTO_PPMSIM);
|
||||||
OCR3A = 50000 ;
|
OCR3A = 50000 ;
|
||||||
OCR3B = 5000 ;
|
OCR3B = 5000 ;
|
||||||
set_timer3_ppm() ;
|
set_timer3_ppm() ;
|
||||||
break ;
|
break ;
|
||||||
#endif
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
set_timer3_capture() ;
|
set_timer3_capture() ;
|
||||||
@@ -751,7 +762,6 @@ void set_timer3_capture()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(PPM16)
|
|
||||||
void set_timer3_ppm()
|
void set_timer3_ppm()
|
||||||
{
|
{
|
||||||
#ifndef SIMU
|
#ifndef SIMU
|
||||||
@@ -802,12 +812,12 @@ ISR(TIMER3_COMPA_vect) //2MHz pulse generation
|
|||||||
ISR(TIMER3_COMPB_vect) //2MHz pulse generation
|
ISR(TIMER3_COMPB_vect) //2MHz pulse generation
|
||||||
{
|
{
|
||||||
sei() ;
|
sei() ;
|
||||||
setupPulsesPPM16() ;
|
setupPulsesPPM16(g_model.protocol) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // SIMU
|
#endif // SIMU
|
||||||
|
|
||||||
void setupPulsesPPM16()
|
void setupPulsesPPM16(uint8_t proto)
|
||||||
{
|
{
|
||||||
int16_t PPM_range = g_model.extendedLimits ? 640*2 : 512*2; //range of 0.7..1.7msec
|
int16_t PPM_range = g_model.extendedLimits ? 640*2 : 512*2; //range of 0.7..1.7msec
|
||||||
|
|
||||||
@@ -816,11 +826,11 @@ void setupPulsesPPM16()
|
|||||||
//The pulse ISR is 2mhz that's why everything is multiplied by 2
|
//The pulse ISR is 2mhz that's why everything is multiplied by 2
|
||||||
uint16_t *ptr ;
|
uint16_t *ptr ;
|
||||||
ptr = (uint16_t *) &pulses2MHz[PULSES_SIZE/2] ;
|
ptr = (uint16_t *) &pulses2MHz[PULSES_SIZE/2] ;
|
||||||
uint8_t p= 16+g_model.ppmNCH*2; //Channels *2
|
uint8_t p= ( ( proto == PROTO_PPM16) ? 16 : 8 ) +g_model.ppmNCH*2 ; //Channels *2
|
||||||
uint16_t q=(g_model.ppmDelay*50+300)*2; //Stoplen *2
|
uint16_t q=(g_model.ppmDelay*50+300)*2; //Stoplen *2
|
||||||
uint16_t rest=22500u*2-q; //Minimum Framelen=22.5 ms
|
uint16_t rest=22500u*2-q; //Minimum Framelen=22.5 ms
|
||||||
rest += (int16_t(g_model.ppmFrameLength))*1000;
|
rest += (int16_t(g_model.ppmFrameLength))*1000;
|
||||||
for (uint8_t i=p-8; i<p; i++) { //NUM_CHNOUT
|
for (uint8_t i=(proto==PROTO_PPM16) ? p-8 : 0; i<p; i++) {
|
||||||
#ifdef PPM_CENTER_ADJUSTABLE
|
#ifdef PPM_CENTER_ADJUSTABLE
|
||||||
int16_t v = limit((int16_t)-PPM_range, g_chans512[i], (int16_t)PPM_range) + 2*(PPM_CENTER+g_model.servoCenter[i]);
|
int16_t v = limit((int16_t)-PPM_range, g_chans512[i], (int16_t)PPM_range) + 2*(PPM_CENTER+g_model.servoCenter[i]);
|
||||||
#else
|
#else
|
||||||
@@ -835,4 +845,3 @@ void setupPulsesPPM16()
|
|||||||
B3_comp_value = rest - 1000 ; // 500uS before end of sync pulse
|
B3_comp_value = rest - 1000 ; // 500uS before end of sync pulse
|
||||||
*(ptr+2) = 0;
|
*(ptr+2) = 0;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LEN_VPROTOS "\006"
|
#define LEN_VPROTOS "\006"
|
||||||
#define TR_VPROTOS "PPM\0 ""PXX\0 ""DSM2\0 ""PPM16\0""FUT\0 ""PPMsim"
|
#define TR_VPROTOS "PPM\0 ""PPM16\0""PPMsim""PXX\0 ""DSM2\0 "
|
||||||
|
|
||||||
#define LEN_POSNEG "\003"
|
#define LEN_POSNEG "\003"
|
||||||
#define TR_POSNEG "POS""NEG"
|
#define TR_POSNEG "POS""NEG"
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LEN_VPROTOS "\006"
|
#define LEN_VPROTOS "\006"
|
||||||
#define TR_VPROTOS "PPM\0 ""PXX\0 ""DSM2\0 ""PPM16\0""FUT\0 PPMsim"
|
#define TR_VPROTOS "PPM\0 ""PPM16\0""PPMsim""PXX\0 ""DSM2\0 "
|
||||||
|
|
||||||
#define LEN_POSNEG "\003"
|
#define LEN_POSNEG "\003"
|
||||||
#define TR_POSNEG "POS""NEG"
|
#define TR_POSNEG "POS""NEG"
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define LEN_VPROTOS "\006"
|
#define LEN_VPROTOS "\006"
|
||||||
#define TR_VPROTOS "PPM\0 ""PXX\0 ""DSM2\0 ""PPM16\0""FUT\0 PPMsim"
|
#define TR_VPROTOS "PPM\0 ""PPM16\0""PPMsim""PXX\0 ""DSM2\0 "
|
||||||
|
|
||||||
#define LEN_POSNEG "\003"
|
#define LEN_POSNEG "\003"
|
||||||
#define TR_POSNEG "POS""NEG"
|
#define TR_POSNEG "POS""NEG"
|
||||||
|
|||||||
Reference in New Issue
Block a user