Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
cc2500_smartport.c File Reference
#include "cc2500_compat.h"
#include "cc2500_rx.h"
#include "cc2500_settings.h"
#include "cc2500_smartport.h"
#include "subsystems/datalink/downlink.h"
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
+ Include dependency graph for cc2500_smartport.c:

Go to the source code of this file.

Data Structures

struct  frSkyTableInfo_s
 

Macros

#define FSSP_DATAID_DOWNLINK   0x5015
 
#define FSSP_DATAID_UPLINK   0x5016
 
#define MAX_DATAIDS   18
 
#define ADD_SENSOR(dataId)   frSkyDataIdTableInfo.table[frSkyDataIdTableInfo.index++] = dataId
 
#define ADD_ESC_SENSOR(dataId)   frSkyEscDataIdTableInfo.table[frSkyEscDataIdTableInfo.index++] = dataId
 

Typedefs

typedef struct frSkyTableInfo_s frSkyTableInfo_t
 

Enumerations

enum  {
  FSSP_DATAID_SPEED = 0x0830, FSSP_DATAID_VFAS = 0x0210, FSSP_DATAID_VFAS1 = 0x0211, FSSP_DATAID_VFAS2 = 0x0212,
  FSSP_DATAID_VFAS3 = 0x0213, FSSP_DATAID_VFAS4 = 0x0214, FSSP_DATAID_VFAS5 = 0x0215, FSSP_DATAID_VFAS6 = 0x0216,
  FSSP_DATAID_VFAS7 = 0x0217, FSSP_DATAID_VFAS8 = 0x0218, FSSP_DATAID_CURRENT = 0x0200, FSSP_DATAID_CURRENT1 = 0x0201,
  FSSP_DATAID_CURRENT2 = 0x0202, FSSP_DATAID_CURRENT3 = 0x0203, FSSP_DATAID_CURRENT4 = 0x0204, FSSP_DATAID_CURRENT5 = 0x0205,
  FSSP_DATAID_CURRENT6 = 0x0206, FSSP_DATAID_CURRENT7 = 0x0207, FSSP_DATAID_CURRENT8 = 0x0208, FSSP_DATAID_RPM = 0x0500,
  FSSP_DATAID_RPM1 = 0x0501, FSSP_DATAID_RPM2 = 0x0502, FSSP_DATAID_RPM3 = 0x0503, FSSP_DATAID_RPM4 = 0x0504,
  FSSP_DATAID_RPM5 = 0x0505, FSSP_DATAID_RPM6 = 0x0506, FSSP_DATAID_RPM7 = 0x0507, FSSP_DATAID_RPM8 = 0x0508,
  FSSP_DATAID_ALTITUDE = 0x0100, FSSP_DATAID_FUEL = 0x0600, FSSP_DATAID_ADC1 = 0xF102, FSSP_DATAID_ADC2 = 0xF103,
  FSSP_DATAID_LATLONG = 0x0800, FSSP_DATAID_CAP_USED = 0x0600, FSSP_DATAID_VARIO = 0x0110, FSSP_DATAID_CELLS = 0x0300,
  FSSP_DATAID_CELLS_LAST = 0x030F, FSSP_DATAID_HEADING = 0x0840, FSSP_DATAID_T1 = 0x0400, FSSP_DATAID_T11 = 0x0401,
  FSSP_DATAID_T2 = 0x0410, FSSP_DATAID_HOME_DIST = 0x0420, FSSP_DATAID_GPS_ALT = 0x0820, FSSP_DATAID_ASPD = 0x0A00,
  FSSP_DATAID_TEMP = 0x0B70, FSSP_DATAID_TEMP1 = 0x0B71, FSSP_DATAID_TEMP2 = 0x0B72, FSSP_DATAID_TEMP3 = 0x0B73,
  FSSP_DATAID_TEMP4 = 0x0B74, FSSP_DATAID_TEMP5 = 0x0B75, FSSP_DATAID_TEMP6 = 0x0B76, FSSP_DATAID_TEMP7 = 0x0B77,
  FSSP_DATAID_TEMP8 = 0x0B78, FSSP_DATAID_A3 = 0x0900, FSSP_DATAID_A4 = 0x0910
}
 
