1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-18 03:52:11 +01:00

OP-932 Fixes the datarate used on PPM only mode, and fixes failsafe on PPM output on OPLM.

This commit is contained in:
Brian Webb 2013-06-26 20:11:39 -07:00
parent caa8d3e70e
commit d5f16faaec

View File

@ -562,6 +562,7 @@ void PIOS_RFM22B_SetChannelConfig(uint32_t rfm22b_id, enum rfm22b_datarate datar
rfm22b_dev->ppm_only_mode = ppm_only; rfm22b_dev->ppm_only_mode = ppm_only;
if (ppm_only) { if (ppm_only) {
rfm22b_dev->one_way_link = true; rfm22b_dev->one_way_link = true;
datarate = RFM22B_PPM_ONLY_DATARATE;
rfm22b_dev->datarate = RFM22B_PPM_ONLY_DATARATE; rfm22b_dev->datarate = RFM22B_PPM_ONLY_DATARATE;
} else { } else {
rfm22b_dev->one_way_link = oneway; rfm22b_dev->one_way_link = oneway;
@ -1906,11 +1907,13 @@ static enum pios_radio_event radio_receivePacket(struct pios_rfm22b_dev *radio_d
} }
if (good_packet || corrected_packet) { if (good_packet || corrected_packet) {
bool valid_input_detected = false;
for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) { for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) {
// Is this a valid channel? // Is this a valid channel?
if (p[0] & (1 << i)) { if (p[0] & (1 << i)) {
uint32_t val = p[i + 1]; uint32_t val = p[i + 1];
radio_dev->ppm[i] = (uint16_t)(1000 + val * 900 / 256); radio_dev->ppm[i] = (uint16_t)(1000 + val * 900 / 256);
valid_input_detected = true;
} else { } else {
radio_dev->ppm[i] = PIOS_RCVR_INVALID; radio_dev->ppm[i] = PIOS_RCVR_INVALID;
} }
@ -1920,7 +1923,7 @@ static enum pios_radio_event radio_receivePacket(struct pios_rfm22b_dev *radio_d
data_len -= RFM22B_PPM_NUM_CHANNELS + 1; data_len -= RFM22B_PPM_NUM_CHANNELS + 1;
// Call the PPM received callback if it's available. // Call the PPM received callback if it's available.
if (radio_dev->ppm_callback) { if (valid_input_detected && radio_dev->ppm_callback) {
radio_dev->ppm_callback(radio_dev->ppm); radio_dev->ppm_callback(radio_dev->ppm);
} }
} }