* WiP: new module interface * WiP: softserial timer DMA * WiP: setup() and send() in one step and remove methods specific to internal or external module * fixes and extra port config * horus targets * module ports have moved * T8 support (only internal module) * fix nv14 * stupid GCC.... * disable BT * remove nv14 telem driver * remove old aux serial driver * Move module buffers out of pulses.h * Soft serial fixes and PXX1 support * Fixed PPM module output * Fixed CLI * compilation fixes * Ported bluetooth and flysky gimbal to new serial driver * Re-enable soft-serial RX * fixes and cleanup * nv14 fixes * Fix flysky gimbals * Ghost module * 16 bytes of RAM * Remove getByte from module API * Ghost cleanup * fix: _half_duplex_input() must be called after usart init * WiP * more cleanup * Remove board specific settings from PXX1 / PXX2 drivers * A bit of PXX2 header cleanup * Add support for OVER8 and ONEBIT * Add some support for inverters (NV14 / EL18) * Support NV14 power fixes in generic board * Fix polarity handling * Fix RX DMA * Fix mixer not running * Add soft-serial polarity control * Quick fix for telemetry polling while module port is changed * Fix bootloader DEBUG * Fix MPM telemetry * Fix pulse start * DSM2 soft-serial fallback * DSMP async module restart * Fix CRSF LUA upstream * Remove global variable telemetryProtocol * Use HAL/LL constants * Fix various issue with AFHDS3 and NV14/EL18 internal module * Fixed S.PORT unit tests * fix: update widx after writing at current index * fix: init error condition * Fix: possible infinite loop in _find_port() * Add support for bidir S.PORT init * Add support for "getLastByte" in HW serial driver * PXX1: Add support for S.PORT based on IDLE callback * Fix rebase error * Fix softserial _rx_fifo_push() * Add softserial support for waitForTxCompleted() * Fix MPM flashing (internal / external) * Fixed external MPM * Activate RX DMA on internal module Seems to work with serial passthrough without issues, at least on the L3R PRO. * Fix softserial DMA on stdlcd F4 targets * Add softserial support for 32bit timers (mostly TIM2) * More precise soft-serial * Fix MPM update using inverters & HW uart * Raise S.PORT DMA/USART IRQ prio to achieve faster switching to input * Remove useless delays * Fix flashing external ELRS module * Added a retry mechanism for FrSky S.PORT update * Remove useless enableRx() * External FrSky modules are all flashed via S.PORT * Remove power management unit update This was only used on the first batch of X-lite.
185 lines
5.6 KiB
C++
185 lines
5.6 KiB
C++
/*
|
|
* Copyright (C) EdgeTX
|
|
*
|
|
* Based on code named
|
|
* opentx - https://github.com/opentx/opentx
|
|
* 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.
|
|
*/
|
|
|
|
#include "opentx.h"
|
|
#include "stamp.h"
|
|
#include <stdarg.h>
|
|
|
|
#if defined(SIMU)
|
|
traceCallbackFunc traceCallback = 0;
|
|
#endif
|
|
|
|
#if defined(SIMU)
|
|
#define PRINTF_BUFFER_SIZE 1024
|
|
void debugPrintf(const char * format, ...)
|
|
{
|
|
va_list arglist;
|
|
char tmp[PRINTF_BUFFER_SIZE];
|
|
|
|
va_start(arglist, format);
|
|
vsnprintf(tmp, PRINTF_BUFFER_SIZE, format, arglist);
|
|
va_end(arglist);
|
|
fputs(tmp, stdout);
|
|
fflush(stdout);
|
|
if (traceCallback) {
|
|
traceCallback(tmp);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#if defined(DEBUG_INTERRUPTS)
|
|
|
|
#if defined(PCBHORUS)
|
|
const char * const interruptNames[INT_LAST] = {
|
|
"Tick ", // INT_TICK,
|
|
"1ms ", // INT_1MS,
|
|
"Ser2 ", // INT_SER2,
|
|
"TelDm", // INT_TELEM_DMA,
|
|
"TelUs", // INT_TELEM_USART,
|
|
"Sdio ", // INT_SDIO,
|
|
"SdDma", // INT_SDIO_DMA,
|
|
"D2S7 ", // INT_DMA2S7,
|
|
"Tim1 ", // INT_TIM1CC,
|
|
"Tim2 ", // INT_TIM2,
|
|
"Tim3 ", // INT_TIM3,
|
|
"BlueT", // INT_BLUETOOTH,
|
|
"USB ", // INT_OTG_FS,
|
|
#if defined(DEBUG_USB_INTERRUPTS)
|
|
" spur", // INT_OTG_FS_SPURIOUS,
|
|
" out", // INT_OTG_FS_OUT_EP,
|
|
" in", // INT_OTG_FS_IN_EP,
|
|
" miss", // INT_OTG_FS_MODEMISMATCH,
|
|
" wake", // INT_OTG_FS_WAKEUP,
|
|
" susp", // INT_OTG_FS_SUSPEND,
|
|
" sof", // INT_OTG_FS_SOF,
|
|
" rxst", // INT_OTG_FS_RX_STAT,
|
|
" rst", // INT_OTG_FS_RESET,
|
|
" enum", // INT_OTG_FS_ENUM,
|
|
" inci", // INT_OTG_FS_INCOMPLETE_IN,
|
|
" inco", // INT_OTG_FS_INCOMPLETE_OUT,
|
|
" sess", // INT_OTG_FS_SESSION,
|
|
" otg", // INT_OTG_FS_OTG,
|
|
" notd", // INT_OTG_FS_RX_NOT_DEVICE,
|
|
#endif // #if defined(DEBUG_USB_INTERRUPTS)
|
|
};
|
|
#elif defined(PCBTARANIS)
|
|
const char * const interruptNames[INT_LAST] = {
|
|
"Tick ", // INT_TICK,
|
|
"5ms ", // INT_5MS,
|
|
"Audio", // INT_AUDIO,
|
|
"BlueT", // INT_BLUETOOTH,
|
|
"Lcd ", // INT_LCD,
|
|
"T1CC ", // INT_TIM1CC,
|
|
"Tim1 ", // INT_TIM1,
|
|
"Tim8 ", // INT_TIM8,
|
|
"Ser2 ", // INT_SER2,
|
|
"TelDm", // INT_TELEM_DMA,
|
|
"TelUs", // INT_TELEM_USART,
|
|
"Train", // INT_TRAINER,
|
|
"Usb ", // INT_OTG_FS,
|
|
#if defined(DEBUG_USB_INTERRUPTS)
|
|
" spur", // INT_OTG_FS_SPURIOUS,
|
|
" out", // INT_OTG_FS_OUT_EP,
|
|
" in", // INT_OTG_FS_IN_EP,
|
|
" miss", // INT_OTG_FS_MODEMISMATCH,
|
|
" wake", // INT_OTG_FS_WAKEUP,
|
|
" susp", // INT_OTG_FS_SUSPEND,
|
|
" sof", // INT_OTG_FS_SOF,
|
|
" rxst", // INT_OTG_FS_RX_STAT,
|
|
" rst", // INT_OTG_FS_RESET,
|
|
" enum", // INT_OTG_FS_ENUM,
|
|
" inci", // INT_OTG_FS_INCOMPLETE_IN,
|
|
" inco", // INT_OTG_FS_INCOMPLETE_OUT,
|
|
" sess", // INT_OTG_FS_SESSION,
|
|
" otg", // INT_OTG_FS_OTG,
|
|
" notd", // INT_OTG_FS_RX_NOT_DEVICE,
|
|
#endif // #if defined(DEBUG_USB_INTERRUPTS)
|
|
};
|
|
#endif
|
|
|
|
struct InterruptCounters interruptCounters;
|
|
#endif //#if defined(DEBUG_INTERRUPTS)
|
|
|
|
#if defined(DEBUG_TIMERS)
|
|
|
|
void DebugTimer::start()
|
|
{
|
|
_start_hiprec = getTmr2MHz();
|
|
_start_loprec = get_tmr10ms();
|
|
}
|
|
|
|
void DebugTimer::stop()
|
|
{
|
|
// getTmr2MHz is 16 bit timer, resolution 0.5us, max measurable value 32.7675 milli seconds
|
|
// tmr10ms_t tmr10ms = get_tmr10ms(); 32 bit timer, resolution 10ms, max measurable value: 42949672.95 s = 1.3 years
|
|
// if time difference is bigger than 30ms, then use low resolution timer
|
|
// otherwise use high resolution
|
|
if ((_start_hiprec == 0) && (_start_loprec == 0)) return;
|
|
|
|
last = get_tmr10ms() - _start_loprec; //use low precision timer
|
|
if (last < 3) {
|
|
//use high precision
|
|
last = (uint16_t)(getTmr2MHz() - _start_hiprec) / 2;
|
|
}
|
|
else {
|
|
last *= 10000ul; //adjust unit to 1us
|
|
}
|
|
evalStats();
|
|
}
|
|
|
|
DebugTimer debugTimers[DEBUG_TIMERS_COUNT];
|
|
|
|
const char * const debugTimerNames[DEBUG_TIMERS_COUNT] = {
|
|
"Pulses int." // debugTimerIntPulses
|
|
,"Pulses dur." // debugTimerIntPulsesDuration
|
|
,"10ms dur. " // debugTimerPer10ms
|
|
,"10ms period" // debugTimerPer10msPeriod
|
|
,"Rotary enc." // debugTimerRotEnc
|
|
,"Haptic " // debugTimerHaptic
|
|
,"Mixer calc " // debugTimerMixer
|
|
,"Tel. wakeup" // debugTimerTelemetryWakeup
|
|
,"perMain dur" // debugTimerPerMain
|
|
," perMain s1" // debugTimerPerMain1
|
|
," guiMain " // debugTimerGuiMain
|
|
," LUA " // debugTimerLua
|
|
," LCD wait " // debugTimerLcdRefreshWait
|
|
," LCD refr." // debugTimerLcdRefresh
|
|
," Menus " // debugTimerMenus
|
|
," Menu hnd" // debugTimerMenuHandlers
|
|
,"Menu Vers. " // debugTimerVersion
|
|
,"Menu simple" // debugTimerSimpleMenu
|
|
,"Menu drawte" // debugTimerDrawText
|
|
,"Menu drawt1" // debugTimerDrawText1
|
|
,"Mix ADC " // debugTimerGetAdc
|
|
,"Mix getsw " // debugTimerGetSwitches
|
|
,"Mix eval " // debugTimerEvalMixes
|
|
,"Mix 10ms " // debugTimerMixes10ms
|
|
,"ADC read " // debugTimerAdcRead
|
|
,"mix-pulses " // debugTimerMixerCalcToUsage
|
|
,"mix-int. " // debugTimerMixerIterval
|
|
,"Audio int. " // debugTimerAudioIterval
|
|
,"Audio dur. " // debugTimerAudioDuration
|
|
," A. consume" // debugTimerAudioConsume
|
|
,"SpaceMouse " // debugTimerSpaceMouseWakeup
|
|
};
|
|
|
|
#endif
|