From 3a0960c1e324ffcf571fdb9efd0560761f3f30e3 Mon Sep 17 00:00:00 2001 From: Bertrand Songis Date: Wed, 3 Jul 2019 07:58:32 +0200 Subject: [PATCH] Bsongis/adc rtc temperature (#6537) RTC voltage + CPU temperature + RTC voltage alarm (thanks @schwabe) --- radio/src/gui/128x64/model_inputs_mixes.cpp | 2 +- radio/src/gui/128x64/radio_hardware.cpp | 22 +-- radio/src/gui/128x64/radio_setup.cpp | 2 +- radio/src/gui/128x64/radio_trainer.cpp | 2 +- radio/src/gui/128x64/view_statistics.cpp | 45 ++++-- radio/src/gui/212x64/radio_hardware.cpp | 2 +- radio/src/gui/212x64/radio_setup.cpp | 2 +- radio/src/gui/212x64/radio_trainer.cpp | 2 +- radio/src/gui/212x64/view_statistics.cpp | 130 ++++++++++------- radio/src/gui/480x272/model_inputs.cpp | 2 +- radio/src/gui/480x272/model_mixes.cpp | 2 +- radio/src/gui/480x272/radio_setup.cpp | 2 +- radio/src/gui/480x272/radio_trainer.cpp | 4 +- radio/src/gui/480x272/radio_version.cpp | 13 +- radio/src/gui/480x272/view_statistics.cpp | 102 ++++++++----- radio/src/gui/common/stdlcd/model_inputs.cpp | 2 +- radio/src/gui/common/stdlcd/model_mixes.cpp | 2 +- radio/src/lua/api_general.cpp | 4 +- radio/src/opentx.cpp | 28 +++- radio/src/opentx.h | 21 +-- radio/src/simu.cpp | 8 ++ .../targets/common/arm/stm32/adc_driver.cpp | 135 +++++++++++------- .../targets/common/arm/stm32/board_common.h | 133 +++++++++++++++++ radio/src/targets/horus/adc_driver.cpp | 46 +++--- radio/src/targets/horus/board.cpp | 2 - radio/src/targets/horus/board.h | 94 ++---------- radio/src/targets/horus/hal.h | 6 +- radio/src/targets/simu/opentxsimulator.cpp | 10 +- radio/src/targets/simu/simpgmspace.cpp | 1 + radio/src/targets/simu/simpgmspace.h | 8 +- radio/src/targets/simu/simueeprom.cpp | 8 -- radio/src/targets/sky9x/board.h | 6 +- radio/src/targets/taranis/board.cpp | 2 - radio/src/targets/taranis/board.h | 99 +------------ radio/src/targets/taranis/hal.h | 13 +- radio/src/tests/gtests.cpp | 5 +- radio/src/translations.cpp | 2 + radio/src/translations.h | 2 + radio/src/translations/cz.h.txt | 4 +- radio/src/translations/de.h.txt | 4 +- radio/src/translations/en.h.txt | 4 +- radio/src/translations/es.h.txt | 4 +- radio/src/translations/fi.h.txt | 4 +- radio/src/translations/fr.h.txt | 4 +- radio/src/translations/it.h.txt | 4 +- radio/src/translations/nl.h.txt | 4 +- radio/src/translations/pl.h.txt | 4 +- radio/src/translations/pt.h.txt | 4 +- radio/src/translations/se.h.txt | 4 +- 49 files changed, 568 insertions(+), 447 deletions(-) create mode 100644 radio/src/targets/common/arm/stm32/board_common.h diff --git a/radio/src/gui/128x64/model_inputs_mixes.cpp b/radio/src/gui/128x64/model_inputs_mixes.cpp index 7fc9d5a44..246c14daa 100644 --- a/radio/src/gui/128x64/model_inputs_mixes.cpp +++ b/radio/src/gui/128x64/model_inputs_mixes.cpp @@ -114,7 +114,7 @@ void insertExpoMix(uint8_t expo, uint8_t idx) memmove(mix+1, mix, (MAX_MIXERS-(idx+1))*sizeof(MixData)); memclear(mix, sizeof(MixData)); mix->destCh = s_currCh-1; - mix->srcRaw = (s_currCh > 4 ? MIXSRC_Rud - 1 + s_currCh : MIXSRC_Rud - 1 + channel_order(s_currCh)); + mix->srcRaw = (s_currCh > 4 ? MIXSRC_Rud - 1 + s_currCh : MIXSRC_Rud - 1 + channelOrder(s_currCh)); mix->weight = 100; } resumeMixerCalculations(); diff --git a/radio/src/gui/128x64/radio_hardware.cpp b/radio/src/gui/128x64/radio_hardware.cpp index b76ef736e..8ef7e3c1b 100644 --- a/radio/src/gui/128x64/radio_hardware.cpp +++ b/radio/src/gui/128x64/radio_hardware.cpp @@ -22,7 +22,7 @@ #if defined(PCBSKY9X) #define HW_SETTINGS_COLUMN (2+(15*FW)) -enum MenuRadioHardwareItems { +enum { ITEM_RADIO_HARDWARE_OPTREX_DISPLAY, ITEM_RADIO_HARDWARE_STICKS_GAINS_LABELS, ITEM_RADIO_HARDWARE_STICK_LV_GAIN, @@ -88,7 +88,7 @@ void menuRadioHardware(event_t event) #endif // PCBSKY9X #if defined(PCBTARANIS) -enum MenuRadioHardwareItems { +enum { ITEM_RADIO_HARDWARE_LABEL_STICKS, ITEM_RADIO_HARDWARE_STICK1, ITEM_RADIO_HARDWARE_STICK2, @@ -115,9 +115,6 @@ enum MenuRadioHardwareItems { ITEM_RADIO_HARDWARE_SJ, #endif ITEM_RADIO_HARDWARE_BATTERY_CALIB, -#if defined(STM32) - ITEM_RADIO_HARDWARE_RTC_BATTERY, -#endif #if defined(TX_CAPACITY_MEASUREMENT) ITEM_RADIO_HARDWARE_CAPACITY_CALIB, #endif @@ -180,12 +177,6 @@ enum MenuRadioHardwareItems { #define SWITCH_TYPE_MAX(sw) ((MIXSRC_SF-MIXSRC_FIRST_SWITCH == sw || MIXSRC_SH-MIXSRC_FIRST_SWITCH == sw || MIXSRC_SI-MIXSRC_FIRST_SWITCH == sw || MIXSRC_SJ-MIXSRC_FIRST_SWITCH == sw) ? SWITCH_2POS : SWITCH_3POS) #endif -#if defined(STM32) - #define RTC_BATT_ROWS READONLY_ROW, -#else - #define RTC_BATT_ROWS -#endif - #if defined(TX_CAPACITY_MEASUREMENT) #define TX_CAPACITY_MEASUREMENT_ROWS 0, #else @@ -222,8 +213,6 @@ void menuRadioHardware(event_t event) SWITCHES_ROWS, 0 /* battery calib */, - RTC_BATT_ROWS - TX_CAPACITY_MEASUREMENT_ROWS TEMPERATURE_CALIB_ROWS @@ -349,13 +338,6 @@ void menuRadioHardware(event_t event) } break; -#if defined(STM32) - case ITEM_RADIO_HARDWARE_RTC_BATTERY: - lcdDrawTextAlignedLeft(y, STR_RTC_BATT); - putsVolts(HW_SETTINGS_COLUMN2, y, vbattRTC, PREC2|LEFT); - break; -#endif - #if defined(TX_CAPACITY_MEASUREMENT) case ITEM_RADIO_HARDWARE_CAPACITY_CALIB: lcdDrawTextAlignedLeft(y, STR_CURRENT_CALIB); diff --git a/radio/src/gui/128x64/radio_setup.cpp b/radio/src/gui/128x64/radio_setup.cpp index b46925906..a87a78e48 100644 --- a/radio/src/gui/128x64/radio_setup.cpp +++ b/radio/src/gui/128x64/radio_setup.cpp @@ -597,7 +597,7 @@ void menuRadioSetup(event_t event) case ITEM_SETUP_RX_CHANNEL_ORD: lcdDrawTextAlignedLeft(y, STR_RXCHANNELORD); // RAET->AETR for (uint8_t i=1; i<=4; i++) { - putsChnLetter(RADIO_SETUP_2ND_COLUMN - FW + i*FW, y, channel_order(i), attr); + putsChnLetter(RADIO_SETUP_2ND_COLUMN - FW + i*FW, y, channelOrder(i), attr); } if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.templateSetup, 0, 23); break; diff --git a/radio/src/gui/128x64/radio_trainer.cpp b/radio/src/gui/128x64/radio_trainer.cpp index 63d295335..2ec5d599f 100644 --- a/radio/src/gui/128x64/radio_trainer.cpp +++ b/radio/src/gui/128x64/radio_trainer.cpp @@ -39,7 +39,7 @@ void menuRadioTrainer(event_t event) y = MENU_HEADER_HEIGHT + 1 + FH; for (uint8_t i=HEADER_LINE; i'); - drawValueWithUnit(MENU_DEBUG_COL2_OFS+FW+1, y, maxTemperature+g_eeGeneral.temperatureCalib, UNIT_TEMPERATURE, LEFT); - y += FH; -#endif - #if defined(COPROCESSOR) lcdDrawTextAlignedLeft(y, STR_COPROC_TEMP); if (Coproc_read==0) { @@ -245,7 +250,23 @@ void menuStatisticsDebug(event_t event) y += FH; #endif - lcdDrawText(4*FW, 7*FH+1, STR_MENUTORESET); +#if defined(STM32) + lcdDrawTextAlignedLeft(y, STR_RTC_BATT); + putsVolts(MENU_DEBUG_COL1_OFS, y, getRTCBatteryVoltage(), PREC2|LEFT); + y += FH; +#endif + +#if defined(PCBSKY9X) + lcdDrawTextAlignedLeft(y, STR_CPU_TEMP); + drawValueWithUnit(MENU_DEBUG_COL1_OFS, y, getTemperature(), UNIT_TEMPERATURE, LEFT); + lcdDrawChar(MENU_DEBUG_COL2_OFS, y, '>'); + drawValueWithUnit(MENU_DEBUG_COL2_OFS+FW+1, y, maxTemperature+g_eeGeneral.temperatureCalib, UNIT_TEMPERATURE, LEFT); +#else + lcdDrawTextAlignedLeft(y, STR_CPU_TEMP); + drawValueWithUnit(MENU_DEBUG_COL1_OFS, y, getTemperature(), UNIT_TEMPERATURE, PREC1|LEFT); +#endif + + lcdDrawText(LCD_W/2, 7*FH+1, STR_MENUTORESET, CENTERED); lcdInvertLastLine(); } @@ -254,7 +275,7 @@ void menuStatisticsDebug2(event_t event) { title(STR_MENUDEBUG); - switch (event) { + switch(event) { case EVT_KEY_FIRST(KEY_ENTER): telemetryErrors = 0; break; @@ -291,7 +312,7 @@ void menuStatisticsDebug2(event_t event) y += FH; #endif - lcdDrawText(4*FW, 7*FH+1, STR_MENUTORESET); + lcdDrawText(LCD_W/2, 7*FH+1, STR_MENUTORESET, CENTERED); lcdInvertLastLine(); } #endif diff --git a/radio/src/gui/212x64/radio_hardware.cpp b/radio/src/gui/212x64/radio_hardware.cpp index 6a92a126b..98e1e3af6 100644 --- a/radio/src/gui/212x64/radio_hardware.cpp +++ b/radio/src/gui/212x64/radio_hardware.cpp @@ -20,7 +20,7 @@ #include "opentx.h" -enum menuRadioHwItems { +enum { ITEM_RADIO_HARDWARE_LABEL_STICKS, ITEM_RADIO_HARDWARE_STICK1, ITEM_RADIO_HARDWARE_STICK2, diff --git a/radio/src/gui/212x64/radio_setup.cpp b/radio/src/gui/212x64/radio_setup.cpp index 4d9e31185..9a8f42959 100644 --- a/radio/src/gui/212x64/radio_setup.cpp +++ b/radio/src/gui/212x64/radio_setup.cpp @@ -477,7 +477,7 @@ void menuRadioSetup(event_t event) case ITEM_SETUP_RX_CHANNEL_ORD: lcdDrawTextAlignedLeft(y, STR_RXCHANNELORD); // RAET->AETR for (uint8_t i=1; i<=4; i++) { - putsChnLetter(RADIO_SETUP_2ND_COLUMN - FW + i*FW, y, channel_order(i), attr); + putsChnLetter(RADIO_SETUP_2ND_COLUMN - FW + i*FW, y, channelOrder(i), attr); } if (attr) CHECK_INCDEC_GENVAR(event, g_eeGeneral.templateSetup, 0, 23); break; diff --git a/radio/src/gui/212x64/radio_trainer.cpp b/radio/src/gui/212x64/radio_trainer.cpp index 4f010595f..0e06600e4 100644 --- a/radio/src/gui/212x64/radio_trainer.cpp +++ b/radio/src/gui/212x64/radio_trainer.cpp @@ -42,7 +42,7 @@ void menuRadioTrainer(event_t event) y = MENU_HEADER_HEIGHT + 1 + FH; for (int i=0; isrcRaw = (s_currCh > 4 ? MIXSRC_Rud - 1 + s_currCh : MIXSRC_Rud - 1 + channel_order(s_currCh)); + expo->srcRaw = (s_currCh > 4 ? MIXSRC_Rud - 1 + s_currCh : MIXSRC_Rud - 1 + channelOrder(s_currCh)); expo->curve.type = CURVE_REF_EXPO; expo->mode = 3; // pos+neg expo->chn = s_currCh - 1; diff --git a/radio/src/gui/480x272/model_mixes.cpp b/radio/src/gui/480x272/model_mixes.cpp index 1672308bd..7b70d1e7c 100644 --- a/radio/src/gui/480x272/model_mixes.cpp +++ b/radio/src/gui/480x272/model_mixes.cpp @@ -84,7 +84,7 @@ void insertMix(uint8_t idx) mix->destCh = s_currCh-1; mix->srcRaw = s_currCh; if (!isSourceAvailable(mix->srcRaw)) { - mix->srcRaw = (s_currCh > 4 ? MIXSRC_Rud - 1 + s_currCh : MIXSRC_Rud - 1 + channel_order(s_currCh)); + mix->srcRaw = (s_currCh > 4 ? MIXSRC_Rud - 1 + s_currCh : MIXSRC_Rud - 1 + channelOrder(s_currCh)); while (!isSourceAvailable(mix->srcRaw)) { mix->srcRaw += 1; } diff --git a/radio/src/gui/480x272/radio_setup.cpp b/radio/src/gui/480x272/radio_setup.cpp index f7c5c4248..cc641c920 100644 --- a/radio/src/gui/480x272/radio_setup.cpp +++ b/radio/src/gui/480x272/radio_setup.cpp @@ -457,7 +457,7 @@ bool menuRadioSetup(event_t event) lcdDrawText(MENUS_MARGIN_LEFT, y, STR_RXCHANNELORD); // RAET->AETR char s[5]; for (uint8_t i=0; i<4; i++) { - s[i] = STR_RETA123[channel_order(i+1)]; + s[i] = STR_RETA123[channelOrder(i+1)]; } s[4] = '\0'; lcdDrawText(RADIO_SETUP_2ND_COLUMN, y, s, attr); diff --git a/radio/src/gui/480x272/radio_trainer.cpp b/radio/src/gui/480x272/radio_trainer.cpp index 1900d84b4..48c6305ef 100644 --- a/radio/src/gui/480x272/radio_trainer.cpp +++ b/radio/src/gui/480x272/radio_trainer.cpp @@ -45,10 +45,10 @@ bool menuRadioTrainer(event_t event) lcdDrawText(TRAINER_COLUMN_3, MENU_HEADER_HEIGHT+1, "Source", HEADER_COLOR); */ - y = MENU_CONTENT_TOP + FH; + y = MENU_CONTENT_TOP; for (uint8_t i=0; isrcRaw = (s_currCh > 4 ? MIXSRC_Rud - 1 + s_currCh : MIXSRC_Rud - 1 + channel_order(s_currCh)); + expo->srcRaw = (s_currCh > 4 ? MIXSRC_Rud - 1 + s_currCh : MIXSRC_Rud - 1 + channelOrder(s_currCh)); expo->curve.type = CURVE_REF_EXPO; expo->mode = 3; // pos+neg expo->chn = s_currCh - 1; diff --git a/radio/src/gui/common/stdlcd/model_mixes.cpp b/radio/src/gui/common/stdlcd/model_mixes.cpp index ec70e8f33..90d509d23 100644 --- a/radio/src/gui/common/stdlcd/model_mixes.cpp +++ b/radio/src/gui/common/stdlcd/model_mixes.cpp @@ -65,7 +65,7 @@ void insertMix(uint8_t idx) mix->destCh = s_currCh-1; mix->srcRaw = s_currCh; if (!isSourceAvailable(mix->srcRaw)) { - mix->srcRaw = (s_currCh > 4 ? MIXSRC_Rud - 1 + s_currCh : MIXSRC_Rud - 1 + channel_order(s_currCh)); + mix->srcRaw = (s_currCh > 4 ? MIXSRC_Rud - 1 + s_currCh : MIXSRC_Rud - 1 + channelOrder(s_currCh)); while (!isSourceAvailable(mix->srcRaw)) { mix->srcRaw += 1; } diff --git a/radio/src/lua/api_general.cpp b/radio/src/lua/api_general.cpp index e19bea366..feae278a1 100644 --- a/radio/src/lua/api_general.cpp +++ b/radio/src/lua/api_general.cpp @@ -1220,7 +1220,7 @@ Get stick that is assigned to a channel. See Default Channel Order in General Se static int luaDefaultStick(lua_State * L) { uint8_t channel = luaL_checkinteger(L, 1); - lua_pushinteger(L, channel_order(channel+1)-1); + lua_pushinteger(L, channelOrder(channel+1)-1); return 1; } @@ -1308,7 +1308,7 @@ static int luaDefaultChannel(lua_State * L) { uint8_t stick = luaL_checkinteger(L, 1); for (int i=1; i<=4; i++) { - int tmp = channel_order(i) - 1; + int tmp = channelOrder(i) - 1; if (tmp == stick) { lua_pushinteger(L, i-1); return 1; diff --git a/radio/src/opentx.cpp b/radio/src/opentx.cpp index ab5e36bfa..96c352d1c 100644 --- a/radio/src/opentx.cpp +++ b/radio/src/opentx.cpp @@ -58,14 +58,14 @@ const uint8_t bchout_ar[] = { 0x87, 0x8D, 0x93, 0x9C, 0xB1, 0xB4, 0xC6, 0xC9, 0xD2, 0xD8, 0xE1, 0xE4 }; -uint8_t channel_order(uint8_t setup, uint8_t x) +uint8_t channelOrder(uint8_t setup, uint8_t x) { return ((*(bchout_ar + setup) >> (6 - (x - 1) * 2)) & 3) + 1; } -uint8_t channel_order(uint8_t x) +uint8_t channelOrder(uint8_t x) { - return channel_order(g_eeGeneral.templateSetup, x); + return channelOrder(g_eeGeneral.templateSetup, x); } /* @@ -299,7 +299,7 @@ void generalDefault() for (int i=0; isrcRaw = MIXSRC_Rud - 1 + stick_index; expo->curve.type = CURVE_REF_EXPO; @@ -843,6 +843,17 @@ void checkSDVersion() } #endif +#if defined(STM32) +static void checkRTCBattery() +{ + if (getRTCBatteryVoltage() < 200) { + ALERT("BATTERY", STR_WARN_RTC_BATTERY_LOW, AU_ERROR); + } + + disableVBatBridge(); +} +#endif + #if defined(PCBTARANIS) || defined(PCBHORUS) void checkFailsafe() { @@ -874,8 +885,9 @@ void checkAll() #endif // we don't check the throttle stick if the radio is not calibrated - if (g_eeGeneral.chkSum == evalChkSum()) + if (g_eeGeneral.chkSum == evalChkSum()) { checkThrottleStick(); + } checkSwitches(); checkFailsafe(); @@ -885,6 +897,10 @@ void checkAll() checkSDVersion(); #endif +#if defined(STM32) + checkRTCBattery(); +#endif + if (g_model.displayChecklist && modelHasNotes()) { readModelNotes(); } diff --git a/radio/src/opentx.h b/radio/src/opentx.h index 99243c1d8..c52cb6826 100644 --- a/radio/src/opentx.h +++ b/radio/src/opentx.h @@ -30,6 +30,13 @@ #include "opentx_types.h" #include "debounce.h" + +#if defined(SIMU) +#include "targets/simu/simpgmspace.h" +#endif + +#include "board.h" + #if defined(STM32) #include "usbd_conf.h" #endif @@ -220,8 +227,6 @@ #define RESXul 1024ul #define RESXl 1024l -#include "board.h" - #if defined(JACK_DETECT_GPIO) #define CASE_JACK_DETECT(x) x, #else @@ -232,10 +237,6 @@ #include "disk_cache.h" #endif -#if defined(SIMU) - #include "targets/simu/simpgmspace.h" -#endif - #include "debug.h" #if defined(PCBTARANIS) || defined(PCBHORUS) @@ -363,7 +364,7 @@ extern const uint8_t modn12x3[]; #define CONVERT_MODE_TRIMS(x) CONVERT_MODE(x) #endif -extern uint8_t channel_order(uint8_t x); +extern uint8_t channelOrder(uint8_t x); #define THRCHK_DEADBAND 16 @@ -1140,9 +1141,9 @@ union ReusableBuffer } moduleSetup; struct { - int16_t midVals[NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_MOUSE_ANALOGS]; - int16_t loVals[NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_MOUSE_ANALOGS]; - int16_t hiVals[NUM_STICKS+NUM_POTS+NUM_SLIDERS+NUM_MOUSE_ANALOGS]; + int16_t midVals[NUM_STICKS+NUM_POTS+NUM_SLIDERS+STORAGE_NUM_MOUSE_ANALOGS]; + int16_t loVals[NUM_STICKS+NUM_POTS+NUM_SLIDERS+STORAGE_NUM_MOUSE_ANALOGS]; + int16_t hiVals[NUM_STICKS+NUM_POTS+NUM_SLIDERS+STORAGE_NUM_MOUSE_ANALOGS]; uint8_t state; #if defined(PCBTARANIS) || defined(PCBHORUS) struct { diff --git a/radio/src/simu.cpp b/radio/src/simu.cpp index 19b822b26..f689176d3 100644 --- a/radio/src/simu.cpp +++ b/radio/src/simu.cpp @@ -553,6 +553,14 @@ uint16_t anaIn(uint8_t chan) #else else if (chan == TX_VOLTAGE) return 1500; +#endif +#if defined(PCBTARANIS) + else if (chan == TX_INTREF) + return 826; // 3V VDD + else if (chan == TX_TEMPERATURE) + return 520; + else if (chan == TX_RTC_VOLTAGE) + return 800; // 2.34V #endif else return 0; diff --git a/radio/src/targets/common/arm/stm32/adc_driver.cpp b/radio/src/targets/common/arm/stm32/adc_driver.cpp index 3e8d83fdf..0bdf92e19 100644 --- a/radio/src/targets/common/arm/stm32/adc_driver.cpp +++ b/radio/src/targets/common/arm/stm32/adc_driver.cpp @@ -23,27 +23,27 @@ #if defined(SIMU) // not needed #elif defined(PCBX10) - const int8_t ana_direction[NUM_ANALOGS] = {1,-1,1,-1, -1,1,-1, 1,-1, 1, 1,1}; + const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, -1,1,-1, 1,-1, 1, 1,1}; #elif defined(PCBX9E) #if defined(HORUS_STICKS) - const int8_t ana_direction[NUM_ANALOGS] = {1,-1,1,-1, -1,-1,-1,1, -1,1,-1,-1, -1}; + const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, -1,-1,-1,1, -1,1,-1,-1, -1, -1,-1,-1}; #else - const int8_t ana_direction[NUM_ANALOGS] = {1,1,-1,-1, -1,-1,-1,1, -1,1,-1,-1, -1}; + const int8_t adcDirection[NUM_ANALOGS] = {1,1,-1,-1, -1,-1,-1,1, -1,1,-1,-1, -1, -1,-1,-1}; #endif - const uint8_t ana_mapping[NUM_ANALOGS] = { 0 /*STICK1*/, 1 /*STICK2*/, 2 /*STICK3*/, 3 /*STICK4*/, - 10 /*POT1*/, 4 /*POT2*/, 5 /*POT3*/, 6 /*POT4*/, - 11 /*SLIDER1*/, 12 /*SLIDER2*/, 7 /*SLIDER3*/, 8 /*SLIDER4*/, - 9 /*TX_VOLTAGE*/ }; + const uint8_t adcMapping[NUM_ANALOGS] = { 0 /*STICK1*/, 1 /*STICK2*/, 2 /*STICK3*/, 3 /*STICK4*/, + 13 /*POT1*/, 4 /*POT2*/, 5 /*POT3*/, 6 /*POT4*/, + 14 /*SLIDER1*/, 15 /*SLIDER2*/, 7 /*SLIDER3*/, 8 /*SLIDER4*/, + 9 /*TX_VOLTAGE*/, 10 /*TX_TEMP*/, 11 /*ADC_INTREF*/, 12 /*TX_VBAT*/ }; #elif defined(PCBX9DP) - const int8_t ana_direction[NUM_ANALOGS] = {1,-1,1,-1, 1,1,-1, 1,1, 1}; + const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, 1,1,-1, 1,1, 1, 1,1,1}; #elif defined(PCBX7) - const int8_t ana_direction[NUM_ANALOGS] = {-1,1,-1,1, 1,1, 1}; + const int8_t adcDirection[NUM_ANALOGS] = {-1,1,-1,1, 1,1, 1, 1,1,1}; #elif defined(PCBX9LITE) - const int8_t ana_direction[NUM_ANALOGS] = {-1,1,-1,1, 1,1}; + const int8_t adcDirection[NUM_ANALOGS] = {-1,1,-1,1, 1,1, 1,1,1}; #elif defined(PCBXLITE) - const int8_t ana_direction[NUM_ANALOGS] = {1,-1,-1,1, -1,1, 1}; + const int8_t adcDirection[NUM_ANALOGS] = {1,-1,-1,1, -1,1, 1, 1,1,1}; #else - const int8_t ana_direction[NUM_ANALOGS] = {1,-1,1,-1, 1,1,0, 1,1, 1}; + const int8_t adcDirection[NUM_ANALOGS] = {1,-1,1,-1, 1,1,0, 1,1, 1, 1,1,1}; #endif #if NUM_PWMSTICKS > 0 @@ -51,14 +51,18 @@ #define NUM_ANALOGS_ADC (STICKS_PWM_ENABLED() ? (NUM_ANALOGS - NUM_PWMSTICKS) : NUM_ANALOGS) #elif defined(PCBX9E) #define FIRST_ANALOG_ADC 0 - #define NUM_ANALOGS_ADC 10 - #define NUM_ANALOGS_ADC_EXT (NUM_ANALOGS - 10) + #define NUM_ANALOGS_ADC 13 + #define NUM_ANALOGS_ADC_EXT (NUM_ANALOGS - NUM_ANALOGS_ADC) #else #define FIRST_ANALOG_ADC 0 #define NUM_ANALOGS_ADC NUM_ANALOGS #endif -uint16_t adcValues[NUM_ANALOGS + 1/*RTC*/] __DMA; +uint16_t adcValues[NUM_ANALOGS] __DMA; + +#if defined(PCBX10) +uint16_t rtcBatteryVoltage; +#endif void adcInit() { @@ -90,60 +94,71 @@ void adcInit() ADC_MAIN->CR1 = ADC_CR1_SCAN; ADC_MAIN->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS; - ADC_MAIN->SQR1 = (NUM_ANALOGS_ADC + 1/*RTC*/ - 1) << 20; // bits 23:20 = number of conversions + ADC_MAIN->SQR1 = (NUM_ANALOGS_ADC - 1) << 20; // bits 23:20 = number of conversions #if defined(PCBX10) if (STICKS_PWM_ENABLED()) { - ADC_MAIN->SQR2 = (ADC_CHANNEL_EXT1<<0) + (ADC_CHANNEL_EXT2<<5); // conversions 7 and more - ADC_MAIN->SQR3 = (ADC_CHANNEL_POT1<<0) + (ADC_CHANNEL_POT2<<5) + (ADC_CHANNEL_POT3<<10) + (ADC_CHANNEL_SLIDER1<<15) + (ADC_CHANNEL_SLIDER2<<20) + (ADC_CHANNEL_BATT<<25); // conversions 1 to 6 + ADC_MAIN->SQR2 = (ADC_CHANNEL_EXT1 << 0) + (ADC_CHANNEL_EXT2 << 5); + ADC_MAIN->SQR3 = (ADC_CHANNEL_POT1 << 0) + (ADC_CHANNEL_POT2 << 5) + (ADC_CHANNEL_POT3 << 10) + (ADC_CHANNEL_SLIDER1 << 15) + (ADC_CHANNEL_SLIDER2 << 20) + (ADC_CHANNEL_BATT << 25); } else { - ADC_MAIN->SQR2 = (ADC_CHANNEL_POT3<<0) + (ADC_CHANNEL_SLIDER1<<5) + (ADC_CHANNEL_SLIDER2<<10) + (ADC_CHANNEL_BATT<<15) + (ADC_CHANNEL_EXT1<<20) + (ADC_CHANNEL_EXT2<<25); // conversions 7 and more - ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH<<0) + (ADC_CHANNEL_STICK_LV<<5) + (ADC_CHANNEL_STICK_RV<<10) + (ADC_CHANNEL_STICK_RH<<15) + (ADC_CHANNEL_POT1<<20) + (ADC_CHANNEL_POT2<<25); // conversions 1 to 6 + ADC_MAIN->SQR2 = (ADC_CHANNEL_POT3 << 0) + (ADC_CHANNEL_SLIDER1 << 5) + (ADC_CHANNEL_SLIDER2 << 10) + (ADC_CHANNEL_BATT << 15) + (ADC_CHANNEL_EXT1 << 20) + (ADC_CHANNEL_EXT2 << 25); + ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_POT2 << 25); } #elif defined(PCBX9E) - ADC_MAIN->SQR2 = (ADC_CHANNEL_POT4<<0) + (ADC_CHANNEL_SLIDER3<<5) + (ADC_CHANNEL_SLIDER4<<10) + (ADC_CHANNEL_BATT<<15) + (ADC_CHANNEL_RTC<<20); // conversions 7 and more - ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH<<0) + (ADC_CHANNEL_STICK_LV<<5) + (ADC_CHANNEL_STICK_RV<<10) + (ADC_CHANNEL_STICK_RH<<15) + (ADC_CHANNEL_POT2<<20) + (ADC_CHANNEL_POT3<<25); // conversions 1 to 6 + ADC_MAIN->SQR1 |= (ADC_Channel_Vbat << 0); + ADC_MAIN->SQR2 = (ADC_CHANNEL_POT4 << 0) + (ADC_CHANNEL_SLIDER3 << 5) + (ADC_CHANNEL_SLIDER4 << 10) + (ADC_CHANNEL_BATT << 15) + (ADC_Channel_TempSensor << 20) + (ADC_Channel_Vrefint << 25); + ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT2 << 20) + (ADC_CHANNEL_POT3 << 25); #elif defined(PCBXLITE) if (STICKS_PWM_ENABLED()) { ADC_MAIN->SQR2 = 0; - ADC_MAIN->SQR3 = (ADC_CHANNEL_POT1<<0) + (ADC_CHANNEL_POT2<<5) + (ADC_CHANNEL_BATT<<10) + (ADC_CHANNEL_RTC<<15); + ADC_MAIN->SQR3 = (ADC_CHANNEL_POT1 << 0) + (ADC_CHANNEL_POT2 << 5) + (ADC_CHANNEL_BATT << 10) + (ADC_Channel_TempSensor << 15) + (ADC_Channel_Vrefint << 20) + (ADC_Channel_Vbat << 25); } else { - ADC_MAIN->SQR2 = (ADC_CHANNEL_BATT<<0) + (ADC_CHANNEL_RTC<<5); - ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH<<0) + (ADC_CHANNEL_STICK_LV<<5) + (ADC_CHANNEL_STICK_RV<<10) + (ADC_CHANNEL_STICK_RH<<15) + (ADC_CHANNEL_POT1<<20) + (ADC_CHANNEL_POT2<<25); // conversions 1 to 6 + ADC_MAIN->SQR2 = (ADC_CHANNEL_BATT << 0) + (ADC_Channel_TempSensor << 5) + (ADC_Channel_Vrefint << 10) + (ADC_Channel_Vbat << 15); + ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_POT2 << 25); } #elif defined(PCBX7) - // TODO why do we invert POT1 and POT2 here? - ADC_MAIN->SQR2 = (ADC_CHANNEL_BATT<<0) + (ADC_CHANNEL_RTC<<5); // conversions 7 and more - ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH<<0) + (ADC_CHANNEL_STICK_LV<<5) + (ADC_CHANNEL_STICK_RV<<10) + (ADC_CHANNEL_STICK_RH<<15) + (ADC_CHANNEL_POT1<<25) + (ADC_CHANNEL_POT2<<20); // conversions 1 to 6 + ADC_MAIN->SQR2 = (ADC_CHANNEL_BATT << 0) + (ADC_Channel_TempSensor << 5) + (ADC_Channel_Vrefint << 10) + (ADC_Channel_Vbat << 15); + ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_POT2 << 25); #elif defined(PCBX9LITE) - ADC_MAIN->SQR2 = (ADC_CHANNEL_RTC<<0); // conversions 7 and more - ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH<<0) + (ADC_CHANNEL_STICK_LV<<5) + (ADC_CHANNEL_STICK_RV<<10) + (ADC_CHANNEL_STICK_RH<<15) + (ADC_CHANNEL_POT1<<20) + (ADC_CHANNEL_BATT<<25); // conversions 1 to 6 -#else - ADC_MAIN->SQR2 = (ADC_CHANNEL_POT3<<0) + (ADC_CHANNEL_SLIDER1<<5) + (ADC_CHANNEL_SLIDER2<<10) + (ADC_CHANNEL_BATT<<15) + (ADC_CHANNEL_RTC<<20); // conversions 7 and more - ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH<<0) + (ADC_CHANNEL_STICK_LV<<5) + (ADC_CHANNEL_STICK_RV<<10) + (ADC_CHANNEL_STICK_RH<<15) + (ADC_CHANNEL_POT1<<20) + (ADC_CHANNEL_POT2<<25); // conversions 1 to 6 + ADC_MAIN->SQR2 = (ADC_Channel_TempSensor << 0) + (ADC_Channel_Vrefint << 5) + (ADC_Channel_Vbat << 10); + ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_BATT << 25); +#elif defined(PCBX9D) || defined(PCBX9DP) + ADC_MAIN->SQR1 |= (ADC_Channel_Vbat<<0); + ADC_MAIN->SQR2 = (ADC_CHANNEL_POT3 << 0) + (ADC_CHANNEL_SLIDER1 << 5) + (ADC_CHANNEL_SLIDER2 << 10) + (ADC_CHANNEL_BATT << 15) + (ADC_Channel_TempSensor << 20) + (ADC_Channel_Vrefint << 25); + ADC_MAIN->SQR3 = (ADC_CHANNEL_STICK_LH << 0) + (ADC_CHANNEL_STICK_LV << 5) + (ADC_CHANNEL_STICK_RV << 10) + (ADC_CHANNEL_STICK_RH << 15) + (ADC_CHANNEL_POT1 << 20) + (ADC_CHANNEL_POT2 << 25); #endif - ADC_MAIN->SMPR1 = ADC_SAMPTIME + (ADC_SAMPTIME<<3) + (ADC_SAMPTIME<<6) + (ADC_SAMPTIME<<9) + (ADC_SAMPTIME<<12) + (ADC_SAMPTIME<<15) + (ADC_SAMPTIME<<18) + (ADC_SAMPTIME<<21) + (ADC_SAMPTIME<<24); - ADC_MAIN->SMPR2 = ADC_SAMPTIME + (ADC_SAMPTIME<<3) + (ADC_SAMPTIME<<6) + (ADC_SAMPTIME<<9) + (ADC_SAMPTIME<<12) + (ADC_SAMPTIME<<15) + (ADC_SAMPTIME<<18) + (ADC_SAMPTIME<<21) + (ADC_SAMPTIME<<24) + (ADC_SAMPTIME<<27); + ADC_MAIN->SMPR1 = (ADC_SAMPTIME << 0) + (ADC_SAMPTIME << 3) + (ADC_SAMPTIME << 6) + (ADC_SAMPTIME << 9) + (ADC_SAMPTIME << 12) + (ADC_SAMPTIME << 15) + (ADC_SAMPTIME << 18) + (ADC_SAMPTIME << 21) + (ADC_SAMPTIME << 24); + ADC_MAIN->SMPR2 = (ADC_SAMPTIME << 0) + (ADC_SAMPTIME << 3) + (ADC_SAMPTIME << 6) + (ADC_SAMPTIME << 9) + (ADC_SAMPTIME << 12) + (ADC_SAMPTIME << 15) + (ADC_SAMPTIME << 18) + (ADC_SAMPTIME << 21) + (ADC_SAMPTIME << 24) + (ADC_SAMPTIME << 27); - ADC->CCR = 0; + ADC->CCR = ADC_CCR_VBATE | ADC_CCR_TSVREFE; // Enable temperature + vbat sensor ADC_DMA_Stream->CR = DMA_SxCR_PL | ADC_DMA_SxCR_CHSEL | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC; ADC_DMA_Stream->PAR = CONVERT_PTR_UINT(&ADC_MAIN->DR); ADC_DMA_Stream->M0AR = CONVERT_PTR_UINT(&adcValues[FIRST_ANALOG_ADC]); - ADC_DMA_Stream->NDTR = NUM_ANALOGS_ADC + 1/*RTC*/; + ADC_DMA_Stream->NDTR = NUM_ANALOGS_ADC; ADC_DMA_Stream->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0; +#if defined(PCBX10) + ADC1->CR1 = ADC_CR1_SCAN; + ADC1->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS; + ADC1->SQR1 = (1 - 1) << 20; + ADC1->SQR2 = 0; + ADC1->SQR3 = (ADC_Channel_Vbat << 0); + ADC1->SMPR1 = (ADC_SAMPTIME << 0) + (ADC_SAMPTIME << 3) + (ADC_SAMPTIME << 6) + (ADC_SAMPTIME << 9) + (ADC_SAMPTIME << 12) + (ADC_SAMPTIME << 15) + (ADC_SAMPTIME << 18) + (ADC_SAMPTIME << 21) + (ADC_SAMPTIME << 24); + ADC1->SMPR2 = (ADC_SAMPTIME << 0) + (ADC_SAMPTIME << 3) + (ADC_SAMPTIME << 6) + (ADC_SAMPTIME << 9) + (ADC_SAMPTIME << 12) + (ADC_SAMPTIME << 15) + (ADC_SAMPTIME << 18) + (ADC_SAMPTIME << 21) + (ADC_SAMPTIME << 24) + (ADC_SAMPTIME << 27); +#endif + #if defined(PCBX9E) ADC_EXT->CR1 = ADC_CR1_SCAN; ADC_EXT->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS; ADC_EXT->SQR1 = (NUM_ANALOGS_ADC_EXT - 1) << 20; ADC_EXT->SQR2 = 0; - ADC_EXT->SQR3 = (ADC_CHANNEL_POT1<<0) + (ADC_CHANNEL_SLIDER1<<5) + (ADC_CHANNEL_SLIDER2<<10); // conversions 1 to 3 + ADC_EXT->SQR3 = (ADC_CHANNEL_POT1 << 0) + (ADC_CHANNEL_SLIDER1 << 5) + (ADC_CHANNEL_SLIDER2 << 10); // conversions 1 to 3 ADC_EXT->SMPR1 = 0; - ADC_EXT->SMPR2 = (ADC_EXT_SAMPTIME<<(3*ADC_CHANNEL_POT1)) + (ADC_EXT_SAMPTIME<<(3*ADC_CHANNEL_SLIDER1)) + (ADC_EXT_SAMPTIME<<(3*ADC_CHANNEL_SLIDER2)); + ADC_EXT->SMPR2 = (ADC_EXT_SAMPTIME << (3*ADC_CHANNEL_POT1)) + (ADC_EXT_SAMPTIME << (3*ADC_CHANNEL_SLIDER1)) + (ADC_EXT_SAMPTIME << (3*ADC_CHANNEL_SLIDER2)); ADC_EXT_DMA_Stream->CR = DMA_SxCR_PL | DMA_SxCR_CHSEL_1 | DMA_SxCR_MSIZE_0 | DMA_SxCR_PSIZE_0 | DMA_SxCR_MINC; ADC_EXT_DMA_Stream->PAR = CONVERT_PTR_UINT(&ADC_EXT->DR); @@ -165,7 +180,12 @@ void adcSingleRead() ADC_MAIN->SR &= ~(uint32_t)(ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR); ADC_SET_DMA_FLAGS(); ADC_DMA_Stream->CR |= DMA_SxCR_EN; // Enable DMA - ADC_MAIN->CR2 |= (uint32_t) ADC_CR2_SWSTART; + ADC_MAIN->CR2 |= (uint32_t)ADC_CR2_SWSTART; + +#if defined(PCBX10) + ADC1->SR &= ~(uint32_t)(ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR); + ADC1->CR2 |= (uint32_t)ADC_CR2_SWSTART; +#endif #if defined(PCBX9E) ADC_EXT_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA @@ -191,6 +211,12 @@ void adcSingleRead() } ADC_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA #endif + +#if defined(PCBX10) + if (ADC->CCR & ADC_CCR_VBATE) { + rtcBatteryVoltage = ADC1->DR; + } +#endif } void adcRead() @@ -221,18 +247,29 @@ void adcRead() #endif } -// TODO -void adcStop() +#if defined(PCBX10) +uint16_t getRTCBatteryVoltage() { + return rtcBatteryVoltage * 330 / 2048; +} +#else +// Returns temperature in 10*C +uint16_t getTemperature() +{ + // VDD IN 1/10 mV + int vdd = 2048 * 12100 / anaIn(TX_INTREF); + int vtemp = vdd * anaIn(TX_TEMPERATURE) / 2048; + + // From Doc ID 15818 Rev 7 for STM32F2: + // 25 C = 0.76V, 2.5 mV/C + return (vtemp - 7600) * 10 / 25 + 250; } -uint16_t getRTCBattVoltage() +uint16_t getRTCBatteryVoltage() { - ADC->CCR |= ADC_CCR_VBATE; - adcSingleRead(); - ADC->CCR &= ADC_CCR_VBATE; - return adcValues[TX_RTC] * 330 / 2048; + return (uint16_t )(12100 * 2048 / anaIn(TX_INTREF) * anaIn(TX_RTC_VOLTAGE) / 204800 * 2); } +#endif #if !defined(SIMU) uint16_t getAnalogValue(uint8_t index) @@ -244,9 +281,9 @@ uint16_t getAnalogValue(uint8_t index) return 0; } #if defined(PCBX9E) - index = ana_mapping[index]; + index = adcMapping[index]; #endif - if (ana_direction[index] < 0) + if (adcDirection[index] < 0) return 4095 - adcValues[index]; else return adcValues[index]; diff --git a/radio/src/targets/common/arm/stm32/board_common.h b/radio/src/targets/common/arm/stm32/board_common.h new file mode 100644 index 000000000..6bd1a1597 --- /dev/null +++ b/radio/src/targets/common/arm/stm32/board_common.h @@ -0,0 +1,133 @@ +/* + * Copyright (C) OpenTX + * + * Based on code named + * th9x - http://code.google.com/p/th9x + * er9x - http://code.google.com/p/er9x + * gruvin9x - http://code.google.com/p/gruvin9x + * + * License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + */ + +#ifndef _BOARD_COMMON_H_ +#define _BOARD_COMMON_H_ + +#include +#include "cpu_id.h" + +#if defined(LUA_EXPORT_GENERATION) +// no includes +#elif defined(STM32F4) +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rcc.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_syscfg.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_gpio.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_exti.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_tim.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_adc.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spi.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_i2c.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rtc.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_pwr.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_usart.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_flash.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dbgmcu.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/misc.h" +#else +#include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_rcc.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_syscfg.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_gpio.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_exti.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_tim.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_adc.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_spi.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_i2c.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_rtc.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_pwr.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_dma.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_usart.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_flash.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_dbgmcu.h" + #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/misc.h" +#endif + +#if defined(__cplusplus) && !defined(SIMU) +extern "C" { +#endif + +#if __clang__ +// clang is very picky about the use of "register" +// Tell clang to ignore the warnings for the following files +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-register" +#endif + +#if __clang__ +// Restore warnings about registers +#pragma clang diagnostic pop +#endif + +#include "usb_driver.h" + +#if !defined(SIMU) +#include "usbd_cdc_core.h" +#include "usbd_msc_core.h" +#include "usbd_hid_core.h" +#include "usbd_usr.h" +#include "usbd_desc.h" +#include "usb_conf.h" +#include "usbd_conf.h" +#endif + +#if defined(__cplusplus) && !defined(SIMU) +} +#endif + +#if defined(SIMU) +#include "../simu/simpgmspace.h" +#endif + +// ADC driver +void adcInit(); +void adcRead(); +uint16_t getAnalogValue(uint8_t index); +uint16_t getBatteryVoltage(); // returns current battery voltage in 10mV steps +uint16_t getTemperature(); +uint16_t getRTCBatteryVoltage(); + +// STM32 uses a 25K+25K voltage divider bridge to measure the battery voltage +// Measuring VBAT puts considerable drain (22 µA) on the battery instead of normal drain (~10 nA) +static inline void enableVBatBridge() +{ + ADC->CCR |= ADC_CCR_VBATE; +} + +static inline void disableVBatBridge() +{ + ADC->CCR &= ~ADC_CCR_VBATE; +} + +// Delays driver +#ifdef __cplusplus +extern "C" { +#endif +void delaysInit(void); +void delay_01us(uint16_t nb); +void delay_us(uint16_t nb); +void delay_ms(uint32_t ms); +#ifdef __cplusplus +} +#endif + +#endif diff --git a/radio/src/targets/horus/adc_driver.cpp b/radio/src/targets/horus/adc_driver.cpp index 34aff8f24..6e333bc0b 100644 --- a/radio/src/targets/horus/adc_driver.cpp +++ b/radio/src/targets/horus/adc_driver.cpp @@ -20,7 +20,8 @@ #include "opentx.h" -uint16_t adcValues[NUM_ANALOGS + 1/*RTC*/] __DMA; +uint16_t adcValues[NUM_ANALOGS] __DMA; +uint16_t rtcBatteryVoltage; #define ADC_CS_HIGH() (ADC_SPI_GPIO->BSRRL = ADC_SPI_PIN_CS) #define ADC_CS_LOW() (ADC_SPI_GPIO->BSRRH = ADC_SPI_PIN_CS) @@ -40,8 +41,6 @@ uint16_t adcValues[NUM_ANALOGS + 1/*RTC*/] __DMA; #define RESETCMD 0x4000 #define MANUAL_MODE 0x1000 // manual mode channel 0 -#define SAMPTIME 2 // sample time = 28 cycles - uint16_t SPIx_ReadWriteByte(uint16_t value) { while (SPI_I2S_GetFlagStatus(ADC_SPI, SPI_I2S_FLAG_TXE) == RESET); @@ -113,22 +112,13 @@ void adcInit() GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(ADC_GPIO_MOUSE, &GPIO_InitStructure); - // RTC battery - ADC1->CR1 = ADC_CR1_SCAN; - ADC1->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS; - ADC1->SQR1 = (1 - 1) << 20; - ADC1->SQR3 = ADC_CHANNEL_RTC; - ADC1->SMPR1 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12) + (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24); - ADC1->SMPR2 = SAMPTIME + (SAMPTIME<<3) + (SAMPTIME<<6) + (SAMPTIME<<9) + (SAMPTIME<<12) + (SAMPTIME<<15) + (SAMPTIME<<18) + (SAMPTIME<<21) + (SAMPTIME<<24) + (SAMPTIME<<27); - - // Track pad ADC3->CR1 = ADC_CR1_SCAN; ADC3->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS; ADC3->SQR1 = (2 - 1) << 20; ADC3->SQR2 = 0; - ADC3->SQR3 = ADC_CHANNEL_MOUSE1 + (ADC_CHANNEL_MOUSE2<<5); - ADC3->SMPR1 = 0; - ADC3->SMPR2 = (ADC_SAMPTIME<<(3*ADC_CHANNEL_MOUSE1)) + (ADC_SAMPTIME<<(3*ADC_CHANNEL_MOUSE2)); + ADC3->SQR3 = (ADC_CHANNEL_MOUSE1 << 0) + (ADC_CHANNEL_MOUSE2 << 5); + ADC3->SMPR1 = (ADC_SAMPTIME << 0) + (ADC_SAMPTIME << 3) + (ADC_SAMPTIME << 6) + (ADC_SAMPTIME << 9) + (ADC_SAMPTIME << 12) + (ADC_SAMPTIME << 15) + (ADC_SAMPTIME << 18) + (ADC_SAMPTIME << 21) + (ADC_SAMPTIME << 24); + ADC3->SMPR2 = (ADC_SAMPTIME << 0) + (ADC_SAMPTIME << 3) + (ADC_SAMPTIME << 6) + (ADC_SAMPTIME << 9) + (ADC_SAMPTIME << 12) + (ADC_SAMPTIME << 15) + (ADC_SAMPTIME << 18) + (ADC_SAMPTIME << 21) + (ADC_SAMPTIME << 24) + (ADC_SAMPTIME << 27); ADC->CCR = 0; // Enable the DMA channel here, DMA2 stream 1, channel 2 @@ -137,6 +127,19 @@ void adcInit() ADC_DMA_Stream->M0AR = CONVERT_PTR_UINT(&adcValues[MOUSE1]); ADC_DMA_Stream->NDTR = 2; ADC_DMA_Stream->FCR = DMA_SxFCR_DMDIS | DMA_SxFCR_FTH_0; + + ADC1->CR1 = ADC_CR1_SCAN; + ADC1->CR2 = ADC_CR2_ADON | ADC_CR2_DMA | ADC_CR2_DDS; + ADC1->SQR1 = (1 - 1) << 20; + ADC1->SQR2 = 0; + ADC1->SQR3 = (ADC_Channel_Vbat << 0); + ADC1->SMPR1 = (ADC_SAMPTIME << 0) + (ADC_SAMPTIME << 3) + (ADC_SAMPTIME << 6) + (ADC_SAMPTIME << 9) + (ADC_SAMPTIME << 12) + (ADC_SAMPTIME << 15) + (ADC_SAMPTIME << 18) + (ADC_SAMPTIME << 21) + (ADC_SAMPTIME << 24); + ADC1->SMPR2 = (ADC_SAMPTIME << 0) + (ADC_SAMPTIME << 3) + (ADC_SAMPTIME << 6) + (ADC_SAMPTIME << 9) + (ADC_SAMPTIME << 12) + (ADC_SAMPTIME << 15) + (ADC_SAMPTIME << 18) + (ADC_SAMPTIME << 21) + (ADC_SAMPTIME << 24) + (ADC_SAMPTIME << 27); +} + +uint16_t getRTCBatteryVoltage() +{ + return rtcBatteryVoltage * 330 / 2048; } const uint16_t adcCommands[MOUSE1+2] = @@ -206,13 +209,14 @@ uint32_t adcReadNextSPIChannel(uint8_t index) void adcOnChipReadStart() { ADC_DMA_Stream->CR &= ~DMA_SxCR_EN; // Disable DMA - ADC1->SR &= ~(uint32_t)(ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR); ADC3->SR &= ~(uint32_t)(ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR); ADC_DMA->LIFCR = DMA_LIFCR_CTCIF0 | DMA_LIFCR_CHTIF0 | DMA_LIFCR_CTEIF0 | DMA_LIFCR_CDMEIF0 | DMA_LIFCR_CFEIF0; // Write ones to clear bits ADC_DMA_Stream->M0AR = CONVERT_PTR_UINT(&adcValues[MOUSE1]); ADC_DMA_Stream->NDTR = 2; ADC_DMA_Stream->CR |= DMA_SxCR_EN; // Enable DMA ADC3->CR2 |= (uint32_t)ADC_CR2_SWSTART; + + ADC1->SR &= ~(uint32_t)(ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR); ADC1->CR2 |= (uint32_t)ADC_CR2_SWSTART; } @@ -256,14 +260,10 @@ void adcRead() for (uint8_t x=0; x> 2; } -} -uint16_t getRTCBattVoltage() -{ - ADC->CCR |= ADC_CCR_VBATE; - adcRead(); - ADC->CCR &= ADC_CCR_VBATE; - return ADC1->DR * 330 / 2048; + if (ADC->CCR & ADC_CCR_VBATE) { + rtcBatteryVoltage = ADC1->DR; + } } #if !defined(SIMU) diff --git a/radio/src/targets/horus/board.cpp b/radio/src/targets/horus/board.cpp index 8ba0c5278..14355e0e3 100644 --- a/radio/src/targets/horus/board.cpp +++ b/radio/src/targets/horus/board.cpp @@ -182,8 +182,6 @@ void boardInit() #endif ledBlue(); - - vbattRTC = getRTCBattVoltage(); #endif } diff --git a/radio/src/targets/horus/board.h b/radio/src/targets/horus/board.h index 48ef15a92..0f331f9e4 100644 --- a/radio/src/targets/horus/board.h +++ b/radio/src/targets/horus/board.h @@ -23,63 +23,14 @@ #include "../definitions.h" #include "../opentx_constants.h" -#include "cpu_id.h" - -#if defined(__cplusplus) && !defined(SIMU) -extern "C" { -#endif - -#if __clang__ -// clang is very picky about the use of "register" -// Tell clang to ignore the warnings for the following files -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-register" -#endif - -#if !defined(LUA_EXPORT_GENERATION) -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rcc.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_syscfg.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_gpio.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_exti.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spi.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_i2c.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rtc.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_pwr.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_usart.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_flash.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_sdio.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dbgmcu.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_ltdc.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_fmc.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_tim.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma2d.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_adc.h" -#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/misc.h" -#endif - -#if __clang__ -// Restore warnings about registers -#pragma clang diagnostic pop -#endif - -#include "usb_driver.h" - -#if !defined(SIMU) -#include "usbd_cdc_core.h" -#include "usbd_msc_core.h" -#include "usbd_hid_core.h" -#include "usbd_usr.h" -#include "usbd_desc.h" -#include "usb_conf.h" -#include "usbd_conf.h" -#endif - +#include "board_common.h" #include "hal.h" -#if defined(__cplusplus) && !defined(SIMU) -} +#if !defined(LUA_EXPORT_GENERATION) +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_sdio.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma2d.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_ltdc.h" +#include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_fmc.h" #endif #define FLASHSIZE 0x200000 @@ -114,18 +65,6 @@ void boardOff(void); void init2MhzTimer(); void init5msTimer(); -// Delays driver -#ifdef __cplusplus -extern "C" { -#endif -void delaysInit(void); -void delay_01us(uint16_t nb); -void delay_us(uint16_t nb); -void delay_ms(uint32_t ms); -#ifdef __cplusplus -} -#endif - // PCBREV driver #define IS_HORUS_PROD() GPIO_ReadInputDataBit(PCBREV_GPIO, PCBREV_GPIO_PIN) #if defined(SIMU) || defined(PCBX10) @@ -393,18 +332,12 @@ enum Analogs { POT1 = POT_FIRST, POT2, POT3, + POT_LAST = POT3, SLIDER_FIRST, - SLIDER1 = SLIDER_FIRST, - SLIDER2, -#if defined(PCBX12S) SLIDER_FRONT_LEFT = SLIDER_FIRST, SLIDER_FRONT_RIGHT, SLIDER_REAR_LEFT, SLIDER_REAR_RIGHT, -#else - SLIDER_REAR_LEFT, - SLIDER_REAR_RIGHT, -#endif SLIDER_LAST = SLIDER_FIRST + NUM_SLIDERS - 1, TX_VOLTAGE, #if defined(PCBX12S) @@ -415,11 +348,11 @@ enum Analogs { EXT1, EXT2, #endif - NUM_ANALOGS, - TX_RTC = NUM_ANALOGS + NUM_ANALOGS }; -#define POT_LAST (SLIDER_FIRST - 1) +#define SLIDER1 SLIDER_FRONT_LEFT +#define SLIDER2 SLIDER_FRONT_RIGHT #define DEFAULT_SWITCH_CONFIG (SWITCH_TOGGLE << 14) + (SWITCH_3POS << 12) + (SWITCH_2POS << 10) + (SWITCH_3POS << 8) + (SWITCH_3POS << 6) + (SWITCH_3POS << 4) + (SWITCH_3POS << 2) + (SWITCH_3POS << 0) #define DEFAULT_POTS_CONFIG (POT_WITH_DETENT << 4) + (POT_MULTIPOS_SWITCH << 2) + (POT_WITHOUT_DETENT << 0) @@ -449,11 +382,7 @@ enum CalibratedAnalogs { #define IS_POT(x) ((x)>=POT_FIRST && (x)<=POT_LAST) #define IS_SLIDER(x) ((x)>=SLIDER_FIRST && (x)<=SLIDER_LAST) -extern uint16_t adcValues[NUM_ANALOGS + 1/*RTC*/]; -void adcInit(void); -void adcRead(void); -uint16_t getRTCBattVoltage(); -uint16_t getAnalogValue(uint8_t index); +extern uint16_t adcValues[NUM_ANALOGS]; #if defined(PCBX12S) #define NUM_MOUSE_ANALOGS 2 @@ -483,7 +412,6 @@ extern volatile uint32_t pwm_interrupt_count; #define BATTERY_MIN 85 // 8.5V #define BATTERY_MAX 115 // 11.5V #endif -uint16_t getBatteryVoltage(); // returns current battery voltage in 10mV steps #if defined(__cplusplus) && !defined(SIMU) extern "C" { diff --git a/radio/src/targets/horus/hal.h b/radio/src/targets/horus/hal.h index 75d8a5c81..c2a631b4d 100644 --- a/radio/src/targets/horus/hal.h +++ b/radio/src/targets/horus/hal.h @@ -214,7 +214,7 @@ #if defined(PCBX12S) #define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOE | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_DMA2) #define ADC_RCC_APB1Periph 0 - #define ADC_RCC_APB2Periph (RCC_APB2Periph_SPI4 | RCC_APB2Periph_ADC3) + #define ADC_RCC_APB2Periph (RCC_APB2Periph_SPI4 | RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC3) #define ADC_SPI SPI4 #define ADC_GPIO_AF GPIO_AF_SPI4 #define ADC_SPI_GPIO GPIOE @@ -233,11 +233,10 @@ #define ADC_DMA DMA2 #define ADC_DMA_Stream DMA2_Stream0 #define ADC_SAMPTIME 3 - #define ADC_CHANNEL_RTC 0 // TODO later ... ADC1_IN18 #elif defined(PCBX10) #define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_DMA2) #define ADC_RCC_APB1Periph (RCC_APB1Periph_TIM5) - #define ADC_RCC_APB2Periph (RCC_APB2Periph_ADC3) + #define ADC_RCC_APB2Periph (RCC_APB2Periph_ADC1 | RCC_APB2Periph_ADC3) #define ADC_GPIO_PIN_STICK_LH GPIO_Pin_0 // PA.00 #define ADC_GPIO_PIN_STICK_LV GPIO_Pin_1 // PA.01 #define ADC_GPIO_PIN_STICK_RH GPIO_Pin_2 // PA.02 @@ -271,7 +270,6 @@ #define ADC_CHANNEL_BATT ADC_Channel_5 // ADC3_IN5 #define ADC_CHANNEL_EXT1 ADC_Channel_6 // ADC3_IN6 #define ADC_CHANNEL_EXT2 ADC_Channel_7 // ADC3_IN7 - #define ADC_CHANNEL_RTC 0 // TODO later ... ADC1_IN18 #define ADC_MAIN ADC3 #define ADC_SAMPTIME 3 #define ADC_DMA DMA2 diff --git a/radio/src/targets/simu/opentxsimulator.cpp b/radio/src/targets/simu/opentxsimulator.cpp index b16be36eb..54b5fc390 100644 --- a/radio/src/targets/simu/opentxsimulator.cpp +++ b/radio/src/targets/simu/opentxsimulator.cpp @@ -25,7 +25,7 @@ #define MAX_LOGICAL_SWITCHES NUM_CSW #endif - #define GET_SWITCH_BOOL(sw__) getSwitch((sw__), 0); +#define GET_SWITCH_BOOL(sw__) getSwitch((sw__), 0); #define OTXS_DBG qDebug() << "(" << simuTimerMicros() << "us)" @@ -93,6 +93,7 @@ void OpenTxSimulator::init() { if (isRunning()) return; + OTXS_DBG; if (!m_timer10ms) { @@ -109,6 +110,13 @@ void OpenTxSimulator::init() QMutexLocker lckr(&m_mtxSimuMain); memset(g_anas, 0, sizeof(g_anas)); + +#if defined(PCBTARANIS) + g_anas[TX_INTREF] = 826; // 3V VDD + g_anas[TX_RTC_VOLTAGE] = 800; // 2,34V + g_anas[TX_TEMPERATURE] = 520; +#endif + simuInit(); } diff --git a/radio/src/targets/simu/simpgmspace.cpp b/radio/src/targets/simu/simpgmspace.cpp index c0d344bd7..d2af0771f 100644 --- a/radio/src/targets/simu/simpgmspace.cpp +++ b/radio/src/targets/simu/simpgmspace.cpp @@ -50,6 +50,7 @@ DMA_Stream_TypeDef dma1_stream1, dma1_stream2, dma1_stream3, dma1_stream4, dma1_ DMA_TypeDef dma2; USART_TypeDef Usart0, Usart1, Usart2, Usart3, Usart4; SysTick_Type systick; +ADC_Common_TypeDef adc; #else Pio Pioa, Piob, Pioc; Pmc pmc; diff --git a/radio/src/targets/simu/simpgmspace.h b/radio/src/targets/simu/simpgmspace.h index 16f99c089..99e686b4c 100644 --- a/radio/src/targets/simu/simpgmspace.h +++ b/radio/src/targets/simu/simpgmspace.h @@ -87,6 +87,7 @@ extern RCC_TypeDef rcc; extern DMA_Stream_TypeDef dma1_stream0, dma1_stream1, dma1_stream2, dma1_stream3, dma1_stream4, dma1_stream5, dma1_stream6, dma1_stream7, dma2_stream1, dma2_stream2, dma2_stream5, dma2_stream6, dma2_stream7; extern DMA_TypeDef dma2; extern SysTick_Type systick; +extern ADC_Common_TypeDef adc; #undef SysTick #define SysTick (&systick) #undef GPIOA @@ -165,6 +166,8 @@ extern SysTick_Type systick; #define DMA2_Stream7 (&dma2_stream7) #undef DMA2 #define DMA2 (&dma2) +#undef ADC +#define ADC (&adc) #elif defined(PCBSKY9X) extern Pmc pmc; #undef PMC @@ -208,12 +211,7 @@ extern Pwm pwm; #define PWM (&pwm) #endif -#if defined(EEPROM_SIZE) -extern uint8_t eeprom[EEPROM_SIZE]; -#else extern uint8_t * eeprom; -#endif - extern void startPdcUsartReceive() ; extern uint32_t txPdcUsart( uint8_t *buffer, uint32_t size ); extern uint32_t txPdcPending(); diff --git a/radio/src/targets/simu/simueeprom.cpp b/radio/src/targets/simu/simueeprom.cpp index 414b73270..ad9dedc13 100644 --- a/radio/src/targets/simu/simueeprom.cpp +++ b/radio/src/targets/simu/simueeprom.cpp @@ -22,20 +22,12 @@ const char * eepromFile = nullptr; FILE * fp = nullptr; - uint32_t eeprom_pointer; uint8_t * eeprom_buffer_data; volatile int32_t eeprom_buffer_size; bool eeprom_read_operation; - bool eeprom_thread_running = false; - -#if defined(EEPROM_SIZE) -uint8_t eeprom[EEPROM_SIZE]; -#else uint8_t * eeprom = nullptr; -#endif - sem_t * eeprom_write_sem; void eepromReadBlock (uint8_t * buffer, size_t address, size_t size) diff --git a/radio/src/targets/sky9x/board.h b/radio/src/targets/sky9x/board.h index 58815c2a8..e173e1fb0 100644 --- a/radio/src/targets/sky9x/board.h +++ b/radio/src/targets/sky9x/board.h @@ -274,6 +274,7 @@ extern "C" { #define NUM_SLIDERS 0 #define STORAGE_NUM_SLIDERS 0 #define NUM_XPOTS 0 +#define NUM_MOUSE_ANALOGS 0 #define STORAGE_NUM_MOUSE_ANALOGS 0 enum Analogs { STICK1, @@ -305,10 +306,11 @@ enum CalibratedAnalogs { #define IS_SLIDER(x) false #define STICKS_PWM_ENABLED() false void adcInit(); -void adcRead(void); +void adcRead(); uint16_t getAnalogValue(uint8_t index); void setSticksGain(uint8_t gains); -#define NUM_MOUSE_ANALOGS 0 +#define enableVBatBridge() do { } while(0) +#define disableVBatBridge() // Battery driver uint16_t getBatteryVoltage(); // returns current battery voltage in 10mV steps diff --git a/radio/src/targets/taranis/board.cpp b/radio/src/targets/taranis/board.cpp index d6f949a50..38d22a454 100644 --- a/radio/src/targets/taranis/board.cpp +++ b/radio/src/targets/taranis/board.cpp @@ -263,8 +263,6 @@ void boardInit() initHeadphoneTrainerSwitch(); - vbattRTC = getRTCBattVoltage(); - #if defined(GYRO) gyroInit(); #endif diff --git a/radio/src/targets/taranis/board.h b/radio/src/targets/taranis/board.h index b659cffab..4d76e0f29 100644 --- a/radio/src/targets/taranis/board.h +++ b/radio/src/targets/taranis/board.h @@ -24,79 +24,9 @@ #include #include "../definitions.h" #include "../opentx_constants.h" -#include "cpu_id.h" - -#if defined(__cplusplus) && !defined(SIMU) -extern "C" { -#endif - -#if __clang__ -// clang is very picky about the use of "register" -// tell it to ignore for the STM32 includes instead of modyfing the orginal files -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wdeprecated-register" -#endif - -#if defined(LUA_EXPORT_GENERATION) - // no includes -#elif defined(STM32F4) - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rcc.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_syscfg.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_gpio.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_exti.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_tim.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_adc.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_spi.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_i2c.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_rtc.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_pwr.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dma.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_usart.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_flash.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/stm32f4xx_dbgmcu.h" - #include "STM32F4xx_DSP_StdPeriph_Lib_V1.4.0/Libraries/STM32F4xx_StdPeriph_Driver/inc/misc.h" -#else - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/CMSIS/Device/ST/STM32F2xx/Include/stm32f2xx.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_rcc.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_syscfg.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_gpio.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_exti.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_tim.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_adc.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_spi.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_i2c.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_rtc.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_pwr.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_dma.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_usart.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_flash.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/stm32f2xx_dbgmcu.h" - #include "STM32F2xx_StdPeriph_Lib_V1.1.0/Libraries/STM32F2xx_StdPeriph_Driver/inc/misc.h" -#endif - -#if __clang__ -// Restore warnings about registers -#pragma clang diagnostic pop -#endif - -#include "usb_driver.h" - -#if !defined(SIMU) - #include "usbd_cdc_core.h" - #include "usbd_msc_core.h" - #include "usbd_hid_core.h" - #include "usbd_usr.h" - #include "usbd_desc.h" - #include "usb_conf.h" - #include "usbd_conf.h" -#endif - +#include "board_common.h" #include "hal.h" -#if defined(__cplusplus) && !defined(SIMU) -} -#endif #if defined(ROTARY_ENCODER_NAVIGATION) // Rotary Encoder driver @@ -131,18 +61,6 @@ void boardOff(void); void init2MhzTimer(); void init5msTimer(); -// Delays driver -#ifdef __cplusplus -extern "C" { -#endif -void delaysInit(void); -void delay_01us(uint16_t nb); -void delay_us(uint16_t nb); -void delay_ms(uint32_t ms); -#ifdef __cplusplus -} -#endif - // SD driver #define BLOCK_SIZE 512 /* Block Size in Bytes */ #if !defined(SIMU) || defined(SIMU_DISKIO) @@ -535,8 +453,10 @@ enum Analogs { SLIDER2, #endif TX_VOLTAGE, - NUM_ANALOGS, - TX_RTC = NUM_ANALOGS + TX_TEMPERATURE, + TX_INTREF, + TX_RTC_VOLTAGE, + NUM_ANALOGS }; #define NUM_POTS (POT_LAST-POT_FIRST+1) @@ -551,7 +471,7 @@ enum Analogs { #if defined(STICKS_PWM) #define NUM_PWMSTICKS 4 #define STICKS_PWM_ENABLED() (!hardwareOptions.sticksPwmDisabled) - void sticksPwmInit(void); + void sticksPwmInit(); void sticksPwmRead(uint16_t * values); extern volatile uint32_t pwm_interrupt_count; // TODO => reusable buffer (boot section) #define NUM_TRIMS_KEYS 4 @@ -606,14 +526,9 @@ enum CalibratedAnalogs { #define IS_SLIDER(x) ((x)>POT_LAST && (x)HIFCR = (DMA_HIFCR_CTCIF4 | DMA_HIFCR_CHTIF4 | DMA_HIFCR_CTEIF4 | DMA_HIFCR_CDMEIF4 | DMA_HIFCR_CFEIF4) #define ADC_TRANSFER_COMPLETE() (ADC_DMA->HISR & DMA_HISR_TCIF4) #define ADC_SAMPTIME 2 // sample time = 28 cycles -#define ADC_CHANNEL_RTC ADC_Channel_18 // ADC1_IN18 #if defined(PCBX9E) #define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOB | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_GPIOF | RCC_AHB1Periph_DMA2) #define ADC_RCC_APB1Periph 0 @@ -710,14 +709,14 @@ #define ADC_CHANNEL_STICK_RH ADC_Channel_1 // ADC1_IN1 #define ADC_CHANNEL_STICK_LV ADC_Channel_2 // ADC1_IN2 #define ADC_CHANNEL_STICK_LH ADC_Channel_3 // ADC1_IN3 - #define ADC_GPIO_PIN_POT1 GPIO_Pin_6 // PA.06 - #define ADC_GPIO_PIN_POT2 GPIO_Pin_0 // PB.00 + #define ADC_GPIO_PIN_POT2 GPIO_Pin_6 // PA.06 + #define ADC_GPIO_PIN_POT1 GPIO_Pin_0 // PB.00 #define ADC_GPIO_PIN_BATT GPIO_Pin_0 // PC.00 - #define ADC_GPIOA_PINS (ADC_GPIO_PIN_STICK_RV | ADC_GPIO_PIN_STICK_RH | ADC_GPIO_PIN_STICK_LH | ADC_GPIO_PIN_STICK_LV | ADC_GPIO_PIN_POT1) - #define ADC_GPIOB_PINS ADC_GPIO_PIN_POT2 + #define ADC_GPIOA_PINS (ADC_GPIO_PIN_STICK_RV | ADC_GPIO_PIN_STICK_RH | ADC_GPIO_PIN_STICK_LH | ADC_GPIO_PIN_STICK_LV | ADC_GPIO_PIN_POT2) + #define ADC_GPIOB_PINS ADC_GPIO_PIN_POT1 #define ADC_GPIOC_PINS ADC_GPIO_PIN_BATT - #define ADC_CHANNEL_POT1 ADC_Channel_6 - #define ADC_CHANNEL_POT2 ADC_Channel_8 + #define ADC_CHANNEL_POT2 ADC_Channel_6 + #define ADC_CHANNEL_POT1 ADC_Channel_8 #define ADC_CHANNEL_BATT ADC_Channel_10 #elif defined(PCBX9LITE) #define ADC_RCC_AHB1Periph (RCC_AHB1Periph_GPIOA | RCC_AHB1Periph_GPIOC | RCC_AHB1Periph_DMA2) diff --git a/radio/src/tests/gtests.cpp b/radio/src/tests/gtests.cpp index 98493ade7..d7b5a0a7c 100644 --- a/radio/src/tests/gtests.cpp +++ b/radio/src/tests/gtests.cpp @@ -148,7 +148,10 @@ int main(int argc, char **argv) { QCoreApplication app(argc, argv); simuInit(); - StartEepromThread(NULL); + StartEepromThread(nullptr); +#if defined(EEPROM_SIZE) + eeprom = (uint8_t *)malloc(EEPROM_SIZE); +#endif menuLevel = 0; menuHandlers[0] = menuMainView; InitGoogleTest(&argc, argv); diff --git a/radio/src/translations.cpp b/radio/src/translations.cpp index 6a6a34901..aed4f47d2 100644 --- a/radio/src/translations.cpp +++ b/radio/src/translations.cpp @@ -362,6 +362,8 @@ const char STR_ALARMSWARN[] = TR_ALARMSWARN; const char STR_SWITCHWARN[] = TR_SWITCHWARN; const char STR_FAILSAFEWARN[] = TR_FAILSAFEWARN; const char STR_WRONG_SDCARDVERSION[] = TR_WRONG_SDCARDVERSION; +const char STR_WARN_RTC_BATTERY_LOW[] = TR_WARN_RTC_BATTERY_LOW; +const char STR_BATTERY[] = TR_BATTERY; const char STR_WRONG_PCBREV[] = TR_WRONG_PCBREV; const char STR_EMERGENCY_MODE[] = TR_EMERGENCY_MODE; const char STR_NO_FAILSAFE[] = TR_NO_FAILSAFE; diff --git a/radio/src/translations.h b/radio/src/translations.h index c91be1df9..a880fd8cf 100644 --- a/radio/src/translations.h +++ b/radio/src/translations.h @@ -540,6 +540,8 @@ extern const char STR_FAILSAFEWARN[]; extern const char STR_NIGHTLY_WARNING[]; extern const char STR_NIGHTLY_NOTSAFE[]; extern const char STR_WRONG_SDCARDVERSION[]; +extern const char STR_WARN_RTC_BATTERY_LOW[]; +extern const char STR_BATTERY[]; extern const char STR_WRONG_PCBREV[]; extern const char STR_EMERGENCY_MODE[]; extern const char STR_NO_FAILSAFE[]; diff --git a/radio/src/translations/cz.h.txt b/radio/src/translations/cz.h.txt index 38d3206e7..cb88b02d7 100644 --- a/radio/src/translations/cz.h.txt +++ b/radio/src/translations/cz.h.txt @@ -639,7 +639,7 @@ #define TR_TMR1JITTERUS "Tmr1 Jitter\037\124us" #define TR_TMIXMAXMS "Tmix max" #define TR_FREE_STACK "Free stack" -#define TR_MENUTORESET CENTER TR_ENTER" >> Reset" +#define TR_MENUTORESET TR_ENTER" >> Reset" #define TR_PPM_TRAINER "TR" #define TR_CH "CH" #define TR_MODEL "MODEL" @@ -802,6 +802,8 @@ #define TR_NIGHTLY_WARNING TR("NOČNÍ", "NOČNÍ SESTAVENÍ") #define TR_NIGHTLY_NOTSAFE "Verze není bezpečná k létání" #define TR_WRONG_SDCARDVERSION "Očekávaná ver.: " +#define TR_WARN_RTC_BATTERY_LOW "RTC Battery low" +#define TR_BATTERY "BATTERY" #define TR_WRONG_PCBREV "Jiná verze PCB/firmware" #define TR_EMERGENCY_MODE "NOUZOVÝ REŽIM" #define TR_PCBREV_ERROR "Chyba PCB" diff --git a/radio/src/translations/de.h.txt b/radio/src/translations/de.h.txt index 22dcaae24..08fd3f864 100644 --- a/radio/src/translations/de.h.txt +++ b/radio/src/translations/de.h.txt @@ -648,7 +648,7 @@ #define TR_TMR1JITTERUS "Tmr1 Jitter\037\124us" #define TR_TMIXMAXMS "Tmix max" #define TR_FREE_STACK "Freier Stack" -#define TR_MENUTORESET CENTER TR_ENTER " für Reset" +#define TR_MENUTORESET TR_ENTER " für Reset" #define TR_PPM_TRAINER "TR" #define TR_CH "CH" #define TR_MODEL "MODELL" @@ -809,6 +809,8 @@ #define TR_NIGHTLY_WARNING TR("NIGHTLY", "NIGHTLY BUILD") #define TR_NIGHTLY_NOTSAFE "Nicht für Flug geeignet" #define TR_WRONG_SDCARDVERSION TR("Erw. Version: ","Erwartete Version: ") +#define TR_WARN_RTC_BATTERY_LOW "RTC Battery low" +#define TR_BATTERY "BATTERY" #define TR_WRONG_PCBREV "Falsches PCB erkannt" #define TR_EMERGENCY_MODE "NOTFALL MODUS" #define TR_PCBREV_ERROR "PCB Problem" diff --git a/radio/src/translations/en.h.txt b/radio/src/translations/en.h.txt index 522df75a9..a8c5dd772 100644 --- a/radio/src/translations/en.h.txt +++ b/radio/src/translations/en.h.txt @@ -643,7 +643,7 @@ #define TR_TMR1JITTERUS "Tmr1 Jitter\037\124us" #define TR_TMIXMAXMS "Tmix max" #define TR_FREE_STACK "Free stack" -#define TR_MENUTORESET CENTER TR_ENTER " to reset" +#define TR_MENUTORESET TR_ENTER " to reset" #define TR_PPM_TRAINER "TR" #define TR_CH "CH" #define TR_MODEL "MODEL" @@ -804,6 +804,8 @@ #define TR_NIGHTLY_WARNING TR("NIGHTLY", "NIGHTLY BUILD") #define TR_NIGHTLY_NOTSAFE "Version not safe to fly" #define TR_WRONG_SDCARDVERSION TR("Expected ver: ","Expected version: ") +#define TR_WARN_RTC_BATTERY_LOW "RTC Battery low" +#define TR_BATTERY "BATTERY" #define TR_WRONG_PCBREV "Wrong PCB detected" #define TR_EMERGENCY_MODE "EMERGENCY MODE" #define TR_PCBREV_ERROR "PCB error" diff --git a/radio/src/translations/es.h.txt b/radio/src/translations/es.h.txt index b4ea0f867..71cf36068 100644 --- a/radio/src/translations/es.h.txt +++ b/radio/src/translations/es.h.txt @@ -653,7 +653,7 @@ #define TR_TMR1JITTERUS "Tmr1 Jitter\037\124us" #define TR_TMIXMAXMS "Tmix max" #define TR_FREE_STACK "Free stack" -#define TR_MENUTORESET CENTER TR_ENTER "Resetear" +#define TR_MENUTORESET TR_ENTER "Resetear" #define TR_PPM_TRAINER "TR" #define TR_CH "CH" #define TR_MODEL "MODELO" @@ -824,6 +824,8 @@ #define TR_NIGHTLY_WARNING TR("NIGHTLY", "NIGHTLY BUILD") #define TR_NIGHTLY_NOTSAFE "Version not safe to fly" #define TR_WRONG_SDCARDVERSION TR("Expected ver: ","Expected version: ") +#define TR_WARN_RTC_BATTERY_LOW "RTC Battery low" +#define TR_BATTERY "BATTERY" #define TR_WRONG_PCBREV "Wrong PCB detected" #define TR_EMERGENCY_MODE "EMERGENCY MODE" #define TR_PCBREV_ERROR "PCB error" diff --git a/radio/src/translations/fi.h.txt b/radio/src/translations/fi.h.txt index fa03cff4b..97a804ef8 100644 --- a/radio/src/translations/fi.h.txt +++ b/radio/src/translations/fi.h.txt @@ -647,7 +647,7 @@ #define TR_TMIXMAXMS "Tmix max" #define TR_FREE_STACK "Free stack" -#define TR_MENUTORESET CENTER TR_ENTER " to reset" +#define TR_MENUTORESET TR_ENTER " to reset" #define TR_PPM_TRAINER "TR" #define TR_CH "CH" #define TR_MODEL "MODEL" @@ -817,6 +817,8 @@ #define TR_NIGHTLY_WARNING TR("NIGHTLY", "NIGHTLY BUILD") #define TR_NIGHTLY_NOTSAFE "Version not safe to fly" #define TR_WRONG_SDCARDVERSION TR("Expected ver: ","Expected version: ") +#define TR_WARN_RTC_BATTERY_LOW "RTC Battery low" +#define TR_BATTERY "BATTERY" #define TR_WRONG_PCBREV "Wrong PCB detected" #define TR_EMERGENCY_MODE "EMERGENCY MODE" #define TR_PCBREV_ERROR "PCB error" diff --git a/radio/src/translations/fr.h.txt b/radio/src/translations/fr.h.txt index fd5ca33e8..0252bd4a9 100644 --- a/radio/src/translations/fr.h.txt +++ b/radio/src/translations/fr.h.txt @@ -658,7 +658,7 @@ #define TR_TMIXMAXMS "Tmix max" #define TR_FREE_STACK "Free stack" -#define TR_MENUTORESET CENTER TR_ENTER" pour reset" +#define TR_MENUTORESET TR_ENTER" pour reset" #define TR_PPM_TRAINER "TR" #define TR_CH "CH" #define TR_MODEL "MODELE" @@ -820,6 +820,8 @@ #define TR_NIGHTLY_WARNING TR("NIGHTLY", "NIGHTLY BUILD") #define TR_NIGHTLY_NOTSAFE "Version de test uniq." #define TR_WRONG_SDCARDVERSION "Version requise: " +#define TR_WARN_RTC_BATTERY_LOW "RTC Battery low" +#define TR_BATTERY "BATTERY" #define TR_WRONG_PCBREV "PCB incorrect détecté" #define TR_EMERGENCY_MODE "MODE SECOURS" #define TR_PCBREV_ERROR "Erreur PCB" diff --git a/radio/src/translations/it.h.txt b/radio/src/translations/it.h.txt index d6b21ae07..99830e6db 100644 --- a/radio/src/translations/it.h.txt +++ b/radio/src/translations/it.h.txt @@ -656,7 +656,7 @@ #define TR_TMR1JITTERUS "Tmr1 Jitter\037\124us" #define TR_TMIXMAXMS "Tmix max" #define TR_FREE_STACK "Free stack" -#define TR_MENUTORESET CENTER TR_ENTER" x Azzerare" +#define TR_MENUTORESET TR_ENTER" x Azzerare" #define TR_PPM_TRAINER "TR" #define TR_CH "CH" #define TR_MODEL "MODELLO" @@ -818,6 +818,8 @@ #define TR_NIGHTLY_WARNING TR("NIGHTLY", "NIGHTLY BUILD") #define TR_NIGHTLY_NOTSAFE "Version not safe to fly" #define TR_WRONG_SDCARDVERSION TR("Expected ver: ","Expected version: ") +#define TR_WARN_RTC_BATTERY_LOW "RTC Battery low" +#define TR_BATTERY "BATTERY" #define TR_WRONG_PCBREV "Wrong PCB detected" #define TR_EMERGENCY_MODE "EMERGENCY MODE" #define TR_PCBREV_ERROR "PCB error" diff --git a/radio/src/translations/nl.h.txt b/radio/src/translations/nl.h.txt index aea5b781a..698eecdc9 100644 --- a/radio/src/translations/nl.h.txt +++ b/radio/src/translations/nl.h.txt @@ -642,7 +642,7 @@ TR_GYR_VSRCRAW #define TR_TMR1JITTERUS "Tmr1 Jitter\037\124us" #define TR_TMIXMAXMS "Tmix max" #define TR_FREE_STACK "Free stack" -#define TR_MENUTORESET CENTER TR_ENTER" voor Reset" +#define TR_MENUTORESET TR_ENTER" voor Reset" #define TR_PPM_TRAINER "TR" #define TR_CH "CH" #define TR_MODEL "MODEL" @@ -807,6 +807,8 @@ TR_GYR_VSRCRAW #define TR_NIGHTLY_WARNING TR("NIGHTLY", "NIGHTLY BUILD") #define TR_NIGHTLY_NOTSAFE "Version not safe to fly" #define TR_WRONG_SDCARDVERSION TR("Verwachte ver: ","Verwachte versie: ") +#define TR_WARN_RTC_BATTERY_LOW "RTC Battery low" +#define TR_BATTERY "BATTERY" #define TR_WRONG_PCBREV "Verkeerde PCB gedetecteerd" #define TR_EMERGENCY_MODE "EMERGENCY MODE" #define TR_PCBREV_ERROR "PCB fout" diff --git a/radio/src/translations/pl.h.txt b/radio/src/translations/pl.h.txt index 5eabd8fbd..9f577a0b5 100644 --- a/radio/src/translations/pl.h.txt +++ b/radio/src/translations/pl.h.txt @@ -656,7 +656,7 @@ #define TR_TMR1JITTERUS "Tmr1 Jitter\037\124us" #define TR_TMIXMAXMS "TmixMaks" #define TR_FREE_STACK "Wolny stos" -#define TR_MENUTORESET CENTER TR_ENTER " >> Reset" +#define TR_MENUTORESET TR_ENTER " >> Reset" #define TR_PPM_TRAINER "TR" #define TR_CH "KN" #define TR_MODEL "MODEL" @@ -818,6 +818,8 @@ #define TR_NIGHTLY_WARNING TR("NIGHTLY", "NIGHTLY BUILD") #define TR_NIGHTLY_NOTSAFE "Version not safe to fly" #define TR_WRONG_SDCARDVERSION TR("Expected ver: ","Expected version: ") +#define TR_WARN_RTC_BATTERY_LOW "RTC Battery low" +#define TR_BATTERY "BATTERY" #define TR_WRONG_PCBREV "Wrong PCB detected" #define TR_EMERGENCY_MODE "EMERGENCY MODE" #define TR_PCBREV_ERROR "PCB error" diff --git a/radio/src/translations/pt.h.txt b/radio/src/translations/pt.h.txt index 34db69a29..b1797e636 100644 --- a/radio/src/translations/pt.h.txt +++ b/radio/src/translations/pt.h.txt @@ -638,7 +638,7 @@ #define TR_TMR1JITTERUS "Tmr1 Jitter\037\124us" #define TR_TMIXMAXMS "Tmix max" #define TR_FREE_STACK "Free stack" -#define TR_MENUTORESET CENTER TR_ENTER" Reinicia" +#define TR_MENUTORESET TR_ENTER" Reinicia" #define TR_PPM_TRAINER "TR" #define TR_CH "CH" #define TR_MODEL "MODEL" @@ -808,6 +808,8 @@ #define TR_NIGHTLY_WARNING TR("NIGHTLY", "NIGHTLY BUILD") #define TR_NIGHTLY_NOTSAFE "Version not safe to fly" #define TR_WRONG_SDCARDVERSION TR("Expected ver: ","Expected version: ") +#define TR_WARN_RTC_BATTERY_LOW "RTC Battery low" +#define TR_BATTERY "BATTERY" #define TR_WRONG_PCBREV "Wrong PCB detected" #define TR_EMERGENCY_MODE "EMERGENCY MODE" #define TR_PCBREV_ERROR "PCB error" diff --git a/radio/src/translations/se.h.txt b/radio/src/translations/se.h.txt index 7c3bd6351..6c263817f 100644 --- a/radio/src/translations/se.h.txt +++ b/radio/src/translations/se.h.txt @@ -655,7 +655,7 @@ #define TR_TMR1JITTERUS "Tmr1 Jitter\037\124us" #define TR_TMIXMAXMS "Tmix max" #define TR_FREE_STACK "Free stack" -#define TR_MENUTORESET CENTER TR_ENTER " Nollar" +#define TR_MENUTORESET TR_ENTER " Nollar" #define TR_PPM_TRAINER "TR" #define TR_CH "KN" #define TR_MODEL "Modell" @@ -818,6 +818,8 @@ #define TR_NIGHTLY_NOTSAFE "Version not safe to fly" #define TR_SDCARDVERSIONWARN "SD Card Check" #define TR_WRONG_SDCARDVERSION TR("Expected ver: ","Expected version: ") +#define TR_WARN_RTC_BATTERY_LOW "RTC Battery low" +#define TR_BATTERY "BATTERY" #define TR_WRONG_PCBREV "Wrong PCB detected" #define TR_EMERGENCY_MODE "EMERGENCY MODE" #define TR_PCBREV_ERROR "PCB error"