mirror of
https://github.com/opentx/opentx.git
synced 2025-07-26 17:55:19 +03:00
[gruvin9x] DSM2-PPM better timings
This commit is contained in:
parent
fa28b67db6
commit
7d63dbf226
3 changed files with 8 additions and 11 deletions
|
@ -97,7 +97,7 @@ uint8_t unexpectedShutdown = 0;
|
||||||
|
|
||||||
uint16_t g_timeMainMax;
|
uint16_t g_timeMainMax;
|
||||||
#if defined(PCBGRUVIN9X)
|
#if defined(PCBGRUVIN9X)
|
||||||
uint8_t g_timeMainLast;
|
uint8_t lastMixerDuration;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(AUDIO) && !defined(PCBSKY9X)
|
#if defined(AUDIO) && !defined(PCBSKY9X)
|
||||||
|
@ -3040,7 +3040,7 @@ ISR(TIMER5_COMPA_vect, ISR_NOBLOCK) // mixer interrupt
|
||||||
}
|
}
|
||||||
|
|
||||||
t0 = getTmr16KHz() - t0;
|
t0 = getTmr16KHz() - t0;
|
||||||
g_timeMainLast = t0 / 8;
|
lastMixerDuration = t0 / 8;
|
||||||
if (t0 > g_timeMainMax) g_timeMainMax = t0 ;
|
if (t0 > g_timeMainMax) g_timeMainMax = t0 ;
|
||||||
|
|
||||||
cli();
|
cli();
|
||||||
|
|
|
@ -771,7 +771,7 @@ extern uint8_t g_tmr1Latency_max;
|
||||||
extern uint8_t g_tmr1Latency_min;
|
extern uint8_t g_tmr1Latency_min;
|
||||||
extern uint16_t g_timeMainMax;
|
extern uint16_t g_timeMainMax;
|
||||||
#if defined(PCBGRUVIN9X)
|
#if defined(PCBGRUVIN9X)
|
||||||
extern uint8_t g_timeMainLast;
|
extern uint8_t lastMixerDuration;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(THRTRACE)
|
#if defined(THRTRACE)
|
||||||
|
|
|
@ -194,13 +194,6 @@ void setupPulsesPPM(uint8_t proto)
|
||||||
uint8_t p = (proto == PROTO_PPM16 ? 16 : 8) + (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
|
||||||
uint32_t rest = 22500u*2 - q; // Minimum Framelen=22.5ms
|
uint32_t rest = 22500u*2 - q; // Minimum Framelen=22.5ms
|
||||||
|
|
||||||
#if defined(PCBGRUVIN9X)
|
|
||||||
if (proto == PROTO_PPM) {
|
|
||||||
OCR5A = (uint16_t)0x7d * (45+g_model.ppmFrameLength-g_timeMainLast-2/*1ms*/);
|
|
||||||
TCNT5 = 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
rest += (int32_t(g_model.ppmFrameLength))*1000;
|
rest += (int32_t(g_model.ppmFrameLength))*1000;
|
||||||
for (uint8_t i=(proto==PROTO_PPM16) ? p-8 : 0; i<p; i++) {
|
for (uint8_t i=(proto==PROTO_PPM16) ? p-8 : 0; i<p; i++) {
|
||||||
|
@ -891,7 +884,7 @@ void setupPulses()
|
||||||
#ifdef DSM2
|
#ifdef DSM2
|
||||||
case PROTO_DSM2:
|
case PROTO_DSM2:
|
||||||
#if defined(PCBGRUVIN9X)
|
#if defined(PCBGRUVIN9X)
|
||||||
OCR5A = (uint16_t)0x7d * (40-g_timeMainLast-2/*1ms*/);
|
OCR5A = (uint16_t)0x7d * (44-lastMixerDuration-2/*1ms*/);
|
||||||
TCNT5 = 0;
|
TCNT5 = 0;
|
||||||
#endif
|
#endif
|
||||||
sei();
|
sei();
|
||||||
|
@ -913,6 +906,10 @@ void setupPulses()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
#if defined(PCBGRUVIN9X)
|
||||||
|
OCR5A = (uint16_t)0x7d * (45+g_model.ppmFrameLength-lastMixerDuration-2/*1ms*/);
|
||||||
|
TCNT5 = 0;
|
||||||
|
#endif
|
||||||
// no sei here
|
// no sei here
|
||||||
setupPulsesPPM(PROTO_PPM);
|
setupPulsesPPM(PROTO_PPM);
|
||||||
// if PPM16, PPM16 pulses are set up automatically within the interrupts
|
// if PPM16, PPM16 pulses are set up automatically within the interrupts
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue