Internal and external module buffers are now private
This commit is contained in:
committed by
Raphael Coeffic
parent
ab6033e4d5
commit
f952c5f7c7
@@ -19,16 +19,15 @@
|
||||
* GNU General Public License for more details.
|
||||
*/
|
||||
|
||||
#include "opentx.h"
|
||||
#include "afhds2.h"
|
||||
#include "flysky.h"
|
||||
|
||||
#include "intmodule_serial_driver.h"
|
||||
#include "mixer_scheduler.h"
|
||||
|
||||
// solely for 'intmoduleFifo'
|
||||
// TODO: remove this non-sense
|
||||
#include "opentx.h"
|
||||
#include "pulses/pxx2.h"
|
||||
#include "pulses/pulses.h"
|
||||
#include "telemetry/telemetry.h"
|
||||
|
||||
afhds2::afhds2() {
|
||||
// TODO Auto-generated constructor stub
|
||||
@@ -53,20 +52,18 @@ static void* afhds2Init(uint8_t module)
|
||||
|
||||
// serial port setup
|
||||
resetPulsesAFHDS2();
|
||||
intmoduleFifo.clear();
|
||||
IntmoduleSerialDriver.init(&afhds2SerialInitParams);
|
||||
void* ctx = IntmoduleSerialDriver.init(&afhds2SerialInitParams);
|
||||
|
||||
// mixer setup
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, AFHDS2_PERIOD);
|
||||
INTERNAL_MODULE_ON();
|
||||
|
||||
return nullptr;
|
||||
return ctx;
|
||||
}
|
||||
|
||||
static void afhds2DeInit(void* context)
|
||||
{
|
||||
INTERNAL_MODULE_OFF();
|
||||
intmoduleFifo.clear();
|
||||
IntmoduleSerialDriver.deinit(context);
|
||||
|
||||
// mixer setup
|
||||
@@ -96,10 +93,16 @@ static void afhds2SendPulses(void* context)
|
||||
IntmoduleSerialDriver.sendBuffer(context, data, size);
|
||||
}
|
||||
|
||||
static int afhds2GetByte(void* context, uint8_t* data)
|
||||
{
|
||||
return IntmoduleSerialDriver.getByte(context, data);
|
||||
}
|
||||
|
||||
const etx_module_driver_t Afhds2InternalDriver = {
|
||||
.protocol = PROTOCOL_CHANNELS_AFHDS2A,
|
||||
.init = afhds2Init,
|
||||
.deinit = afhds2DeInit,
|
||||
.setupPulses = afhds2SetupPulses,
|
||||
.sendPulses = afhds2SendPulses,
|
||||
.sendPulses = afhds2SendPulses,
|
||||
.getByte = afhds2GetByte,
|
||||
};
|
||||
|
||||
@@ -128,12 +128,9 @@ static void* crossfireInitInternal(uint8_t module)
|
||||
// serial port setup
|
||||
etx_serial_init params(intmoduleCrossfireInitParams);
|
||||
params.baudrate = INT_CROSSFIRE_BAUDRATE;
|
||||
|
||||
intmoduleFifo.clear();
|
||||
IntmoduleSerialDriver.init(¶ms);
|
||||
INTERNAL_MODULE_ON();
|
||||
|
||||
return nullptr;
|
||||
return IntmoduleSerialDriver.init(¶ms);
|
||||
}
|
||||
|
||||
static void crossfireDeInitInternal(void* context)
|
||||
@@ -143,7 +140,6 @@ static void crossfireDeInitInternal(void* context)
|
||||
INTERNAL_MODULE_OFF();
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, 0);
|
||||
intmoduleStop();
|
||||
intmoduleFifo.clear();
|
||||
}
|
||||
|
||||
static void crossfireSetupPulsesInternal(void* context, int16_t* channels, uint8_t nChannels)
|
||||
@@ -159,12 +155,18 @@ static void crossfireSendPulsesInternal(void* context)
|
||||
intmodulePulsesData.crossfire.length);
|
||||
}
|
||||
|
||||
static int crossfireGetByteInternal(void* context, uint8_t* data)
|
||||
{
|
||||
return IntmoduleSerialDriver.getByte(context, data);
|
||||
}
|
||||
|
||||
etx_module_driver_t CrossfireInternalDriver = {
|
||||
.protocol = PROTOCOL_CHANNELS_CROSSFIRE,
|
||||
.init = crossfireInitInternal,
|
||||
.deinit = crossfireDeInitInternal,
|
||||
.setupPulses = crossfireSetupPulsesInternal,
|
||||
.sendPulses = crossfireSendPulsesInternal,
|
||||
.getByte = crossfireGetByteInternal,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ static void sendConfig(uint8_t moduleIdx);
|
||||
static void sendDSM(uint8_t moduleIdx);
|
||||
#endif
|
||||
|
||||
#if defined(INTMODULE_USART)
|
||||
#if defined(INTMODULE_USART) && defined(INTERNAL_MODULE_MULTI)
|
||||
#include "intmodule_serial_driver.h"
|
||||
|
||||
etx_serial_init multiSerialInitParams = {
|
||||
@@ -65,7 +65,7 @@ etx_serial_init multiSerialInitParams = {
|
||||
|
||||
static void sendMulti(uint8_t moduleIdx, uint8_t b)
|
||||
{
|
||||
#if defined(HARDWARE_INTERNAL_MODULE)
|
||||
#if defined(INTERNAL_MODULE_MULTI)
|
||||
if (moduleIdx == INTERNAL_MODULE) {
|
||||
intmodulePulsesData.multi.sendByte(b);
|
||||
}
|
||||
@@ -222,7 +222,6 @@ static void* multiInit(uint8_t module)
|
||||
|
||||
// serial port setup
|
||||
intmodulePulsesData.multi.initFrame();
|
||||
intmoduleFifo.clear();
|
||||
void* uart_ctx = IntmoduleSerialDriver.init(&multiSerialInitParams);
|
||||
|
||||
// mixer setup
|
||||
@@ -266,6 +265,11 @@ static void multiSendPulses(void* context)
|
||||
intmodulePulsesData.multi.getSize());
|
||||
}
|
||||
|
||||
static int multiGetByte(void* context, uint8_t* data)
|
||||
{
|
||||
return IntmoduleSerialDriver.getByte(context, data);
|
||||
}
|
||||
|
||||
#include "hal/module_driver.h"
|
||||
|
||||
const etx_module_driver_t MultiInternalDriver = {
|
||||
@@ -273,7 +277,8 @@ const etx_module_driver_t MultiInternalDriver = {
|
||||
.init = multiInit,
|
||||
.deinit = multiDeInit,
|
||||
.setupPulses = multiSetupPulses,
|
||||
.sendPulses = multiSendPulses
|
||||
.sendPulses = multiSendPulses,
|
||||
.getByte = multiGetByte,
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
@@ -356,6 +356,16 @@ uint8_t getRequiredProtocol(uint8_t module)
|
||||
static void* internalModuleContext = nullptr;
|
||||
static const etx_module_driver_t* internalModuleDriver = nullptr;
|
||||
|
||||
const etx_module_driver_t* getIntModuleDriver()
|
||||
{
|
||||
return internalModuleDriver;
|
||||
}
|
||||
|
||||
void* getIntModuleCtx()
|
||||
{
|
||||
return internalModuleContext;
|
||||
}
|
||||
|
||||
static void enablePulsesInternalModule(uint8_t protocol)
|
||||
{
|
||||
// start new protocol hardware here
|
||||
@@ -519,6 +529,16 @@ bool setupPulsesInternalModule()
|
||||
static void* externalModuleContext = nullptr;
|
||||
static const etx_module_driver_t* externalModuleDriver = nullptr;
|
||||
|
||||
const etx_module_driver_t* getExtModuleDriver()
|
||||
{
|
||||
return externalModuleDriver;
|
||||
}
|
||||
|
||||
void* getExtModuleCtx()
|
||||
{
|
||||
return externalModuleContext;
|
||||
}
|
||||
|
||||
void enablePulsesExternalModule(uint8_t protocol)
|
||||
{
|
||||
// start new protocol hardware here
|
||||
|
||||
@@ -229,11 +229,15 @@ extern TrainerPulsesData trainerPulsesData;
|
||||
bool setupPulsesInternalModule();
|
||||
void stopPulsesInternalModule();
|
||||
void intmoduleSendNextFrame();
|
||||
const etx_module_driver_t* getIntModuleDriver();
|
||||
void* getIntModuleCtx();
|
||||
#endif
|
||||
#if defined(HARDWARE_EXTERNAL_MODULE)
|
||||
bool setupPulsesExternalModule();
|
||||
void stopPulsesExternalModule();
|
||||
void extmoduleSendNextFrame();
|
||||
const etx_module_driver_t* getExtModuleDriver();
|
||||
void* getExtModuleCtx();
|
||||
#endif
|
||||
void restartModule(uint8_t idx);
|
||||
void setupPulsesDSM2();
|
||||
@@ -251,7 +255,6 @@ void intmodulePpmStart();
|
||||
void intmodulePxx1PulsesStart();
|
||||
void intmodulePxx1SerialStart();
|
||||
void extmodulePxx1PulsesStart();
|
||||
void extmodulePxx1SerialStart();
|
||||
void extmodulePpmStart();
|
||||
void intmoduleStop();
|
||||
void extmoduleStop();
|
||||
|
||||
@@ -648,7 +648,6 @@ void Pxx2OtaUpdate::flashFirmware(const char * filename, ProgressHandler progres
|
||||
|
||||
static void* pxx2InitInternal(uint8_t moduleType)
|
||||
{
|
||||
intmoduleFifo.clear();
|
||||
void* uart_ctx = IntmoduleSerialDriver.init(&pxx2SerialInitParams);
|
||||
resetAccessAuthenticationCount();
|
||||
|
||||
@@ -697,6 +696,11 @@ static void pxx2SendPulsesInternal(void* context)
|
||||
}
|
||||
}
|
||||
|
||||
static int pxx2GetByteInternal(void* context, uint8_t* data)
|
||||
{
|
||||
return IntmoduleSerialDriver.getByte(context, data);
|
||||
}
|
||||
|
||||
#include "hal/module_driver.h"
|
||||
|
||||
const etx_module_driver_t Pxx2InternalDriver = {
|
||||
@@ -705,6 +709,7 @@ const etx_module_driver_t Pxx2InternalDriver = {
|
||||
.deinit = pxx2DeInitInternal,
|
||||
.setupPulses = pxx2SetupPulsesInternal,
|
||||
.sendPulses = pxx2SendPulsesInternal,
|
||||
.getByte = pxx2GetByteInternal,
|
||||
};
|
||||
|
||||
#if defined(EXTMODULE_USART)
|
||||
|
||||
@@ -23,9 +23,8 @@
|
||||
#define _PULSES_PXX2_H_
|
||||
|
||||
#include "fifo.h"
|
||||
#include "io/frsky_pxx2.h"
|
||||
#include "popups.h"
|
||||
#include "./pxx.h"
|
||||
#include "pxx.h"
|
||||
|
||||
#include "hal/serial_driver.h"
|
||||
#include "hal/module_driver.h"
|
||||
@@ -424,9 +423,6 @@ PXX2ModuleSetup& getPXX2ModuleSetupBuffer();
|
||||
BindInformation& getPXX2BindInformationBuffer();
|
||||
PXX2HardwareAndSettings& getPXX2HardwareAndSettingsBuffer();
|
||||
|
||||
extern ModuleFifo intmoduleFifo;
|
||||
extern ModuleFifo extmoduleFifo;
|
||||
|
||||
class Pxx2CrcMixin {
|
||||
protected:
|
||||
void initCrc()
|
||||
|
||||
Reference in New Issue
Block a user