mixer_interrupt branch merged to trunk

timers on stock board should be more accurate
This commit is contained in:
bsongis
2012-06-18 13:38:31 +00:00
parent 963b07439b
commit 342b643661
9 changed files with 233 additions and 120 deletions
+5
View File
@@ -119,6 +119,11 @@ inline void board_init()
OCR4A = 0x7d;
TCCR4B = (1 << WGM42) | (3<<CS40); // CTC OCR1A, 16MHz / 64 (4us ticks)
/* Mixer interrupt */
OCR5A = 0x7d * 40; /* 20ms */
TCCR5B = (1 << WGM52) | (3<<CS50); // CTC OCR1A, 16MHz / 64 (4us ticks)
TIMSK5 |= (1<<OCIE5A);
#ifdef EXTRA_ROTARY_ENCODERS
//configure uart1 here
DDRD &= ~(1 << 2);
+22 -2
View File
@@ -38,12 +38,30 @@ void putEvent(uint8_t evt)
{
s_evt = evt;
}
#if defined(PCBV4)
uint8_t getEvent(bool trim)
{
uint8_t evt = s_evt;
int8_t k = (s_evt & EVT_KEY_MASK) - TRM_BASE;
bool trim_evt = (k>=0 && k<8);
if (trim == trim_evt) {
s_evt = 0;
return evt;
}
else {
return 0;
}
}
#else
uint8_t getEvent()
{
uint8_t evt = s_evt;
s_evt = 0;
return evt;
}
#endif
#if defined(PCBARM)
#define KEY_LONG_DELAY 32
@@ -105,7 +123,7 @@ void Key::input(bool val, EnumKeys enuk)
m_state >>= 1;
m_cnt = 0;
}
//fallthrough
// no break
case 1:
if( (m_cnt & (m_state-1)) == 0) putEvent(EVT_KEY_REPT(enuk));
break;
@@ -133,7 +151,6 @@ void killEvents(uint8_t event)
if(event < (int)DIM(keys)) keys[event].killEvents();
}
//uint16_t g_anaIns[8];
volatile uint16_t g_tmr10ms;
volatile uint8_t g_blinkTmr10ms;
@@ -141,6 +158,9 @@ void per10ms()
{
g_tmr10ms++;
g_blinkTmr10ms++;
if (s_noHi) s_noHi--;
if (trimsCheckTimer) trimsCheckTimer --;
#if defined (PCBARM)
Tenms |= 1 ; // 10 mS has passed
+2 -12
View File
@@ -110,7 +110,7 @@ void eeWriteBlockCmp(const void *i_pointer_ram, uint16_t i_pointer_eeprom, size_
#endif
if (s_sync_write) {
while (eeprom_buffer_size > 0) wdt_reset();
while (eeprom_buffer_size > 0) WDT_RESET_STOCK();
}
}
@@ -545,8 +545,6 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
}
#endif
wdt_reset();
// check and create folder here
strcpy_P(buf, STR_MODELS_PATH);
#ifndef SIMU
@@ -559,8 +557,6 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
}
#endif
wdt_reset();
buf[sizeof(MODELS_PATH)-1] = '/';
eeLoadModelName(i_fileSrc, &buf[sizeof(MODELS_PATH)]);
buf[sizeof(MODELS_PATH)+FILENAME_MAXLEN] = '\0';
@@ -599,8 +595,6 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
return SDCARD_ERROR(result);
}
wdt_reset();
result = f_write(&archiveFile, &g_eeGeneral.myVers, 1, &written);
if (result != FR_OK) {
return SDCARD_ERROR(result);
@@ -614,7 +608,6 @@ const pm_char * eeBackupModel(uint8_t i_fileSrc)
if (result != FR_OK) {
return SDCARD_ERROR(result);
}
wdt_reset();
}
f_close(&archiveFile);
@@ -632,8 +625,6 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
return SDCARD_ERROR(result);
}
wdt_reset();
strcpy_P(buf, STR_MODELS_PATH);
buf[sizeof(MODELS_PATH)-1] = '/';
strcpy(&buf[sizeof(MODELS_PATH)], model_name);
@@ -671,7 +662,6 @@ const pm_char * eeRestoreModel(uint8_t i_fileDst, char *model_name)
s_sync_write = false;
return STR_EEPROMOVERFLOW;
}
wdt_reset();
}
} while (read == 15);
@@ -805,7 +795,7 @@ void RlcFile::nextRlcWriteStep()
void RlcFile::flush()
{
while (eeprom_buffer_size > 0) wdt_reset();
while (eeprom_buffer_size > 0) WDT_RESET_STOCK();
s_sync_write = true;
while (m_write_len && !s_write_err)
-4
View File
@@ -54,8 +54,6 @@ const pm_char * openLogs()
return SDCARD_ERROR(result);
}
wdt_reset();
strcpy_P(buf, STR_LOGS_PATH);
result = f_opendir(&folder, buf);
@@ -66,8 +64,6 @@ const pm_char * openLogs()
return SDCARD_ERROR(result);
}
wdt_reset();
buf[sizeof(LOGS_PATH)-1] = '/';
memcpy(&buf[sizeof(LOGS_PATH)], g_model.name, sizeof(g_model.name));
buf[sizeof(LOGS_PATH)+FILENAME_MAXLEN] = '\0';
+40 -2
View File
@@ -150,7 +150,6 @@ bool listSDcardModels()
FRESULT res = f_opendir(&dir, MODELS_PATH); /* Open the directory */
if (res == FR_OK) {
for (;;) {
wdt_reset();
res = f_readdir(&dir, &fno); /* Read a directory item */
if (res != FR_OK || fno.fname[0] == 0) break; /* Break on error or end of dir */
if (fno.fname[0] == '.') continue; /* Ignore dot entry */
@@ -1229,8 +1228,28 @@ bool reachExpoMixCountLimit(uint8_t expo)
return false;
}
#if defined(PCBV4)
inline void pauseMixerCalculations()
{
cli();
TIMSK5 &= ~(1<<OCIE5A);
sei();
}
inline void resumeMixerCalculations()
{
cli();
TIMSK5 |= (1<<OCIE5A);
sei();
}
#else
#define pauseMixerCalculations()
#define resumeMixerCalculations()
#endif
void deleteExpoMix(uint8_t expo, uint8_t idx)
{
pauseMixerCalculations();
if (expo) {
memmove(expoaddress(idx), expoaddress(idx+1), (MAX_EXPOS-(idx+1))*sizeof(ExpoData));
memset(expoaddress(MAX_EXPOS-1), 0, sizeof(ExpoData));
@@ -1239,12 +1258,14 @@ void deleteExpoMix(uint8_t expo, uint8_t idx)
memmove(mixaddress(idx), mixaddress(idx+1), (MAX_MIXERS-(idx+1))*sizeof(MixData));
memset(mixaddress(MAX_MIXERS-1), 0, sizeof(MixData));
}
resumeMixerCalculations();
STORE_MODELVARS;
}
static int8_t s_currCh;
void insertExpoMix(uint8_t expo, uint8_t idx)
{
pauseMixerCalculations();
if (expo) {
ExpoData *expo = expoaddress(idx);
memmove(expo+1, expo, (MAX_EXPOS-(idx+1))*sizeof(ExpoData));
@@ -1261,11 +1282,13 @@ void insertExpoMix(uint8_t expo, uint8_t idx)
mix->srcRaw = (s_currCh > 4 ? s_currCh : channel_order(s_currCh));
mix->weight = 100;
}
resumeMixerCalculations();
STORE_MODELVARS;
}
void copyExpoMix(uint8_t expo, uint8_t idx)
{
pauseMixerCalculations();
if (expo) {
ExpoData *expo = expoaddress(idx);
memmove(expo+1, expo, (MAX_EXPOS-(idx+1))*sizeof(ExpoData));
@@ -1274,6 +1297,7 @@ void copyExpoMix(uint8_t expo, uint8_t idx)
MixData *mix = mixaddress(idx);
memmove(mix+1, mix, (MAX_MIXERS-(idx+1))*sizeof(MixData));
}
resumeMixerCalculations();
STORE_MODELVARS;
}
@@ -1283,11 +1307,13 @@ void memswap(void *a, void *b, uint8_t size)
uint8_t *y = (uint8_t*)b;
uint8_t temp ;
pauseMixerCalculations();
while (size--) {
temp = *x;
*x++ = *y;
*y++ = temp;
}
resumeMixerCalculations();
}
bool swapExpo(uint8_t &idx, uint8_t up)
@@ -1923,7 +1949,9 @@ void menuProcLimits(uint8_t _event)
if (event==EVT_KEY_LONG(KEY_MENU)) {
s_noHi = NO_HI_LEN;
killEvents(event);
pauseMixerCalculations();
moveTrimsToOffsets(); // if highlighted and menu pressed - move trims to offsets
resumeMixerCalculations();
}
}
return;
@@ -1961,11 +1989,21 @@ void menuProcLimits(uint8_t _event)
lcd_outdezAtt( 8*FW, y, ld->offset, attr|PREC1);
#endif
if (active) {
ld->offset = checkIncDec(event, ld->offset, -1000, 1000, EE_MODEL|NO_INCDEC_MARKS);
int16_t new_offset = checkIncDec(event, ld->offset, -1000, 1000, EE_MODEL|NO_INCDEC_MARKS);
#if defined(PCBV4)
if (checkIncDec_Ret)
#endif
{
pauseMixerCalculations();
ld->offset = new_offset;
resumeMixerCalculations();
}
}
else if (attr && event==EVT_KEY_LONG(KEY_MENU)) {
int16_t zero = g_chans512[k];
pauseMixerCalculations();
ld->offset = (ld->revert) ? -zero : zero;
resumeMixerCalculations();
s_editMode = 0;
STORE_MODELVARS;
}
+142 -87
View File
@@ -55,9 +55,10 @@ ModelData g_model;
uint8_t g_tmr1Latency_max;
uint8_t g_tmr1Latency_min;
#endif
uint16_t g_timeMain;
#ifdef DEBUG
uint16_t g_time_per10;
uint16_t g_timeMainMax;
#if defined(PCBV4)
uint8_t g_timeMainLast;
#endif
#ifdef AUDIO
@@ -771,7 +772,7 @@ void clearKeyEvents()
#ifdef SIMU
while (keyDown() && main_thread_running) sleep(1/*ms*/);
#else
while (keyDown()) wdt_reset(); // loop until all keys are up
while (keyDown()) WDT_RESET_STOCK(); // loop until all keys are up
#endif
memset(keys, 0, sizeof(keys));
putEvent(0);
@@ -902,7 +903,7 @@ void checkTHR()
checkBacklight();
wdt_reset();
WDT_RESET_STOCK();
}
}
@@ -945,7 +946,7 @@ void checkSwitches()
checkBacklight();
wdt_reset();
WDT_RESET_STOCK();
#ifdef SIMU
if (!main_thread_running) return;
@@ -972,7 +973,7 @@ void alert(const pm_char * t, const pm_char *s)
checkBacklight();
wdt_reset();
WDT_RESET_STOCK();
}
}
@@ -1003,12 +1004,21 @@ void message(const pm_char *title, const pm_char *t, const char *last)
clearKeyEvents();
}
#if defined(PCBV4)
void checkTrims()
{
uint8_t event = getEvent(true);
#else
uint8_t checkTrim(uint8_t event)
{
#endif
int8_t k = (event & EVT_KEY_MASK) - TRM_BASE;
int8_t s = g_model.trimInc;
if (k>=0 && k<8) { // && (event & _MSK_KEY_REPT))
#if !defined(PCBV4)
if (k>=0 && k<8)
#endif
{ // && (event & _MSK_KEY_REPT))
//LH_DWN LH_UP LV_DWN LV_UP RV_DWN RV_UP RH_DWN RH_UP
uint8_t idx = CONVERT_MODE(1+k/2) - 1;
uint8_t phase = getTrimFlightPhase(s_perout_flight_phase, idx);
@@ -1063,9 +1073,13 @@ uint8_t checkTrim(uint8_t event)
AUDIO_TRIM();
#endif
}
#if !defined(PCBV4)
return 0;
#endif
}
#if !defined(PCBV4)
return event;
#endif
}
#ifdef SIMU
@@ -1245,7 +1259,6 @@ void getADC_bandgap()
#endif // SIMU
uint8_t g_vbat100mV = 0;
volatile uint8_t tick10ms = 0;
uint16_t g_LightOffCounter;
@@ -1797,7 +1810,7 @@ void perOut()
sDelay[i] = md->delayUp * 100;
}
if (sDelay[i]) { // perform delay
if(tick10ms) sDelay[i]--;
if(tick10ms) sDelay[i]-=tick10ms;
if (!md->swtch) {
v = -1024;
}
@@ -1818,7 +1831,7 @@ void perOut()
sDelay[i] = md->delayDown * 100;
}
if (sDelay[i]) { // perform delay
if(tick10ms) sDelay[i]--;
if(tick10ms) sDelay[i]-=tick10ms;
if (!md->swtch) v = +1024;
has_delay = true;
}
@@ -1852,7 +1865,7 @@ void perOut()
//act[i] += diff>0 ? (32768)/((int16_t)100*md->speedUp) : -(32768)/((int16_t)100*md->speedDown);
//-100..100 => 32768 -> 100*83886/256 = 32768, For MAX we divide by 2 since it's asymmetrical
if (tick10ms) {
int32_t rate = (int32_t)DEL_MULT*2048*100;
int32_t rate = (int32_t)DEL_MULT*2048*100*tick10ms;
if(md->weight) rate /= abs(md->weight);
act[i] = (diff>0) ? ((md->speedUp>0) ? act[i]+(rate)/((int16_t)50*md->speedUp) : (int32_t)v*DEL_MULT) :
@@ -1925,12 +1938,27 @@ char userDataDisplayBuf[TELEM_SCREEN_BUFFER_SIZE];
#endif
int32_t sum_chans512[NUM_CHNOUT] = {0};
void perMain()
inline void doMixerCalculations(uint16_t tmr10ms, uint8_t tick10ms)
{
static uint16_t lastTMR;
uint16_t tmr10ms = get_tmr10ms();
tick10ms = (tmr10ms != lastTMR);
lastTMR = tmr10ms;
if (g_eeGeneral.filterInput == 1) {
getADC_filt() ;
}
else if ( g_eeGeneral.filterInput == 2) {
getADC_osmp() ;
}
else {
getADC_single() ;
}
#if defined(PCBARM) && defined(REVB)
Current_analogue = ( Current_analogue * 31 + s_anaFilt[8] ) >> 5 ;
#elif defined(PCBV4)
// For PCB V4, use our own 1.2V, external reference (connected to ADC3)
ADCSRB &= ~(1<<MUX5);
ADMUX = 0x03|ADC_VREF_TYPE; // Switch MUX to internal reference
#elif defined(PCBSTD)
ADMUX = 0x1E|ADC_VREF_TYPE; // Switch MUX to internal reference
#endif
#define MAX_ACT 0xffff
static uint16_t fp_act[MAX_PHASES] = {0};
@@ -1998,29 +2026,14 @@ void perMain()
sei();
}
// TODO same code here + integrate the timer which could be common
#if defined(PCBARM)
if (Tenms) {
Tenms = 0 ;
if (Eeprom32_process_state != E32_IDLE)
ee32_process();
else if (TIME_TO_WRITE)
eeCheck();
#if !defined(SIMU)
sd_poll_10mS();
#endif
}
#else
if (!eeprom_buffer_size) {
if (theFile.isWriting())
theFile.nextWriteStep();
else if (TIME_TO_WRITE)
eeCheck();
}
// Bandgap has had plenty of time to settle...
#if not defined(PCBARM)
getADC_bandgap();
#endif
if (!tick10ms) return; //make sure the rest happen only every 10ms.
/* Throttle trace */
int16_t val;
if (g_model.thrTraceSrc == 0) {
@@ -2036,7 +2049,6 @@ void perMain()
val += RESX;
val /= (RESX/16); // calibrate it
// Throttle trace start
static uint16_t s_time_tot;
static uint16_t s_time_trace;
static uint8_t s_cnt_1s;
@@ -2071,7 +2083,6 @@ void perMain()
if (s_traceCnt >= 0) s_traceCnt++; // TODO to be checked
}
}
// Throttle trace end
// Timers start
for (uint8_t i=0; i<2; i++) {
@@ -2102,7 +2113,7 @@ void perMain()
lastSwPos[i] = swPos;
}
if ( (s_timerVal_10ms[i] += 1 ) >= 100 ) {
if ( (s_timerVal_10ms[i] += tick10ms ) >= 100 ) {
s_timerVal_10ms[i] -= 100 ;
if (tv) s_timerVal[i] = tv - s_timerVal[i];
@@ -2176,16 +2187,16 @@ void perMain()
for (uint8_t p=0; p<MAX_PHASES; p++) {
if (s_fade_flight_phases & (1<<p)) {
if (p == phase) {
if (MAX_ACT - fp_act[p] > delta)
fp_act[p] += delta;
if (MAX_ACT - fp_act[p] > delta * tick10ms)
fp_act[p] += delta * tick10ms;
else {
fp_act[p] = MAX_ACT;
s_fade_flight_phases -= (1<<p);
}
}
else {
if (fp_act[p] > delta)
fp_act[p] -= delta;
if (fp_act[p] > delta * tick10ms)
fp_act[p] -= delta * tick10ms;
else {
fp_act[p] = 0;
s_fade_flight_phases -= (1<<p);
@@ -2196,9 +2207,42 @@ void perMain()
}
evalFunctions();
}
if (s_noHi) s_noHi--;
if (trimsCheckTimer) trimsCheckTimer --;
void perMain()
{
static uint16_t lastTMR;
uint16_t tmr10ms = get_tmr10ms();
uint8_t tick10ms = (tmr10ms - lastTMR);
lastTMR = tmr10ms;
#if !defined(PCBV4)
doMixerCalculations(tmr10ms, tick10ms);
#endif
// TODO same code here + integrate the timer which could be common
#if defined(PCBARM)
if (Tenms) {
Tenms = 0 ;
if (Eeprom32_process_state != E32_IDLE)
ee32_process();
else if (TIME_TO_WRITE)
eeCheck();
#if !defined(SIMU)
sd_poll_10mS();
#endif
}
#else
if (!eeprom_buffer_size) {
if (theFile.isWriting())
theFile.nextWriteStep();
else if (TIME_TO_WRITE)
eeCheck();
}
#endif
if (!tick10ms) return; //make sure the rest happen only every 10ms.
if (g_eeGeneral.inactivityTimer && g_vbat100mV>50) {
inacCounter++;
@@ -2243,8 +2287,13 @@ void perMain()
#endif
lcd_clear();
#if defined(PCBV4)
uint8_t evt = getEvent(false);
#else
uint8_t evt = getEvent();
evt = checkTrim(evt);
#endif
// TODO port lightOnStickMove from er9x + flash saving, call checkBacklight()
if(g_LightOffCounter) g_LightOffCounter--;
@@ -2320,6 +2369,7 @@ void perMain()
break;
}
}
int16_t g_ppmIns[8];
uint8_t ppmInState = 0; //0=unsync 1..8= wait for value i-1
@@ -2351,6 +2401,43 @@ uint16_t getTmr16KHz()
}
}
#if defined (PCBV4)
ISR(TIMER5_COMPA_vect, ISR_NOBLOCK) // mixer interrupt
{
cli();
TIMSK5 &= ~(1<<OCIE5A); //stop reentrance
OCR5A = 0x7d * 40; /* 20ms */
sei();
uint16_t t0 = getTmr16KHz();
static uint16_t lastTMR;
uint16_t tmr10ms = get_tmr10ms();
uint8_t tick10ms = (tmr10ms - lastTMR);
lastTMR = tmr10ms;
if (s_current_protocol < PROTO_NONE) {
checkTrims();
doMixerCalculations(tmr10ms, tick10ms);
}
heartbeat |= HEART_TIMER10ms;
if (heartbeat == HEART_TIMER_PULSES+HEART_TIMER10ms) {
wdt_reset();
heartbeat = 0;
}
t0 = getTmr16KHz() - t0;
g_timeMainLast = t0 / 8;
if (t0 > g_timeMainMax) g_timeMainMax = t0 ;
cli();
TIMSK5 |= (1<<OCIE5A); //stop reentrance
sei();
}
#endif
#if defined (PCBV4)
ISR(TIMER2_COMPA_vect, ISR_NOBLOCK) //10ms timer
#else
@@ -2376,7 +2463,7 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer
#endif
sei();
#if defined (PCBSTD) && defined (AUDIO)
AUDIO_DRIVER();
static uint8_t cnt10ms = 77; // execute 10ms code once every 78 ISRs
@@ -2391,39 +2478,29 @@ ISR(TIMER0_COMP_vect, ISR_NOBLOCK) //10ms timer
HAPTIC_HEARTBEAT();
#endif
#ifdef DEBUG
// Record start time from TCNT1 to record excution time
cli();
uint16_t dt=TCNT1;// TCNT1 (used for PPM out pulse generation) is running at 2MHz
sei();
#endif
per10ms();
#if defined (PCBV4) && defined(SDCARD)
disk_timerproc();
#endif
#if !defined(PCBV4)
heartbeat |= HEART_TIMER10ms;
#ifdef DEBUG
// Record per10ms ISR execution time, in us(x2) for STAT2 page
cli();
uint16_t dt2 = TCNT1; // capture end time
sei();
g_time_per10 = dt2 - dt; // NOTE: These spike to nearly 65535 just now and then. Why? :/
#endif
#if defined (PCBSTD) && defined (AUDIO)
} // end 10ms event
#endif
cli();
#if defined (PCBV4)
TIMSK2 |= (1<<OCIE2A);
#else
TIMSK |= (1<<OCIE0);
#endif
sei();
}
@@ -2820,37 +2897,13 @@ int main(void)
#if defined(PCBARM)
uint16_t t0 = getTmr2MHz();
#else
uint16_t t0 = getTmr16KHz();
#endif
if (g_eeGeneral.filterInput == e_adc_filtered) {
getADC_filt() ;
}
else if ( g_eeGeneral.filterInput == e_adc_osmp) {
getADC_osmp() ;
}
else {
getADC_single() ;
}
#if defined(PCBARM) && defined(REVB)
Current_analogue = ( Current_analogue * 31 + s_anaFilt[8] ) >> 5 ;
#elif defined(PCBV4)
// For PCB V4, use our own 1.2V, external reference (connected to ADC3)
ADCSRB &= ~(1<<MUX5);
ADMUX = 0x03|ADC_VREF_TYPE; // Switch MUX to internal reference
#elif defined(PCBSTD)
ADMUX = 0x1E|ADC_VREF_TYPE; // Switch MUX to internal reference
uint16_t t0 = getTmr16KHz();
#endif
perMain();
// Bandgap has had plenty of time to settle...
#if not defined(PCBARM)
getADC_bandgap();
#endif
#if !defined(PCBV4)
if(heartbeat == 0x3)
{
wdt_reset();
@@ -2862,7 +2915,9 @@ int main(void)
t0 = getTmr16KHz() - t0;
#endif
if (t0 > g_timeMain) g_timeMain = t0 ;
if (t0 > g_timeMainMax) g_timeMainMax = t0 ;
#endif
}
#if defined(PCBARM) || defined(PCBV4)
+13 -4
View File
@@ -41,6 +41,12 @@
#include <string.h>
#include <stddef.h>
#if defined(PCBSTD)
#define WDT_RESET_STOCK() wdt_reset()
#else
#define WDT_RESET_STOCK()
#endif
#if defined(PCBARM)
#include "board_ersky9x.h"
#endif
@@ -478,7 +484,11 @@ extern char idx2char(int8_t idx);
void clearKeyEvents();
void pauseEvents(uint8_t enuk);
void killEvents(uint8_t enuk);
#if defined(PCBV4)
uint8_t getEvent(bool trim);
#else
uint8_t getEvent();
#endif
void putEvent(uint8_t evt);
uint8_t keyDown();
@@ -559,9 +569,9 @@ void resetAll();
extern uint8_t g_tmr1Latency_max;
extern uint8_t g_tmr1Latency_min;
extern uint16_t g_timeMain;
#ifdef DEBUG
extern uint16_t g_time_per10;
extern uint16_t g_timeMainMax;
#if defined(PCBV4)
extern uint8_t g_timeMainLast;
#endif
#define MAXTRACE 120
@@ -748,7 +758,6 @@ extern uint8_t ppmInState; //0=unsync 1..8= wait for value i-1
extern int16_t g_ppmIns[8];
extern int16_t ex_chans[NUM_CHNOUT]; // Outputs (before LIMITS) of the last perMain
extern int16_t g_chans512[NUM_CHNOUT];
extern volatile uint8_t tick10ms;
extern uint16_t BandGap;
extern uint16_t expou(uint16_t x, uint16_t k);
+6
View File
@@ -204,6 +204,12 @@ void setupPulsesPPM(uint8_t proto)
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
uint32_t rest = 22500u*2 - q; // Minimum Framelen=22.5ms
#if defined(PCBV4)
OCR5A = (uint16_t)0x7d * (45+g_model.ppmFrameLength-g_timeMainLast-2/*1ms*/);
TCNT5 = 0;
#endif
rest += (int32_t(g_model.ppmFrameLength))*1000;
for (uint8_t i=(proto==PROTO_PPM16) ? p-8 : 0; i<p; i++) {
#ifdef PPM_CENTER_ADJUSTABLE
+3 -9
View File
@@ -88,7 +88,7 @@ void menuProcDebug(uint8_t event)
g_tmr1Latency_min = 0xff;
g_tmr1Latency_max = 0;
#endif
g_timeMain = 0;
g_timeMainMax = 0;
AUDIO_KEYPAD_UP();
break;
case EVT_KEY_FIRST(KEY_DOWN):
@@ -111,9 +111,9 @@ void menuProcDebug(uint8_t event)
lcd_putsLeft(4*FH, STR_TMAINMAXMS);
#if defined(PCBARM)
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 4*FH, (g_timeMain)/20, PREC2);
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 4*FH, (g_timeMainMax)/20, PREC2);
#else
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 4*FH, (g_timeMain*100)/16, PREC2);
lcd_outdezAtt(MENU_DEBUG_COL_OFS, 4*FH, (g_timeMainMax*100)/16, PREC2);
#endif
#if defined(PCBARM)
@@ -133,11 +133,5 @@ void menuProcDebug(uint8_t event)
lcd_outdezAtt(14*FW, 5*FH, stack_free(), UNSIGN) ;
#endif
#ifdef DEBUG
lcd_puts( 0*FW, 6*FH, STR_T10MSUS);
lcd_outdez8(MENU_DEBUG_COL_OFS, 6*FH, g_time_per10/2 );
#endif
lcd_puts( 3*FW, 7*FH, STR_MENUTORESET);
}