Multi internal driver
This commit is contained in:
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "io/multi_protolist.h"
|
#include "io/multi_protolist.h"
|
||||||
#include "telemetry/multi.h"
|
#include "telemetry/multi.h"
|
||||||
|
#include "mixer_scheduler.h"
|
||||||
|
|
||||||
// for the MULTI protocol definition
|
// for the MULTI protocol definition
|
||||||
// see https://github.com/pascallanger/DIY-Multiprotocol-TX-Module
|
// see https://github.com/pascallanger/DIY-Multiprotocol-TX-Module
|
||||||
@@ -249,6 +250,67 @@ void setupPulsesMultiInternalModule()
|
|||||||
intmodulePulsesData.multi.initFrame();
|
intmodulePulsesData.multi.initFrame();
|
||||||
setupPulsesMulti(INTERNAL_MODULE);
|
setupPulsesMulti(INTERNAL_MODULE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void* multiInit(uint8_t module)
|
||||||
|
{
|
||||||
|
(void)module;
|
||||||
|
|
||||||
|
// serial port setup
|
||||||
|
intmodulePulsesData.multi.initFrame();
|
||||||
|
intmoduleFifo.clear();
|
||||||
|
IntmoduleSerialDriver.init(&multiSerialInitParams);
|
||||||
|
|
||||||
|
// mixer setup
|
||||||
|
mixerSchedulerSetPeriod(INTERNAL_MODULE, MULTIMODULE_PERIOD);
|
||||||
|
|
||||||
|
// reset status
|
||||||
|
getMultiModuleStatus(INTERNAL_MODULE).failsafeChecked = false;
|
||||||
|
getMultiModuleStatus(INTERNAL_MODULE).flags = 0;
|
||||||
|
|
||||||
|
#if defined(MULTI_PROTOLIST)
|
||||||
|
TRACE("enablePulsesInternalModule(): trigger scan");
|
||||||
|
MultiRfProtocols::instance(INTERNAL_MODULE)->triggerScan();
|
||||||
|
TRACE("counter = %d", moduleState[INTERNAL_MODULE].counter);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void multiDeInit(void* context)
|
||||||
|
{
|
||||||
|
(void)context;
|
||||||
|
mixerSchedulerSetPeriod(INTERNAL_MODULE, 0);
|
||||||
|
IntmoduleSerialDriver.deinit();
|
||||||
|
//TODO: power OFF ???
|
||||||
|
}
|
||||||
|
|
||||||
|
static void multiSetupPulses(void* context, int16_t* channels, uint8_t nChannels)
|
||||||
|
{
|
||||||
|
(void)context;
|
||||||
|
// TODO:
|
||||||
|
(void)channels;
|
||||||
|
(void)nChannels;
|
||||||
|
|
||||||
|
intmodulePulsesData.multi.initFrame();
|
||||||
|
setupPulsesMulti(INTERNAL_MODULE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void multiSendPulses(void* context)
|
||||||
|
{
|
||||||
|
(void)context;
|
||||||
|
IntmoduleSerialDriver.sendBuffer(intmodulePulsesData.multi.getData(),
|
||||||
|
intmodulePulsesData.multi.getSize());
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "hal/module_driver.h"
|
||||||
|
|
||||||
|
const etx_module_driver_t MultiInternalDriver = {
|
||||||
|
.protocol = PROTOCOL_CHANNELS_MULTIMODULE,
|
||||||
|
.init = multiInit,
|
||||||
|
.deinit = multiDeInit,
|
||||||
|
.setupPulses = multiSetupPulses,
|
||||||
|
.sendPulses = multiSendPulses
|
||||||
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void sendChannels(uint8_t moduleIdx)
|
void sendChannels(uint8_t moduleIdx)
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "pulses_common.h"
|
#include "pulses_common.h"
|
||||||
#include "hal/serial_driver.h"
|
#include "hal/serial_driver.h"
|
||||||
|
#include "hal/module_driver.h"
|
||||||
|
|
||||||
void multiPatchCustom(uint8_t moduleIdx);
|
void multiPatchCustom(uint8_t moduleIdx);
|
||||||
void convertEtxProtocolToMulti(int *protocol, int *subprotocol);
|
void convertEtxProtocolToMulti(int *protocol, int *subprotocol);
|
||||||
@@ -45,5 +46,6 @@ class UartMultiPulses: public DataBuffer<uint8_t, 64>
|
|||||||
};
|
};
|
||||||
|
|
||||||
extern etx_serial_init multiSerialInitParams;
|
extern etx_serial_init multiSerialInitParams;
|
||||||
|
extern const etx_module_driver_t MultiInternalDriver;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -24,7 +24,6 @@
|
|||||||
#include "heartbeat_driver.h"
|
#include "heartbeat_driver.h"
|
||||||
|
|
||||||
#include "io/frsky_pxx2.h"
|
#include "io/frsky_pxx2.h"
|
||||||
#include "io/multi_protolist.h"
|
|
||||||
#include "pulses/pxx2.h"
|
#include "pulses/pxx2.h"
|
||||||
#include "pulses/flysky.h"
|
#include "pulses/flysky.h"
|
||||||
|
|
||||||
@@ -40,6 +39,11 @@
|
|||||||
#include "pulses/crossfire.h"
|
#include "pulses/crossfire.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(MULTIMODULE)
|
||||||
|
#include "io/multi_protolist.h"
|
||||||
|
#include "pulses/multi.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
uint8_t s_pulses_paused = 0;
|
uint8_t s_pulses_paused = 0;
|
||||||
ModuleState moduleState[NUM_MODULES];
|
ModuleState moduleState[NUM_MODULES];
|
||||||
InternalModulePulsesData intmodulePulsesData __DMA;
|
InternalModulePulsesData intmodulePulsesData __DMA;
|
||||||
@@ -324,24 +328,8 @@ static void enablePulsesInternalModule(uint8_t protocol)
|
|||||||
|
|
||||||
#if defined(INTERNAL_MODULE_MULTI)
|
#if defined(INTERNAL_MODULE_MULTI)
|
||||||
case PROTOCOL_CHANNELS_MULTIMODULE:
|
case PROTOCOL_CHANNELS_MULTIMODULE:
|
||||||
// TODO: use module interface
|
internalModuleContext = MultiInternalDriver.init(INTERNAL_MODULE);
|
||||||
// serial port setup
|
internalModuleDriver = &MultiInternalDriver;
|
||||||
intmodulePulsesData.multi.initFrame();
|
|
||||||
intmoduleFifo.clear();
|
|
||||||
IntmoduleSerialDriver.init(&multiSerialInitParams);
|
|
||||||
|
|
||||||
// mixer setup
|
|
||||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, MULTIMODULE_PERIOD);
|
|
||||||
|
|
||||||
// reset status
|
|
||||||
getMultiModuleStatus(INTERNAL_MODULE).failsafeChecked = false;
|
|
||||||
getMultiModuleStatus(INTERNAL_MODULE).flags = 0;
|
|
||||||
|
|
||||||
#if defined(MULTI_PROTOLIST)
|
|
||||||
TRACE("enablePulsesInternalModule(): trigger scan");
|
|
||||||
MultiRfProtocols::instance(INTERNAL_MODULE)->triggerScan();
|
|
||||||
TRACE("counter = %d", moduleState[INTERNAL_MODULE].counter);
|
|
||||||
#endif
|
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -409,13 +397,6 @@ bool setupPulsesInternalModule(uint8_t protocol)
|
|||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(INTERNAL_MODULE_MULTI)
|
|
||||||
case PROTOCOL_CHANNELS_MULTIMODULE:
|
|
||||||
setupPulsesMultiInternalModule();
|
|
||||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, MULTIMODULE_PERIOD);
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(AFHDS2)
|
#if defined(AFHDS2)
|
||||||
case PROTOCOL_CHANNELS_AFHDS2A:
|
case PROTOCOL_CHANNELS_AFHDS2A:
|
||||||
{
|
{
|
||||||
@@ -480,13 +461,6 @@ void intmoduleSendNextFrame()
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(INTERNAL_MODULE_MULTI)
|
|
||||||
case PROTOCOL_CHANNELS_MULTIMODULE:
|
|
||||||
IntmoduleSerialDriver.sendBuffer(intmodulePulsesData.multi.getData(),
|
|
||||||
intmodulePulsesData.multi.getSize());
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(AFHDS2)
|
#if defined(AFHDS2)
|
||||||
case PROTOCOL_CHANNELS_AFHDS2A: {
|
case PROTOCOL_CHANNELS_AFHDS2A: {
|
||||||
uint8_t* data = (uint8_t*)intmodulePulsesData.flysky.pulses;
|
uint8_t* data = (uint8_t*)intmodulePulsesData.flysky.pulses;
|
||||||
|
|||||||
Reference in New Issue
Block a user