fix: Missing configurable port code, R9M Access, support FRM303 via mod (#3442)
* Fix configurable external module port * Added FRM303 support for TX16S via AUX1 mod, i.e. direct connect AUX1 TX/RX to PPM/Heartbeat pins. --------- Co-authored-by: raphaelcoeffic <raphael.coeffic@frafos.com>
This commit is contained in:
co-authored by
raphaelcoeffic
parent
e03add0b86
commit
125fd2ba28
@@ -31,6 +31,16 @@ extern const uint8_t _n_modules;
|
|||||||
static etx_module_state_t _module_states[MAX_MODULES];
|
static etx_module_state_t _module_states[MAX_MODULES];
|
||||||
static uint8_t _module_power;
|
static uint8_t _module_power;
|
||||||
|
|
||||||
|
#if defined(CONFIGURABLE_MODULE_PORT)
|
||||||
|
// supplemental configurable port
|
||||||
|
static etx_module_port_t _extra_module_port;
|
||||||
|
|
||||||
|
void modulePortConfigExtra(const etx_module_port_t* port)
|
||||||
|
{
|
||||||
|
memcpy(&_extra_module_port, port, sizeof(_extra_module_port));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void modulePortInit()
|
void modulePortInit()
|
||||||
{
|
{
|
||||||
memset(_module_states, 0, sizeof(_module_states));
|
memset(_module_states, 0, sizeof(_module_states));
|
||||||
@@ -42,16 +52,6 @@ void modulePortInit()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIGURABLE_MODULE_PORT)
|
|
||||||
// supplemental configurable port
|
|
||||||
static etx_module_port_t _extra_module_port;
|
|
||||||
|
|
||||||
void modulePortConfigExtra(const etx_module_port_t* port)
|
|
||||||
{
|
|
||||||
memcpy(&_extra_module_port, port, sizeof(_extra_module_port));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static void modulePortClear(etx_module_state_t* st)
|
static void modulePortClear(etx_module_state_t* st)
|
||||||
{
|
{
|
||||||
memset(st, 0, sizeof(etx_module_state_t));
|
memset(st, 0, sizeof(etx_module_state_t));
|
||||||
|
|||||||
@@ -992,10 +992,18 @@ static void* initModule(uint8_t module)
|
|||||||
module == INTERNAL_MODULE ? ETX_Pol_Normal : ETX_Pol_Inverted;
|
module == INTERNAL_MODULE ? ETX_Pol_Normal : ETX_Pol_Inverted;
|
||||||
mod_st = modulePortInitSerial(module, ETX_MOD_PORT_UART, ¶ms);
|
mod_st = modulePortInitSerial(module, ETX_MOD_PORT_UART, ¶ms);
|
||||||
|
|
||||||
if (module == EXTERNAL_MODULE && !mod_st) {
|
#if defined(CONFIGURABLE_MODULE_PORT)
|
||||||
|
if (!mod_st && module == EXTERNAL_MODULE) {
|
||||||
|
// Try Connect using aux serial mod
|
||||||
|
params.polarity = ETX_Pol_Normal;
|
||||||
|
mod_st = modulePortInitSerial(module, ETX_MOD_PORT_UART, ¶ms);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!mod_st && module == EXTERNAL_MODULE) {
|
||||||
// soft-serial fallback
|
// soft-serial fallback
|
||||||
params.baudrate = AFHDS3_SOFTSERIAL_BAUDRATE;
|
params.baudrate = AFHDS3_SOFTSERIAL_BAUDRATE;
|
||||||
params.direction = ETX_Dir_RX;
|
params.direction = ETX_Dir_TX;
|
||||||
period = AFHDS3_SOFTSERIAL_COMMAND_TIMEOUT * 1000 /* us */;
|
period = AFHDS3_SOFTSERIAL_COMMAND_TIMEOUT * 1000 /* us */;
|
||||||
mod_st = modulePortInitSerial(module, ETX_MOD_PORT_SOFT_INV, ¶ms);
|
mod_st = modulePortInitSerial(module, ETX_MOD_PORT_SOFT_INV, ¶ms);
|
||||||
// TODO: telemetry RX ???
|
// TODO: telemetry RX ???
|
||||||
|
|||||||
@@ -470,7 +470,7 @@ static void pulsesEnableModule(uint8_t module, uint8_t protocol)
|
|||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(INTERNAL_MODULE_AFHDS3)
|
#if defined(INTERNAL_MODULE_AFHDS3) || defined(AFHDS3)
|
||||||
case PROTOCOL_CHANNELS_AFHDS3:
|
case PROTOCOL_CHANNELS_AFHDS3:
|
||||||
_init_module(module, &afhds3::ProtoDriver);
|
_init_module(module, &afhds3::ProtoDriver);
|
||||||
break;
|
break;
|
||||||
|
|||||||
+12
-4
@@ -29,6 +29,11 @@
|
|||||||
|
|
||||||
#include "hal/serial_port.h"
|
#include "hal/serial_port.h"
|
||||||
|
|
||||||
|
#if defined(CONFIGURABLE_MODULE_PORT)
|
||||||
|
#include "hal/module_port.h"
|
||||||
|
#include "tasks/mixer_task.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !defined(BOOT)
|
#if !defined(BOOT)
|
||||||
#include "opentx.h"
|
#include "opentx.h"
|
||||||
#include "lua/lua_api.h"
|
#include "lua/lua_api.h"
|
||||||
@@ -257,13 +262,14 @@ static void serialSetCallBacks(int mode, void* ctx, const etx_serial_port_t* por
|
|||||||
etx_module_port_t mod_port;
|
etx_module_port_t mod_port;
|
||||||
memset(&mod_port, 0, sizeof(mod_port));
|
memset(&mod_port, 0, sizeof(mod_port));
|
||||||
auto mod_st = modulePortGetState(EXTERNAL_MODULE);
|
auto mod_st = modulePortGetState(EXTERNAL_MODULE);
|
||||||
if (mod_st && mod_st->tx.hw_def == port->hw_def) {
|
if (mod_st && mod_st->tx.port &&
|
||||||
|
mod_st->tx.port->hw_def == port->hw_def) {
|
||||||
// port is in use, let's stop it
|
// port is in use, let's stop it
|
||||||
mixerTaskStop();
|
mixerTaskStop();
|
||||||
pausePulses();
|
pulsesStop();
|
||||||
pulsesStopModule(EXTERNAL_MODULE);
|
pulsesStopModule(EXTERNAL_MODULE);
|
||||||
modulePortConfigExtra(&mod_port);
|
modulePortConfigExtra(&mod_port);
|
||||||
resumePulses();
|
pulsesStart();
|
||||||
mixerTaskStart();
|
mixerTaskStart();
|
||||||
} else {
|
} else {
|
||||||
modulePortConfigExtra(&mod_port);
|
modulePortConfigExtra(&mod_port);
|
||||||
@@ -397,10 +403,12 @@ void serialInit(uint8_t port_nr, int mode)
|
|||||||
#if defined(CONFIGURABLE_MODULE_PORT)
|
#if defined(CONFIGURABLE_MODULE_PORT)
|
||||||
if (mode == UART_MODE_EXT_MODULE) {
|
if (mode == UART_MODE_EXT_MODULE) {
|
||||||
etx_module_port_t mod_port = {
|
etx_module_port_t mod_port = {
|
||||||
.port = ETX_MOD_PORT_EXTERNAL_UART,
|
.port = ETX_MOD_PORT_UART,
|
||||||
.type = ETX_MOD_TYPE_SERIAL,
|
.type = ETX_MOD_TYPE_SERIAL,
|
||||||
.dir_flags = ETX_MOD_DIR_TX_RX,
|
.dir_flags = ETX_MOD_DIR_TX_RX,
|
||||||
.drv = { .serial = port->uart },
|
.drv = { .serial = port->uart },
|
||||||
|
.hw_def = port->hw_def,
|
||||||
|
.set_inverted = nullptr,
|
||||||
};
|
};
|
||||||
modulePortConfigExtra(&mod_port);
|
modulePortConfigExtra(&mod_port);
|
||||||
state->mode = mode;
|
state->mode = mode;
|
||||||
|
|||||||
@@ -193,6 +193,10 @@ if(IMU_LSM6DS33)
|
|||||||
set(AUX_SERIAL OFF)
|
set(AUX_SERIAL OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(AUX_SERIAL)
|
||||||
|
add_definitions(-DCONFIGURABLE_MODULE_PORT)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(NOT INTERNAL_MODULE_PXX1)
|
if(NOT INTERNAL_MODULE_PXX1)
|
||||||
option(ALLOW_TRAINER_MULTI "Allow multimodule to be use as trainer input" OFF)
|
option(ALLOW_TRAINER_MULTI "Allow multimodule to be use as trainer input" OFF)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
Reference in New Issue
Block a user