Pulses refactoring (another one!) (#6510)

Pulses refactoring (another one!)
This commit is contained in:
Bertrand Songis
2019-06-17 12:02:42 +02:00
committed by GitHub
parent 1f1ccf277c
commit b20e4a6be4
18 changed files with 183 additions and 494 deletions
+25 -10
View File
@@ -359,15 +359,18 @@ void FrskyDeviceFirmwareUpdate::flashFirmware(const char * filename)
{
pausePulses();
#if defined(HARDWARE_INTERNAL_MODULE)
uint8_t intPwr = IS_INTERNAL_MODULE_ON();
INTERNAL_MODULE_OFF();
#endif
uint8_t extPwr = IS_EXTERNAL_MODULE_ON();
EXTERNAL_MODULE_OFF();
SPORT_UPDATE_POWER_OFF();
drawProgressScreen(getBasename(filename), STR_DEVICE_RESET, 0, 0);
INTERNAL_MODULE_OFF();
EXTERNAL_MODULE_OFF();
SPORT_UPDATE_POWER_OFF();
/* wait 2s off */
watchdogSuspend(2000);
RTOS_WAIT_MS(2000);
@@ -399,13 +402,16 @@ void FrskyDeviceFirmwareUpdate::flashFirmware(const char * filename)
RTOS_WAIT_MS(2000);
telemetryClearFifo();
#if defined(HARDWARE_INTERNAL_MODULE)
if (intPwr) {
INTERNAL_MODULE_ON();
setupPulses(INTERNAL_MODULE);
setupPulsesInternalModule();
}
#endif
if (extPwr) {
EXTERNAL_MODULE_ON();
setupPulses(EXTERNAL_MODULE);
setupPulsesExternalModule();
}
state = SPORT_IDLE;
@@ -620,11 +626,14 @@ void FrskyChipFirmwareUpdate::flashFirmware(const char * filename)
pausePulses();
#if defined(HARDWARE_INTERNAL_MODULE)
uint8_t intPwr = IS_INTERNAL_MODULE_ON();
uint8_t extPwr = IS_EXTERNAL_MODULE_ON();
INTERNAL_MODULE_OFF();
#endif
uint8_t extPwr = IS_EXTERNAL_MODULE_ON();
EXTERNAL_MODULE_OFF();
SPORT_UPDATE_POWER_OFF();
/* wait 2s off */
@@ -646,7 +655,10 @@ void FrskyChipFirmwareUpdate::flashFirmware(const char * filename)
POPUP_INFORMATION(STR_FIRMWARE_UPDATE_SUCCESS);
}
#if defined(HARDWARE_INTERNAL_MODULE)
INTERNAL_MODULE_OFF();
#endif
EXTERNAL_MODULE_OFF();
SPORT_UPDATE_POWER_OFF();
@@ -654,13 +666,16 @@ void FrskyChipFirmwareUpdate::flashFirmware(const char * filename)
watchdogSuspend(2000);
RTOS_WAIT_MS(2000);
#if defined(HARDWARE_INTERNAL_MODULE)
if (intPwr) {
INTERNAL_MODULE_ON();
setupPulses(INTERNAL_MODULE);
setupPulsesInternalModule();
}
#endif
if (extPwr) {
EXTERNAL_MODULE_ON();
setupPulses(EXTERNAL_MODULE);
setupPulsesExternalModule();
}
resumePulses();
+102 -127
View File
@@ -133,76 +133,21 @@ uint8_t getRequiredProtocol(uint8_t module)
return protocol;
}
void disablePulses(uint8_t module, uint8_t protocol)
{
// stop existing protocol hardware
switch (protocol) {
#if defined(PXX1)
case PROTOCOL_CHANNELS_PXX1_PULSES:
disable_pxx1_pulses(module);
break;
#if defined(INTMODULE_USART) || defined(EXTMODULE_USART)
case PROTOCOL_CHANNELS_PXX1_SERIAL:
disable_pxx1_serial(module);
break;
#endif
#endif
#if defined(DSM2)
case PROTOCOL_CHANNELS_DSM2_LP45:
case PROTOCOL_CHANNELS_DSM2_DSM2:
case PROTOCOL_CHANNELS_DSM2_DSMX:
disable_serial(module);
break;
#endif
#if defined(CROSSFIRE)
case PROTOCOL_CHANNELS_CROSSFIRE:
// TODO disable_module_timer(module);
break;
#endif
#if defined(PXX2)
case PROTOCOL_CHANNELS_PXX2:
disable_pxx2(module);
break;
#endif
#if defined(MULTIMODULE)
case PROTOCOL_CHANNELS_MULTIMODULE:
#endif
#if defined(SBUS)
case PROTOCOL_CHANNELS_SBUS:
disable_serial(module);
break;
#endif
#if defined(PPM)
case PROTOCOL_CHANNELS_PPM:
disable_ppm(module);
break;
#endif
}
}
void enablePulses(uint8_t module, uint8_t protocol)
void enablePulsesExternalModule(uint8_t protocol)
{
// start new protocol hardware here
switch (protocol) {
#if defined(PXX1)
case PROTOCOL_CHANNELS_PXX1_PULSES:
init_pxx1_pulses(module);
break;
#if defined(INTMODULE_USART) || defined(EXTMODULE_USART)
case PROTOCOL_CHANNELS_PXX1_SERIAL:
init_pxx1_serial(module);
extmodulePxx1PulsesStart();
break;
#endif
#if defined(PXX1) && defined(EXTMODULE_USART)
case PROTOCOL_CHANNELS_PXX1_SERIAL:
extmodulePxx1SerialStart();
break;
#endif
#if defined(DSM2)
@@ -215,13 +160,13 @@ void enablePulses(uint8_t module, uint8_t protocol)
#if defined(CROSSFIRE)
case PROTOCOL_CHANNELS_CROSSFIRE:
// TODO init_module_timer(module, CROSSFIRE_PERIOD, true);
EXTERNAL_MODULE_ON();
break;
#endif
#if defined(PXX2)
case PROTOCOL_CHANNELS_PXX2:
init_pxx2(module);
extmoduleInvertedSerialStart(PXX2_EXTERNAL_MODULE_BAUDRATE);
break;
#endif
@@ -239,54 +184,7 @@ void enablePulses(uint8_t module, uint8_t protocol)
#if defined(PPM)
case PROTOCOL_CHANNELS_PPM:
init_ppm(module);
break;
#endif
default:
// TODO some reworking needed here ...
#if defined(PXX2)
disable_pxx2(module);
#endif
break;
}
}
void setupPulsesInternalModule(uint8_t protocol)
{
switch (protocol) {
#if defined(HARDWARE_INTERNAL_MODULE) && defined(PXX1) && !defined(INTMODULE_USART)
case PROTOCOL_CHANNELS_PXX1_PULSES:
intmodulePulsesData.pxx.setupFrame(INTERNAL_MODULE);
scheduleNextMixerCalculation(INTERNAL_MODULE, INTMODULE_PXX_PERIOD);
break;
#endif
#if defined(PXX1) && defined(INTMODULE_USART)
case PROTOCOL_CHANNELS_PXX1_SERIAL:
intmodulePulsesData.pxx_uart.setupFrame(INTERNAL_MODULE);
scheduleNextMixerCalculation(INTERNAL_MODULE, INTMODULE_PXX_PERIOD);
break;
#endif
#if defined(PXX2)
case PROTOCOL_CHANNELS_PXX2:
intmodulePulsesData.pxx2.setupFrame(INTERNAL_MODULE);
if (moduleState[INTERNAL_MODULE].mode == MODULE_MODE_SPECTRUM_ANALYSER || moduleState[INTERNAL_MODULE].mode == MODULE_MODE_POWER_METER) {
scheduleNextMixerCalculation(INTERNAL_MODULE, PXX2_TOOLS_PERIOD);
}
#if !defined(INTMODULE_HEARTBEAT)
else {
scheduleNextMixerCalculation(INTERNAL_MODULE, PXX2_PERIOD);
}
#endif
break;
#endif
#if defined(PCBTARANIS) && defined(INTERNAL_MODULE_PPM)
case PROTOCOL_CHANNELS_PPM:
setupPulsesPPM(&extmodulePulsesData.ppm, g_model.moduleData[INTERNAL_MODULE].channelsStart, g_model.moduleData[INTERNAL_MODULE].channelsCount, g_model.moduleData[INTERNAL_MODULE].ppm.frameLength);
scheduleNextMixerCalculation(INTERNAL_MODULE, PPM_PERIOD(INTERNAL_MODULE));
extmodulePpmStart();
break;
#endif
@@ -361,35 +259,112 @@ void setupPulsesExternalModule(uint8_t protocol)
}
}
void setupPulses(uint8_t module, uint8_t protocol)
{
switch (module) {
#if defined(HARDWARE_INTERNAL_MODULE)
case INTERNAL_MODULE:
setupPulsesInternalModule(protocol);
void enablePulsesInternalModule(uint8_t protocol)
{
// start new protocol hardware here
switch (protocol) {
#if defined(PXX1) && !defined(INTMODULE_USART)
case PROTOCOL_CHANNELS_PXX1_PULSES:
intmodulePxx1PulsesStart();
break;
#endif
case EXTERNAL_MODULE:
setupPulsesExternalModule(protocol);
#if defined(PXX1) && defined(INTMODULE_USART)
case PROTOCOL_CHANNELS_PXX1_SERIAL:
intmodulePxx1SerialStart();
break;
#endif
#if defined(PXX2)
case PROTOCOL_CHANNELS_PXX2:
intmoduleSerialStart(INTMODULE_PXX_BAUDRATE, true);
break;
#endif
default:
break;
}
}
bool setupPulses(uint8_t module)
void setupPulsesInternalModule(uint8_t protocol)
{
uint8_t protocol = getRequiredProtocol(module);
switch (protocol) {
#if defined(HARDWARE_INTERNAL_MODULE) && defined(PXX1) && !defined(INTMODULE_USART)
case PROTOCOL_CHANNELS_PXX1_PULSES:
intmodulePulsesData.pxx.setupFrame(INTERNAL_MODULE);
scheduleNextMixerCalculation(INTERNAL_MODULE, INTMODULE_PXX_PERIOD);
break;
#endif
heartbeat |= (HEART_TIMER_PULSES << module);
#if defined(PXX1) && defined(INTMODULE_USART)
case PROTOCOL_CHANNELS_PXX1_SERIAL:
intmodulePulsesData.pxx_uart.setupFrame(INTERNAL_MODULE);
scheduleNextMixerCalculation(INTERNAL_MODULE, INTMODULE_PXX_PERIOD);
break;
#endif
if (moduleState[module].protocol != protocol) {
disablePulses(module, moduleState[module].protocol);
moduleState[module].protocol = protocol;
enablePulses(module, protocol);
#if defined(PXX2)
case PROTOCOL_CHANNELS_PXX2:
intmodulePulsesData.pxx2.setupFrame(INTERNAL_MODULE);
if (moduleState[INTERNAL_MODULE].mode == MODULE_MODE_SPECTRUM_ANALYSER || moduleState[INTERNAL_MODULE].mode == MODULE_MODE_POWER_METER) {
scheduleNextMixerCalculation(INTERNAL_MODULE, PXX2_TOOLS_PERIOD);
}
#if !defined(INTMODULE_HEARTBEAT)
else {
scheduleNextMixerCalculation(INTERNAL_MODULE, PXX2_PERIOD);
}
#endif
break;
#endif
#if defined(PCBTARANIS) && defined(INTERNAL_MODULE_PPM)
case PROTOCOL_CHANNELS_PPM:
setupPulsesPPM(&extmodulePulsesData.ppm, g_model.moduleData[INTERNAL_MODULE].channelsStart, g_model.moduleData[INTERNAL_MODULE].channelsCount, g_model.moduleData[INTERNAL_MODULE].ppm.frameLength);
scheduleNextMixerCalculation(INTERNAL_MODULE, PPM_PERIOD(INTERNAL_MODULE));
break;
#endif
default:
break;
}
}
bool setupPulsesInternalModule()
{
uint8_t protocol = getRequiredProtocol(INTERNAL_MODULE);
heartbeat |= (HEART_TIMER_PULSES << INTERNAL_MODULE);
if (moduleState[INTERNAL_MODULE].protocol != protocol) {
intmoduleStop();
moduleState[INTERNAL_MODULE].protocol = protocol;
enablePulsesInternalModule(protocol);
return false;
}
else {
setupPulses(module, protocol);
setupPulsesInternalModule(protocol);
return true;
}
}
#endif
bool setupPulsesExternalModule()
{
uint8_t protocol = getRequiredProtocol(EXTERNAL_MODULE);
heartbeat |= (HEART_TIMER_PULSES << EXTERNAL_MODULE);
if (moduleState[EXTERNAL_MODULE].protocol != protocol) {
extmoduleStop();
moduleState[EXTERNAL_MODULE].protocol = protocol;
enablePulsesExternalModule(protocol);
return false;
}
else {
setupPulsesExternalModule(protocol);
return true;
}
}
+14 -15
View File
@@ -302,7 +302,8 @@ union TrainerPulsesData {
extern TrainerPulsesData trainerPulsesData;
bool setupPulses(uint8_t module);
bool setupPulsesInternalModule();
bool setupPulsesExternalModule();
void setupPulsesDSM2();
void setupPulsesCrossfire();
void setupPulsesMultimodule();
@@ -314,28 +315,26 @@ void sendByteDsm2(uint8_t b);
void putDsm2Flush();
void putDsm2SerialBit(uint8_t bit);
void sendByteSbus(uint8_t b);
#if defined(HUBSAN)
void Hubsan_Init();
#endif
void intmodulePxx1PulsesStart();
void intmodulePxx1SerialStart();
void extmodulePxx1PulsesStart();
void extmodulePxx1SerialStart();
void extmodulePpmStart();
void intmoduleStop();
void extmoduleStop();
inline void startPulses()
{
s_pulses_paused = false;
#if defined(PCBTARANIS) || defined(PCBHORUS)
setupPulses(INTERNAL_MODULE);
setupPulses(EXTERNAL_MODULE);
#else
setupPulses(EXTERNAL_MODULE);
#if defined(HARDWARE_INTERNAL_MODULE)
setupPulsesInternalModule();
#endif
#if defined(PCBSKY9X)
init_ppm(EXTRA_MODULE);
#endif
setupPulsesExternalModule();
#if defined(HUBSAN)
Hubsan_Init();
#if defined(HARDWARE_EXTRA_MODULE)
extramodulePpmStart();
#endif
}
@@ -197,7 +197,6 @@ set(FIRMWARE_TARGET_SRC
set(TARGET_SRC
${TARGET_SRC}
pulses_driver.cpp
keys_driver.cpp
telemetry_driver.cpp
)
@@ -41,7 +41,7 @@ void intmoduleStop()
GPIO_ResetBits(INTMODULE_GPIO, INTMODULE_TX_GPIO_PIN | INTMODULE_RX_GPIO_PIN);
}
void intmodulePxxStart()
void intmodulePxx1SerialStart()
{
intmoduleSerialStart(INTMODULE_PXX_BAUDRATE, false);
}
-16
View File
@@ -208,31 +208,15 @@ void SDRAM_Init(void);
#define IS_PXX1_INTERNAL_ENABLED() (true)
#endif
void init_ppm(uint8_t module);
void disable_ppm(uint8_t module);
void init_pxx1_pulses(uint8_t module);
void init_pxx1_serial(uint8_t module);
void disable_pxx1_pulses(uint8_t module);
void disable_pxx1_serial(uint8_t module);
void init_pxx2(uint8_t module);
void disable_pxx2(uint8_t module);
void disable_serial(uint8_t module);
void init_intmodule_heartbeat();
void check_intmodule_heartbeat();
void intmoduleStop();
void intmoduleSerialStart(uint32_t baudrate, uint8_t rxEnable);
void intmodulePxxStart();
void intmoduleSendBuffer(const uint8_t * data, uint8_t size);
void intmoduleSendNextFrame();
void extmoduleSerialStart(uint32_t baudrate, uint32_t period_half_us, bool inverted);
void extmoduleSendNextFrame();
void extmoduleStop();
void extmodulePpmStart();
void extmodulePxxStart();
void extmodulePxx2Start();
// Trainer driver
void init_trainer_ppm(void);
+2 -7
View File
@@ -83,7 +83,7 @@ void extmodulePpmStart()
NVIC_SetPriority(EXTMODULE_TIMER_IRQn, 7);
}
void extmodulePxxStart()
void extmodulePxx1PulsesStart()
{
EXTERNAL_MODULE_ON();
@@ -127,11 +127,6 @@ void extmodulePxxStart()
NVIC_SetPriority(EXTMODULE_TIMER_IRQn, 7);
}
void extmodulePxx2Start()
{
// TODO just enable the S.PORT line (or let telemetry init do it)
}
#if defined(DSM2)
void extmoduleSerialStart(uint32_t /*baudrate*/, uint32_t period_half_us, bool inverted)
{
@@ -284,6 +279,6 @@ extern "C" void EXTMODULE_TIMER_IRQHandler()
{
EXTMODULE_TIMER->DIER &= ~TIM_DIER_CC2IE; // Stop this interrupt
EXTMODULE_TIMER->SR &= ~TIM_SR_CC2IF;
if (setupPulses(EXTERNAL_MODULE))
if (setupPulsesExternalModule())
extmoduleSendNextFrame();
}
-93
View File
@@ -1,93 +0,0 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "opentx.h"
void init_ppm(uint8_t module)
{
if (module == EXTERNAL_MODULE) {
extmodulePpmStart();
}
}
void disable_ppm(uint8_t module)
{
if (module == EXTERNAL_MODULE) {
extmoduleStop();
}
}
void init_pxx2(uint8_t module)
{
if (module == INTERNAL_MODULE)
intmoduleSerialStart(INTMODULE_PXX_BAUDRATE, true);
else
extmodulePxx2Start();
}
void disable_pxx2(uint8_t module)
{
if (module == INTERNAL_MODULE)
intmoduleStop();
else
extmoduleStop();
}
void init_pxx1_pulses(uint8_t module)
{
if (module == INTERNAL_MODULE)
intmodulePxxStart();
else
extmodulePxxStart();
}
void init_pxx1_serial(uint8_t module)
{
if (module == INTERNAL_MODULE)
intmodulePxxStart();
else
extmodulePxxStart();
}
void disable_pxx1_pulses(uint8_t module)
{
if (module == INTERNAL_MODULE)
intmoduleStop();
else
extmoduleStop();
}
void disable_pxx1_serial(uint8_t module)
{
if (module == INTERNAL_MODULE)
intmoduleStop();
else
extmoduleStop();
}
#if defined(DSM2)
void disable_serial(uint8_t module)
{
if (module == EXTERNAL_MODULE) {
extmoduleStop();
}
}
#endif
+1
View File
@@ -60,6 +60,7 @@ Pio Pioa, Piob, Pioc;
Pmc pmc;
Ssc ssc;
Pwm pwm;
Tc tc1;
Twi Twio;
Usart Usart0;
Dacc dacc;
+6
View File
@@ -172,6 +172,12 @@ extern Pmc pmc;
extern Ssc ssc;
#undef SSC
#define SSC (&ssc)
extern Pmc pmc;
#undef PMC
#define PMC (&pmc)
extern Tc tc1;
#undef TC1
#define TC1 (&tc1)
extern Pio Pioa, Piob, Pioc;
extern Twi Twio;
extern Dacc dacc;
-8
View File
@@ -229,14 +229,6 @@ uint32_t readTrims(void);
#define KEYS_PRESSED() readKeys()
// Pulses driver
void init_no_pulses(uint32_t port);
void init_ppm(uint32_t port);
void disable_ppm(uint32_t port);
void init_pxx1_pulses(uint32_t port);
void disable_pxx1_pulses(uint32_t port);
void disable_serial(uint32_t port);
void init_module_timer( uint32_t module_index, uint32_t period, uint8_t state);
void disable_module_timer( uint32_t module_index);
void extmoduleSerialStart(uint32_t baudrate, uint32_t period_half_us, bool inverted);
void extmoduleSendNextFrame();
+18 -63
View File
@@ -108,6 +108,8 @@ void init_second_ppm(uint32_t period)
setExtraModulePolarity();
}
/*
// TODO re-add it later
void disable_second_ppm()
{
Pio * pioptr = PIOC;
@@ -115,16 +117,6 @@ void disable_second_ppm()
PWM->PWM_IDR1 = PWM_IDR1_CHID1;
}
void init_no_pulses(uint32_t port)
{
if (port == EXTERNAL_MODULE) {
init_main_ppm(3000, 0);
}
else {
// TODO
}
}
void init_module_timer(uint32_t port, uint32_t period, uint8_t state)
{
if (port == EXTERNAL_MODULE) {
@@ -132,32 +124,16 @@ void init_module_timer(uint32_t port, uint32_t period, uint8_t state)
init_main_ppm(3000, 0);
}
}
*/
void disable_module_timer(uint32_t port)
void extmodulePpmStart()
{
if (port == EXTERNAL_MODULE) {
disable_ppm(EXTERNAL_MODULE);
}
init_main_ppm(3000, 1);
}
void init_ppm(uint32_t port)
void extramodulePpmStart()
{
if (port == EXTERNAL_MODULE) {
init_main_ppm(3000, 1);
}
else {
init_second_ppm(3000);
}
}
void disable_ppm(uint32_t port)
{
if (port == EXTERNAL_MODULE) {
disable_main_ppm();
}
else {
disable_second_ppm();
}
init_second_ppm(3000);
}
// Initialise the SSC to allow PXX output.
@@ -201,26 +177,16 @@ void disable_ssc()
sscptr->SSC_CR = SSC_CR_TXDIS;
}
void init_pxx1_pulses(uint32_t port)
void extmodulePxx1PulsesStart()
{
if (port == EXTERNAL_MODULE) {
init_main_ppm(2500 * 2, 0);
init_ssc(125); // 8us per bit
}
else {
// TODO
}
init_main_ppm(2500 * 2, 0);
init_ssc(125); // 8us per bit
}
void disable_pxx1_pulses(uint32_t port)
void extmoduleStop()
{
if (port == EXTERNAL_MODULE) {
disable_ssc();
disable_ppm(EXTERNAL_MODULE);
}
else {
// TODO
}
disable_ssc();
disable_main_ppm();
}
void extmoduleSerialStart(uint32_t baudrate, uint32_t period_half_us, bool inverted)
@@ -236,21 +202,10 @@ void extmoduleSerialStart(uint32_t baudrate, uint32_t period_half_us, bool inver
}
}
void disable_serial(uint32_t port)
{
if (port == EXTERNAL_MODULE) {
disable_ssc();
disable_ppm(EXTERNAL_MODULE);
}
else {
// TODO
}
}
void extmoduleSendNextFrame()
{
}
#if !defined(SIMU)
extern "C" void PWM_IRQHandler(void)
{
@@ -272,7 +227,7 @@ extern "C" void PWM_IRQHandler(void)
}
pwmptr->PWM_CH_NUM[3].PWM_CPDRUPD = period; // Period in half uS
if (period != 2500 * 2) {
setupPulses(EXTERNAL_MODULE);
setupPulsesExternalModule();
setExternalModulePolarity();
}
else {
@@ -297,7 +252,7 @@ extern "C" void PWM_IRQHandler(void)
}
pwmptr->PWM_CH_NUM[3].PWM_CPDRUPD = period; // Period in half uS
if (period != 2500 * 2) {
setupPulses(EXTERNAL_MODULE);
setupPulsesExternalModule();
}
else {
// Kick off serial output here
@@ -323,7 +278,7 @@ extern "C" void PWM_IRQHandler(void)
}
pwmptr->PWM_CH_NUM[3].PWM_CPDRUPD = period; // Period in half uS
if (period != 3500 * 2) {
setupPulses(EXTERNAL_MODULE);
setupPulsesExternalModule();
}
else {
// Kick off serial output here
@@ -338,7 +293,7 @@ extern "C" void PWM_IRQHandler(void)
pwmptr->PWM_CH_NUM[3].PWM_CPDRUPD = *extmodulePulsesData.ppm.ptr++;
if (*extmodulePulsesData.ppm.ptr == 0) {
setExternalModulePolarity();
setupPulses(EXTERNAL_MODULE);
setupPulsesExternalModule();
}
break;
+1 -1
View File
@@ -178,7 +178,7 @@ if(PCB STREQUAL XLITE OR PCB STREQUAL XLITES OR PCB STREQUAL X9LITE)
${TARGET_SRC}
../common/arm/stm32/intmodule_serial_driver.cpp
)
else()
elseif(NOT (PCB STREQUAL X7 AND PCBREV STREQUAL T12))
set(TARGET_SRC
${TARGET_SRC}
intmodule_pulses_driver.cpp
-19
View File
@@ -199,29 +199,10 @@ uint32_t isBootloaderStart(const uint8_t * buffer);
#define IS_INTERNAL_MODULE_ON() (GPIO_ReadInputDataBit(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN) == Bit_SET)
#endif
void init_ppm(uint8_t module);
void disable_ppm(uint8_t module);
void init_pxx2(uint8_t module);
void disable_pxx2(uint8_t module);
void init_pxx1_pulses(uint8_t module);
void init_pxx1_serial(uint8_t module);
void disable_pxx1_pulses(uint8_t module);
void disable_pxx1_serial(uint8_t module);
void disable_serial(uint8_t module);
void intmoduleStop();
void intmodulePxxStart();
void intmoduleSerialStart(uint32_t baudrate, uint8_t rxEnable);
#if defined(INTERNAL_MODULE_PPM)
void intmodulePpmStart(void);
#endif
void intmoduleSendBuffer(const uint8_t * data, uint8_t size);
void intmoduleSendNextFrame();
void extmoduleStop();
void extmodulePpmStart();
void extmodulePxxPulsesStart();
void extmodulePxxSerialStart();
void extmodulePxx2Start();
void extmoduleSerialStart(uint32_t baudrate, uint32_t period_half_us, bool inverted);
void extmoduleInvertedSerialStart(uint32_t baudrate);
void extmoduleSendBuffer(const uint8_t * data, uint8_t size);
+3 -13
View File
@@ -196,20 +196,10 @@ extern "C" void EXTMODULE_USART_IRQHandler(void)
status = EXTMODULE_USART->SR;
}
}
void extmodulePxx2Start()
{
extmoduleInvertedSerialStart(PXX2_EXTERNAL_MODULE_BAUDRATE);
}
#else
void extmodulePxx2Start()
{
// TODO just enable the S.PORT line (or let telemetry init do it)
}
#endif
#if defined(PXX1)
void extmodulePxxPulsesStart()
void extmodulePxx1PulsesStart()
{
EXTERNAL_MODULE_ON();
@@ -246,7 +236,7 @@ void extmodulePxxPulsesStart()
#endif
#if defined(PXX1) && defined(EXTMODULE_USART)
void extmodulePxxSerialStart()
void extmodulePxx1SerialStart()
{
extmoduleInvertedSerialStart(EXTMODULE_PXX_SERIAL_BAUDRATE);
}
@@ -340,7 +330,7 @@ extern "C" void EXTMODULE_TIMER_CC_IRQHandler()
{
EXTMODULE_TIMER->DIER &= ~TIM_DIER_CC2IE; // Stop this interrupt
EXTMODULE_TIMER->SR &= ~TIM_SR_CC2IF;
if (setupPulses(EXTERNAL_MODULE)) {
if (setupPulsesExternalModule()) {
extmoduleSendNextFrame();
}
}
@@ -83,12 +83,7 @@ void intmoduleSendNextFrame()
}
}
void intmoduleSerialStart(uint32_t baudrate, uint8_t rxEnable)
{
// nothing, the pulses will be sent through telemetry port
}
void intmodulePxxStart()
void intmodulePxx1PulsesStart()
{
INTERNAL_MODULE_ON();
@@ -172,7 +167,7 @@ extern "C" void INTMODULE_TIMER_CC_IRQHandler()
{
INTMODULE_TIMER->DIER &= ~TIM_DIER_CC2IE; // Stop this interrupt
INTMODULE_TIMER->SR &= ~TIM_SR_CC2IF;
if (setupPulses(INTERNAL_MODULE)) {
if (setupPulsesInternalModule()) {
intmoduleSendNextFrame();
}
}
-106
View File
@@ -1,106 +0,0 @@
/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include "opentx.h"
#if defined(PXX1)
void init_pxx1_pulses(uint8_t module)
{
if (module == INTERNAL_MODULE)
intmodulePxxStart();
else
extmodulePxxPulsesStart();
}
void init_pxx1_serial(uint8_t module)
{
if (module == INTERNAL_MODULE)
intmodulePxxStart();
#if defined(EXTMODULE_USART)
else
extmodulePxxSerialStart();
#endif
}
void disable_pxx1_pulses(uint8_t module)
{
if (module == INTERNAL_MODULE)
intmoduleStop();
else
extmoduleStop();
}
void disable_pxx1_serial(uint8_t module)
{
if (module == INTERNAL_MODULE)
intmoduleStop();
else
extmoduleStop();
}
#endif
void init_pxx2(uint8_t module)
{
if (module == INTERNAL_MODULE)
intmoduleSerialStart(INTMODULE_PXX_BAUDRATE, true);
else
extmodulePxx2Start();
}
void disable_pxx2(uint8_t module)
{
if (module == INTERNAL_MODULE)
intmoduleStop();
else
extmoduleStop();
}
#if defined(DSM2)
void disable_serial(uint8_t module)
{
if (module == EXTERNAL_MODULE) {
extmoduleStop();
}
}
#endif
void init_ppm(uint8_t module)
{
if (module == EXTERNAL_MODULE) {
extmodulePpmStart();
}
#if defined(INTERNAL_MODULE_PPM)
else {
intmodulePpmStart();
}
#endif
}
void disable_ppm(uint8_t module)
{
if (module == EXTERNAL_MODULE) {
extmoduleStop();
}
#if defined(INTERNAL_MODULE_PPM)
else {
intmoduleStop();
}
#endif
}
+8 -7
View File
@@ -87,15 +87,16 @@ bool isModuleSynchronous(uint8_t module)
void sendSynchronousPulses()
{
for (uint8_t module = 0; module < NUM_MODULES; module++) {
if (isModuleSynchronous(module) && setupPulses(module)) {
#if defined(HARDWARE_INTERNAL_MODULE)
if (module == INTERNAL_MODULE)
intmoduleSendNextFrame();
if (isModuleSynchronous(INTERNAL_MODULE)) {
if (setupPulsesInternalModule())
intmoduleSendNextFrame();
}
#endif
if (module == EXTERNAL_MODULE)
extmoduleSendNextFrame();
}
if (isModuleSynchronous(EXTERNAL_MODULE)) {
if (setupPulsesExternalModule())
extmoduleSendNextFrame();
}
}