1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-30 15:52:12 +01:00

OP-1686 Slave Oplink may want to receive PPM data in PPM_Only mode

This commit is contained in:
Laurent Lalanne 2015-01-25 01:44:51 +01:00 committed by Karl Knutsson
parent d161ebbc74
commit b9bfcd18d2
3 changed files with 55 additions and 56 deletions

View File

@ -751,7 +751,7 @@ void PIOS_Board_Init(void)
PIOS_RFM22B_SetCoordinatorID(pios_rfm22b_id, oplinkSettings.CoordID); PIOS_RFM22B_SetCoordinatorID(pios_rfm22b_id, oplinkSettings.CoordID);
/* Set the PPM callback if we should be receiving PPM. */ /* Set the PPM callback if we should be receiving PPM. */
if (ppm_mode) { if (ppm_mode || (ppm_only && !is_coordinator)) {
PIOS_RFM22B_SetPPMCallback(pios_rfm22b_id, PIOS_Board_PPM_callback); PIOS_RFM22B_SetPPMCallback(pios_rfm22b_id, PIOS_Board_PPM_callback);
} }

View File

@ -442,71 +442,70 @@ void PIOS_Board_Init(void)
PIOS_RFM22B_SetChannelConfig(pios_rfm22b_id, datarate, oplinkSettings.MinChannel, oplinkSettings.MaxChannel, is_coordinator, is_oneway, ppm_mode, ppm_only); PIOS_RFM22B_SetChannelConfig(pios_rfm22b_id, datarate, oplinkSettings.MinChannel, oplinkSettings.MaxChannel, is_coordinator, is_oneway, ppm_mode, ppm_only);
/* Set the PPM callback if we should be receiving PPM. */ /* Set the PPM callback if we should be receiving PPM. */
if (ppm_mode) { if (ppm_mode || (ppm_only && !is_coordinator)) {
PIOS_RFM22B_SetPPMCallback(pios_rfm22b_id, PIOS_Board_PPM_callback); PIOS_RFM22B_SetPPMCallback(pios_rfm22b_id, PIOS_Board_PPM_callback);
} }
// Reinitilize the modem to affect te changes. // Reinitilize the modem to affect te changes.
PIOS_RFM22B_Reinit(pios_rfm22b_id); PIOS_RFM22B_Reinit(pios_rfm22b_id);
} else { } else {
oplinkStatus.LinkState = OPLINKSTATUS_LINKSTATE_DISABLED; oplinkStatus.LinkState = OPLINKSTATUS_LINKSTATE_DISABLED;
} }
// Update the object // Update the object
OPLinkStatusSet(&oplinkStatus); OPLinkStatusSet(&oplinkStatus);
// Update the com baud rate. // Update the com baud rate.
uint32_t comBaud = 9600; uint32_t comBaud = 9600;
switch (oplinkSettings.ComSpeed) { switch (oplinkSettings.ComSpeed) {
case OPLINKSETTINGS_COMSPEED_4800: case OPLINKSETTINGS_COMSPEED_4800:
comBaud = 4800; comBaud = 4800;
break; break;
case OPLINKSETTINGS_COMSPEED_9600: case OPLINKSETTINGS_COMSPEED_9600:
comBaud = 9600; comBaud = 9600;
break; break;
case OPLINKSETTINGS_COMSPEED_19200: case OPLINKSETTINGS_COMSPEED_19200:
comBaud = 19200; comBaud = 19200;
break; break;
case OPLINKSETTINGS_COMSPEED_38400: case OPLINKSETTINGS_COMSPEED_38400:
comBaud = 38400; comBaud = 38400;
break; break;
case OPLINKSETTINGS_COMSPEED_57600: case OPLINKSETTINGS_COMSPEED_57600:
comBaud = 57600; comBaud = 57600;
break; break;
case OPLINKSETTINGS_COMSPEED_115200: case OPLINKSETTINGS_COMSPEED_115200:
comBaud = 115200; comBaud = 115200;
break; break;
} }
if (PIOS_COM_TELEMETRY) { if (PIOS_COM_TELEMETRY) {
PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, comBaud); PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, comBaud);
} }
/* Remap AFIO pin */ /* Remap AFIO pin */
GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST, ENABLE); GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST, ENABLE);
#ifdef PIOS_INCLUDE_ADC #ifdef PIOS_INCLUDE_ADC
PIOS_ADC_Init(); PIOS_ADC_Init();
#endif #endif
}
static void PIOS_Board_PPM_callback(const int16_t *channels)
{
#if defined(PIOS_INCLUDE_PPM) && defined(PIOS_INCLUDE_PPM_OUT)
if (pios_ppm_out_id) {
for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) {
if (channels[i] != PIOS_RCVR_INVALID) {
PIOS_PPM_OUT_Set(PIOS_PPM_OUTPUT, i, channels[i]);
} }
}
} static void PIOS_Board_PPM_callback(const int16_t * channels) {
#if defined(PIOS_INCLUDE_PPM) && defined(PIOS_INCLUDE_PPM_OUT)
if (pios_ppm_out_id) {
for (uint8_t i = 0; i < RFM22B_PPM_NUM_CHANNELS; ++i) {
if (channels[i] != PIOS_RCVR_INVALID) {
PIOS_PPM_OUT_Set(PIOS_PPM_OUTPUT, i, channels[i]);
}
}
}
#if defined(PIOS_INCLUDE_SERVO) #if defined(PIOS_INCLUDE_SERVO)
for (uint8_t i = 0; i < servo_count; ++i) { for (uint8_t i = 0; i < servo_count; ++i) {
uint16_t val = (channels[i] == PIOS_RCVR_INVALID) ? 0 : channels[i]; uint16_t val = (channels[i] == PIOS_RCVR_INVALID) ? 0 : channels[i];
PIOS_Servo_Set(i, val); PIOS_Servo_Set(i, val);
} }
#endif /* PIOS_INCLUDE_SERVO */ #endif /* PIOS_INCLUDE_SERVO */
#endif /* PIOS_INCLUDE_PPM && PIOS_INCLUDE_PPM_OUT */ #endif /* PIOS_INCLUDE_PPM && PIOS_INCLUDE_PPM_OUT */
} }
/** /**
* @} * @}

View File

@ -774,7 +774,7 @@ void PIOS_Board_Init(void)
PIOS_RFM22B_SetChannelConfig(pios_rfm22b_id, datarate, oplinkSettings.MinChannel, oplinkSettings.MaxChannel, is_coordinator, is_oneway, ppm_mode, ppm_only); PIOS_RFM22B_SetChannelConfig(pios_rfm22b_id, datarate, oplinkSettings.MinChannel, oplinkSettings.MaxChannel, is_coordinator, is_oneway, ppm_mode, ppm_only);
/* Set the PPM callback if we should be receiving PPM. */ /* Set the PPM callback if we should be receiving PPM. */
if (ppm_mode) { if (ppm_mode || (ppm_only && !is_coordinator)) {
PIOS_RFM22B_SetPPMCallback(pios_rfm22b_id, PIOS_Board_PPM_callback); PIOS_RFM22B_SetPPMCallback(pios_rfm22b_id, PIOS_Board_PPM_callback);
} }