APM:Libraries
Classes | Macros | Enumerations | Functions | Variables
st24.cpp File Reference
#include <stdio.h>
#include <stdint.h>
#include "st24.h"
Include dependency graph for st24.cpp:

Go to the source code of this file.

Classes

struct  ReceiverFcPacket
 
struct  ChannelData12
 
struct  ChannelData24
 
struct  TelemetryData
 

Macros

#define ST24_DATA_LEN_MAX   64
 
#define ST24_STX1   0x55
 
#define ST24_STX2   0x55
 
#define ST24_RANGE_MIN   0.0f
 
#define ST24_RANGE_MAX   4096.0f
 
#define ST24_TARGET_MIN   1000.0f
 
#define ST24_TARGET_MAX   2000.0f
 
#define ST24_SCALE_FACTOR   ((ST24_TARGET_MAX - ST24_TARGET_MIN) / (ST24_RANGE_MAX - ST24_RANGE_MIN))
 
#define ST24_SCALE_OFFSET   (int)(ST24_TARGET_MIN - (ST24_SCALE_FACTOR * ST24_RANGE_MIN + 0.5f))
 

Enumerations

enum  ST24_PACKET_TYPE { ST24_PACKET_TYPE_CHANNELDATA12 = 0, ST24_PACKET_TYPE_CHANNELDATA24, ST24_PACKET_TYPE_TRANSMITTERGPSDATA }
 
enum  ST24_DECODE_STATE {
  ST24_DECODE_STATE_UNSYNCED = 0, ST24_DECODE_STATE_GOT_STX1, ST24_DECODE_STATE_GOT_STX2, ST24_DECODE_STATE_GOT_LEN,
  ST24_DECODE_STATE_GOT_TYPE, ST24_DECODE_STATE_GOT_DATA
}
 

Functions

static uint8_t st24_common_crc8 (uint8_t *ptr, uint8_t len)
 
int st24_decode (uint8_t byte, uint8_t *rssi, uint8_t *rx_count, uint16_t *channel_count, uint16_t *channels, uint16_t max_chan_count)
 

Variables

static enum ST24_DECODE_STATE _decode_state = ST24_DECODE_STATE_UNSYNCED
 
static uint8_t _rxlen
 
static ReceiverFcPacket _rxpacket
 

Macro Definition Documentation

◆ ST24_DATA_LEN_MAX

#define ST24_DATA_LEN_MAX   64

Definition at line 50 of file st24.cpp.

◆ ST24_RANGE_MAX

#define ST24_RANGE_MAX   4096.0f

Definition at line 154 of file st24.cpp.

◆ ST24_RANGE_MIN

#define ST24_RANGE_MIN   0.0f

Definition at line 153 of file st24.cpp.

◆ ST24_SCALE_FACTOR

#define ST24_SCALE_FACTOR   ((ST24_TARGET_MAX - ST24_TARGET_MIN) / (ST24_RANGE_MAX - ST24_RANGE_MIN))

Definition at line 160 of file st24.cpp.

Referenced by st24_decode().

◆ ST24_SCALE_OFFSET

#define ST24_SCALE_OFFSET   (int)(ST24_TARGET_MIN - (ST24_SCALE_FACTOR * ST24_RANGE_MIN + 0.5f))

Definition at line 161 of file st24.cpp.

Referenced by st24_decode().

◆ ST24_STX1

#define ST24_STX1   0x55

Definition at line 51 of file st24.cpp.

Referenced by st24_decode().

◆ ST24_STX2

#define ST24_STX2   0x55

Definition at line 52 of file st24.cpp.

Referenced by st24_decode().

◆ ST24_TARGET_MAX

#define ST24_TARGET_MAX   2000.0f

Definition at line 157 of file st24.cpp.

◆ ST24_TARGET_MIN

#define ST24_TARGET_MIN   1000.0f

Definition at line 156 of file st24.cpp.

Enumeration Type Documentation

◆ ST24_DECODE_STATE

Enumerator
ST24_DECODE_STATE_UNSYNCED 
ST24_DECODE_STATE_GOT_STX1 
ST24_DECODE_STATE_GOT_STX2 
ST24_DECODE_STATE_GOT_LEN 
ST24_DECODE_STATE_GOT_TYPE 
ST24_DECODE_STATE_GOT_DATA 

Definition at line 143 of file st24.cpp.

◆ ST24_PACKET_TYPE

Enumerator
ST24_PACKET_TYPE_CHANNELDATA12 
ST24_PACKET_TYPE_CHANNELDATA24 
ST24_PACKET_TYPE_TRANSMITTERGPSDATA 

Definition at line 54 of file st24.cpp.

Function Documentation

◆ st24_common_crc8()

static uint8_t st24_common_crc8 ( uint8_t *  ptr,
uint8_t  len 
)
static

Definition at line 168 of file st24.cpp.

Referenced by st24_decode().

Here is the caller graph for this function:

◆ st24_decode()

int st24_decode ( uint8_t  byte,
uint8_t *  rssi,
uint8_t *  rx_count,
uint16_t *  channel_count,
uint16_t *  channels,
uint16_t  max_chan_count 
)

Decoder for ST24 protocol

Parameters
bytecurrent char to read
rssipointer to a byte where the RSSI value is written back to
rx_countpointer to a byte where the receive count of packets signce last wireless frame is written back to
channelspointer to a datastructure of size max_chan_count where channel values (12 bit) are written back to
max_chan_countmaximum channels to decode - if more channels are decoded, the last n are skipped and success (0) is returned
Returns
0 for success (a decoded packet), 1 for no packet yet (accumulating), 2 for unknown packet, 3 for out of sync, 4 for checksum error

Definition at line 195 of file st24.cpp.

Referenced by Linux::RCInput::add_st24_input().

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

Variable Documentation

◆ _decode_state

enum ST24_DECODE_STATE _decode_state = ST24_DECODE_STATE_UNSYNCED
static

Definition at line 163 of file st24.cpp.

Referenced by st24_decode().

◆ _rxlen

uint8_t _rxlen
static

Definition at line 164 of file st24.cpp.

Referenced by st24_decode().

◆ _rxpacket

ReceiverFcPacket _rxpacket
static

Definition at line 166 of file st24.cpp.