56 #define ST24_RANGE_MIN 500.0f 57 #define ST24_RANGE_MAX 3500.0f 59 #define ST24_TARGET_MIN 1000.0f 60 #define ST24_TARGET_MAX 2000.0f 63 #define ST24_SCALE_FACTOR ((ST24_TARGET_MAX - ST24_TARGET_MIN) / (ST24_RANGE_MAX - ST24_RANGE_MIN)) 64 #define ST24_SCALE_OFFSET (int)(ST24_TARGET_MIN - (ST24_SCALE_FACTOR * ST24_RANGE_MIN + 0.5f)) 77 for (i = 0x80; i != 0; i >>= 1) {
78 if ((crc & 0x80) != 0) {
86 if ((*ptr & i) != 0) {
98 int st24_decode(uint8_t
byte, uint8_t *rssi, uint8_t *lost_count, uint16_t *channel_count, uint16_t *channels,
99 uint16_t max_chan_count)
127 if ((
unsigned)byte <=
sizeof(_rxpacket.
length) +
sizeof(_rxpacket.
type) +
sizeof(_rxpacket.
st24_data)) {
164 switch (_rxpacket.
type) {
170 *rssi = d->
rssi * (100.0f / 255.0f);
174 *channel_count = (max_chan_count < 12) ? max_chan_count : 12;
176 unsigned stride_count = (*channel_count * 3) / 2;
177 unsigned chan_index = 0;
179 for (
unsigned i = 0; i < stride_count; i += 3) {
180 channels[chan_index] = ((uint16_t)d->
channel[i] << 4);
181 channels[chan_index] |= ((uint16_t)(0xF0 & d->
channel[i + 1]) >> 4);
186 channels[chan_index] = ((uint16_t)d->
channel[i + 2]);
187 channels[chan_index] |= (((uint16_t)(0x0F & d->
channel[i + 1])) << 8);
199 *rssi = d->
rssi * (100.0f / 255.0f);
203 *channel_count = (max_chan_count < 24) ? max_chan_count : 24;
205 unsigned stride_count = (*channel_count * 3) / 2;
206 unsigned chan_index = 0;
208 for (
unsigned i = 0; i < stride_count; i += 3) {
209 channels[chan_index] = ((uint16_t)d->
channel[i] << 4);
210 channels[chan_index] |= ((uint16_t)(0xF0 & d->
channel[i + 1]) >> 4);
215 channels[chan_index] = ((uint16_t)d->
channel[i + 2]);
216 channels[chan_index] |= (((uint16_t)(0x0F & d->
channel[i + 1])) << 8);
uint8_t lost_count
Number of UART packets sent since reception of last RF frame (100 frame means RC timeout of 1s) ...
const char * decode_states[]
uint8_t channel[18]
channel data, 12 channels (12 bit numbers)
static ReceiverFcPacket & _rxpacket
uint8_t type
from enum ST24_PACKET_TYPE
#define ST24_SCALE_OFFSET
uint8_t rssi
signal strength
__EXPORT rc_decode_buf_t rc_decode_buf
static enum ST24_DECODE_STATE _decode_state
uint8_t channel[36]
channel data, 24 channels (12 bit numbers)
RC Channel data (12 channels).
uint8_t st24_data[ST24_DATA_LEN_MAX]
RC protocol definition for Yuneec ST24 transmitter.
uint8_t crc8
crc8 checksum, calculated by st24_common_crc8 and including fields length, type and st24_data ...
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
RC Channel data (12 channels).
uint8_t rssi
signal strength
uint8_t st24_common_crc8(uint8_t *ptr, uint8_t len)
CRC8 implementation for ST24 protocol.
ReceiverFcPacket _strxpacket
int st24_decode(uint8_t byte, uint8_t *rssi, uint8_t *lost_count, uint16_t *channel_count, uint16_t *channels, uint16_t max_chan_count)
Decoder for ST24 protocol.
uint8_t length
length includes type, data, and crc = sizeof(type)+sizeof(data[payload_len])+sizeof(crc8) ...
#define ST24_SCALE_FACTOR
uint8_t lost_count
Number of UART packets sent since reception of last RF frame (100 frame means RC timeout of 1s) ...