WiP
This commit is contained in:
@@ -45,8 +45,6 @@ const etx_serial_init afhds2SerialInitParams = {
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = true,
|
||||
.rx_dma_buf = nullptr,
|
||||
.rx_dma_buf_len = 0,
|
||||
.on_receive = intmoduleFifoReceive,
|
||||
.on_error = intmoduleFifoError,
|
||||
};
|
||||
@@ -69,11 +67,9 @@ static void* afhds2Init(uint8_t module)
|
||||
|
||||
static void afhds2DeInit(void* context)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
INTERNAL_MODULE_OFF();
|
||||
intmoduleFifo.clear();
|
||||
IntmoduleSerialDriver.deinit();
|
||||
IntmoduleSerialDriver.deinit(context);
|
||||
|
||||
// mixer setup
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, 0);
|
||||
@@ -97,11 +93,9 @@ static void afhds2SetupPulses(void* context, int16_t* channels, uint8_t nChannel
|
||||
|
||||
static void afhds2SendPulses(void* context)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
uint8_t* data = (uint8_t*)intmodulePulsesData.flysky.pulses;
|
||||
uint16_t size = intmodulePulsesData.flysky.ptr - data;
|
||||
IntmoduleSerialDriver.sendBuffer(data, size);
|
||||
IntmoduleSerialDriver.sendBuffer(context, data, size);
|
||||
}
|
||||
|
||||
const etx_module_driver_t Afhds2InternalDriver = {
|
||||
|
||||
@@ -134,8 +134,6 @@ static const etx_serial_init intmoduleCrossfireInitParams = {
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = true,
|
||||
.rx_dma_buf = nullptr,
|
||||
.rx_dma_buf_len = 0,
|
||||
.on_receive = intmoduleCRSF_rx,
|
||||
.on_error = nullptr,
|
||||
};
|
||||
@@ -177,9 +175,7 @@ static void crossfireSetupPulsesInternal(void* context, int16_t* channels, uint8
|
||||
|
||||
static void crossfireSendPulsesInternal(void* context)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
IntmoduleSerialDriver.sendBuffer(intmodulePulsesData.crossfire.pulses,
|
||||
IntmoduleSerialDriver.sendBuffer(context, intmodulePulsesData.crossfire.pulses,
|
||||
intmodulePulsesData.crossfire.length);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,8 +60,6 @@ etx_serial_init multiSerialInitParams = {
|
||||
.stop_bits = ETX_StopBits_Two,
|
||||
.word_length = ETX_WordLength_9,
|
||||
.rx_enable = true,
|
||||
.rx_dma_buf = nullptr,
|
||||
.rx_dma_buf_len = 0,
|
||||
.on_receive = intmoduleFifoReceive,
|
||||
.on_error = intmoduleFifoError,
|
||||
};
|
||||
@@ -260,7 +258,7 @@ static void* multiInit(uint8_t module)
|
||||
// serial port setup
|
||||
intmodulePulsesData.multi.initFrame();
|
||||
intmoduleFifo.clear();
|
||||
IntmoduleSerialDriver.init(&multiSerialInitParams);
|
||||
void* uart_ctx = IntmoduleSerialDriver.init(&multiSerialInitParams);
|
||||
|
||||
// mixer setup
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, MULTIMODULE_PERIOD);
|
||||
@@ -276,16 +274,14 @@ static void* multiInit(uint8_t module)
|
||||
TRACE("counter = %d", moduleState[INTERNAL_MODULE].counter);
|
||||
#endif
|
||||
|
||||
return nullptr;
|
||||
return uart_ctx;
|
||||
}
|
||||
|
||||
static void multiDeInit(void* context)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
INTERNAL_MODULE_OFF();
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, 0);
|
||||
IntmoduleSerialDriver.deinit();
|
||||
IntmoduleSerialDriver.deinit(context);
|
||||
}
|
||||
|
||||
static void multiSetupPulses(void* context, int16_t* channels, uint8_t nChannels)
|
||||
@@ -301,8 +297,7 @@ static void multiSetupPulses(void* context, int16_t* channels, uint8_t nChannels
|
||||
|
||||
static void multiSendPulses(void* context)
|
||||
{
|
||||
(void)context;
|
||||
IntmoduleSerialDriver.sendBuffer(intmodulePulsesData.multi.getData(),
|
||||
IntmoduleSerialDriver.sendBuffer(context, intmodulePulsesData.multi.getData(),
|
||||
intmodulePulsesData.multi.getSize());
|
||||
}
|
||||
|
||||
|
||||
@@ -476,8 +476,8 @@ void enablePulsesExternalModule(uint8_t protocol)
|
||||
|
||||
#if defined(PXX1) && defined(HARDWARE_EXTERNAL_MODULE_SIZE_SML)
|
||||
case PROTOCOL_CHANNELS_PXX1_SERIAL:
|
||||
extmodulePxx1SerialStart();
|
||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, EXTMODULE_PXX1_SERIAL_PERIOD);
|
||||
externalModuleContext = Pxx1ExternalSerialDriver.init(EXTERNAL_MODULE);
|
||||
externalModuleDriver = &Pxx1ExternalSerialDriver;
|
||||
break;
|
||||
#endif
|
||||
|
||||
@@ -522,12 +522,8 @@ void enablePulsesExternalModule(uint8_t protocol)
|
||||
|
||||
#if defined(MULTIMODULE)
|
||||
case PROTOCOL_CHANNELS_MULTIMODULE:
|
||||
#if defined(PCBSKY9X)
|
||||
extmoduleSerialStart(MULTIMODULE_BAUDRATE, MULTIMODULE_PERIOD * 2000, true);
|
||||
#else
|
||||
extmoduleSerialStart();
|
||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, MULTIMODULE_PERIOD);
|
||||
#endif
|
||||
getMultiModuleStatus(EXTERNAL_MODULE).failsafeChecked = false;
|
||||
getMultiModuleStatus(EXTERNAL_MODULE).flags = 0;
|
||||
#if defined(MULTI_PROTOLIST)
|
||||
@@ -558,6 +554,7 @@ void enablePulsesExternalModule(uint8_t protocol)
|
||||
|
||||
#if defined(AFHDS3)
|
||||
case PROTOCOL_CHANNELS_AFHDS3:
|
||||
// convert to serial module interface
|
||||
extmodulePulsesData.afhds3.init(EXTERNAL_MODULE);
|
||||
extmoduleSerialStart();
|
||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, AFHDS3_COMMAND_TIMEOUT * 1000 /* us */);
|
||||
@@ -591,12 +588,6 @@ bool setupPulsesExternalModule(uint8_t protocol)
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#if defined(PXX1) && defined(HARDWARE_EXTERNAL_MODULE_SIZE_SML)
|
||||
case PROTOCOL_CHANNELS_PXX1_SERIAL:
|
||||
extmodulePulsesData.pxx_uart.setupFrame(EXTERNAL_MODULE);
|
||||
return true;
|
||||
#endif
|
||||
|
||||
#if defined(SBUS)
|
||||
case PROTOCOL_CHANNELS_SBUS:
|
||||
setupPulsesSbus();
|
||||
@@ -681,13 +672,6 @@ void extmoduleSendNextFrame()
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(PXX1) && defined(HARDWARE_EXTERNAL_MODULE_SIZE_SML)
|
||||
case PROTOCOL_CHANNELS_PXX1_SERIAL:
|
||||
ExtmoduleSerialDriver.sendBuffer(extmodulePulsesData.pxx_uart.getData(),
|
||||
extmodulePulsesData.pxx_uart.getSize());
|
||||
break;
|
||||
#endif
|
||||
|
||||
#if defined(AFHDS3)
|
||||
case PROTOCOL_CHANNELS_AFHDS3:
|
||||
#if defined(EXTMODULE_USART) && defined(EXTMODULE_TX_INVERT_GPIO)
|
||||
|
||||
+61
-11
@@ -231,17 +231,13 @@ static const etx_serial_init pxx1SerialInit = {
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = false,
|
||||
.rx_dma_buf = nullptr,
|
||||
.rx_dma_buf_len = 0,
|
||||
.on_receive = intmoduleFifoReceive,
|
||||
.on_error = intmoduleFifoError,
|
||||
};
|
||||
|
||||
static void* pxx1InitInternal(uint8_t module)
|
||||
{
|
||||
(void)module;
|
||||
|
||||
IntmoduleSerialDriver.init(&pxx1SerialInit);
|
||||
void* uart_ctx = IntmoduleSerialDriver.init(&pxx1SerialInit);
|
||||
|
||||
#if defined(INTMODULE_HEARTBEAT)
|
||||
init_intmodule_heartbeat();
|
||||
@@ -249,19 +245,17 @@ static void* pxx1InitInternal(uint8_t module)
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, INTMODULE_PXX1_SERIAL_PERIOD);
|
||||
INTERNAL_MODULE_ON();
|
||||
|
||||
return nullptr;
|
||||
return uart_ctx;
|
||||
}
|
||||
|
||||
static void pxx1DeInitInternal(void* context)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
INTERNAL_MODULE_OFF();
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, 0);
|
||||
#if defined(INTMODULE_HEARTBEAT)
|
||||
stop_intmodule_heartbeat();
|
||||
#endif
|
||||
IntmoduleSerialDriver.deinit();
|
||||
IntmoduleSerialDriver.deinit(context);
|
||||
}
|
||||
|
||||
static void pxx1SetupPulsesInternal(void* context, int16_t* channels, uint8_t nChannels)
|
||||
@@ -276,8 +270,7 @@ static void pxx1SetupPulsesInternal(void* context, int16_t* channels, uint8_t nC
|
||||
|
||||
static void pxx1SendPulsesInternal(void* context)
|
||||
{
|
||||
(void)context;
|
||||
IntmoduleSerialDriver.sendBuffer(intmodulePulsesData.pxx_uart.getData(),
|
||||
IntmoduleSerialDriver.sendBuffer(context, intmodulePulsesData.pxx_uart.getData(),
|
||||
intmodulePulsesData.pxx_uart.getSize());
|
||||
}
|
||||
|
||||
@@ -290,3 +283,60 @@ const etx_module_driver_t Pxx1InternalSerialDriver = {
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(EXTMODULE_USART) && defined(HARDWARE_EXTERNAL_MODULE_SIZE_SML)
|
||||
#include "extmodule_serial_driver.h"
|
||||
|
||||
static const etx_serial_init pxx1ExtSerialInit = {
|
||||
.baudrate = EXTMODULE_PXX1_SERIAL_BAUDRATE,
|
||||
.parity = ETX_Parity_None,
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = false,
|
||||
.on_receive = extmoduleFifoReceive,
|
||||
.on_error = extmoduleFifoError,
|
||||
};
|
||||
|
||||
static void* pxx1InitExternal(uint8_t module)
|
||||
{
|
||||
void* uart_ctx = ExtmoduleSerialDriver.init(&pxx1ExtSerialInit);
|
||||
|
||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, EXTMODULE_PXX1_SERIAL_PERIOD);
|
||||
EXTERNAL_MODULE_ON();
|
||||
|
||||
return uart_ctx;
|
||||
}
|
||||
|
||||
static void pxx1DeInitExternal(void* context)
|
||||
{
|
||||
EXTERNAL_MODULE_OFF();
|
||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, 0);
|
||||
ExtmoduleSerialDriver.deinit(context);
|
||||
}
|
||||
|
||||
static void pxx1SetupPulsesExternal(void* context, int16_t* channels, uint8_t nChannels)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
// TODO:
|
||||
(void)channels;
|
||||
(void)nChannels;
|
||||
|
||||
extmodulePulsesData.pxx_uart.setupFrame(EXTERNAL_MODULE);
|
||||
}
|
||||
|
||||
static void pxx1SendPulsesExternal(void* context)
|
||||
{
|
||||
ExtmoduleSerialDriver.sendBuffer(context, extmodulePulsesData.pxx_uart.getData(),
|
||||
extmodulePulsesData.pxx_uart.getSize());
|
||||
}
|
||||
|
||||
const etx_module_driver_t Pxx1ExternalSerialDriver = {
|
||||
.protocol = PROTOCOL_CHANNELS_PXX1_SERIAL,
|
||||
.init = pxx1InitExternal,
|
||||
.deinit = pxx1DeInitExternal,
|
||||
.setupPulses = pxx1SetupPulsesExternal,
|
||||
.sendPulses = pxx1SendPulsesExternal,
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -168,6 +168,12 @@ typedef Pxx1Pulses<UartPxx1Transport> UartPxx1Pulses;
|
||||
typedef Pxx1Pulses<StandardPxx1Transport<PwmPxxBitTransport>> PwmPxx1Pulses;
|
||||
typedef Pxx1Pulses<StandardPxx1Transport<SerialPxxBitTransport>> SerialPxx1Pulses;
|
||||
|
||||
#if defined(INTMODULE_USART)
|
||||
extern const etx_module_driver_t Pxx1InternalSerialDriver;
|
||||
#endif
|
||||
|
||||
#if defined(EXTMODULE_USART)
|
||||
extern const etx_module_driver_t Pxx1ExternalSerialDriver;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
@@ -36,8 +36,6 @@ const etx_serial_init pxx2SerialInitParams = {
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = true,
|
||||
.rx_dma_buf = nullptr,
|
||||
.rx_dma_buf_len = 0,
|
||||
.on_receive = intmoduleFifoReceive,
|
||||
.on_error = intmoduleFifoError,
|
||||
};
|
||||
@@ -652,7 +650,7 @@ void Pxx2OtaUpdate::flashFirmware(const char * filename, ProgressHandler progres
|
||||
static void* pxx2InitInternal(uint8_t moduleType)
|
||||
{
|
||||
intmoduleFifo.clear();
|
||||
IntmoduleSerialDriver.init(&pxx2SerialInitParams);
|
||||
void* uart_ctx = IntmoduleSerialDriver.init(&pxx2SerialInitParams);
|
||||
resetAccessAuthenticationCount();
|
||||
|
||||
#if defined(INTMODULE_HEARTBEAT)
|
||||
@@ -662,13 +660,13 @@ static void* pxx2InitInternal(uint8_t moduleType)
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, PXX2_PERIOD);
|
||||
INTERNAL_MODULE_ON();
|
||||
|
||||
return nullptr;
|
||||
return uart_ctx;
|
||||
}
|
||||
|
||||
static void pxx2DeInitInternal(void* context)
|
||||
{
|
||||
INTERNAL_MODULE_OFF();
|
||||
IntmoduleSerialDriver.deinit();
|
||||
IntmoduleSerialDriver.deinit(context);
|
||||
#if defined(INTMODULE_HEARTBEAT)
|
||||
stop_intmodule_heartbeat();
|
||||
#endif
|
||||
@@ -694,10 +692,8 @@ static void pxx2SetupPulsesInternal(void* context, int16_t* channels, uint8_t nC
|
||||
|
||||
static void pxx2SendPulsesInternal(void* context)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
if (pxx2InternalSendNextFrame) {
|
||||
IntmoduleSerialDriver.sendBuffer(intmodulePulsesData.pxx2.getData(),
|
||||
IntmoduleSerialDriver.sendBuffer(context, intmodulePulsesData.pxx2.getData(),
|
||||
intmodulePulsesData.pxx2.getSize());
|
||||
}
|
||||
}
|
||||
@@ -721,8 +717,6 @@ static const etx_serial_init pxx2ExtSerialInitParams = {
|
||||
.stop_bits = ETX_StopBits_One,
|
||||
.word_length = ETX_WordLength_8,
|
||||
.rx_enable = true,
|
||||
.rx_dma_buf = nullptr,
|
||||
.rx_dma_buf_len = 0,
|
||||
.on_receive = extmoduleFifoReceive,
|
||||
.on_error = extmoduleFifoError,
|
||||
};
|
||||
@@ -743,21 +737,19 @@ static void* pxx2InitExternal(uint8_t module)
|
||||
{
|
||||
etx_serial_init params(pxx2ExtSerialInitParams);
|
||||
params.baudrate = PXX2_HIGHSPEED_BAUDRATE;
|
||||
ExtmoduleSerialDriver.init(¶ms);
|
||||
void* uart_ctx = ExtmoduleSerialDriver.init(¶ms);
|
||||
|
||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, PXX2_NO_HEARTBEAT_PERIOD);
|
||||
EXTERNAL_MODULE_ON();
|
||||
|
||||
return nullptr;
|
||||
return uart_ctx;
|
||||
}
|
||||
|
||||
static void pxx2DeInitExternal(void* context)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
EXTERNAL_MODULE_OFF();
|
||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, 0);
|
||||
ExtmoduleSerialDriver.deinit();
|
||||
ExtmoduleSerialDriver.deinit(context);
|
||||
}
|
||||
|
||||
static void pxx2SetupPulsesExternal(void* context, int16_t* channels, uint8_t nChannels)
|
||||
@@ -768,8 +760,7 @@ static void pxx2SetupPulsesExternal(void* context, int16_t* channels, uint8_t nC
|
||||
|
||||
static void pxx2SendPulsesExternal(void* context)
|
||||
{
|
||||
(void)context;
|
||||
ExtmoduleSerialDriver.sendBuffer(extmodulePulsesData.pxx2.getData(),
|
||||
ExtmoduleSerialDriver.sendBuffer(context, extmodulePulsesData.pxx2.getData(),
|
||||
extmodulePulsesData.pxx2.getSize());
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user