diff --git a/src/drivers/boards/px4fmu-v4/board_config.h b/src/drivers/boards/px4fmu-v4/board_config.h index d57396a8fd..d464c8af2a 100644 --- a/src/drivers/boards/px4fmu-v4/board_config.h +++ b/src/drivers/boards/px4fmu-v4/board_config.h @@ -215,7 +215,7 @@ __BEGIN_DECLS #define HRT_PPM_CHANNEL 3 /* use capture/compare channel 2 */ #define GPIO_PPM_IN (GPIO_ALT|GPIO_AF2|GPIO_PULLUP|GPIO_PORTB|GPIO_PIN0) -#define SBUS_SERIAL_PORT "/dev/ttyS4" +#define RC_SERIAL_PORT "/dev/ttyS4" /* PWM input driver. Use FMU AUX5 pins attached to timer4 channel 2 */ #define PWMIN_TIMER 4 @@ -226,7 +226,10 @@ __BEGIN_DECLS #define GPIO_LED_SAFETY (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN3) #define GPIO_BTN_SAFETY (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTC|GPIO_PIN4) #define GPIO_PERIPH_3V3_EN (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN5) +/* for R07, this signal is active low */ #define GPIO_SBUS_INV (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTC|GPIO_PIN13) +/* for R12, this signal is active high */ +//#define GPIO_SBUS_INV (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_SET|GPIO_PORTC|GPIO_PIN13) #define GPIO_8266_GPIO0 (GPIO_INPUT|GPIO_PULLUP|GPIO_PORTE|GPIO_PIN2) #define GPIO_SPEKTRUM_PWR_EN (GPIO_OUTPUT|GPIO_PUSHPULL|GPIO_SPEED_2MHz|GPIO_OUTPUT_CLEAR|GPIO_PORTE|GPIO_PIN4) diff --git a/src/drivers/px4fmu/fmu.cpp b/src/drivers/px4fmu/fmu.cpp index 05d7047c97..9747cd660c 100644 --- a/src/drivers/px4fmu/fmu.cpp +++ b/src/drivers/px4fmu/fmu.cpp @@ -631,19 +631,9 @@ PX4FMU::cycle() update_pwm_rev_mask(); -#ifdef SBUS_SERIAL_PORT - _sbus_fd = sbus_init(SBUS_SERIAL_PORT, false); -#endif - -#ifdef DSM_SERIAL_PORT - // XXX rather than opening it we need to cycle between protocols until one is locked in - //_dsm_fd = dsm_init(DSM_SERIAL_PORT); -#endif - _initialized = true; } - if (_groups_subscribed != _groups_required) { subscribe(); _groups_subscribed = _groups_required; @@ -811,15 +801,18 @@ PX4FMU::cycle() bool rc_updated = false; -#ifdef SBUS_SERIAL_PORT +#ifdef RC_SERIAL_PORT bool sbus_failsafe, sbus_frame_drop; uint16_t raw_rc_values[input_rc_s::RC_INPUT_MAX_CHANNELS]; uint16_t raw_rc_count; - bool sbus_updated = sbus_input(_sbus_fd, &raw_rc_values[0], &raw_rc_count, &sbus_failsafe, &sbus_frame_drop, + + // read port + bool sbus_updated = sbus_input(_sbus_fd, &raw_rc_values[0], &raw_rc_count, + &sbus_failsafe, &sbus_frame_drop, input_rc_s::RC_INPUT_MAX_CHANNELS); if (sbus_updated) { - // we have a new PPM frame. Publish it. + // we have a new SBUS frame. Publish it. _rc_in.channel_count = raw_rc_count; if (_rc_in.channel_count > input_rc_s::RC_INPUT_MAX_CHANNELS) { @@ -848,8 +841,8 @@ PX4FMU::cycle() #ifdef HRT_PPM_CHANNEL // see if we have new PPM input data - if ((ppm_last_valid_decode != _rc_in.timestamp_last_signal) && - ppm_decoded_channels > 3) { + if ((ppm_last_valid_decode != _rc_in.timestamp_last_signal) + && ppm_decoded_channels > 3) { // we have a new PPM frame. Publish it. _rc_in.channel_count = ppm_decoded_channels; @@ -2224,7 +2217,7 @@ fmu_main(int argc, char *argv[]) } if (!strcmp(verb, "info")) { -#ifdef SBUS_SERIAL_PORT +#ifdef RC_SERIAL_PORT warnx("frame drops: %u", sbus_dropped_frames()); #endif return 0;