This commit is contained in:
Raphael Coeffic
2022-03-20 16:22:14 +01:00
parent da59fca1bc
commit 530d395204
66 changed files with 1267 additions and 1081 deletions
-11
View File
@@ -245,16 +245,6 @@ if(BLUETOOTH)
add_definitions(-DHARDWARE_TRAINER_BLUETOOTH)
endif()
if (AUX_SERIAL)
add_definitions(-DAUX_SERIAL)
set(AUX_SERIAL_DRIVER ../common/arm/stm32/aux_serial_driver.cpp)
endif()
if (AUX2_SERIAL)
add_definitions(-DAUX2_SERIAL)
set(AUX_SERIAL_DRIVER ../common/arm/stm32/aux_serial_driver.cpp)
endif()
if (SBUS_TRAINER)
add_definitions(-DSBUS_TRAINER)
set(SRC
@@ -266,7 +256,6 @@ endif()
set(FIRMWARE_TARGET_SRC
${FIRMWARE_TARGET_SRC}
${LCD_DRIVER}
${AUX_SERIAL_DRIVER}
${FLYSKY_HALL_STICKS_DRIVER}
${IMU_LSM6DS33_DRIVER}
${TOUCH_DRIVER}
+72 -32
View File
@@ -19,13 +19,21 @@
* GNU General Public License for more details.
*/
#include "stm32_hal_ll.h"
#include "opentx.h"
#include "hal/adc_driver.h"
#include "../common/arm/stm32/timers_driver.h"
#include "hal/serial_driver.h"
#include "hal/serial_port.h"
#include "timers_driver.h"
#if defined(AUX_SERIAL) || defined(AUX2_SERIAL)
#include "aux_serial_driver.h"
#endif
#if !defined(PCBX12S)
#include "../common/arm/stm32/stm32_hal_adc.h"
#include "stm32_hal_adc.h"
#define ADC_DRIVER stm32_hal_adc_driver
#else
#include "x12s_adc_driver.h"
@@ -58,30 +66,6 @@ void watchdogInit(unsigned int duration)
IWDG->KR = 0xCCCC; // start
}
#if defined(AUX_SERIAL_PWR_GPIO)
void auxSerialPowerOn()
{
GPIO_SetBits(AUX_SERIAL_PWR_GPIO, AUX_SERIAL_PWR_GPIO_PIN);
}
void auxSerialPowerOff()
{
GPIO_ResetBits(AUX_SERIAL_PWR_GPIO, AUX_SERIAL_PWR_GPIO_PIN);
}
#endif
#if defined(AUX2_SERIAL_PWR_GPIO)
void aux2SerialPowerOn()
{
GPIO_SetBits(AUX2_SERIAL_PWR_GPIO, AUX2_SERIAL_PWR_GPIO_PIN);
}
void aux2SerialPowerOff()
{
GPIO_ResetBits(AUX2_SERIAL_PWR_GPIO, AUX2_SERIAL_PWR_GPIO_PIN);
}
#endif
#if HAS_SPORT_UPDATE_CONNECTOR()
void sportUpdateInit()
{
@@ -193,12 +177,7 @@ void boardInit()
__enable_irq();
#if defined(DEBUG) && defined(AUX_SERIAL)
auxSerialInit(UART_MODE_DEBUG, 0); // default serial mode (None if DEBUG not defined)
#endif
#if defined(DEBUG) && defined(AUX2_SERIAL)
aux2SerialInit(UART_MODE_DEBUG, 0); // default serial mode (None if DEBUG not defined)
#endif
initSerialPorts();
TRACE("\nHorus board started :)");
TRACE("RCC->CSR = %08x", RCC->CSR);
@@ -359,3 +338,64 @@ bool isBacklightEnabled()
return true;
return boardBacklightOn;
}
static void _aux_pwr(GPIO_TypeDef *GPIOx, uint32_t pin, uint8_t on)
{
LL_GPIO_InitTypeDef pinInit;
LL_GPIO_StructInit(&pinInit);
pinInit.Pin = pin;
pinInit.Mode = LL_GPIO_MODE_OUTPUT;
pinInit.Pull = LL_GPIO_PULL_UP;
LL_GPIO_Init(GPIOx, &pinInit);
if (on) {
LL_GPIO_SetOutputPin(GPIOx, pin);
} else {
LL_GPIO_ResetOutputPin(GPIOx, pin);
}
}
#if defined(AUX_SERIAL)
void set_aux_pwr(uint8_t on)
{
#if defined(AUX_SERIAL_PWR_GPIO)
_aux_pwr(AUX_SERIAL_PWR_GPIO, AUX_SERIAL_PWR_GPIO_PIN, on);
#endif
}
const etx_serial_port_t auxSerialPort = {
&AuxSerialDriver,
set_aux_pwr,
};
#define AUX_SERIAL_PORT &auxSerialPort
#else
#define AUX_SERIAL_PORT nullptr
#endif
#if defined(AUX2_SERIAL)
void set_aux2_pwr(uint8_t on)
{
#if defined(AUX2_SERIAL_PWR_GPIO)
_aux_pwr(AUX2_SERIAL_PWR_GPIO, AUX2_SERIAL_PWR_GPIO_PIN, on);
#endif
}
const etx_serial_port_t aux2SerialPort = {
&Aux2SerialDriver,
set_aux2_pwr,
};
#define AUX2_SERIAL_PORT &aux2SerialPort
#else
#define AUX2_SERIAL_PORT nullptr
#endif // AUX2_SERIAL
static const etx_serial_port_t* serialPorts[MAX_AUX_SERIAL] = {
AUX_SERIAL_PORT,
AUX2_SERIAL_PORT,
};
const etx_serial_port_t* auxSerialGetPort(int port_nr)
{
if (port_nr >= MAX_AUX_SERIAL) return nullptr;
return serialPorts[port_nr];
}
+3 -39
View File
@@ -26,6 +26,7 @@
#include "opentx_constants.h"
#include "board_common.h"
#include "hal.h"
#include "hal/serial_port.h"
#include "watchdog_driver.h"
@@ -198,9 +199,6 @@ void stop_trainer_ppm();
void init_trainer_capture();
void stop_trainer_capture();
// SBUS
int sbusGetByte(uint8_t * byte);
// Keys driver
enum EnumKeys
{
@@ -623,7 +621,7 @@ void telemetryPortSetDirectionInput();
void telemetryPortSetDirectionOutput();
void sportSendByte(uint8_t byte);
void sportSendBuffer(const uint8_t * buffer, uint32_t count);
bool telemetryGetByte(uint8_t * byte);
bool sportGetByte(uint8_t * byte);
void telemetryClearFifo();
extern uint32_t telemetryErrors;
@@ -654,32 +652,8 @@ void sportUpdatePowerInit();
#define DEBUG_BAUDRATE 115200
#define LUA_DEFAULT_BAUDRATE 115200
#endif
#if defined(AUX_SERIAL)
#define auxSerialTelemetryInit(protocol) auxSerialInit(UART_MODE_TELEMETRY, protocol)
void auxSerialPowerOn();
void auxSerialPowerOff();
#if defined(AUX_SERIAL_PWR_GPIO)
#define AUX_SERIAL_POWER_ON() auxSerialPowerOn()
#define AUX_SERIAL_POWER_OFF() auxSerialPowerOff()
#else
#define AUX_SERIAL_POWER_ON()
#define AUX_SERIAL_POWER_OFF()
#endif
#endif
// Aux2 serial port driver
#if defined(AUX2_SERIAL)
#define aux2SerialTelemetryInit(protocol) aux2SerialInit(UART_MODE_TELEMETRY, protocol)
void aux2SerialPowerOn();
void aux2SerialPowerOff();
#if defined(AUX2_SERIAL_PWR_GPIO)
#define AUX2_SERIAL_POWER_ON() aux2SerialPowerOn()
#define AUX2_SERIAL_POWER_OFF() aux2SerialPowerOff()
#else
#define AUX2_SERIAL_POWER_ON()
#define AUX2_SERIAL_POWER_OFF()
#endif
#endif
const etx_serial_port_t* auxSerialGetPort(int port_nr);
// Haptic driver
void hapticInit();
@@ -711,14 +685,4 @@ void bluetoothWriteWakeup();
uint8_t bluetoothIsWriting();
void bluetoothDisable();
#if defined(__cplusplus)
#include "fifo.h"
#include "dmafifo.h"
extern DMAFifo<512> telemetryFifo;
typedef DMAFifo<32> AuxSerialRxFifo;
extern AuxSerialRxFifo auxSerialRxFifo;
extern AuxSerialRxFifo aux2SerialRxFifo;
extern volatile uint32_t externalModulePort;
#endif
#endif // _BOARD_H_
@@ -22,6 +22,9 @@
#include "opentx.h"
#include "flyskyHallStick_driver.h"
#include "fifo.h"
#include "dmafifo.h"
DMAFifo<HALLSTICK_BUFF_SIZE> hallDMAFifo __DMA (FLYSKY_HALL_DMA_Stream_RX);
Fifo<uint8_t, HALLSTICK_BUFF_SIZE> hallStickTxFifo;
unsigned char HallCmd[264] __DMA;
+4 -1
View File
@@ -21,6 +21,9 @@
#include "opentx.h"
#include "fifo.h"
#include "dmafifo.h"
Fifo<uint8_t, TELEMETRY_FIFO_SIZE> telemetryNoDMAFifo;
uint32_t telemetryErrors = 0;
@@ -415,7 +418,7 @@ extern "C" void TELEMETRY_TIMER_IRQHandler()
}
// TODO we should have telemetry in an higher layer, functions above should move to a sport_driver.cpp
bool telemetryGetByte(uint8_t * byte)
bool sportGetByte(uint8_t * byte)
{
#if defined(PCBX12S)
if (telemetryFifoMode & TELEMETRY_SERIAL_WITHOUT_DMA)
@@ -142,22 +142,3 @@ extern "C" void TRAINER_TIMER_IRQHandler()
}
}
}
int sbusGetByte(uint8_t * byte)
{
switch (currentTrainerMode) {
#if defined(AUX_SERIAL) || defined(AUX2_SERIAL)
case TRAINER_MODE_MASTER_BATTERY_COMPARTMENT:
#if defined(AUX_SERIAL)
if (auxSerialMode == UART_MODE_SBUS_TRAINER)
return auxSerialRxFifo.pop(*byte);
#endif
#if defined(AUX2_SERIAL)
if (aux2SerialMode == UART_MODE_SBUS_TRAINER)
return aux2SerialRxFifo.pop(*byte);
#endif
#endif
default:
return false;
}
}