WiP PoC AFHDS3 internal module

This commit is contained in:
Raphael Coeffic
2022-08-11 12:15:46 +02:00
committed by Raphael Coeffic
parent 5132e11d41
commit bb6c6d6e2d
30 changed files with 1313 additions and 990 deletions
+5 -19
View File
@@ -510,26 +510,12 @@ PACK(struct ModuleData {
rx_freq[1] = 0;
}
} flysky);
NOBACKUP(PACK(struct {
uint8_t bindPower:3;
uint8_t runPower:3;
uint8_t emi:1;
NOBACKUP(struct {
uint8_t emi:2;
uint8_t telemetry:1;
uint16_t failsafeTimeout;
uint8_t rx_freq[2];
uint8_t mode:2;
uint8_t reserved:6;
uint16_t rxFreq()
{
return (uint16_t)rx_freq[0] | (((uint16_t)rx_freq[1]) << 8);
}
void setRxFreq(uint16_t value)
{
rx_freq[0] = value & 0xFF;
rx_freq[1] = value >> 8;
}
} afhds3));
uint8_t phyMode:3;
uint8_t reserved:2;
} afhds3);
NOBACKUP(struct {
uint8_t raw12bits:1;
uint8_t telemetryBaudrate:3;
+58 -45
View File
@@ -23,9 +23,22 @@
#include "opentx.h"
#include "pulses/flysky.h"
#include "pulses/afhds3.h"
#define SET_DIRTY() storageDirty(EE_MODEL)
static const char* _afhds3_region[] = { "CE", "FCC" };
static const char* _afhds3_phy_mode[] = {
// V0
"Classic 18ch",
"Classic 10ch",
// V1
"Routine 18ch",
"Fast 8ch",
"Lora 12ch",
};
class FSProtoOpts : public FormGroup
{
std::function<uint8_t()> _getMode;
@@ -104,19 +117,6 @@ void FlySkySettings::update()
#endif
#if defined(AFHDS3)
if (isModuleAFHDS3(moduleIdx)) {
new FSProtoOpts(
line, [=]() { return md->afhds3.mode; },
[=](uint8_t v) { md->afhds3.mode = v; });
// TYPE
line = newLine(&grid);
new StaticText(line, rect_t{}, STR_TYPE, 0, COLOR_THEME_PRIMARY1);
// This is chosen when binding (menu? see stdlcd/model_setup_afhds3.cpp)
new StaticText(line, rect_t{},
md->afhds3.telemetry ? STR_AFHDS3_ONE_TO_ONE_TELEMETRY
: TR_AFHDS3_ONE_TO_MANY,
0, COLOR_THEME_PRIMARY1);
// Status
line = newLine(&grid);
@@ -127,42 +127,55 @@ void FlySkySettings::update()
return std::string(msg);
});
// Power source
// TYPE
line = newLine(&grid);
new StaticText(line, rect_t{}, STR_AFHDS3_POWER_SOURCE, 0,
COLOR_THEME_PRIMARY1);
new DynamicText(line, rect_t{}, [=] {
char msg[64] = "";
getModuleSyncStatusString(moduleIdx, msg);
return std::string(msg);
});
new StaticText(line, rect_t{}, STR_TYPE, 0, COLOR_THEME_PRIMARY1);
// RX Freq
line = newLine(&grid);
new StaticText(line, rect_t{}, STR_AFHDS3_RX_FREQ, 0, COLOR_THEME_PRIMARY1);
auto edit = new NumberEdit(line, rect_t{}, MIN_FREQ, MAX_FREQ,
GET_DEFAULT(md->afhds3.rxFreq()));
edit->setSetValueHandler(
[=](int32_t newValue) { md->afhds3.setRxFreq((uint16_t)newValue); });
edit->setSuffix(STR_HZ);
auto box = new FormGroup(line, rect_t{});
box->setFlexLayout(LV_FLEX_FLOW_ROW);
// Module actual power
line = newLine(&grid);
new StaticText(line, rect_t{}, STR_AFHDS3_ACTUAL_POWER, 0,
COLOR_THEME_PRIMARY1);
new DynamicText(line, rect_t{}, [=] {
char msg[64] = "";
getStringAtIndex(msg, STR_AFHDS3_POWERS, actualAfhdsRunPower(moduleIdx));
return std::string(msg);
});
new Choice(box, rect_t{}, _afhds3_region, 1, afhds3::LNK_ES_FCC,
GET_SET_DEFAULT(md->afhds3.emi));
// Module power
line = newLine(&grid);
new StaticText(line, rect_t{}, STR_RF_POWER, 0, COLOR_THEME_PRIMARY1);
new Choice(line, rect_t{}, STR_AFHDS3_POWERS,
afhds3::RUN_POWER::RUN_POWER_FIRST,
afhds3::RUN_POWER::RUN_POWER_LAST,
GET_SET_DEFAULT(md->afhds3.runPower));
new Choice(box, rect_t{}, _afhds3_phy_mode, 0, afhds3::PHYMODE_MAX,
GET_SET_DEFAULT(md->afhds3.phyMode));
// // Power source
// line = newLine(&grid);
// new StaticText(line, rect_t{}, STR_AFHDS3_POWER_SOURCE, 0,
// COLOR_THEME_PRIMARY1);
// new DynamicText(line, rect_t{}, [=] {
// char msg[64] = "";
// getModuleSyncStatusString(moduleIdx, msg);
// return std::string(msg);
// });
// // RX Freq
// line = newLine(&grid);
// new StaticText(line, rect_t{}, STR_AFHDS3_RX_FREQ, 0, COLOR_THEME_PRIMARY1);
// auto edit = new NumberEdit(line, rect_t{}, AFHDS3_MIN_FREQ, AFHDS3_MAX_FREQ,
// GET_DEFAULT(md->afhds3.rxFreq()));
// edit->setSetValueHandler(
// [=](int32_t newValue) { md->afhds3.setRxFreq((uint16_t)newValue); });
// edit->setSuffix(STR_HZ);
// // Module actual power
// line = newLine(&grid);
// new StaticText(line, rect_t{}, STR_AFHDS3_ACTUAL_POWER, 0,
// COLOR_THEME_PRIMARY1);
// new DynamicText(line, rect_t{}, [=] {
// char msg[64] = "";
// getStringAtIndex(msg, STR_AFHDS3_POWERS, actualAfhdsRunPower(moduleIdx));
// return std::string(msg);
// });
// // Module power
// line = newLine(&grid);
// new StaticText(line, rect_t{}, STR_RF_POWER, 0, COLOR_THEME_PRIMARY1);
// new Choice(line, rect_t{}, STR_AFHDS3_POWERS,
// afhds3::RUN_POWER::RUN_POWER_FIRST,
// afhds3::RUN_POWER::RUN_POWER_LAST,
// GET_SET_DEFAULT(md->afhds3.runPower));
}
#endif
}
File diff suppressed because it is too large Load Diff
+37 -547
View File
@@ -32,260 +32,50 @@
#include "fifo.h"
#include "hal/module_driver.h"
#include "afhds3_transport.h"
#define AFHDS_MAX_PULSES 72
//max number of transitions measured so far 290 + 10%
#define AFHDS_MAX_PULSES_TRANSITIONS 320
//#define AFHDS3_SLOW
#define AFHDS3_MIN_FREQ 50
#define AFHDS3_MAX_FREQ 400
#define AFHDS3_MAX_CHANNELS 18
#define AFHDS3_FAILSAFE_MIN -15000
#define AFHDS3_FAILSAFE_MAX 15000
#if defined(EXTMODULE_USART) && defined(EXTMODULE_TX_INVERT_GPIO)
#define AFHDS3_BAUDRATE 1500000
#define AFHDS3_COMMAND_TIMEOUT 5
#elif !defined(AFHDS3_SLOW)
// 1s = 1 000 000 us
// 1000000/115200 = 8,68 us
// actual timer is ticking in 0,5 us = 8,68*2 = 17,36 because it must be integer take 17
// difference 1000000 / x = 8.5 --> x = 117 647 = difference = 1.2 %
// allowed half a bit difference on the last bit -- should be fine
#define AFHDS3_BAUDRATE 115200
//Because timer is ticking with 0.5us
#define BITLEN_AFHDS (17)
#define AFHDS3_COMMAND_TIMEOUT 15
#else
// 1000000/57600 = 17,36 us
#define AFHDS3_BAUDRATE 57600
// 64* 86 = 11 110
#define AFHDS3_COMMAND_TIMEOUT 20
#define BITLEN_AFHDS (35)
#endif
#define AFHDS3_FRAME_HALF_US AFHDS3_COMMAND_TIMEOUT * 2000
//get channel value outside of afhds3 namespace
int32_t getChannelValue(uint8_t channel);
//use uint16_t instead of pulse_duration_t
namespace afhds3
{
enum AfhdsSpecialChars
{
END = 0xC0, //Frame end
START = END,
ESC_END = 0xDC, //Escaped frame end - in case END occurs in fame then ESC ESC_END must be used
ESC = 0xDB, //Escaping character
ESC_ESC = 0xDD, //Escaping character in case ESC occurs in fame then ESC ESC_ESC must be used
enum eLNK_EMIStandard {
LNK_ES_FREE = 0,
LNK_ES_CE,
LNK_ES_FCC,
};
struct Data
{
#if defined(EXTMODULE_USART) && defined(EXTMODULE_TX_INVERT_GPIO)
uint8_t pulses[AFHDS_MAX_PULSES];
uint8_t * ptr;
enum eDATA_PHYMODE {
// V0
CLASSIC_FLCR1_18CH=0,
CLASSIC_FLCR6_10CH,
// V1
ROUTINE_FLCR1_18CH,
ROUTINE_FLCR6_8CH,
ROUTINE_LORA_12CH,
// must be last
PHYMODE_MAX = ROUTINE_LORA_12CH
};
#if defined(AFHDS3_EXT_UART)
typedef SerialData ExtmoduleData;
#else
uint32_t pulsesSize;
uint16_t pulses[AFHDS_MAX_PULSES_TRANSITIONS];
uint32_t total;
typedef PulsesData ExtmoduleData;
#endif
uint8_t frame_index;
uint8_t crc;
uint8_t state;
uint8_t timeout;
uint8_t esc_state;
void reset()
{
#if defined(EXTMODULE_USART) && defined(EXTMODULE_TX_INVERT_GPIO)
ptr = pulses;
#else
pulsesSize = 0;
#endif
}
#if defined(EXTMODULE_USART) && defined(EXTMODULE_TX_INVERT_GPIO)
void sendByte(uint8_t b)
{
#if !defined(SIMU)
*ptr++ = b;
#endif
}
const uint8_t* getData()
{
return pulses;
}
void flush()
{
}
#else
inline void _send_level(uint16_t v)
{
if (pulsesSize >= AFHDS_MAX_PULSES_TRANSITIONS) {
return;
}
pulses[pulsesSize++] = v;
}
void sendByte(uint8_t b)
{
if (pulsesSize >= AFHDS_MAX_PULSES_TRANSITIONS) {
return;
}
//use 8n1
//parity: If the parity is enabled, then the MSB bit of the data to be transmitted is changed by the parity bit
//start is always 0
bool level = 0;
uint16_t length = BITLEN_AFHDS; //start bit
for (uint8_t i = 0; i <= 8; i++)
{ //8 data bits + Stop=1
bool next_level = b & 1;
if (level == next_level) {
length += BITLEN_AFHDS;
}
else {
_send_level(length);
length = BITLEN_AFHDS;
level = next_level;
}
b = (b >> 1) | 0x80; // shift left to get next bit, fill msb with stop bit - needed just once
}
_send_level(length); //last bit (stop)
}
//add remaining time of frame
void flush()
{
pulses[pulsesSize - 1] = 60000;
}
const uint16_t * getData()
{
return pulses;
}
#if defined(INTERNAL_MODULE_AFHDS3)
typedef SerialData IntmoduleData;
#endif
uint32_t getSize() const
{
#if defined(EXTMODULE_USART) && defined(EXTMODULE_TX_INVERT_GPIO)
return ptr - pulses;
#else
return pulsesSize;
extern etx_module_driver_t externalDriver;
#if defined(INTERNAL_MODULE_AFHDS3)
extern etx_module_driver_t internalDriver;
#endif
}
};
enum DeviceAddress
{
TRANSMITTER = 0x01,
MODULE = 0x03,
};
enum FRAME_TYPE: uint8_t
{
REQUEST_GET_DATA = 0x01, //Get data response: ACK + DATA
REQUEST_SET_EXPECT_DATA = 0x02, //Set data response: ACK + DATA
REQUEST_SET_EXPECT_ACK = 0x03, //Set data response: ACK
REQUEST_SET_NO_RESP = 0x05, //Set data response: none
RESPONSE_DATA = 0x10, //Response ACK + DATA
RESPONSE_ACK = 0x20, //Response ACK
NOT_USED = 0xff
};
enum COMMAND: uint8_t
{
MODULE_READY = 0x01,
MODULE_STATE = 0x02,
MODULE_MODE = 0x03,
MODULE_SET_CONFIG = 0x04,
MODULE_GET_CONFIG = 0x06,
CHANNELS_FAILSAFE_DATA = 0x07,
TELEMETRY_DATA = 0x09,
SEND_COMMAND = 0x0C,
COMMAND_RESULT = 0x0D,
MODULE_POWER_STATUS = 0x0F,
MODULE_VERSION = 0x1F,
VIRTUAL_FAILSAFE = 0x99, // virtual command used to trigger failsafe
UNDEFINED = 0xFF
};
enum COMMAND_DIRECTION
{
RADIO_TO_MODULE = 0,
MODULE_TO_RADIO = 1
};
enum DATA_TYPE
{
READY_DT, // 8 bytes 0x01 Not ready 0x02 Ready
STATE_DT, // See MODULE_STATE
MODE_DT,
MOD_CONFIG_DT,
CHANNELS_DT,
TELEMETRY_DT,
MODULE_POWER_DT,
MODULE_VERSION_DT,
EMPTY_DT,
};
//enum used by command response -> translate to ModuleState
enum MODULE_READY_E
{
MODULE_STATUS_UNKNOWN = 0x00,
MODULE_STATUS_NOT_READY = 0x01,
MODULE_STATUS_READY = 0x02
};
enum ModuleState
{
STATE_NOT_READY = 0x00, //virtual
STATE_HW_ERROR = 0x01,
STATE_BINDING = 0x02,
STATE_SYNC_RUNNING = 0x03,
STATE_SYNC_DONE = 0x04,
STATE_STANDBY = 0x05,
STATE_UPDATING_WAIT = 0x06,
STATE_UPDATING_MOD = 0x07,
STATE_UPDATING_RX = 0x08,
STATE_UPDATING_RX_FAILED = 0x09,
STATE_RF_TESTING = 0x0a,
STATE_READY = 0x0b, //virtual
STATE_HW_TEST = 0xff,
};
//used for set command
enum MODULE_MODE_E
{
STANDBY = 0x01,
BIND = 0x02, //after bind module will enter run mode
RUN = 0x03,
RX_UPDATE = 0x04, //after successful update module will enter standby mode, otherwise hw error will be raised
MODULE_MODE_UNKNOWN = 0xFF
};
enum CMD_RESULT
{
FAILURE = 0x01,
SUCCESS = 0x02,
};
#define MIN_FREQ 50
#define MAX_FREQ 400
#define MAX_CHANNELS 18
#define FAILSAFE_KEEP_LAST 0x8000
#define FAILSAFE_MIN -15000
#define FAILSAFE_MAX 15000
enum BIND_POWER
{
MIN_16dBm = 0x00,
BIND_POWER_FIRST = MIN_16dBm,
MIN_5dBm = 0x01,
MIN_0dbm = 0x02,
PLUS_5dBm = 0x03,
PLUS_14dBm = 0x04,
BIND_POWER_LAST = PLUS_14dBm,
};
enum RUN_POWER
{
@@ -298,311 +88,11 @@ enum RUN_POWER
RUN_POWER_LAST = PLUS_33dBm,
};
enum EMI_STANDARD
{
FCC = 0x00,
CE = 0x01
};
void getStatusString(uint8_t module, char* buffer);
void getPowerStatus(uint8_t module, char* buffer);
enum TELEMETRY
{
TELEMETRY_DISABLED = 0x00,
TELEMETRY_ENABLED = 0x01
};
RUN_POWER getActualRunPower(uint8_t module);
enum PULSE_MODE
{
PWM_MODE = 0x00,
PPM_MODE = 0x01,
};
enum SERIAL_MODE
{
IBUS = 0x00,
SBUS_MODE = 0x02
};
PACK(struct Config_s {
uint8_t bindPower;
uint8_t runPower;
uint8_t emiStandard;
uint8_t telemetry;
uint16_t pwmFreq;
uint8_t pulseMode;
uint8_t serialMode;
uint8_t channelCount;
uint16_t failSafeTimout;
int16_t failSafeMode[MAX_CHANNELS];
});
union Config_u
{
Config_s config;
uint8_t buffer[sizeof(Config_s)];
};
enum CHANNELS_DATA_MODE
{
CHANNELS = 0x01,
FAIL_SAFE = 0x02,
};
PACK(struct ChannelsData {
uint8_t mode;
uint8_t channelsNumber;
int16_t data[MAX_CHANNELS];
});
union ChannelsData_u
{
ChannelsData data;
uint8_t buffer[sizeof(ChannelsData)];
};
PACK(struct TelemetryData
{
uint8_t sensorType;
uint8_t length;
uint8_t type;
uint8_t semsorID;
uint8_t data[8];
});
enum MODULE_POWER_SOURCE
{
INTERNAL = 0x01,
EXTERNAL = 0x02,
};
PACK(struct ModuleVersion
{
uint32_t productNumber;
uint32_t hardwereVersion;
uint32_t bootloaderVersion;
uint32_t firmwareVersion;
uint32_t rfVersion;
});
PACK(struct CommandResult_s
{
uint16_t command;
uint8_t result;
uint8_t respLen;
});
union AfhdsFrameData
{
uint8_t value;
Config_s Config;
ChannelsData Channels;
TelemetryData Telemetry;
ModuleVersion Version;
CommandResult_s CommandResult;
};
PACK(struct AfhdsFrame
{
uint8_t startByte;
uint8_t address;
uint8_t frameNumber;
uint8_t frameType;
uint8_t command;
uint8_t value;
AfhdsFrameData * GetData()
{
return reinterpret_cast<AfhdsFrameData*>(&value);
}
});
#define FRM302_STATUS 0x56
enum State
{
UNKNOWN = 0,
SENDING_COMMAND,
AWAITING_RESPONSE,
IDLE
};
// one byte frames for request queue
struct Frame
{
enum COMMAND command;
enum FRAME_TYPE frameType;
uint8_t payload;
uint8_t frameNumber;
bool useFrameNumber;
uint8_t payloadSize;
};
// simple fifo implementation because Pulses is used as member of union and can not be non trivial type
struct CommandFifo
{
Frame commandFifo[8];
volatile uint32_t setIndex;
volatile uint32_t getIndex;
void clearCommandFifo();
inline uint32_t nextIndex(uint32_t idx) const
{
return (idx + 1) & (sizeof(commandFifo) / sizeof(commandFifo[0]) - 1);
}
inline uint32_t prevIndex(uint32_t idx) const
{
if (idx == 0)
{
return (sizeof(commandFifo) / sizeof(commandFifo[0]) - 1);
}
return (idx - 1);
}
inline bool isEmpty() const
{
return (getIndex == setIndex);
}
inline void skip()
{
getIndex = nextIndex(getIndex);
}
void enqueueACK(COMMAND command, uint8_t frameNumber);
void enqueue(COMMAND command, FRAME_TYPE frameType, bool useData = false, uint8_t byteContent = 0);
};
void processTelemetryData(uint8_t date, uint8_t module);
class PulsesData: public Data, CommandFifo
{
public:
/**
* Initialize class for operation
* @param moduleIndex index of module one of INTERNAL_MODULE, EXTERNAL_MODULE
* @param resetFrameCount flag if current frame count should be reseted
*/
void init(uint8_t moduleIndex, bool resetFrameCount = true);
/**
* Fills DMA buffers with frame to be send depending on actual state
*/
void setupFrame();
/**
* Gets actual module status into provided buffer
* @param statusText target buffer for status
*/
void getStatusString(char * statusText) const;
/**
* Gets actual power source and voltage
*/
void getPowerStatus(char* buffer) const;
RUN_POWER actualRunPower() const;
/**
* Sends stop command to prevent any further module operations
*/
void stop();
protected:
void setConfigFromModel();
private:
inline void putBytes(uint8_t* data, int length);
inline void putFrame(COMMAND command, FRAME_TYPE frameType, uint8_t* data = nullptr, uint8_t dataLength = 0, uint8_t* frame_index = nullptr);
void parseData(uint8_t* rxBuffer, uint8_t rxBufferCount);
void setState(uint8_t state);
bool syncSettings();
void requestInfoAndRun(bool send = false);
uint8_t setFailSafe(int16_t* target);
inline int16_t convert(int channelValue);
void sendChannelsData();
void clearFrameData();
void processTelemetryData(uint8_t byte, uint8_t* rxBuffer, uint8_t& rxBufferCount, uint8_t maxSize);
//friendship declaration - use for passing telemetry
friend void processTelemetryData(uint8_t data, uint8_t module);
/**
* Returns max power that currently can be set - use it to validate before synchronization of settings
*/
RUN_POWER getMaxRunPower() const;
RUN_POWER getRunPower() const;
bool isConnectedUnicast();
bool isConnectedMulticast();
/**
* Index of the module
*/
uint8_t module_index;
/**
* Target mode to be set to the module one of MODULE_MODE_E
*/
uint8_t requestedModuleMode;
/**
* Internal operation state one of UNKNOWN, SENDING_COMMAND, AWAITING_RESPONSE, IDLE
* Used to avoid sending commands when not allowed to
*/
State operationState;
/**
* Actual repeat count for requested command/operation - incremented by every attempt sending anything
*/
uint16_t repeatCount;
/**
* Command count used for counting actual number of commands sent in run mode
*/
uint32_t cmdCount;
/**
* Command index of command to be send when cmdCount reached necessary value
*/
uint32_t cmdIndex;
/**
* Actual power source of the module - should be requested time to time
* Currently requested once
*/
enum MODULE_POWER_SOURCE powerSource;
/**
* Pointer to module config - it is making operations easier and faster
*/
ModuleData* moduleData;
/**
* Actual module configuration - must be requested from module
*/
Config_u cfg;
/**
* Actual module version - must be requested from module
*/
ModuleVersion version;
};
extern etx_module_driver_t externalDriver;
#if defined(INTERNAL_MODULE_AFHDS3)
extern etx_module_driver_t internalDriver;
#endif
} /* Namespace ahfds3 */
void processTelemetryData(uint8_t data, uint8_t module);
} // namespace afhds3
+128
View File
@@ -0,0 +1,128 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* 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 "afhds3_transport.h"
// timer is 2 MHz
#if defined(AFHDS3_SLOW)
// 1000000/57600 = 17,36 us
#define BITLEN_AFHDS (35)
#else
// 1000000/115200 = 8,68 us
#define BITLEN_AFHDS (17)
#endif
namespace afhds3
{
static void _serial_reset(void* buffer)
{
auto data = (SerialData*)buffer;
data->ptr = data->pulses;
}
static void _serial_sendByte(void* buffer, uint8_t b)
{
auto data = (SerialData*)buffer;
*(data->ptr++) = b;
}
static void _serial_flush(void*) {}
uint32_t _serial_getSize(void* buffer)
{
auto data = (SerialData*)buffer;
return data->ptr - data->pulses;
}
static void _pulses_reset(void* buffer)
{
auto data = (PulsesData*)buffer;
data->ptr = data->pulses;
}
static inline void _pulses_send_level(PulsesData* data, uint16_t v)
{
uint32_t size = data->ptr - data->pulses;
if (size >= AFHDS_MAX_PULSES_TRANSITIONS) return;
*(data->ptr)++ = v;
}
static void _pulses_sendByte(void* buffer, uint8_t b)
{
auto data = (PulsesData*)buffer;
uint32_t size = data->ptr - data->pulses;
if (size >= AFHDS_MAX_PULSES_TRANSITIONS) return;
// use 8n1
// parity: If the parity is enabled, then the MSB bit of the data to be
// transmitted is changed by the parity bit start is always 0
bool level = 0;
uint16_t length = BITLEN_AFHDS; // start bit
for (uint8_t i = 0; i <= 8; i++) { // 8 data bits + Stop=1
bool next_level = b & 1;
if (level == next_level) {
length += BITLEN_AFHDS;
} else {
_pulses_send_level(data, length);
length = BITLEN_AFHDS;
level = next_level;
}
b = (b >> 1) | 0x80; // shift left to get next bit, fill msb with stop
// bit - needed just once
}
_pulses_send_level(data, length); // last bit (stop)
}
static void _pulses_flush(void* buffer)
{
// TODO: use less, as the new driver can handle it
auto data = (PulsesData*)buffer;
*data->ptr = 60000;
}
uint32_t _pulses_getSize(void* buffer)
{
auto data = (PulsesData*)buffer;
return data->ptr - data->pulses;
}
void Transport::init(Type t)
{
if (t == Serial) {
reset = _serial_reset;
sendByte = _serial_sendByte;
flush = _serial_flush;
getSize = _serial_getSize;
} else if (t == Pulses) {
reset = _pulses_reset;
sendByte = _pulses_sendByte;
flush = _pulses_flush;
getSize = _pulses_getSize;
} else {
reset = nullptr;
sendByte = nullptr;
flush = nullptr;
getSize = nullptr;
}
}
};
+88
View File
@@ -0,0 +1,88 @@
/*
* Copyright (C) EdgeTX
*
* Based on code named
* opentx - https://github.com/opentx/opentx
* 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.
*/
#pragma once
#include <stdint.h>
#include "hal.h"
#define AFHDS_MAX_PULSES 128
// max number of transitions measured so far 290 + 10%
// TODO: define as a function of MAX_PULSES
#define AFHDS_MAX_PULSES_TRANSITIONS 320
#if defined(EXTMODULE_USART) && defined(EXTMODULE_TX_INVERT_GPIO)
#define AFHDS3_EXT_UART
#else
#define AFHDS3_EXT_SOFTSERIAL
#endif
#define AFHDS3_UART_BAUDRATE 1500000
#define AFHDS3_UART_COMMAND_TIMEOUT 5
#if defined(AFHDS3_SLOW)
#define AFHDS3_SOFTSERIAL_BAUDRATE 57600
#define AFHDS3_SOFTSERIAL_COMMAND_TIMEOUT 20
#else
#define AFHDS3_SOFTSERIAL_BAUDRATE 115200
#define AFHDS3_SOFTSERIAL_COMMAND_TIMEOUT 15
#endif
namespace afhds3
{
struct SerialData {
uint8_t pulses[AFHDS_MAX_PULSES];
uint8_t* ptr;
};
struct PulsesData {
uint16_t pulses[AFHDS_MAX_PULSES_TRANSITIONS];
uint16_t* ptr;
};
#if defined(EXTMODULE_USART) && defined(EXTMODULE_TX_INVERT_GPIO)
typedef SerialData ExtmoduleData;
#else
typedef PulsesData ExtmoduleData;
#endif
#if defined(INTERNAL_MODULE_AFHDS3)
typedef SerialData IntmoduleData;
#endif
struct Transport {
enum Type {
Serial,
Pulses
};
void (*reset)(void* buffer);
void (*sendByte)(void* buffer, uint8_t b);
void (*flush)(void* buffer);
uint32_t (*getSize)(void* buffer);
void init(Type t);
};
};
+8 -18
View File
@@ -784,26 +784,17 @@ inline void resetAccessAuthenticationCount()
#endif
}
inline void resetAfhds3Options(uint8_t moduleIdx)
inline void resetAfhdsOptions(uint8_t moduleIdx)
{
auto & data = g_model.moduleData[moduleIdx];
//data.rfProtocol = 0;
data.subType = 0;
#if defined(AFHDS3)
data.afhds3.bindPower = 0;
data.afhds3.runPower = 0;
data.afhds3.emi = 0;
data.subType = FLYSKY_SUBTYPE_AFHDS3;
data.afhds3.emi = 2; // FCC
data.afhds3.telemetry = 1;
data.afhds3.rx_freq[0] = 50;
data.afhds3.rx_freq[1] = 0;
data.afhds3.failsafeTimeout = 1000;
data.channelsCount = 14 - 8;
data.failsafeMode = 1;
//" PWM+i"" PWM+s"" PPM+i"" PPM+s"
data.subType = 0;
for (uint8_t channel = 0; channel < MAX_OUTPUT_CHANNELS; channel++) {
g_model.failsafeChannels[channel] = 0;
}
data.afhds3.phyMode = 0;
#elif defined(AFHDS2A)
data.subType = FLYSKY_SUBTYPE_AFHDS2A;
data.flysky.setDefault();
#endif
}
@@ -819,8 +810,7 @@ inline void setModuleType(uint8_t moduleIdx, uint8_t moduleType)
else if (moduleData.type == MODULE_TYPE_PPM)
setDefaultPpmFrameLength(moduleIdx);
else if (moduleData.type == MODULE_TYPE_FLYSKY) {
// TODO: what if AFHDS2A
resetAfhds3Options(moduleIdx);
resetAfhdsOptions(moduleIdx);
}
else
resetAccessAuthenticationCount();
+10 -6
View File
@@ -52,6 +52,10 @@
#include "pulses/afhds2.h"
#endif
#if defined(AFHDS3)
#include "pulses/afhds3.h"
#endif
uint8_t s_pulses_paused = 0;
ModuleState moduleState[NUM_MODULES];
InternalModulePulsesData intmodulePulsesData __DMA;
@@ -174,8 +178,8 @@ void getModuleStatusString(uint8_t moduleIdx, char * statusText)
}
#endif
#if defined(AFHDS3)
if (moduleIdx == EXTERNAL_MODULE && isModuleAFHDS3(moduleIdx)) {
extmodulePulsesData.afhds3.getStatusString(statusText);
if (isModuleAFHDS3(moduleIdx)) {
afhds3::getStatusString(moduleIdx, statusText);
}
#endif
}
@@ -189,8 +193,8 @@ void getModuleSyncStatusString(uint8_t moduleIdx, char * statusText)
}
#endif
#if defined(AFHDS3)
if (moduleIdx == EXTERNAL_MODULE && isModuleAFHDS3(moduleIdx)) {
extmodulePulsesData.afhds3.getPowerStatus(statusText);
if (isModuleAFHDS3(moduleIdx)) {
afhds3::getPowerStatus(moduleIdx, statusText);
}
#endif
}
@@ -198,8 +202,8 @@ void getModuleSyncStatusString(uint8_t moduleIdx, char * statusText)
#if defined(AFHDS3)
uint8_t actualAfhdsRunPower(int moduleIndex)
{
if (moduleIndex == EXTERNAL_MODULE && isModuleAFHDS3(moduleIndex)) {
return (uint8_t)extmodulePulsesData.afhds3.actualRunPower();
if (isModuleAFHDS3(moduleIndex)) {
return (uint8_t)afhds3::getActualRunPower(moduleIndex);
}
return 0;
}
+3 -3
View File
@@ -28,8 +28,8 @@
#include "pxx1.h"
#include "pxx2.h"
#include "multi.h"
#include "afhds3.h"
#include "afhds2.h"
#include "afhds3_transport.h"
#include "modules_helpers.h"
#include "ff.h"
#include "hal/module_driver.h"
@@ -173,7 +173,7 @@ union InternalModulePulsesData {
#endif
#if defined(INTERNAL_MODULE_AFHDS3)
afhds3::PulsesData afhds3;
afhds3::IntmoduleData afhds3;
#endif
#if defined(INTERNAL_MODULE_PPM)
@@ -199,7 +199,7 @@ union ExternalModulePulsesData {
#endif
#if defined(AFHDS3)
afhds3::PulsesData afhds3;
afhds3::ExtmoduleData afhds3;
#endif
PpmPulsesData<pulse_duration_t> ppm;
@@ -660,14 +660,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -692,7 +688,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -628,14 +628,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -660,7 +656,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -628,14 +628,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -660,7 +656,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -628,14 +628,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -660,7 +656,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -634,14 +634,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -666,7 +662,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -628,14 +628,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -660,7 +656,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -628,14 +628,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -660,7 +656,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -685,14 +685,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -717,7 +713,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -683,14 +683,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -715,7 +711,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -628,14 +628,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -660,7 +656,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -636,14 +636,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -668,7 +664,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -675,14 +675,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -707,7 +703,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -613,14 +613,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -645,7 +641,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -623,14 +623,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -655,7 +651,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -620,14 +620,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -652,7 +648,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -624,14 +624,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -656,7 +652,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
@@ -628,14 +628,10 @@ static const struct YamlNode struct_anonymous_9[] = {
YAML_END
};
static const struct YamlNode struct_anonymous_10[] = {
YAML_UNSIGNED( "bindPower", 3 ),
YAML_UNSIGNED( "runPower", 3 ),
YAML_UNSIGNED( "emi", 1 ),
YAML_UNSIGNED( "emi", 2 ),
YAML_UNSIGNED( "telemetry", 1 ),
YAML_UNSIGNED( "failsafeTimeout", 16 ),
YAML_ARRAY("rx_freq", 8, 2, struct_unsigned_8, NULL),
YAML_UNSIGNED( "mode", 2 ),
YAML_UNSIGNED( "reserved", 6 ),
YAML_UNSIGNED( "phyMode", 3 ),
YAML_UNSIGNED( "reserved", 2 ),
YAML_END
};
static const struct YamlNode struct_anonymous_11[] = {
@@ -660,7 +656,7 @@ static const struct YamlNode union_anonymous_4_elmts[] = {
YAML_STRUCT("sbus", 16, struct_anonymous_7, NULL),
YAML_STRUCT("pxx2", 200, struct_anonymous_8, NULL),
YAML_STRUCT("flysky", 56, struct_anonymous_9, NULL),
YAML_STRUCT("afhds3", 64, struct_anonymous_10, NULL),
YAML_STRUCT("afhds3", 8, struct_anonymous_10, NULL),
YAML_STRUCT("ghost", 8, struct_anonymous_11, NULL),
YAML_STRUCT("crsf", 8, struct_anonymous_12, NULL),
YAML_STRUCT("dsmp", 8, struct_anonymous_13, NULL),
+5 -8
View File
@@ -235,6 +235,11 @@ endif()
if(AFHDS3)
add_definitions(-DAFHDS3)
set(PULSES_SRC
${PULSES_SRC}
afhds3.cpp
afhds3_transport.cpp
)
endif()
if(CROSSFIRE)
@@ -249,14 +254,6 @@ if(CROSSFIRE)
)
endif()
if(AFHDS3)
add_definitions(-DAFHDS3)
set(PULSES_SRC
${PULSES_SRC}
afhds3.cpp
)
endif()
if(MULTIMODULE OR AFHDS3)
set(SRC ${SRC} telemetry/flysky_ibus.cpp )
endif()
+1
View File
@@ -830,6 +830,7 @@
#define INTMODULE_DMA_STREAM_IRQHandler DMA2_Stream7_IRQHandler
#define INTMODULE_DMA_FLAG_TC DMA_FLAG_TCIF7
#define INTMODULE_DMA_CHANNEL DMA_Channel_4
// RX DMA: DMA2_Stream2 - Channel 4
#if defined(PCBX12S)
#define INTMODULE_BOOTCMD_GPIO GPIOC
#define INTMODULE_BOOTCMD_GPIO_PIN GPIO_Pin_2 // PC.02
+5 -2
View File
@@ -103,8 +103,11 @@ void SDRAM_Init();
#if !defined(SIMU)
#define INTERNAL_MODULE_OFF() GPIO_SetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN)
#define INTERNAL_MODULE_ON() GPIO_ResetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN)
// #define INTERNAL_MODULE_OFF() GPIO_SetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN)
// #define INTERNAL_MODULE_ON() GPIO_ResetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN)
#define INTERNAL_MODULE_OFF() GPIO_ResetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN)
#define INTERNAL_MODULE_ON() GPIO_SetBits(INTMODULE_PWR_GPIO, INTMODULE_PWR_GPIO_PIN)
void EXTERNAL_MODULE_ON();
void EXTERNAL_MODULE_OFF();
#define BLUETOOTH_MODULE_ON() GPIO_ResetBits(BLUETOOTH_ON_GPIO, BLUETOOTH_ON_GPIO_PIN)
+4 -3
View File
@@ -154,7 +154,7 @@ void telemetryStart()
{
if (!telemetryTimer) {
telemetryTimer =
xTimerCreateStatic("Telem", 4 / RTOS_MS_PER_TICK, pdTRUE, (void*)0,
xTimerCreateStatic("Telem", 2 / RTOS_MS_PER_TICK, pdTRUE, (void*)0,
telemetryTimerCb, &telemetryTimerBuffer);
}
@@ -576,8 +576,9 @@ void telemetryInit(uint8_t protocol)
#if defined(AFHDS3)
else if (protocol == PROTOCOL_TELEMETRY_AFHDS3) {
telemetryPortInvertedInit(AFHDS3_BAUDRATE);
telemetryPortSetDirectionInput();
// TODO:
// telemetryPortInvertedInit(AFHDS3_BAUDRATE);
// telemetryPortSetDirectionInput();
}
#endif