enum  { TELEMETRY_STATE_UNINITIALIZED, TELEMETRY_STATE_INITIALIZED_SERIAL, TELEMETRY_STATE_INITIALIZED_EXTERNAL }
 

Functions

smartPortPayload_tsmartPortDataReceive (uint16_t c, bool *clearToSend, smartPortCheckQueueEmptyFn *checkQueueEmpty, bool useChecksum)
 
static void smartPortSendPackage (uint16_t id, uint32_t val)
 
static void initSmartPortSensors (void)
 
bool initSmartPortTelemetryExternal (smartPortWriteFrameFn *smartPortWriteFrameExternal)
 
void processSmartPortTelemetry (smartPortPayload_t *payload, volatile bool *clearToSend, const timeUs_t *requestTimeout)
 

Variables

smartPortDownlinkFnsmartPortDownlink = NULL
 
smartPortUplinkFnsmartPortUplink = NULL
 
static uint16_t frSkyDataIdTable [MAX_DATAIDS]
 
static frSkyTableInfo_t frSkyDataIdTableInfo = { frSkyDataIdTable, 0, 0 }
 
static uint8_t telemetryState = TELEMETRY_STATE_UNINITIALIZED
 
static smartPortWriteFrameFnsmartPortWriteFrame
 

Data Structure Documentation

◆ frSkyTableInfo_s

struct frSkyTableInfo_s

Definition at line 195 of file cc2500_smartport.c.

Data Fields
uint8_t index
uint8_t size
uint16_t * table

Macro Definition Documentation

◆ ADD_ESC_SENSOR

#define ADD_ESC_SENSOR (   dataId)    frSkyEscDataIdTableInfo.table[frSkyEscDataIdTableInfo.index++] = dataId

Definition at line 348 of file cc2500_smartport.c.

◆ ADD_SENSOR

#define ADD_SENSOR (   dataId)    frSkyDataIdTableInfo.table[frSkyDataIdTableInfo.index++] = dataId

Definition at line 347 of file cc2500_smartport.c.

◆ FSSP_DATAID_DOWNLINK

#define FSSP_DATAID_DOWNLINK   0x5015

Definition at line 19 of file cc2500_smartport.c.

◆ FSSP_DATAID_UPLINK

#define FSSP_DATAID_UPLINK   0x5016

Definition at line 20 of file cc2500_smartport.c.

◆ MAX_DATAIDS

#define MAX_DATAIDS   18

Definition at line 181 of file cc2500_smartport.c.

Typedef Documentation

◆ frSkyTableInfo_t

Enumeration Type Documentation

◆ anonymous enum

