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);
/* 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);
}

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);
/* Set the PPM callback if we should be receiving PPM. */
if (ppm_mode) {
PIOS_RFM22B_SetPPMCallback(pios_rfm22b_id, PIOS_Board_PPM_callback);
}
if (ppm_mode || (ppm_only && !is_coordinator)) {
PIOS_RFM22B_SetPPMCallback(pios_rfm22b_id, PIOS_Board_PPM_callback);
}
// Reinitilize the modem to affect te changes.
PIOS_RFM22B_Reinit(pios_rfm22b_id);
} else {
oplinkStatus.LinkState = OPLINKSTATUS_LINKSTATE_DISABLED;
}
// Reinitilize the modem to affect te changes.
PIOS_RFM22B_Reinit(pios_rfm22b_id);
} else {
oplinkStatus.LinkState = OPLINKSTATUS_LINKSTATE_DISABLED;
}
// Update the object
OPLinkStatusSet(&oplinkStatus);
// Update the object
OPLinkStatusSet(&oplinkStatus);
// Update the com baud rate.
uint32_t comBaud = 9600;
switch (oplinkSettings.ComSpeed) {
case OPLINKSETTINGS_COMSPEED_4800:
comBaud = 4800;
break;
case OPLINKSETTINGS_COMSPEED_9600:
comBaud = 9600;
break;
case OPLINKSETTINGS_COMSPEED_19200:
comBaud = 19200;
break;
case OPLINKSETTINGS_COMSPEED_38400:
comBaud = 38400;
break;
case OPLINKSETTINGS_COMSPEED_57600:
comBaud = 57600;
break;
case OPLINKSETTINGS_COMSPEED_115200:
comBaud = 115200;
break;
}
if (PIOS_COM_TELEMETRY) {
PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, comBaud);
}
// Update the com baud rate.
uint32_t comBaud = 9600;
switch (oplinkSettings.ComSpeed) {
case OPLINKSETTINGS_COMSPEED_4800:
comBaud = 4800;
break;
case OPLINKSETTINGS_COMSPEED_9600:
comBaud = 9600;
break;
case OPLINKSETTINGS_COMSPEED_19200:
comBaud = 19200;
break;
case OPLINKSETTINGS_COMSPEED_38400:
comBaud = 38400;
break;
case OPLINKSETTINGS_COMSPEED_57600:
comBaud = 57600;
break;
case OPLINKSETTINGS_COMSPEED_115200:
comBaud = 115200;
break;
}
if (PIOS_COM_TELEMETRY) {
PIOS_COM_ChangeBaud(PIOS_COM_TELEMETRY, comBaud);
}
/* Remap AFIO pin */
GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST, ENABLE);
/* Remap AFIO pin */
GPIO_PinRemapConfig(GPIO_Remap_SWJ_NoJTRST, ENABLE);
#ifdef PIOS_INCLUDE_ADC
PIOS_ADC_Init();
PIOS_ADC_Init();
#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)
for (uint8_t i = 0; i < servo_count; ++i) {
uint16_t val = (channels[i] == PIOS_RCVR_INVALID) ? 0 : channels[i];
PIOS_Servo_Set(i, val);
}
for (uint8_t i = 0; i < servo_count; ++i) {
uint16_t val = (channels[i] == PIOS_RCVR_INVALID) ? 0 : channels[i];
PIOS_Servo_Set(i, val);
}
#endif /* PIOS_INCLUDE_SERVO */
#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);
/* 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);
}