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