anonymous enum
Enumerator
FSSP_DATAID_SPEED 
FSSP_DATAID_VFAS 
FSSP_DATAID_VFAS1 
FSSP_DATAID_VFAS2 
FSSP_DATAID_VFAS3 
FSSP_DATAID_VFAS4 
FSSP_DATAID_VFAS5 
FSSP_DATAID_VFAS6 
FSSP_DATAID_VFAS7 
FSSP_DATAID_VFAS8 
FSSP_DATAID_CURRENT 
FSSP_DATAID_CURRENT1 
FSSP_DATAID_CURRENT2 
FSSP_DATAID_CURRENT3 
FSSP_DATAID_CURRENT4 
FSSP_DATAID_CURRENT5 
FSSP_DATAID_CURRENT6 
FSSP_DATAID_CURRENT7 
FSSP_DATAID_CURRENT8 
FSSP_DATAID_RPM 
FSSP_DATAID_RPM1 
FSSP_DATAID_RPM2 
FSSP_DATAID_RPM3 
FSSP_DATAID_RPM4 
FSSP_DATAID_RPM5 
FSSP_DATAID_RPM6 
FSSP_DATAID_RPM7 
FSSP_DATAID_RPM8 
FSSP_DATAID_ALTITUDE 
FSSP_DATAID_FUEL 
FSSP_DATAID_ADC1 
FSSP_DATAID_ADC2 
FSSP_DATAID_LATLONG 
FSSP_DATAID_CAP_USED 
FSSP_DATAID_VARIO 
FSSP_DATAID_CELLS 
FSSP_DATAID_CELLS_LAST 
FSSP_DATAID_HEADING 
FSSP_DATAID_T1 
FSSP_DATAID_T11 
FSSP_DATAID_T2 
FSSP_DATAID_HOME_DIST 
FSSP_DATAID_GPS_ALT 
FSSP_DATAID_ASPD 
FSSP_DATAID_TEMP 
FSSP_DATAID_TEMP1 
FSSP_DATAID_TEMP2 
FSSP_DATAID_TEMP3 
FSSP_DATAID_TEMP4 
FSSP_DATAID_TEMP5 
FSSP_DATAID_TEMP6 
FSSP_DATAID_TEMP7 
FSSP_DATAID_TEMP8 
FSSP_DATAID_A3 
FSSP_DATAID_A4 

Definition at line 116 of file cc2500_smartport.c.

◆ anonymous enum

anonymous enum
Enumerator
TELEMETRY_STATE_UNINITIALIZED 
TELEMETRY_STATE_INITIALIZED_SERIAL 
TELEMETRY_STATE_INITIALIZED_EXTERNAL 

Definition at line 215 of file cc2500_smartport.c.

Function Documentation

◆ initSmartPortSensors()

◆ initSmartPortTelemetryExternal()

bool initSmartPortTelemetryExternal ( smartPortWriteFrameFn smartPortWriteFrameExternal)

Definition at line 480 of file cc2500_smartport.c.

References initSmartPortSensors(), smartPortWriteFrame, TELEMETRY_STATE_INITIALIZED_EXTERNAL, TELEMETRY_STATE_UNINITIALIZED, and telemetryState.

Referenced by frSkyXInit().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ processSmartPortTelemetry()

void processSmartPortTelemetry ( smartPortPayload_t payload,
volatile bool *  clearToSend,
const timeUs_t requestTimeout 
)

Definition at line 533 of file cc2500_smartport.c.

