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:
bsongis
2012-04-29 09:36:12 +00:00
parent 8868ee2686
commit 94d344765d
8 changed files with 53 additions and 39 deletions
-7
View File
@@ -89,9 +89,6 @@ SDCARD = NO
# PXX (FrSky PCM) protocol
PXX = NO
# PPM16
PPM16 = NO
# DSM2 (Spektrum) protocol
DSM2 = NO
@@ -389,10 +386,6 @@ ifeq ($(PXX), YES)
CPPDEFS += -DPXX
endif
ifeq ($(PPM16), YES)
CPPDEFS += -DPPM16
endif
ifeq ($(DSM2), SERIAL)
CPPDEFS += -DDSM2 -DDSM2_SERIAL
endif
+13 -12
View File
@@ -550,7 +550,7 @@ void menuProcModel(uint8_t event)
lcd_outdezNAtt(7*FW,0,g_eeGeneral.currModel+1,INVERS+LEADING0,2);
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;
@@ -657,23 +657,21 @@ void menuProcModel(uint8_t event)
lcd_putsLeft(y, STR_PROTO);
lcd_putsiAtt(MODEL_PARAM_OFS, y, STR_VPROTOS, protocol,
(attr && m_posHorz==0 ? (s_editMode>0 ? BLINK|INVERS : INVERS):0));
if (protocol == PROTO_PPM || protocol == PROTO_FAAST) {
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_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));
if (protocol <= PROTO_PPMSIM) {
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);
}
#ifdef DSM2
else if (protocol == PROTO_DSM2) {
if (m_posHorz > 1) m_posHorz = 1;
int8_t x = limit((int8_t)0, (int8_t)g_model.ppmNCH, (int8_t)2);
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
else if (attr) {
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) {
case 0:
CHECK_INCDEC_MODELVAR(event, g_model.protocol,0, PROTO_MAX-1);
@@ -686,25 +684,28 @@ void menuProcModel(uint8_t event)
#endif
CHECK_INCDEC_MODELVAR(event, g_model.ppmNCH, -2, 4);
break;
case 2:
CHECK_INCDEC_MODELVAR(event, g_model.ppmDelay, -4, 10);
break;
}
}
break;
case ITEM_MODEL_PROTOCOL_PARAMS:
if (protocol == PROTO_PPM || protocol == PROTO_FAAST) {
if (protocol <= PROTO_PPMSIM) {
lcd_putsLeft( y, STR_PPMFRAME);
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_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)) {
switch (m_posHorz) {
case 0:
CHECK_INCDEC_MODELVAR(event, g_model.ppmFrameLength, -20, 20);
break;
case 1:
CHECK_INCDEC_MODELVAR(event, g_model.ppmDelay, -4, 10);
break;
case 2:
CHECK_INCDEC_MODELVAR(event, g_model.pulsePol, 0, 1);
break;
}
+3 -4
View File
@@ -140,7 +140,7 @@ PACK(typedef struct t_EEGeneral {
int8_t beeperLength:3;
uint8_t hapticStrength:3;
uint8_t gpsFormat:1;
uint8_t spare4:1;
uint8_t unexpectedShutdown:1;
uint8_t speakerPitch;
EXTRA_ARM_FIELDS
@@ -506,11 +506,10 @@ PACK(typedef struct t_TimerData {
enum Protocols {
PROTO_PPM,
PROTO_PPM16,
PROTO_PPMSIM,
PROTO_PXX,
PROTO_DSM2,
PROTO_PPM16,
PROTO_FAAST,
PROTO_PPMSIM,
PROTO_MAX
};
+15 -3
View File
@@ -2527,13 +2527,16 @@ int main(void)
#endif
#if defined(PCBV4)
if (MCUSR != (1 << PORF))
if (MCUSR != (1 << PORF) && !g_eeGeneral.unexpectedShutdown)
#elif defined(PCBSTD)
if (MCUCSR != (1 << PORF))
if (MCUCSR != (1 << PORF))
#else
if (!g_eeGeneral.unexpectedShutdown)
#endif
{
#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();
#endif
@@ -2548,6 +2551,13 @@ int main(void)
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
lcdSetRefVolt(g_eeGeneral.contrast);
@@ -2630,6 +2640,8 @@ int main(void)
// Time to switch off
lcd_clear() ;
displayPopup(STR_SHUTDOWN);
g_eeGeneral.unexpectedShutdown=0;
eeDirty(EE_GENERAL);
eeCheck(true);
lcd_clear() ;
refreshDisplay() ;
+19 -10
View File
@@ -55,7 +55,7 @@ inline void DSM2_EnableTXD(void)
void set_timer3_capture( void ) ;
void set_timer3_ppm( void ) ;
void setupPulsesPPM16( void ) ;
void setupPulsesPPM16( uint8_t proto ) ;
void startPulses()
{
@@ -583,7 +583,6 @@ void setupPulses()
break;
#endif
#if defined(PPM16)
case PROTO_PPM16 :
TCCR1B = 0 ; // Stop counter
OCR1A = 40000 ; // Next frame starts in 20 mS
@@ -595,12 +594,24 @@ void setupPulses()
TIMSK |= 0x10 ; // Enable COMPA
TCCR1A = (0<<WGM10) ;
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 ;
OCR3B = 5000 ;
set_timer3_ppm() ;
break ;
#endif
default:
set_timer3_capture() ;
@@ -751,7 +762,6 @@ void set_timer3_capture()
#endif
}
#if defined(PPM16)
void set_timer3_ppm()
{
#ifndef SIMU
@@ -802,12 +812,12 @@ ISR(TIMER3_COMPA_vect) //2MHz pulse generation
ISR(TIMER3_COMPB_vect) //2MHz pulse generation
{
sei() ;
setupPulsesPPM16() ;
setupPulsesPPM16(g_model.protocol) ;
}
#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
@@ -816,11 +826,11 @@ void setupPulsesPPM16()
//The pulse ISR is 2mhz that's why everything is multiplied by 2
uint16_t *ptr ;
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 rest=22500u*2-q; //Minimum Framelen=22.5 ms
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
int16_t v = limit((int16_t)-PPM_range, g_chans512[i], (int16_t)PPM_range) + 2*(PPM_CENTER+g_model.servoCenter[i]);
#else
@@ -835,4 +845,3 @@ void setupPulsesPPM16()
B3_comp_value = rest - 1000 ; // 500uS before end of sync pulse
*(ptr+2) = 0;
}
#endif
+1 -1
View File
@@ -47,7 +47,7 @@
#endif
#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 TR_POSNEG "POS""NEG"
+1 -1
View File
@@ -47,7 +47,7 @@
#endif
#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 TR_POSNEG "POS""NEG"
+1 -1
View File
@@ -47,7 +47,7 @@
#endif
#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 TR_POSNEG "POS""NEG"