78 #define SUMD_RANGE_MIN 0.0f 79 #define SUMD_RANGE_MAX 4096.0f 81 #define SUMD_TARGET_MIN 1000.0f 82 #define SUMD_TARGET_MAX 2000.0f 85 #define SUMD_SCALE_FACTOR ((SUMD_TARGET_MAX - SUMD_TARGET_MIN) / (SUMD_RANGE_MAX - SUMD_RANGE_MIN)) 86 #define SUMD_SCALE_OFFSET (int)(SUMD_TARGET_MIN - (SUMD_SCALE_FACTOR * SUMD_RANGE_MIN + 0.5f)) 96 crc ^= (uint16_t)value << 8;
98 for (i = 0; i < 8; i++) {
99 crc = (crc & 0x8000) ? (crc << 1) ^ 0x1021 : (crc << 1);
111 int sumd_decode(uint8_t byte, uint8_t *rssi, uint8_t *rx_count, uint16_t *channel_count, uint16_t *channels,
112 uint16_t max_chan_count,
bool *failsafe)
120 printf(
" SUMD_DECODE_STATE_UNSYNCED \n") ;
135 printf(
" SUMD_DECODE_STATE_GOT_HEADER: %x \n", byte) ;
162 printf(
" SUMD_DECODE_STATE_GOT_STATE: %x \n", byte) ;
186 printf(
" SUMD_DECODE_STATE_GOT_LEN: %x (%d) \n", byte, byte) ;
209 printf(
" SUMD_DECODE_STATE_GOT_DATA[%d]: %x\n",
_rxlen - 2, byte) ;
216 printf(
" SUMD_DECODE_STATE_GOT_DATA -- finish --\n") ;
227 printf(
" SUMD_DECODE_STATE_GOT_CRC16[1]: %x [%x]\n", byte, ((
_crc16 >> 8) & 0xff)) ;
243 printf(
" SUMD_DECODE_STATE_GOT_CRC16[2]: %x [%x]\n", byte, (
_crc16 & 0xff)) ;
254 printf(
" SUMD_DECODE_STATE_GOT_SUMH_TELEMETRY: %x\n", byte) ;
266 printf(
" SUMD_DECODE_STATE_GOT_CRC[2]: %x [%x]\n\n", byte, (
_crc16 & 0xff)) ;
274 _rxpacket.
crc8 = byte;
277 printf(
" SUMD_DECODE_STATE_GOT_CRC8_SUMH: %x [%x]\n\n", byte,
_crc8) ;
287 printf(
" CRC - OK \n") ;
292 printf(
" Got valid SUMD Packet\n") ;
297 printf(
" Got valid SUMH Packet\n") ;
303 printf(
" RXLEN: %d [Chans: %d] \n\n",
_rxlen - 1, (
_rxlen - 1) / 2) ;
308 uint8_t _cnt = *rx_count + 1;
317 if ((uint16_t)_rxpacket.
length > max_chan_count) {
318 _rxpacket.
length = (uint8_t) max_chan_count;
321 *channel_count = (uint16_t)_rxpacket.
length;
327 channels[0] = (uint16_t)((_rxpacket.
sumd_data[1 * 2 + 1] << 8) | _rxpacket.
sumd_data[1 * 2 + 2]) >> 3;
329 channels[1] = (uint16_t)((_rxpacket.
sumd_data[2 * 2 + 1] << 8) | _rxpacket.
sumd_data[2 * 2 + 2]) >> 3;
331 channels[2] = (uint16_t)((_rxpacket.
sumd_data[0 * 2 + 1] << 8) | _rxpacket.
sumd_data[0 * 2 + 2]) >> 3;
333 channels[3] = (uint16_t)((_rxpacket.
sumd_data[3 * 2 + 1] << 8) | _rxpacket.
sumd_data[3 * 2 + 2]) >> 3;
336 unsigned chan_index = 4;
338 for (i = 4; i < _rxpacket.
length; i++) {
340 printf(
"ch[%d] : %x %x [ %x %d ]\n", i + 1, _rxpacket.
sumd_data[i * 2 + 1], _rxpacket.
sumd_data[i * 2 + 2],
345 channels[chan_index] = (uint16_t)((_rxpacket.
sumd_data[i * 2 + 1] << 8) | _rxpacket.
sumd_data[i * 2 + 2]) >> 3;
357 printf(
" CRC - fail \n") ;
int sumd_decode(uint8_t byte, uint8_t *rssi, uint8_t *rx_count, uint16_t *channel_count, uint16_t *channels, uint16_t max_chan_count, bool *failsafe)
Decoder for SUMD/SUMH protocol.
uint8_t crc16_low
Low Byte of 16 Bit CRC.
RC protocol definition for Graupner HoTT transmitter.
uint8_t sumd_crc8(uint8_t crc, uint8_t value)
CRC8 implementation for SUMH protocol.
uint16_t sumd_crc16(uint16_t crc, uint8_t value)
CRC16 implementation for SUMD protocol.
static ReceiverFcPacketHoTT & _rxpacket
__EXPORT rc_decode_buf_t rc_decode_buf
uint8_t sumd_data[SUMD_MAX_CHANNELS *2]
ChannelData (High Byte/ Low Byte)
ReceiverFcPacketHoTT _hottrxpacket
static enum SUMD_DECODE_STATE _decode_state
uint8_t header
0xA8 for a valid packet
uint8_t telemetry
Telemetry request.
#define SUMD_MAX_CHANNELS
uint8_t crc16_high
High Byte of 16 Bit CRC.
uint8_t status
0x01 valid and live SUMD data frame / 0x00 = SUMH / 0x81 = Failsafe