References ARMING_FLAG, attitude, cmpTimeUs(), currentControlRateProfile, currentPidProfile, pidGains_s::D, FD_PITCH, FD_ROLL, FD_YAW, featureIsEnabled, FLIGHT_MODE, frSkyDataIdTableInfo, FSSP_DATAID_A4, FSSP_DATAID_ALTITUDE, FSSP_DATAID_CURRENT, FSSP_DATAID_CURRENT1, FSSP_DATAID_CURRENT2, FSSP_DATAID_CURRENT3, FSSP_DATAID_CURRENT4, FSSP_DATAID_CURRENT5, FSSP_DATAID_CURRENT6, FSSP_DATAID_CURRENT7, FSSP_DATAID_CURRENT8, FSSP_DATAID_DOWNLINK, FSSP_DATAID_FUEL, FSSP_DATAID_GPS_ALT, FSSP_DATAID_HEADING, FSSP_DATAID_HOME_DIST, FSSP_DATAID_LATLONG, FSSP_DATAID_RPM, FSSP_DATAID_RPM1, FSSP_DATAID_RPM2, FSSP_DATAID_RPM3, FSSP_DATAID_RPM4, FSSP_DATAID_RPM5, FSSP_DATAID_RPM6, FSSP_DATAID_RPM7, FSSP_DATAID_RPM8, FSSP_DATAID_SPEED, FSSP_DATAID_T1, FSSP_DATAID_T11, FSSP_DATAID_T2, FSSP_DATAID_TEMP, FSSP_DATAID_TEMP1, FSSP_DATAID_TEMP2, FSSP_DATAID_TEMP3, FSSP_DATAID_TEMP4, FSSP_DATAID_TEMP5, FSSP_DATAID_TEMP6, FSSP_DATAID_TEMP7, FSSP_DATAID_TEMP8, FSSP_DATAID_UPLINK, FSSP_DATAID_VARIO, FSSP_DATAID_VFAS, FSSP_DATAID_VFAS1, FSSP_DATAID_VFAS2, FSSP_DATAID_VFAS3, FSSP_DATAID_VFAS4, FSSP_DATAID_VFAS5, FSSP_DATAID_VFAS6, FSSP_DATAID_VFAS7, FSSP_DATAID_VFAS8, getAmperage, getBatteryCellCount, getBatteryVoltage, getEstimatedAltitudeCm, getEstimatedVario, getMAhDrawn, pidGains_s::I, frSkyTableInfo_s::index, isArmingDisabled, micros, pidGains_s::P, pidProfile_s::pid, PID_PITCH, PID_ROLL, PID_YAW, controlRateConfig_t::rates, sensors, frSkyTableInfo_s::size, smartPortDownlink, smartPortSendPackage(), smartPortUplink, frSkyTableInfo_s::table, telemetryConfig(), UNUSED, smartPortPayload_s::valueId, mesonh.mesonh_atmosphere::X, mesonh.mesonh_atmosphere::Y, and mesonh.mesonh_atmosphere::Z.

Referenced by frSkyXProcessFrame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smartPortDataReceive()

smartPortPayload_t* smartPortDataReceive ( uint16_t  c,
bool *  clearToSend,
smartPortCheckQueueEmptyFn checkQueueEmpty,
bool  useChecksum 
)

Definition at line 238 of file cc2500_smartport.c.

References c(), checksum, FSSP_DLE, FSSP_DLE_XOR, FSSP_SENSOR_ID1, FSSP_SENSOR_ID2, and FSSP_START_STOP.

Referenced by frSkyXProcessFrame().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ smartPortSendPackage()

static void smartPortSendPackage ( uint16_t  id,
uint32_t  val 
)
static

Definition at line 337 of file cc2500_smartport.c.

References smartPortPayload_s::data, smartPortPayload_s::frameId, FSSP_DATA_FRAME, smartPortWriteFrame, val, and smartPortPayload_s::valueId.

Referenced by processSmartPortTelemetry().

+ Here is the caller graph for this function:

Variable Documentation

◆ frSkyDataIdTable

uint16_t frSkyDataIdTable[MAX_DATAIDS]
static

Definition at line 183 of file cc2500_smartport.c.

◆ frSkyDataIdTableInfo

frSkyTableInfo_t frSkyDataIdTableInfo = { frSkyDataIdTable, 0, 0 }
static

Definition at line 201 of file cc2500_smartport.c.

Referenced by initSmartPortSensors(), and processSmartPortTelemetry().

◆ smartPortDownlink

smartPortDownlinkFn* smartPortDownlink = NULL

Definition at line 22 of file cc2500_smartport.c.

Referenced by datalink_frsky_x_init(), and processSmartPortTelemetry().

◆ smartPortUplink

smartPortUplinkFn* smartPortUplink = NULL

Definition at line 23 of file cc2500_smartport.c.

Referenced by datalink_frsky_x_init(), and processSmartPortTelemetry().

◆ smartPortWriteFrame

smartPortWriteFrameFn* smartPortWriteFrame
static

Definition at line 232 of file cc2500_smartport.c.

Referenced by initSmartPortTelemetryExternal(), and smartPortSendPackage().

◆ telemetryState

uint8_t telemetryState = TELEMETRY_STATE_UNINITIALIZED
static

Definition at line 222 of file cc2500_smartport.c.

Referenced by initSmartPortTelemetryExternal().