/** Decode the raw buffer */ static void decode_sbus_buffer (const uint8_t *src, uint16_t *dst, bool_t *available, uint16_t *dstppm) { // reset counters uint8_t byteInRawBuf = 0; uint8_t bitInRawBuf = 0; uint8_t channel = 0; uint8_t bitInChannel = 0; // clear bits memset (dst, 0, SBUS_NB_CHANNEL*sizeof(uint16_t)); // decode sbus data for (uint8_t i=0; i< (SBUS_NB_CHANNEL*SBUS_BIT_PER_CHANNEL); i++) { if (src[byteInRawBuf] & (1<<bitInRawBuf)) dst[channel] |= (1<<bitInChannel); bitInRawBuf++; bitInChannel++; if (bitInRawBuf == SBUS_BIT_PER_BYTE) { bitInRawBuf = 0; byteInRawBuf++; } if (bitInChannel == SBUS_BIT_PER_CHANNEL) { bitInChannel = 0; #if PERIODIC_TELEMETRY dstppm[channel] = USEC_OF_RC_PPM_TICKS(dst[channel]); #endif channel++; } } // test frame lost flag *available = !bit_is_set(src[SBUS_FLAGS_BYTE], SBUS_FRAME_LOST_BIT); }
static void send_ppm(struct transport_tx *trans, struct link_device *dev) { uint16_t ppm_pulses_usec[RADIO_CTL_NB]; for (int i = 0; i < RADIO_CTL_NB; i++) { ppm_pulses_usec[i] = USEC_OF_RC_PPM_TICKS(ppm_pulses[i]); } pprz_msg_send_PPM(trans, dev, AC_ID, &radio_control.frame_rate, RADIO_CTL_NB, ppm_pulses_usec); }