Problem with timers after 10 seconds

Warning removed
This commit is contained in:
bsongis
2012-08-28 10:14:24 +00:00
parent c08302ecb5
commit 0dac1386ec
6 changed files with 39 additions and 37 deletions
+2 -2
View File
@@ -146,8 +146,8 @@ void killEvents(uint8_t event)
if (event < (int)DIM(keys)) keys[event].killEvents(); if (event < (int)DIM(keys)) keys[event].killEvents();
} }
volatile uint16_t g_tmr10ms; volatile tmr10ms_t g_tmr10ms;
volatile uint8_t g_blinkTmr10ms; volatile uint8_t g_blinkTmr10ms;
void per10ms() void per10ms()
{ {
+1 -3
View File
@@ -513,6 +513,7 @@ const char * sdSwReset(uint32_t retry)
#define OCR_SDIO_MP (1UL << 27) #define OCR_SDIO_MP (1UL << 27)
#define OCR_SDIO_NF (7UL << 28) #define OCR_SDIO_NF (7UL << 28)
#if 0
const char * sdIdentify() const char * sdIdentify()
{ {
uint8_t mem = 0, io = 0, f8 = 0, mp = 1; uint8_t mem = 0, io = 0, f8 = 0, mp = 1;
@@ -608,7 +609,6 @@ const char * sdIdentify()
return 0; return 0;
} }
#if 0
const char * sdEnum() const char * sdEnum()
{ {
uint8_t mem , io; uint8_t mem , io;
@@ -709,9 +709,7 @@ const char * sdEnum()
if (bwExec || hsExec) SdMmcUpdateInformation(pSd, hsExec, 1); if (bwExec || hsExec) SdMmcUpdateInformation(pSd, hsExec, 1);
return 0; return 0;
} }
#endif
#if 0
void sdInit() void sdInit()
{ {
const char * result; const char * result;
+1 -1
View File
@@ -129,7 +129,7 @@ void writeLogs()
{ {
if (isFunctionActive(FUNC_LOGS) && logDelay > 0) { if (isFunctionActive(FUNC_LOGS) && logDelay > 0) {
uint16_t tmr10ms = get_tmr10ms(); uint16_t tmr10ms = get_tmr10ms();
if (lastLogTime == 0 || tmr10ms - lastLogTime >= 10*logDelay) { if (lastLogTime == 0 || (tmr10ms_t)(tmr10ms - lastLogTime) >= (tmr10ms_t)logDelay*10) {
lastLogTime = tmr10ms; lastLogTime = tmr10ms;
if (!g_oLogFile.fs) { if (!g_oLogFile.fs) {
+17 -14
View File
@@ -643,30 +643,33 @@ const char * displayMenu(uint8_t event)
} }
char statusLineMsg[STATUS_LINE_LENGTH]; char statusLineMsg[STATUS_LINE_LENGTH];
uint16_t statusLineTimeout = 0; tmr10ms_t statusLineTime = 0;
uint8_t statusLineHeight = 0; uint8_t statusLineHeight = 0;
void showStatusLine() void showStatusLine()
{ {
statusLineHeight = 0; statusLineHeight = 0;
statusLineTimeout = get_tmr10ms() + 3*100; /* 3 seconds */ statusLineTime = get_tmr10ms();
} }
#define STATUS_LINE_DELAY (3 * 100) /* 3s */
void drawStatusLine() void drawStatusLine()
{ {
if (get_tmr10ms() < statusLineTimeout) { if (statusLineTime) {
if (statusLineHeight < 8) statusLineHeight++; if ((tmr10ms_t)(get_tmr10ms() - statusLineTime) <= (tmr10ms_t)STATUS_LINE_DELAY) {
} if (statusLineHeight < 8) statusLineHeight++;
else if (statusLineHeight) { }
statusLineHeight--; else if (statusLineHeight) {
} statusLineHeight--;
else { }
return; else {
} statusLineTime = 0;
}
lcd_filled_rect(0, 7*FH+8-statusLineHeight, DISPLAY_W, 8, SOLID, WHITE); lcd_filled_rect(0, 8*FH-statusLineHeight, DISPLAY_W, 8, SOLID, WHITE);
lcd_putsAtt(5, 7*FH+1+8-statusLineHeight, statusLineMsg, BSS); lcd_putsAtt(5, 8*FH+1-statusLineHeight, statusLineMsg, BSS);
lcd_filled_rect(0, 7*FH+8-statusLineHeight, DISPLAY_W, 8, SOLID); lcd_filled_rect(0, 8*FH-statusLineHeight, DISPLAY_W, 8, SOLID);
}
} }
#endif #endif
+14 -14
View File
@@ -754,7 +754,7 @@ bool getSwitch(int8_t swtch, bool nc)
uint8_t switches_states = 0; uint8_t switches_states = 0;
int8_t getMovedSwitch() int8_t getMovedSwitch()
{ {
static uint16_t s_last_time = 0; static tmr10ms_t s_last_time = 0;
int8_t result = 0; int8_t result = 0;
@@ -783,7 +783,7 @@ int8_t getMovedSwitch()
} }
} }
if (get_tmr10ms() - s_last_time > 10) if ((tmr10ms_t)(get_tmr10ms() - s_last_time) > 10)
result = 0; result = 0;
s_last_time = get_tmr10ms(); s_last_time = get_tmr10ms();
@@ -983,7 +983,7 @@ void doSplash()
#if defined(PCBSTD) #if defined(PCBSTD)
lcdSetRefVolt(g_eeGeneral.contrast); lcdSetRefVolt(g_eeGeneral.contrast);
#else #else
uint16_t curTime = get_tmr10ms() + 10; tmr10ms_t curTime = get_tmr10ms() + 10;
uint8_t contrast = 10; uint8_t contrast = 10;
lcdSetRefVolt(contrast); lcdSetRefVolt(contrast);
#endif #endif
@@ -995,7 +995,7 @@ void doSplash()
uint16_t inacSum = stickMoveValue(); uint16_t inacSum = stickMoveValue();
uint16_t tgtime = get_tmr10ms() + SPLASH_TIMEOUT; tmr10ms_t tgtime = get_tmr10ms() + SPLASH_TIMEOUT;
while (tgtime != get_tmr10ms()) while (tgtime != get_tmr10ms())
{ {
#ifdef SIMU #ifdef SIMU
@@ -2215,7 +2215,7 @@ char userDataDisplayBuf[TELEM_SCREEN_BUFFER_SIZE];
#if defined(SIMU) #if defined(SIMU)
#define TIME_TO_WRITE s_eeDirtyMsk #define TIME_TO_WRITE s_eeDirtyMsk
#else #else
#define TIME_TO_WRITE (s_eeDirtyMsk && (get_tmr10ms() - s_eeDirtyTime10ms) >= WRITE_DELAY_10MS) #define TIME_TO_WRITE (s_eeDirtyMsk && (tmr10ms_t)(get_tmr10ms() - s_eeDirtyTime10ms) >= (tmr10ms_t)WRITE_DELAY_10MS)
#endif #endif
#ifdef BOLD_FONT #ifdef BOLD_FONT
@@ -2517,9 +2517,9 @@ inline void doMixerCalculations(uint16_t tmr10ms, uint8_t tick10ms)
void perMain() void perMain()
{ {
static uint16_t lastTMR; static tmr10ms_t lastTMR;
uint16_t tmr10ms = get_tmr10ms(); tmr10ms_t tmr10ms = get_tmr10ms();
uint8_t tick10ms = (tmr10ms - lastTMR); uint8_t tick10ms = (tmr10ms > lastTMR ? tmr10ms - lastTMR : 1);
lastTMR = tmr10ms; lastTMR = tmr10ms;
#if defined(PCBSTD) || defined(SIMU) #if defined(PCBSTD) || defined(SIMU)
@@ -2733,9 +2733,9 @@ ISR(TIMER5_COMPA_vect, ISR_NOBLOCK) // mixer interrupt
uint16_t t0 = getTmr16KHz(); uint16_t t0 = getTmr16KHz();
static uint16_t lastTMR; static tmr10ms_t lastTMR;
uint16_t tmr10ms = get_tmr10ms(); tmr10ms_t tmr10ms = get_tmr10ms();
uint8_t tick10ms = (tmr10ms - lastTMR); uint8_t tick10ms = (tmr10ms > lastTMR ? tmr10ms - lastTMR : 1);
lastTMR = tmr10ms; lastTMR = tmr10ms;
if (s_current_protocol < PROTO_NONE) { if (s_current_protocol < PROTO_NONE) {
@@ -3158,9 +3158,9 @@ void mixerTask(void * pdata)
if (!s_pulses_paused) { if (!s_pulses_paused) {
uint16_t t0 = getTmr2MHz(); uint16_t t0 = getTmr2MHz();
static uint16_t lastTMR; static tmr10ms_t lastTMR;
uint16_t tmr10ms = get_tmr10ms(); tmr10ms_t tmr10ms = get_tmr10ms();
uint8_t tick10ms = (tmr10ms - lastTMR); uint8_t tick10ms = (tmr10ms > lastTMR ? tmr10ms - lastTMR : 1);
lastTMR = tmr10ms; lastTMR = tmr10ms;
if (s_current_protocol < PROTO_NONE) { if (s_current_protocol < PROTO_NONE) {
+4 -3
View File
@@ -803,12 +803,14 @@ inline int16_t calc100toRESX(int8_t x)
extern int16_t calc1000toRESX(int16_t x); extern int16_t calc1000toRESX(int16_t x);
#endif #endif
extern volatile uint16_t g_tmr10ms;
#if defined(PCBARM) #if defined(PCBARM)
// This doesn't need protection on this processor // This doesn't need protection on this processor
#define tmr10ms_t uint32_t
extern volatile tmr10ms_t g_tmr10ms;
#define get_tmr10ms() g_tmr10ms #define get_tmr10ms() g_tmr10ms
#else #else
#define tmr10ms_t uint16_t
extern volatile tmr10ms_t g_tmr10ms;
extern inline uint16_t get_tmr10ms() extern inline uint16_t get_tmr10ms()
{ {
uint16_t time ; uint16_t time ;
@@ -827,7 +829,6 @@ extern const char stamp3[];
extern const char stamp4[]; extern const char stamp4[];
extern uint8_t g_vbat100mV; extern uint8_t g_vbat100mV;
extern volatile uint16_t g_tmr10ms;
extern volatile uint8_t g_blinkTmr10ms; extern volatile uint8_t g_blinkTmr10ms;
extern uint8_t g_beepCnt; extern uint8_t g_beepCnt;
extern uint8_t g_beepVal[5]; extern uint8_t g_beepVal[5];