diff --git a/flight/targets/boards/discoveryf4bare/firmware/pios_board.c b/flight/targets/boards/discoveryf4bare/firmware/pios_board.c index c4f7b7309..3876a28cd 100644 --- a/flight/targets/boards/discoveryf4bare/firmware/pios_board.c +++ b/flight/targets/boards/discoveryf4bare/firmware/pios_board.c @@ -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); } diff --git a/flight/targets/boards/oplinkmini/firmware/pios_board.c b/flight/targets/boards/oplinkmini/firmware/pios_board.c index a682ec241..4a027c647 100644 --- a/flight/targets/boards/oplinkmini/firmware/pios_board.c +++ b/flight/targets/boards/oplinkmini/firmware/pios_board.c @@ -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 */ -} + } /** * @} diff --git a/flight/targets/boards/revolution/firmware/pios_board.c b/flight/targets/boards/revolution/firmware/pios_board.c index 3723845e9..84877b342 100644 --- a/flight/targets/boards/revolution/firmware/pios_board.c +++ b/flight/targets/boards/revolution/firmware/pios_board.c @@ -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); }