chore: New module/serial API (#3055)
* 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.
This commit is contained in:
@@ -21,16 +21,84 @@
|
||||
|
||||
#include "opentx.h"
|
||||
|
||||
#if defined(PXX2)
|
||||
|
||||
#if defined(LIBOPENUI)
|
||||
#include "libopenui.h"
|
||||
#endif
|
||||
|
||||
#if defined(INTMODULE_USART)
|
||||
#include "intmodule_serial_driver.h"
|
||||
#endif
|
||||
#include "pulses/pxx2.h"
|
||||
#include "pulses/pxx2_transport.h"
|
||||
|
||||
static_assert(PXX2_FRAME_MAXLENGTH <= INTMODULE_FIFO_SIZE, "");
|
||||
|
||||
static const char * const PXX2ModulesNames[] = {
|
||||
"---",
|
||||
"XJT",
|
||||
"ISRM",
|
||||
"ISRM-PRO",
|
||||
"ISRM-S",
|
||||
"R9M",
|
||||
"R9MLite",
|
||||
"R9MLite-PRO",
|
||||
"ISRM-N",
|
||||
"ISRM-S-X9",
|
||||
"ISRM-S-X10E",
|
||||
"XJT Lite",
|
||||
"ISRM-S-X10S",
|
||||
"ISRM-X9LiteS"
|
||||
};
|
||||
|
||||
const char * getPXX2ModuleName(uint8_t modelId)
|
||||
{
|
||||
if (modelId < DIM(PXX2ModulesNames))
|
||||
return PXX2ModulesNames[modelId];
|
||||
else
|
||||
return PXX2ModulesNames[0];
|
||||
}
|
||||
|
||||
static const char * const PXX2ReceiversNames[] = {
|
||||
"---",
|
||||
"X8R",
|
||||
"RX8R",
|
||||
"RX8R-PRO",
|
||||
"RX6R",
|
||||
"RX4R",
|
||||
"G-RX8",
|
||||
"G-RX6",
|
||||
"X6R",
|
||||
"X4R",
|
||||
"X4R-SB",
|
||||
"XSR",
|
||||
"XSR-M",
|
||||
"RXSR",
|
||||
"S6R",
|
||||
"S8R",
|
||||
"XM",
|
||||
"XM+",
|
||||
"XMR",
|
||||
"R9",
|
||||
"R9-SLIM",
|
||||
"R9-SLIM+",
|
||||
"R9-MINI",
|
||||
"R9-MM",
|
||||
"R9-STAB", // R9-STAB has OTA
|
||||
"R9-MINI-OTA", // this one has OTA (different bootloader)
|
||||
"R9-MM-OTA", // this one has OTA (different bootloader)
|
||||
"R9-SLIM+-OTA", // this one has OTA (different bootloader)
|
||||
"Archer-X", // this one has OTA (internal module)
|
||||
"R9MX", // this one has OTA
|
||||
"R9SX", // this one has OTA
|
||||
};
|
||||
|
||||
const char * getPXX2ReceiverName(uint8_t modelId)
|
||||
{
|
||||
if (modelId < DIM(PXX2ReceiversNames))
|
||||
return PXX2ReceiversNames[modelId];
|
||||
else
|
||||
return PXX2ReceiversNames[0];
|
||||
}
|
||||
|
||||
static void processGetHardwareInfoFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
if (moduleState[module].mode != MODULE_MODE_GET_HARDWARE_INFO) {
|
||||
@@ -216,14 +284,8 @@ static void processResetFrame(uint8_t module, const uint8_t * frame)
|
||||
|
||||
static void processTelemetryFrame(uint8_t module, const uint8_t * frame)
|
||||
{
|
||||
for (uint8_t i = 0; i < 1 + frame[0]; i++) {
|
||||
telemetryMirrorSend(frame[i]);
|
||||
}
|
||||
|
||||
uint8_t origin = (module << 2) + (frame[3] & 0x03);
|
||||
if (origin != TELEMETRY_ENDPOINT_SPORT) {
|
||||
sportProcessTelemetryPacketWithoutCrc(origin, &frame[4]);
|
||||
}
|
||||
uint8_t origin = frame[3] & 0x03;
|
||||
sportProcessTelemetryPacketWithoutCrc(module, origin, &frame[4]);
|
||||
}
|
||||
|
||||
#if defined(INTERNAL_MODULE_PXX2) && defined(ACCESS_DENIED) && !defined(SIMU)
|
||||
@@ -254,9 +316,10 @@ static void processAuthenticationFrame(uint8_t module, const uint8_t * frame,
|
||||
|
||||
moduleState[module].mode = MODULE_MODE_AUTHENTICATION;
|
||||
|
||||
Pxx2Pulses &pxx2 = intmodulePulsesData.pxx2;
|
||||
pxx2.setupAuthenticationFrame(module, cryptoType, (const uint8_t *)messageDigest);
|
||||
drv->sendBuffer(ctx, pxx2.getData(), pxx2.getSize());
|
||||
uint8_t* module_buffer = pulsesGetModuleBuffer(module);
|
||||
Pxx2Pulses pxx2(module_buffer);
|
||||
pxx2.setupAuthenticationFrame(module, cryptoType, (const uint8_t *)messageDigest);
|
||||
drv->sendBuffer(ctx, module_buffer, pxx2.getSize());
|
||||
|
||||
// we remain in AUTHENTICATION mode to avoid a CHANNELS frame is sent at the
|
||||
// end of the mixing process
|
||||
@@ -417,3 +480,4 @@ void processPXX2Frame(uint8_t module, const uint8_t * frame,
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user