mirror of
https://github.com/opentx/opentx.git
synced 2025-07-16 12:55:12 +03:00
Bsongis/adc rtc temperature (#6537)
RTC voltage + CPU temperature + RTC voltage alarm (thanks @schwabe)
This commit is contained in:
parent
6ba4b84a45
commit
3a0960c1e3
49 changed files with 568 additions and 447 deletions
|
@ -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();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -39,7 +39,7 @@ void menuRadioTrainer(event_t event)
|
|||
y = MENU_HEADER_HEIGHT + 1 + FH;
|
||||
|
||||
for (uint8_t i=HEADER_LINE; i<HEADER_LINE+NUM_STICKS; i++) {
|
||||
uint8_t chan = channel_order(i+1-HEADER_LINE);
|
||||
uint8_t chan = channelOrder(i+1-HEADER_LINE);
|
||||
volatile TrainerMix * td = &g_eeGeneral.trainer.mix[chan-1];
|
||||
|
||||
drawSource(0, y, MIXSRC_Rud-1+chan, (menuVerticalPosition==i && CURSOR_ON_LINE()) ? INVERS : 0);
|
||||
|
|
|
@ -57,6 +57,7 @@ void menuStatisticsView(event_t event)
|
|||
storageDirty(EE_GENERAL);
|
||||
sessionTimer = 0;
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
|
@ -108,6 +109,11 @@ void menuStatisticsDebug(event_t event)
|
|||
title(STR_MENUDEBUG);
|
||||
|
||||
switch (event) {
|
||||
case EVT_ENTRY:
|
||||
case EVT_ENTRY_UP:
|
||||
enableVBatBridge();
|
||||
break;
|
||||
|
||||
case EVT_KEY_LONG(KEY_ENTER):
|
||||
#if defined(PCBSKY9X)
|
||||
g_eeGeneral.mAhUsed = 0;
|
||||
|
@ -120,14 +126,19 @@ void menuStatisticsDebug(event_t event)
|
|||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_ENTER):
|
||||
#if defined(LUA)
|
||||
maxLuaInterval = 0;
|
||||
maxLuaDuration = 0;
|
||||
#endif
|
||||
maxMixerDuration = 0;
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
#if defined(NAVIGATION_X7)
|
||||
case EVT_KEY_BREAK(KEY_PAGE):
|
||||
disableVBatBridge();
|
||||
chainMenu(menuStatisticsDebug2);
|
||||
return;
|
||||
break;
|
||||
#endif
|
||||
|
||||
case EVT_KEY_FIRST(KEY_DOWN):
|
||||
|
@ -135,10 +146,12 @@ void menuStatisticsDebug(event_t event)
|
|||
case EVT_KEY_LONG(KEY_PAGE):
|
||||
#endif
|
||||
killEvents(event);
|
||||
disableVBatBridge();
|
||||
chainMenu(menuStatisticsView);
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
disableVBatBridge();
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
}
|
||||
|
@ -169,14 +182,6 @@ void menuStatisticsDebug(event_t event)
|
|||
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);
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
#include "opentx.h"
|
||||
|
||||
enum menuRadioHwItems {
|
||||
enum {
|
||||
ITEM_RADIO_HARDWARE_LABEL_STICKS,
|
||||
ITEM_RADIO_HARDWARE_STICK1,
|
||||
ITEM_RADIO_HARDWARE_STICK2,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -42,7 +42,7 @@ void menuRadioTrainer(event_t event)
|
|||
y = MENU_HEADER_HEIGHT + 1 + FH;
|
||||
|
||||
for (int i=0; i<NUM_STICKS; i++) {
|
||||
uint8_t chan = channel_order(i+1);
|
||||
uint8_t chan = channelOrder(i+1);
|
||||
TrainerMix * td = &g_eeGeneral.trainer.mix[chan-1];
|
||||
|
||||
putsStickName(0, y, chan-1, (menuVerticalPosition==i && CURSOR_ON_LINE()) ? INVERS : 0);
|
||||
|
|
|
@ -29,8 +29,7 @@ void menuStatisticsView(event_t event)
|
|||
{
|
||||
title(STR_MENUSTAT);
|
||||
|
||||
switch(event)
|
||||
{
|
||||
switch(event) {
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
case EVT_KEY_BREAK(KEY_PAGE):
|
||||
chainMenu(menuStatisticsDebug);
|
||||
|
@ -116,14 +115,19 @@ void menuStatisticsDebug(event_t event)
|
|||
}
|
||||
#endif
|
||||
|
||||
switch(event)
|
||||
{
|
||||
switch(event) {
|
||||
case EVT_ENTRY:
|
||||
case EVT_ENTRY_UP:
|
||||
enableVBatBridge();
|
||||
break;
|
||||
|
||||
case EVT_KEY_LONG(KEY_ENTER):
|
||||
g_eeGeneral.globalTimer = 0;
|
||||
storageDirty(EE_GENERAL);
|
||||
sessionTimer = 0;
|
||||
storageDirty(EE_GENERAL);
|
||||
killEvents(event);
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_ENTER):
|
||||
#if defined(LUA)
|
||||
maxLuaInterval = 0;
|
||||
|
@ -132,20 +136,24 @@ void menuStatisticsDebug(event_t event)
|
|||
maxMixerDuration = 0;
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_DOWN):
|
||||
case EVT_KEY_LONG(KEY_PAGE):
|
||||
killEvents(event);
|
||||
chainMenu(menuStatisticsView);
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
case EVT_KEY_BREAK(KEY_PAGE):
|
||||
disableVBatBridge();
|
||||
chainMenu(menuStatisticsDebug2);
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_DOWN):
|
||||
case EVT_KEY_LONG(KEY_PAGE):
|
||||
killEvents(event);
|
||||
disableVBatBridge();
|
||||
chainMenu(menuStatisticsView);
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
disableVBatBridge();
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
|
||||
#if defined(WATCHDOG_TEST)
|
||||
case EVT_KEY_LONG(KEY_MENU):
|
||||
{
|
||||
|
@ -157,44 +165,73 @@ void menuStatisticsDebug(event_t event)
|
|||
#endif
|
||||
}
|
||||
|
||||
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW3, "Free Mem");
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW3, availableMemory(), LEFT);
|
||||
lcdDrawText(lcdLastRightPos, MENU_DEBUG_ROW3, "b");
|
||||
uint8_t y = FH + 1;
|
||||
|
||||
#if defined(STM32) && !defined(SIMU) && defined(DEBUG)
|
||||
lcdDrawTextAlignedLeft(y, "Usb");
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS, y, charsWritten, LEFT);
|
||||
lcdDrawText(lcdLastRightPos, y, " ");
|
||||
lcdDrawNumber(lcdLastRightPos, y, APP_Rx_ptr_in, LEFT);
|
||||
lcdDrawText(lcdLastRightPos, y, " ");
|
||||
lcdDrawNumber(lcdLastRightPos, y, APP_Rx_ptr_out, LEFT);
|
||||
lcdDrawText(lcdLastRightPos, y, " ");
|
||||
lcdDrawNumber(lcdLastRightPos, y, usbWraps, LEFT);
|
||||
y += FH;
|
||||
#endif
|
||||
|
||||
#if defined(STM32)
|
||||
lcdDrawTextAlignedLeft(y, "Free Mem");
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS, y, availableMemory(), LEFT);
|
||||
lcdDrawText(lcdLastRightPos, y, "b");
|
||||
y += FH;
|
||||
#endif
|
||||
|
||||
#if defined(LUA)
|
||||
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW2, "Lua scripts");
|
||||
lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW2+1, "[Duration]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW2, 10*maxLuaDuration, LEFT);
|
||||
lcdDrawText(lcdLastRightPos+2, MENU_DEBUG_ROW2+1, "[Interval]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW2, 10*maxLuaInterval, LEFT);
|
||||
lcdDrawTextAlignedLeft(y, "Lua scripts");
|
||||
lcdDrawText(MENU_DEBUG_COL1_OFS, y+1, "[Duration]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, y, 10*maxLuaDuration, LEFT);
|
||||
lcdDrawText(lcdLastRightPos+2, y+1, "[Interval]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, y, 10*maxLuaInterval, LEFT);
|
||||
y += FH;
|
||||
#endif
|
||||
|
||||
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW1, STR_TMIXMAXMS);
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW1, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT);
|
||||
lcdDrawText(lcdLastRightPos, MENU_DEBUG_ROW1, "ms");
|
||||
lcdDrawTextAlignedLeft(y, STR_TMIXMAXMS);
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS, y, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT);
|
||||
lcdDrawText(lcdLastRightPos, y, "ms");
|
||||
y += FH;
|
||||
|
||||
#if !defined(SIMU) && defined(DEBUG)
|
||||
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW4, "Usb");
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW4, charsWritten, LEFT);
|
||||
lcdDrawText(lcdLastRightPos, MENU_DEBUG_ROW4, " ");
|
||||
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW4, APP_Rx_ptr_in, LEFT);
|
||||
lcdDrawText(lcdLastRightPos, MENU_DEBUG_ROW4, " ");
|
||||
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW4, APP_Rx_ptr_out, LEFT);
|
||||
lcdDrawText(lcdLastRightPos, MENU_DEBUG_ROW4, " ");
|
||||
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW4, usbWraps, LEFT);
|
||||
lcdDrawTextAlignedLeft(y, STR_FREE_STACK);
|
||||
lcdDrawText(MENU_DEBUG_COL1_OFS, y+1, "[M]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, y, menusStack.available(), LEFT);
|
||||
lcdDrawText(lcdLastRightPos+2, y+1, "[X]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, y, mixerStack.available(), LEFT);
|
||||
lcdDrawText(lcdLastRightPos+2, y+1, "[A]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, y, audioStack.available(), LEFT);
|
||||
lcdDrawText(lcdLastRightPos+2, y+1, "[I]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, y, stackAvailable(), LEFT);
|
||||
y += FH;
|
||||
|
||||
#if defined(DEBUG_LATENCY)
|
||||
lcdDrawTextAlignedLeft(y, "Hearbeat");
|
||||
if (heartbeatCapture.valid)
|
||||
lcdDrawNumber(MENU_DEBUG_COL1_OFS, y, heartbeatCapture.count, LEFT);
|
||||
else
|
||||
lcdDrawText(MENU_DEBUG_COL1_OFS, y, "---");
|
||||
y += FH;
|
||||
#endif
|
||||
|
||||
lcdDrawTextAlignedLeft(MENU_DEBUG_ROW5, STR_FREE_STACK);
|
||||
lcdDrawText(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW5+1, "[M]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW5, menusStack.available(), LEFT);
|
||||
lcdDrawText(lcdLastRightPos+2, MENU_DEBUG_ROW5+1, "[X]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW5, mixerStack.available(), LEFT);
|
||||
lcdDrawText(lcdLastRightPos+2, MENU_DEBUG_ROW5+1, "[A]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW5, audioStack.available(), LEFT);
|
||||
lcdDrawText(lcdLastRightPos+2, MENU_DEBUG_ROW5+1, "[I]", SMLSIZE);
|
||||
lcdDrawNumber(lcdLastRightPos, MENU_DEBUG_ROW5, stackAvailable(), LEFT);
|
||||
#if defined(STM32)
|
||||
lcdDrawTextAlignedLeft(y, STR_RTC_BATT);
|
||||
putsVolts(MENU_DEBUG_COL1_OFS, y, getRTCBatteryVoltage(), PREC2|LEFT);
|
||||
y += FH;
|
||||
#endif
|
||||
|
||||
lcdDrawText(3*FW, 7*FH+1, STR_MENUTORESET);
|
||||
#if defined(STM32)
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -202,11 +239,7 @@ void menuStatisticsDebug2(event_t event)
|
|||
{
|
||||
title(STR_MENUDEBUG);
|
||||
|
||||
switch(event)
|
||||
{
|
||||
|
||||
|
||||
|
||||
switch(event) {
|
||||
case EVT_KEY_FIRST(KEY_UP):
|
||||
case EVT_KEY_BREAK(KEY_PAGE):
|
||||
#if defined(DEBUG_TRACE_BUFFER)
|
||||
|
@ -222,7 +255,6 @@ void menuStatisticsDebug2(event_t event)
|
|||
chainMenu(menuStatisticsDebug);
|
||||
break;
|
||||
|
||||
|
||||
case EVT_KEY_FIRST(KEY_EXIT):
|
||||
chainMenu(menuMainView);
|
||||
break;
|
||||
|
@ -237,7 +269,7 @@ void menuStatisticsDebug2(event_t event)
|
|||
lcdDrawNumber(MENU_DEBUG_COL1_OFS, MENU_DEBUG_ROW1, telemetryErrors, RIGHT);
|
||||
|
||||
|
||||
lcdDrawText(3*FW, 7*FH+1, STR_MENUTORESET);
|
||||
lcdDrawText(LCD_W/2, 7*FH+1, STR_MENUTORESET, CENTERED);
|
||||
lcdInvertLastLine();
|
||||
}
|
||||
|
||||
|
|
|
@ -95,7 +95,7 @@ void insertExpo(uint8_t idx)
|
|||
ExpoData * expo = expoAddress(idx);
|
||||
memmove(expo+1, expo, (MAX_EXPOS-(idx+1))*sizeof(ExpoData));
|
||||
memclear(expo, sizeof(ExpoData));
|
||||
expo->srcRaw = (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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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; i<NUM_STICKS; i++) {
|
||||
uint8_t chan = channel_order(i+1);
|
||||
uint8_t chan = channelOrder(i+1);
|
||||
TrainerMix * td = &g_eeGeneral.trainer.mix[chan-1];
|
||||
|
||||
drawSource(MENUS_MARGIN_LEFT, y, MIXSRC_Rud-1+chan, ((menuVerticalPosition==i && CURSOR_ON_LINE()) ? INVERS : 0));
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
bool menuRadioVersion(event_t event)
|
||||
{
|
||||
char id[27];
|
||||
|
||||
#if 0
|
||||
if (warningResult) {
|
||||
warningResult = 0;
|
||||
|
@ -36,12 +37,12 @@ bool menuRadioVersion(event_t event)
|
|||
|
||||
SIMPLE_MENU(STR_MENUVERSION, RADIO_ICONS, menuTabGeneral, MENU_RADIO_VERSION, 0);
|
||||
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + FH, vers_stamp);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 2*FH, date_stamp);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 3*FH, time_stamp);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 4*FH, eeprom_stamp);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 5*FH, "UID:");
|
||||
lcdDrawText(MENUS_MARGIN_LEFT + 64, MENU_CONTENT_TOP + 5*FH, id);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP, vers_stamp);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + FH, date_stamp);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 2*FH, time_stamp);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 3*FH, eeprom_stamp);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP + 4*FH, "UID:");
|
||||
lcdDrawText(MENUS_MARGIN_LEFT + 64, MENU_CONTENT_TOP + 4*FH, id);
|
||||
|
||||
#if 0
|
||||
if (event == EVT_KEY_LONG(KEY_ENTER)) {
|
||||
|
|
|
@ -95,8 +95,12 @@ bool menuStatsGraph(event_t event)
|
|||
|
||||
bool menuStatsDebug(event_t event)
|
||||
{
|
||||
switch(event)
|
||||
{
|
||||
switch(event) {
|
||||
case EVT_ENTRY:
|
||||
case EVT_ENTRY_UP:
|
||||
enableVBatBridge();
|
||||
break;
|
||||
|
||||
case EVT_KEY_FIRST(KEY_ENTER):
|
||||
maxMixerDuration = 0;
|
||||
#if defined(LUA)
|
||||
|
@ -106,51 +110,71 @@ bool menuStatsDebug(event_t event)
|
|||
break;
|
||||
}
|
||||
|
||||
SIMPLE_MENU("Debug", STATS_ICONS, menuTabStats, e_StatsDebug, 1);
|
||||
if (!check_simple(event, e_StatsDebug, menuTabStats, DIM(menuTabStats), 1)) {
|
||||
disableVBatBridge();
|
||||
return false;
|
||||
}
|
||||
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP, "Free Mem");
|
||||
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP, availableMemory(), LEFT, 0, NULL, "b");
|
||||
drawMenuTemplate("Debug", 0, STATS_ICONS, OPTION_MENU_TITLE_BAR);
|
||||
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+FH, STR_TMIXMAXMS);
|
||||
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+FH, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT, 0, NULL, "ms");
|
||||
coord_t y = MENU_CONTENT_TOP;
|
||||
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+2*FH, STR_FREE_STACK);
|
||||
lcdDrawText(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+2*FH+1, "[Menus]", HEADER_COLOR|SMLSIZE);
|
||||
lcdDrawNumber(lcdNextPos+5, MENU_CONTENT_TOP+2*FH, menusStack.available(), LEFT);
|
||||
lcdDrawText(lcdNextPos+20, MENU_CONTENT_TOP+2*FH+1, "[Mix]", HEADER_COLOR|SMLSIZE);
|
||||
lcdDrawNumber(lcdNextPos+5, MENU_CONTENT_TOP+2*FH, mixerStack.available(), LEFT);
|
||||
lcdDrawText(lcdNextPos+20, MENU_CONTENT_TOP+2*FH+1, "[Audio]", HEADER_COLOR|SMLSIZE);
|
||||
lcdDrawNumber(lcdNextPos+5, MENU_CONTENT_TOP+2*FH, audioStack.available(), LEFT);
|
||||
|
||||
int line = 3;
|
||||
|
||||
#if defined(DISK_CACHE)
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+line*FH, "SD cache hits");
|
||||
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+line*FH, diskCache.getHitRate(), PREC1|LEFT, 0, NULL, "%");
|
||||
++line;
|
||||
#endif
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, "Free Mem");
|
||||
lcdDrawNumber(MENU_STATS_COLUMN1, y, availableMemory(), LEFT, 0, NULL, "b");
|
||||
y += FH;
|
||||
|
||||
#if defined(LUA)
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+line*FH, "Lua duration");
|
||||
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+line*FH, 10*maxLuaDuration, LEFT, 0, NULL, "ms");
|
||||
++line;
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, "Lua scripts");
|
||||
lcdDrawText(MENU_STATS_COLUMN1, y+1, "[Duration]", HEADER_COLOR|SMLSIZE);
|
||||
lcdDrawNumber(lcdNextPos+5, y, 10*maxLuaDuration, LEFT, 0, NULL, "ms");
|
||||
lcdDrawText(lcdNextPos+20, y+1, "[Interval]", HEADER_COLOR|SMLSIZE);
|
||||
lcdDrawNumber(lcdNextPos+5, y, 10*maxLuaDuration, LEFT, 0, NULL, "ms");
|
||||
y += FH;
|
||||
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+line*FH, "Lua interval");
|
||||
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+line*FH, 10*maxLuaInterval, LEFT, 0, NULL, "ms");
|
||||
++line;
|
||||
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+line*FH, "Lua memory");
|
||||
lcdDrawText(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+line*FH+1, "[S]", HEADER_COLOR|SMLSIZE);
|
||||
lcdDrawNumber(lcdNextPos+5, MENU_CONTENT_TOP+line*FH, luaGetMemUsed(lsScripts), LEFT);
|
||||
lcdDrawText(lcdNextPos+20, MENU_CONTENT_TOP+line*FH+1, "[W]", HEADER_COLOR|SMLSIZE);
|
||||
lcdDrawNumber(lcdNextPos+5, MENU_CONTENT_TOP+line*FH, luaGetMemUsed(lsWidgets), LEFT);
|
||||
lcdDrawText(lcdNextPos+20, MENU_CONTENT_TOP+line*FH+1, "[B]", HEADER_COLOR|SMLSIZE);
|
||||
lcdDrawNumber(lcdNextPos+5, MENU_CONTENT_TOP+line*FH, luaExtraMemoryUsage, LEFT);
|
||||
++line;
|
||||
// lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+line*FH, "Lua memory");
|
||||
lcdDrawText(MENU_STATS_COLUMN1, y+1, "[S]", HEADER_COLOR|SMLSIZE);
|
||||
lcdDrawNumber(lcdNextPos+5, y, luaGetMemUsed(lsScripts), LEFT);
|
||||
lcdDrawText(lcdNextPos+20, y+1, "[W]", HEADER_COLOR|SMLSIZE);
|
||||
lcdDrawNumber(lcdNextPos+5, y, luaGetMemUsed(lsWidgets), LEFT);
|
||||
lcdDrawText(lcdNextPos+20, y+1, "[B]", HEADER_COLOR|SMLSIZE);
|
||||
lcdDrawNumber(lcdNextPos+5, y, luaExtraMemoryUsage, LEFT);
|
||||
y += FH;
|
||||
#endif
|
||||
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, MENU_CONTENT_TOP+line*FH, "Tlm RX Errs");
|
||||
lcdDrawNumber(MENU_STATS_COLUMN1, MENU_CONTENT_TOP+line*FH, telemetryErrors, LEFT);
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_TMIXMAXMS);
|
||||
lcdDrawNumber(MENU_STATS_COLUMN1, y, DURATION_MS_PREC2(maxMixerDuration), PREC2|LEFT, 0, NULL, "ms");
|
||||
y += FH;
|
||||
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_FREE_STACK);
|
||||
lcdDrawText(MENU_STATS_COLUMN1, y+1, "[Menus]", HEADER_COLOR|SMLSIZE);
|
||||
lcdDrawNumber(lcdNextPos+5, y, menusStack.available(), LEFT);
|
||||
lcdDrawText(lcdNextPos+20, y+1, "[Mix]", HEADER_COLOR|SMLSIZE);
|
||||
lcdDrawNumber(lcdNextPos+5, y, mixerStack.available(), LEFT);
|
||||
lcdDrawText(lcdNextPos+20, y+1, "[Audio]", HEADER_COLOR|SMLSIZE);
|
||||
lcdDrawNumber(lcdNextPos+5, y, audioStack.available(), LEFT);
|
||||
y += FH;
|
||||
|
||||
#if defined(STM32)
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, STR_RTC_BATT);
|
||||
drawValueWithUnit(MENU_STATS_COLUMN1, y, getRTCBatteryVoltage(), UNIT_VOLTS, PREC2|LEFT);
|
||||
y += FH;
|
||||
#endif
|
||||
|
||||
//#if defined(STM32)
|
||||
// lcdDrawText(MENUS_MARGIN_LEFT, y, STR_CPU_TEMP);
|
||||
// drawValueWithUnit(MENU_STATS_COLUMN1, y, getTemperature(), UNIT_TEMPERATURE, PREC1|LEFT);
|
||||
// y += FH;
|
||||
//#endif
|
||||
|
||||
#if defined(DISK_CACHE)
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, "SD cache hits");
|
||||
lcdDrawNumber(MENU_STATS_COLUMN1, y, diskCache.getHitRate(), PREC1|LEFT, 0, NULL, "%");
|
||||
y += FH;
|
||||
#endif
|
||||
|
||||
lcdDrawText(MENUS_MARGIN_LEFT, y, "Telem RX Errs");
|
||||
lcdDrawNumber(MENU_STATS_COLUMN1, y, telemetryErrors, LEFT);
|
||||
// y += FH;
|
||||
|
||||
lcdDrawText(LCD_W/2, MENU_FOOTER_TOP, STR_MENUTORESET, MENU_TITLE_COLOR | CENTERED);
|
||||
return true;
|
||||
|
|
|
@ -54,7 +54,7 @@ void insertExpo(uint8_t idx)
|
|||
ExpoData * expo = expoAddress(idx);
|
||||
memmove(expo+1, expo, (MAX_EXPOS-(idx+1))*sizeof(ExpoData));
|
||||
memclear(expo, sizeof(ExpoData));
|
||||
expo->srcRaw = (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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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; i<NUM_STICKS; ++i) {
|
||||
g_eeGeneral.trainer.mix[i].mode = 2;
|
||||
g_eeGeneral.trainer.mix[i].srcChn = channel_order(i+1) - 1;
|
||||
g_eeGeneral.trainer.mix[i].srcChn = channelOrder(i+1) - 1;
|
||||
g_eeGeneral.trainer.mix[i].studWeight = 100;
|
||||
}
|
||||
|
||||
|
@ -345,7 +345,7 @@ void defaultInputs()
|
|||
clearInputs();
|
||||
|
||||
for (int i=0; i<NUM_STICKS; i++) {
|
||||
uint8_t stick_index = channel_order(i+1);
|
||||
uint8_t stick_index = channelOrder(i+1);
|
||||
ExpoData *expo = expoAddress(i);
|
||||
expo->srcRaw = 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();
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,52 +94,63 @@ 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;
|
||||
|
@ -167,6 +182,11 @@ void adcSingleRead()
|
|||
ADC_DMA_Stream->CR |= DMA_SxCR_EN; // Enable DMA
|
||||
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
|
||||
ADC_EXT->SR &= ~(uint32_t) ( ADC_SR_EOC | ADC_SR_STRT | ADC_SR_OVR );
|
||||
|
@ -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];
|
||||
|
|
133
radio/src/targets/common/arm/stm32/board_common.h
Normal file
133
radio/src/targets/common/arm/stm32/board_common.h
Normal file
|
@ -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 <inttypes.h>
|
||||
#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
|
|
@ -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<NUM_ANALOGS-MOUSE1; x++) {
|
||||
adcValues[MOUSE1+x] = temp[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)
|
||||
|
|
|
@ -182,8 +182,6 @@ void boardInit()
|
|||
#endif
|
||||
|
||||
ledBlue();
|
||||
|
||||
vbattRTC = getRTCBattVoltage();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -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" {
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -263,8 +263,6 @@ void boardInit()
|
|||
|
||||
initHeadphoneTrainerSwitch();
|
||||
|
||||
vbattRTC = getRTCBattVoltage();
|
||||
|
||||
#if defined(GYRO)
|
||||
gyroInit();
|
||||
#endif
|
||||
|
|
|
@ -24,79 +24,9 @@
|
|||
#include <inttypes.h>
|
||||
#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)<TX_VOLTAGE)
|
||||
|
||||
void adcInit(void);
|
||||
void adcRead(void);
|
||||
extern uint16_t adcValues[NUM_ANALOGS + 1/*RTC*/];
|
||||
uint16_t getAnalogValue(uint8_t index);
|
||||
uint16_t getRTCBattVoltage();
|
||||
extern uint16_t adcValues[NUM_ANALOGS];
|
||||
|
||||
// Battery driver
|
||||
uint16_t getBatteryVoltage(); // returns current battery voltage in 10mV steps
|
||||
#if defined(PCBX9E)
|
||||
// NI-MH 9.6V
|
||||
#define BATTERY_WARN 87 // 8.7V
|
||||
|
|
|
@ -604,7 +604,6 @@
|
|||
#define ADC_SET_DMA_FLAGS() ADC_DMA->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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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[];
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue