Fixed module power ON/OFF
This commit is contained in:
@@ -60,6 +60,7 @@ static void* afhds2Init(uint8_t module)
|
||||
|
||||
// mixer setup
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, AFHDS2_PERIOD);
|
||||
INTERNAL_MODULE_ON();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@@ -68,6 +69,7 @@ static void afhds2DeInit(void* context)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
INTERNAL_MODULE_OFF();
|
||||
intmoduleFifo.clear();
|
||||
IntmoduleSerialDriver.deinit();
|
||||
|
||||
|
||||
@@ -151,6 +151,7 @@ static void* crossfireInitInternal(uint8_t module)
|
||||
|
||||
intmoduleFifo.clear();
|
||||
IntmoduleSerialDriver.init(¶ms);
|
||||
INTERNAL_MODULE_ON();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@@ -159,6 +160,7 @@ static void crossfireDeInitInternal(void* context)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
INTERNAL_MODULE_OFF();
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, 0);
|
||||
intmoduleStop();
|
||||
intmoduleFifo.clear();
|
||||
@@ -192,6 +194,7 @@ static void* crossfireInitExternal(uint8_t module)
|
||||
{
|
||||
telemetryInit(PROTOCOL_TELEMETRY_CROSSFIRE);
|
||||
mixerSchedulerSetPeriod(module, CROSSFIRE_PERIOD);
|
||||
EXTERNAL_MODULE_ON();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -199,6 +202,8 @@ static void crossfireDeInitExternal(void* context)
|
||||
{
|
||||
(void)context;
|
||||
telemetryProtocol = 0xFF;
|
||||
|
||||
EXTERNAL_MODULE_OFF();
|
||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -262,6 +262,7 @@ static void* multiInit(uint8_t module)
|
||||
|
||||
// mixer setup
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, MULTIMODULE_PERIOD);
|
||||
INTERNAL_MODULE_ON();
|
||||
|
||||
// reset status
|
||||
getMultiModuleStatus(INTERNAL_MODULE).failsafeChecked = false;
|
||||
@@ -279,9 +280,10 @@ static void* multiInit(uint8_t module)
|
||||
static void multiDeInit(void* context)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
INTERNAL_MODULE_OFF();
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, 0);
|
||||
IntmoduleSerialDriver.deinit();
|
||||
//TODO: power OFF ???
|
||||
}
|
||||
|
||||
static void multiSetupPulses(void* context, int16_t* channels, uint8_t nChannels)
|
||||
|
||||
@@ -462,7 +462,6 @@ void enablePulsesExternalModule(uint8_t protocol)
|
||||
externalModuleDriver->deinit(externalModuleContext);
|
||||
externalModuleDriver = nullptr;
|
||||
externalModuleContext = nullptr;
|
||||
EXTERNAL_MODULE_PWR_OFF();
|
||||
} else {
|
||||
extmoduleStop();
|
||||
}
|
||||
@@ -497,7 +496,6 @@ void enablePulsesExternalModule(uint8_t protocol)
|
||||
|
||||
#if defined(CROSSFIRE)
|
||||
case PROTOCOL_CHANNELS_CROSSFIRE:
|
||||
EXTERNAL_MODULE_ON();
|
||||
externalModuleContext = CrossfireExternalDriver.init(EXTERNAL_MODULE);
|
||||
externalModuleDriver = &CrossfireExternalDriver;
|
||||
break;
|
||||
@@ -741,7 +739,6 @@ void stopPulsesExternalModule()
|
||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, 0);
|
||||
extmoduleStop();
|
||||
}
|
||||
EXTERNAL_MODULE_PWR_OFF();
|
||||
moduleState[EXTERNAL_MODULE].protocol = PROTOCOL_CHANNELS_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -245,6 +245,7 @@ static void* pxx1InitInternal(uint8_t module)
|
||||
init_intmodule_heartbeat();
|
||||
#endif
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, INTMODULE_PXX1_SERIAL_PERIOD);
|
||||
INTERNAL_MODULE_ON();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@@ -253,6 +254,7 @@ static void pxx1DeInitInternal(void* context)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
INTERNAL_MODULE_OFF();
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, 0);
|
||||
#if defined(INTMODULE_HEARTBEAT)
|
||||
stop_intmodule_heartbeat();
|
||||
|
||||
@@ -658,12 +658,14 @@ static void* pxx2InitInternal(uint8_t moduleType)
|
||||
init_intmodule_heartbeat();
|
||||
#endif
|
||||
mixerSchedulerSetPeriod(INTERNAL_MODULE, PXX2_PERIOD);
|
||||
INTERNAL_MODULE_ON();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void pxx2DeInitInternal(void* context)
|
||||
{
|
||||
INTERNAL_MODULE_OFF();
|
||||
IntmoduleSerialDriver.deinit();
|
||||
#if defined(INTMODULE_HEARTBEAT)
|
||||
stop_intmodule_heartbeat();
|
||||
@@ -723,24 +725,24 @@ static const etx_serial_init pxx2ExtSerialInitParams = {
|
||||
|
||||
static void* pxx2InitLowSpeed(uint8_t module)
|
||||
{
|
||||
if (module == EXTERNAL_MODULE) {
|
||||
etx_serial_init params(pxx2ExtSerialInitParams);
|
||||
params.baudrate = PXX2_LOWSPEED_BAUDRATE;
|
||||
ExtmoduleSerialDriver.init(¶ms);
|
||||
etx_serial_init params(pxx2ExtSerialInitParams);
|
||||
params.baudrate = PXX2_LOWSPEED_BAUDRATE;
|
||||
ExtmoduleSerialDriver.init(¶ms);
|
||||
|
||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, PXX2_NO_HEARTBEAT_PERIOD);
|
||||
return (void*)EXTERNAL_MODULE;
|
||||
}
|
||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, PXX2_NO_HEARTBEAT_PERIOD);
|
||||
EXTERNAL_MODULE_ON();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
static void* pxx2InitExternal(uint8_t moduleType)
|
||||
static void* pxx2InitExternal(uint8_t module)
|
||||
{
|
||||
etx_serial_init params(pxx2ExtSerialInitParams);
|
||||
params.baudrate = PXX2_HIGHSPEED_BAUDRATE;
|
||||
ExtmoduleSerialDriver.init(¶ms);
|
||||
|
||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, PXX2_NO_HEARTBEAT_PERIOD);
|
||||
EXTERNAL_MODULE_ON();
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
@@ -749,6 +751,7 @@ static void pxx2DeInitExternal(void* context)
|
||||
{
|
||||
(void)context;
|
||||
|
||||
EXTERNAL_MODULE_OFF();
|
||||
mixerSchedulerSetPeriod(EXTERNAL_MODULE, 0);
|
||||
ExtmoduleSerialDriver.deinit();
|
||||
}
|
||||
|
||||
@@ -36,6 +36,8 @@ extern "C" {
|
||||
|
||||
void extmoduleStop()
|
||||
{
|
||||
EXTERNAL_MODULE_OFF();
|
||||
|
||||
NVIC_DisableIRQ(EXTMODULE_TIMER_DMA_STREAM_IRQn);
|
||||
|
||||
EXTMODULE_TIMER_DMA_STREAM->CR &= ~DMA_SxCR_EN; // Disable DMA
|
||||
|
||||
@@ -121,12 +121,7 @@ uint32_t isBootloaderStart(const uint8_t * buffer);
|
||||
#endif
|
||||
|
||||
#define EXTERNAL_MODULE_ON() EXTERNAL_MODULE_PWR_ON()
|
||||
|
||||
#if defined(EXTMODULE_USART)
|
||||
#define EXTERNAL_MODULE_OFF() extmoduleStop()
|
||||
#else
|
||||
#define EXTERNAL_MODULE_OFF() EXTERNAL_MODULE_PWR_OFF()
|
||||
#endif
|
||||
#define EXTERNAL_MODULE_OFF() EXTERNAL_MODULE_PWR_OFF()
|
||||
|
||||
#if defined(RADIO_T12)
|
||||
#define IS_INTERNAL_MODULE_ON() false
|
||||
|
||||
Reference in New Issue
Block a user