More AVR removal

This commit is contained in:
Bertrand Songis
2018-08-05 13:12:51 +02:00
parent ea76998beb
commit ed91931184
23 changed files with 71 additions and 258 deletions
+34 -118
View File
@@ -87,7 +87,7 @@
#define CASE_PWM_BACKLIGHT(x)
#endif
#if defined(TELEMETRY_FRSKY) && defined(FRSKY_HUB) && defined(GPS)
#if defined(TELEMETRY_FRSKY) && defined(GPS)
#define CASE_GPS(x) x,
#else
#define CASE_GPS(x)
@@ -187,7 +187,7 @@
#define IF_FAI_CHOICE(x)
#endif
#define IS_FAI_FORBIDDEN(idx) (IS_FAI_ENABLED() && isFaiForbidden(idx))
#define IS_FAI_FORBIDDEN(idx) (IS_FAI_ENABLED() && isFaiForbidden(idx))
#if defined(BLUETOOTH)
#if defined(X9E) && !defined(USEHORUSBT)
@@ -202,17 +202,6 @@
#define IS_SLAVE_TRAINER() (g_model.trainerMode == TRAINER_MODE_SLAVE)
#endif
#define MASTER_VOLUME
#if !defined(CPUM64) && !defined(ACCURAT_THROTTLE_TIMER)
// code cost is about 16 bytes for higher throttle accuracy for timer
// would not be noticable anyway, because all version up to this change had only 16 steps;
// now it has already 32 steps; this define would increase to 128 steps
#if !defined(ACCURAT_THROTTLE_TIMER)
#define ACCURAT_THROTTLE_TIMER
#endif
#endif
// RESX range is used for internal calculation; The menu says -100.0 to 100.0; internally it is -1024 to 1024 to allow some optimizations
#define RESX_SHIFT 10
#define RESX 1024
@@ -247,7 +236,7 @@
#include "myeeprom.h"
#define memclear(p, s) memset(p, 0, s)
#define memclear(p, s) memset(p, 0, s)
void memswap(void * a, void * b, uint8_t size);
@@ -338,7 +327,6 @@ typedef struct {
#include "strhelpers.h"
#include "gui.h"
#if !defined(SIMU)
#define assert(x)
#if !defined(DEBUG)
@@ -480,17 +468,11 @@ enum PerOutMode {
e_perout_mode_noinput = e_perout_mode_notrainer+e_perout_mode_notrims+e_perout_mode_nosticks
};
// Fiddle to force compiler to use a pointer
#define FORCE_INDIRECT(ptr)
extern uint8_t mixerCurrentFlightMode;
extern uint8_t lastFlightMode;
extern uint8_t flightModeTransitionLast;
#define bitfield_channels_t uint32_t
typedef uint32_t bitfield_channels_t;
#if defined(SIMU)
inline int availableMemory() { return 1000; }
@@ -506,9 +488,9 @@ void evalMixes(uint8_t tick10ms);
void doMixerCalculations();
void scheduleNextMixerCalculation(uint8_t module, uint16_t period_ms);
void checkTrims();
void checkTrims();
void perMain();
NOINLINE void per10ms();
void per10ms();
getvalue_t getValue(mixsrc_t i);
@@ -518,9 +500,9 @@ bool getSwitch(swsrc_t swtch, uint8_t flags=0);
void logicalSwitchesTimerTick();
void logicalSwitchesReset();
void evalLogicalSwitches(bool isCurrentPhase=true);
void logicalSwitchesCopyState(uint8_t src, uint8_t dst);
#define LS_RECURSIVE_EVALUATION_RESET()
void evalLogicalSwitches(bool isCurrentPhase=true);
void logicalSwitchesCopyState(uint8_t src, uint8_t dst);
#define LS_RECURSIVE_EVALUATION_RESET()
#if defined(PCBTARANIS) || defined(PCBHORUS)
void getSwitchesPosition(bool startup);
@@ -531,9 +513,9 @@ void logicalSwitchesReset();
extern swarnstate_t switches_states;
swsrc_t getMovedSwitch();
#define GET_MOVED_SOURCE_PARAMS uint8_t min
int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS);
#define GET_MOVED_SOURCE(min, max) getMovedSource(min)
#define GET_MOVED_SOURCE_PARAMS uint8_t min
int8_t getMovedSource(GET_MOVED_SOURCE_PARAMS);
#define GET_MOVED_SOURCE(min, max) getMovedSource(min)
#if defined(FLIGHT_MODES)
extern uint8_t getFlightMode();
@@ -541,7 +523,7 @@ swsrc_t getMovedSwitch();
#define getFlightMode() 0
#endif
#define getTrimFlightMode(phase, idx) (phase)
#define getTrimFlightMode(phase, idx) (phase)
#if defined(GVARS)
extern int8_t trimGvar[NUM_TRIMS];
@@ -553,7 +535,7 @@ swsrc_t getMovedSwitch();
trim_t getRawTrimValue(uint8_t phase, uint8_t idx);
int getTrimValue(uint8_t phase, uint8_t idx);
bool setTrimValue(uint8_t phase, uint8_t idx, int trim);
bool setTrimValue(uint8_t phase, uint8_t idx, int trim);
#if defined(ROTARY_ENCODERS)
int16_t getRotaryEncoder(uint8_t idx);
@@ -575,12 +557,11 @@ extern uint16_t s_timeCumThr;
extern uint16_t s_timeCum16ThrP;
#if defined(OVERRIDE_CHANNEL_FUNCTION)
#define OVERRIDE_CHANNEL_UNDEFINED -4096
#define OVERRIDE_CHANNEL_UNDEFINED -4096
extern safetych_t safetyCh[MAX_OUTPUT_CHANNELS];
#endif
extern uint8_t trimsCheckTimer;
extern uint8_t trimsDisplayTimer;
extern uint8_t trimsDisplayMask;
@@ -590,7 +571,6 @@ extern uint8_t unexpectedShutdown;
extern uint16_t maxMixerDuration;
#define DURATION_MS_PREC2(x) ((x)/20)
#if defined(THRTRACE)
@@ -660,22 +640,21 @@ void doLoopCommonActions();
#define BITMASK(bit) (1<<(bit))
#if !defined(UNUSED)
#define UNUSED(x) ((void)(x)) /* to avoid warnings */
#endif
/// returns the number of elements of an array
#define DIM(arr) (sizeof((arr))/sizeof((arr)[0]))
template<class t> FORCEINLINE t min(t a, t b) { return a<b?a:b; }
template<class t> FORCEINLINE t max(t a, t b) { return a>b?a:b; }
template<class t> FORCEINLINE t sgn(t a) { return a>0 ? 1 : (a < 0 ? -1 : 0); }
template<class t> FORCEINLINE t limit(t mi, t x, t ma) { return min(max(mi,x),ma); }
template<class t> void SWAP(t & a, t & b) { t tmp = b; b = a; a = tmp; }
template<class t> inline t min(t a, t b) { return a<b?a:b; }
template<class t> inline t max(t a, t b) { return a>b?a:b; }
template<class t> inline t sgn(t a) { return a>0 ? 1 : (a < 0 ? -1 : 0); }
template<class t> inline t limit(t mi, t x, t ma) { return min(max(mi,x),ma); }
template<class t> inline void SWAP(t & a, t & b) { t tmp = b; b = a; a = tmp; }
uint16_t isqrt32(uint32_t n);
#if !defined(BOOT)
#if defined(BOOT)
#define pauseMixerCalculations()
#define resumeMixerCalculations()
#else
#include "tasks_arm.h"
extern RTOS_MUTEX_HANDLE mixerMutex;
inline void pauseMixerCalculations()
@@ -687,9 +666,6 @@ inline void resumeMixerCalculations()
{
RTOS_UNLOCK_MUTEX(mixerMutex);
}
#else
#define pauseMixerCalculations()
#define resumeMixerCalculations()
#endif
void generalDefault();
@@ -746,6 +722,7 @@ extern const char eeprom_stamp[];
#else
extern const char vers_stamp[];
#endif
/**
* Tries to find opentx version in the first 1024 byte of either firmware/bootloader (the one not running) or the buffer
* @param buffer If non-null find the firmware version in the buffer instead
@@ -764,16 +741,14 @@ extern uint8_t g_vbat100mV;
#define g_blinkTmr10ms (*(uint8_t*)&g_tmr10ms)
extern uint8_t g_beepCnt;
extern uint8_t g_beepVal[5];
#include "trainer_input.h"
extern int32_t chans[MAX_OUTPUT_CHANNELS];
extern int16_t ex_chans[MAX_OUTPUT_CHANNELS]; // Outputs (before LIMITS) of the last perMain
extern int16_t channelOutputs[MAX_OUTPUT_CHANNELS];
extern uint16_t BandGap;
#define NUM_INPUTS (MAX_INPUTS)
#define NUM_INPUTS (MAX_INPUTS)
int expo(int x, int k);
@@ -856,13 +831,10 @@ int8_t getCurveX(int noPoints, int point);
void resetCustomCurveX(int8_t * points, int noPoints);
bool moveCurve(uint8_t index, int8_t shift); // TODO bool?
#define APPLY_EXPOS_EXTRA_PARAMS_INC , uint8_t ovwrIdx=0, int16_t ovwrValue=0
#define APPLY_EXPOS_EXTRA_PARAMS , uint8_t ovwrIdx, int16_t ovwrValue
void clearInputs();
void defaultInputs();
void applyExpos(int16_t * anas, uint8_t mode APPLY_EXPOS_EXTRA_PARAMS_INC);
void applyExpos(int16_t * anas, uint8_t mode, uint8_t ovwrIdx=0, int16_t ovwrValue=0);
int16_t applyLimits(uint8_t channel, int32_t value);
void evalInputs(uint8_t mode);
@@ -885,7 +857,7 @@ LogicalSwitchData * lswAddress(uint8_t idx);
// static variables used in evalFlightModeMixes - moved here so they don't interfere with the stack
// It's also easier to initialize them here.
extern int8_t virtualInputsTrims[NUM_INPUTS];
extern int8_t virtualInputsTrims[NUM_INPUTS];
extern int16_t anas [NUM_INPUTS];
extern int16_t trims[NUM_TRIMS];
@@ -895,17 +867,16 @@ extern uint8_t s_mixer_first_run_done;
void applyDefaultTemplate();
void incSubtrim(uint8_t idx, int16_t inc);
void instantTrim();
void evalTrims();
void copyTrimsToOffset(uint8_t ch);
void copySticksToOffset(uint8_t ch);
void moveTrimsToOffsets();
#define ACTIVE_PHASES_TYPE uint16_t
typedef uint16_t ACTIVE_PHASES_TYPE;
#define DELAY_POS_SHIFT 0
#define DELAY_POS_MARGIN 3
#define delayval_t int16_t
typedef int16_t delayval_t;
PACK(typedef struct {
uint16_t delay;
int16_t now; // timer trigger source -> off, abs, stk, stk%, sw/!sw, !m_sw/!m_sw
@@ -984,7 +955,6 @@ uint16_t crc16(const uint8_t * ptr, uint32_t len);
#define PLAY_REPEAT(x) (x) /* Range 0 to 15 */
#define PLAY_NOW 0x10
#define PLAY_BACKGROUND 0x20
#define PLAY_INCREMENT(x) ((uint8_t)(((uint8_t)x) << 6)) /* -1, 0, 1, 2 */
enum AUDIO_SOUNDS {
AUDIO_HELLO,
@@ -1146,7 +1116,6 @@ union ReusableBuffer
uint8_t r9mPower;
} modelsetup;
// 103 bytes
struct
{
@@ -1189,8 +1158,6 @@ union ReusableBuffer
extern union ReusableBuffer reusableBuffer;
void checkFlashOnBeep();
uint8_t zlen(const char *str, uint8_t size);
bool zexist(const char *str, uint8_t size);
unsigned int effectiveLen(const char * str, unsigned int size);
@@ -1206,36 +1173,7 @@ char * strcat_zchar(char *dest, const char *name, uint8_t size, const char *defa
#define ZEXIST(s) zexist(s, sizeof(s))
// Stick tolerance varies between transmitters, Higher is better
#if defined (PCB9XR) || defined (PCB9XR128)
#define STICK_TOLERANCE 16
#else
#define STICK_TOLERANCE 64
#endif
#if defined(FRSKY_HUB) && defined(GAUGES)
enum BarThresholdIdx {
THLD_ALT,
THLD_RPM,
THLD_FUEL,
THLD_T1,
THLD_T2,
THLD_SPEED,
THLD_DIST,
THLD_GPSALT,
THLD_CELL,
THLD_CELLS_SUM,
THLD_VFAS,
THLD_CURRENT,
THLD_CONSUMPTION,
THLD_MAX,
};
#define FILL_THRESHOLD(idx, val) barsThresholds[idx] = (val)
extern bar_threshold_t barsThresholds[THLD_MAX];
#else
#define FILL_THRESHOLD(idx, val)
#endif
#define STICK_TOLERANCE 64
#if defined(TELEMETRY_FRSKY)
ls_telemetry_value_t minTelemValue(source_t channel);
@@ -1246,17 +1184,9 @@ extern bar_threshold_t barsThresholds[THLD_MAX];
#endif
getvalue_t convert16bitsTelemValue(source_t channel, ls_telemetry_value_t value);
ls_telemetry_value_t max8bitsTelemValue(source_t channel);
getvalue_t convert8bitsTelemValue(source_t channel, ls_telemetry_value_t value);
getvalue_t convertLswTelemValue(LogicalSwitchData * cs);
#define convertTelemValue(channel, value) convert16bitsTelemValue(channel, value)
#define convertBarTelemValue(channel, value) convert8bitsTelemValue(channel, value)
#define maxBarTelemValue(channel) max8bitsTelemValue(channel)
lcdint_t applyChannelRatio(source_t channel, lcdint_t val);
#define ANA_CHANNEL_UNIT(channel) g_model.frsky.channels[channel].type
#define convertTelemValue(channel, value) convert16bitsTelemValue(channel, value)
inline int div_and_round(int num, int den)
{
@@ -1273,11 +1203,6 @@ inline int div_and_round(int num, int den)
}
#if defined(TELEMETRY_FRSKY)
extern const uint8_t bchunit_ar[];
#define FRSKY_MULTIPLIER_MAX 5
enum TelemetryViews {
TELEMETRY_CUSTOM_SCREEN_1,
TELEMETRY_CUSTOM_SCREEN_2,
@@ -1287,7 +1212,6 @@ enum TelemetryViews {
};
extern uint8_t s_frsky_view;
#endif
#define EARTH_RADIUSKM ((uint32_t)6371)
@@ -1303,15 +1227,7 @@ void varioWakeup();
#define IS_SOUND_OFF() (g_eeGeneral.beepMode == e_mode_quiet)
#endif
#define IS_IMPERIAL_ENABLE() (g_eeGeneral.imperial)
#if defined(TELEMETRY_FRSKY) && defined(FRSKY_HUB) && defined(GPS)
#define IS_GPS_AVAILABLE() IS_USR_PROTO_FRSKY_HUB()
#else
#define IS_GPS_AVAILABLE() (0)
#endif
#define IS_IMPERIAL_ENABLE() (g_eeGeneral.imperial)
#if defined(PCBTARANIS)
extern const unsigned char logo_taranis[];
@@ -1375,7 +1291,7 @@ extern JitterMeter<uint16_t> avgJitter[NUM_ANALOGS];
#endif
#if defined(BLUETOOTH)
#include "bluetooth.h"
#include "bluetooth.h"
#endif
#endif // _OPENTX_H_