Asym ghost support (#7910)

This commit is contained in:
3djc
2020-09-05 08:24:07 +02:00
committed by GitHub
parent 7f5dc552ef
commit 159a891ab4
10 changed files with 64 additions and 16 deletions
+5 -1
View File
@@ -39,7 +39,11 @@ uint8_t createGhostChannelsFrame(uint8_t * frame, int16_t * pulses)
}
uint8_t * buf = frame;
*buf++ = GHST_ADDR_MODULE;
#if SPORT_MAX_BAUDRATE < 400000
*buf++ = g_eeGeneral.telemetryBaudrate == GHST_TELEMETRY_RATE_400K ? GHST_ADDR_MODULE_SYM : GHST_ADDR_MODULE_ASYM;
#else
*buf++ = GHST_ADDR_MODULE_SYM;
#endif
*buf++ = GHST_UL_RC_CHANS_SIZE;
uint8_t * crc_start = buf;
*buf++ = lastGhostFrameId;
@@ -14,7 +14,6 @@ option(PPM "PPM TX Module" ON)
option(DSM2 "DSM2 TX Module" ON)
option(SBUS "SBUS TX Module" ON)
option(CROSSFIRE "Crossfire TX Module" ON)
option(GHOST "Ghost TX Module" ON)
option(MULTIMODULE "DIY Multiprotocol TX Module (https://github.com/pascallanger/DIY-Multiprotocol-TX-Module)" ON)
option(DEBUG_INTERRUPTS "Count interrupts" OFF)
option(DEBUG_LATENCY "Debug latency" OFF)
+1
View File
@@ -4,6 +4,7 @@ option(PXX1 "PXX1 protocol support" ON)
option(PXX2 "PXX2 protocol support" OFF)
option(AFHDS3 "AFHDS3 TX Module" ON)
option(MULTIMODULE "DIY Multiprotocol TX Module (https://github.com/pascallanger/DIY-Multiprotocol-TX-Module)" ON)
option(GHOST "Ghost TX Module" ON)
set(PWR_BUTTON "PRESS" CACHE STRING "Pwr button type (PRESS/SWITCH)")
set(CPU_TYPE STM32F4)
@@ -240,6 +240,11 @@ void telemetryPortInvertedRxBit()
void telemetryPortSetDirectionOutput()
{
#if defined(GHOST) && SPORT_MAX_BAUDRATE < 400000
if (isModuleGhost(EXTERNAL_MODULE)) {
TELEMETRY_USART->BRR = BRR_400K;
}
#endif
TELEMETRY_DIR_GPIO->BSRRL = TELEMETRY_DIR_GPIO_PIN; // output enable
TELEMETRY_USART->CR1 &= ~USART_CR1_RE; // turn off receiver
}
@@ -252,6 +257,11 @@ void sportWaitTransmissionComplete()
void telemetryPortSetDirectionInput()
{
sportWaitTransmissionComplete();
#if defined(GHOST) && SPORT_MAX_BAUDRATE < 400000
if (isModuleGhost(EXTERNAL_MODULE) && g_eeGeneral.telemetryBaudrate == GHST_TELEMETRY_RATE_115K) {
TELEMETRY_USART->BRR = BRR_115K;
}
#endif
TELEMETRY_DIR_GPIO->BSRRH = TELEMETRY_DIR_GPIO_PIN; // output disable
TELEMETRY_USART->CR1 |= USART_CR1_RE; // turn on receiver
}
+1
View File
@@ -11,6 +11,7 @@ set(RADIO_DEPENDENCIES ${RADIO_DEPENDENCIES} 9x_bitmaps)
set(PPM_LIMITS_SYMETRICAL YES)
set(PXX1 YES)
set(AFHDS3 NO)
set(GHOST NO)
add_definitions(-DDISABLE_MULTI_UPDATE)
if(PCB STREQUAL 9XRPRO)
+1
View File
@@ -3,6 +3,7 @@ option(LCD_DUAL_BUFFER "Dual LCD Buffer" OFF)
option(PXX1 "PXX1 protocol support" ON)
option(PXX2 "PXX2 protocol support" OFF)
option(AFHDS3 "AFHDS3 TX Module" OFF)
option(GHOST "Ghost TX Module" ON)
option(INTERNAL_MODULE_PPM "Support for PPM internal module" OFF)
option(AUTOUPDATE "Auto update internal chips from SD" OFF)
@@ -203,6 +203,11 @@ void telemetryPortInvertedRxBit()
void telemetryPortSetDirectionOutput()
{
#if defined(GHOST) && SPORT_MAX_BAUDRATE < 400000
if (isModuleGhost(EXTERNAL_MODULE)) {
TELEMETRY_USART->BRR = BRR_400K;
}
#endif
TELEMETRY_DIR_OUTPUT();
TELEMETRY_USART->CR1 &= ~USART_CR1_RE; // turn off receiver
}
@@ -215,6 +220,11 @@ void sportWaitTransmissionComplete()
void telemetryPortSetDirectionInput()
{
sportWaitTransmissionComplete();
#if defined(GHOST) && SPORT_MAX_BAUDRATE < 400000
if (isModuleGhost(EXTERNAL_MODULE) && g_eeGeneral.telemetryBaudrate == GHST_TELEMETRY_RATE_115K) {
TELEMETRY_USART->BRR = BRR_115K;
}
#endif
TELEMETRY_DIR_INPUT();
TELEMETRY_USART->CR1 |= USART_CR1_RE; // turn on receiver
}
+22
View File
@@ -125,6 +125,11 @@ void processGhostTelemetryFrame()
switch(id) {
case GHST_DL_LINK_STAT:
{
#if defined(BLUETOOTH)
if (g_eeGeneral.bluetoothMode == BLUETOOTH_TELEMETRY && bluetooth.state == BLUETOOTH_STATE_CONNECTED) {
bluetooth.write(telemetryRxBuffer, telemetryRxBufferCount);
}
#endif
uint8_t rssiVal = min<uint8_t>(telemetryRxBuffer[3], 100);
uint8_t lqVal = min<uint8_t>(telemetryRxBuffer[4], 100);
uint8_t snrVal = min<uint8_t>(telemetryRxBuffer[5], 100);
@@ -157,6 +162,11 @@ void processGhostTelemetryFrame()
case GHST_DL_VTX_STAT:
{
#if defined(BLUETOOTH)
if (g_eeGeneral.bluetoothMode == BLUETOOTH_TELEMETRY && bluetooth.state == BLUETOOTH_STATE_CONNECTED) {
bluetooth.write(telemetryRxBuffer, telemetryRxBufferCount);
}
#endif
uint8_t vtxBandEnum = min<uint8_t>(telemetryRxBuffer[8], GHST_VTX_BAND_MAX);
const GhostSensor * sensor = getGhostSensor(GHOST_ID_VTX_BAND);
@@ -173,6 +183,18 @@ void processGhostTelemetryFrame()
void processGhostTelemetryData(uint8_t data)
{
#if defined(AUX_SERIAL)
if (g_eeGeneral.auxSerialMode == UART_MODE_TELEMETRY_MIRROR) {
auxSerialPutc(data);
}
#endif
#if defined(AUX2_SERIAL)
if (g_eeGeneral.aux2SerialMode == UART_MODE_TELEMETRY_MIRROR) {
aux2SerialPutc(data);
}
#endif
if (telemetryRxBufferCount == 0 && data != GHST_ADDR_RADIO) {
TRACE("[GH] address 0x%02X error", data);
return;
+11 -12
View File
@@ -26,7 +26,8 @@
// Device (destination) address
#define GHST_ADDR_RADIO 0x80 // phase 1
#define GHST_ADDR_MODULE 0x81
#define GHST_ADDR_MODULE_SYM 0x81 // symmetrical, 400k pulses, 400k telemetry
#define GHST_ADDR_MODULE_ASYM 0x88 // asymmetrical, 400k pulses, 115k telemetry
#define GHST_ADDR_FC 0x82
#define GHST_ADDR_GOGGLES 0x83 // phase 2
#define GHST_ADDR_5G_TXCTRL 0x84 // phase 3
@@ -96,19 +97,17 @@ void ghostSetDefault(int index, uint8_t id, uint8_t subId);
#if SPORT_MAX_BAUDRATE < 400000
// For radios which can't support telemetry at high rates, offer baud rate choices
// (modified vs. unmodified radios)
const uint32_t GHOST_BAUDRATES[] = {
400000,
115200,
constexpr uint16_t BRR_400K = PERI1_FREQUENCY / 400000;
constexpr uint16_t BRR_115K = PERI1_FREQUENCY / 115200;
enum GhostTelemetryBaudrates
{
GHST_TELEMETRY_RATE_400K,
GHST_TELEMETRY_RATE_115K
};
const uint8_t GHOST_PERIODS[] = {
4,
16,
};
#define GHOST_BAUDRATE GHOST_BAUDRATES[g_eeGeneral.telemetryBaudrate]
#define GHOST_PERIOD GHOST_PERIODS[g_eeGeneral.telemetryBaudrate]
#else
#endif
#define GHOST_BAUDRATE 400000
#define GHOST_PERIOD 4
#endif
#endif // _GHOST_H_
+3 -2
View File
@@ -23,10 +23,11 @@
#include "frsky.h"
#include "crossfire.h"
#include "ghost.h"
#include "myeeprom.h"
#include "io/frsky_sport.h"
#if defined(GHOST)
#include "ghost.h"
#endif
#if defined(MULTIMODULE)
#include "spektrum.h"
#include "hitec.h"