From 07e6df9ea59700f740606f33c4390f988676c799 Mon Sep 17 00:00:00 2001 From: openfsguruh Date: Fri, 16 May 2014 16:14:30 +0200 Subject: [PATCH 1/2] first 68 bytes flash savings. Bring back to pointer and add volatile --- radio/src/opentx.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 29c6b1e2b..66856c815 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1374,13 +1374,16 @@ uint16_t anaIn(uint8_t chan) return *p; #else static const pm_char crossAna[] PROGMEM = {3,1,2,0,4,5,6,7}; - uint16_t temp = s_anaFilt[pgm_read_byte(crossAna+chan)]; #if defined(FRSKY_STICKS) + uint16_t temp = s_anaFilt[pgm_read_byte(crossAna+chan)]; if (chan < NUM_STICKS && (g_eeGeneral.stickReverse & (1 << chan))) { temp = 2048 - temp; } -#endif return temp; +#else + volatile uint16_t *p = &s_anaFilt[pgm_read_byte(crossAna+chan)]; + return *p; +#endif #endif } From 9bbe3236abdf915272cc3f6bf082d9972df99d82 Mon Sep 17 00:00:00 2001 From: openfsguruh Date: Fri, 16 May 2014 16:48:07 +0200 Subject: [PATCH 2/2] a special volatile saves 40 bytes if FRSKY_STICKS used --- radio/src/opentx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index 66856c815..72b222b9c 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -1375,7 +1375,7 @@ uint16_t anaIn(uint8_t chan) #else static const pm_char crossAna[] PROGMEM = {3,1,2,0,4,5,6,7}; #if defined(FRSKY_STICKS) - uint16_t temp = s_anaFilt[pgm_read_byte(crossAna+chan)]; + volatile uint16_t temp = s_anaFilt[pgm_read_byte(crossAna+chan)]; // volatile saves here 40 bytes; maybe removed for newer AVR when available if (chan < NUM_STICKS && (g_eeGeneral.stickReverse & (1 << chan))) { temp = 2048 - temp; }