diff --git a/flight/CopterControl/Makefile b/flight/CopterControl/Makefile index d8a74bc49..790a7e666 100644 --- a/flight/CopterControl/Makefile +++ b/flight/CopterControl/Makefile @@ -240,7 +240,6 @@ SRC += $(PIOSSTM32F10X)/pios_spi.c SRC += $(PIOSSTM32F10X)/pios_ppm.c SRC += $(PIOSSTM32F10X)/pios_pwm.c SRC += $(PIOSSTM32F10X)/pios_dsm.c -SRC += $(PIOSSTM32F10X)/pios_sbus.c SRC += $(PIOSSTM32F10X)/pios_debug.c SRC += $(PIOSSTM32F10X)/pios_gpio.c SRC += $(PIOSSTM32F10X)/pios_exti.c @@ -270,6 +269,7 @@ SRC += $(PIOSCOMMON)/pios_flash_jedec.c SRC += $(PIOSCOMMON)/pios_adxl345.c SRC += $(PIOSCOMMON)/pios_mpu6000.c SRC += $(PIOSCOMMON)/pios_com.c +SRC += $(PIOSCOMMON)/pios_sbus.c #SRC += $(PIOSCOMMON)/pios_i2c_esc.c #SRC += $(PIOSCOMMON)/pios_bmp085.c SRC += $(PIOSCOMMON)/pios_rcvr.c diff --git a/flight/PiOS/STM32F10x/pios_sbus.c b/flight/PiOS/Common/pios_sbus.c similarity index 100% rename from flight/PiOS/STM32F10x/pios_sbus.c rename to flight/PiOS/Common/pios_sbus.c diff --git a/flight/RevoMini/Makefile b/flight/RevoMini/Makefile index 67a1b6f3c..03e91d3ee 100644 --- a/flight/RevoMini/Makefile +++ b/flight/RevoMini/Makefile @@ -171,6 +171,7 @@ SRC += $(PIOSCOMMON)/pios_crc.c SRC += $(PIOSCOMMON)/pios_com.c SRC += $(PIOSCOMMON)/pios_rfm22b.c SRC += $(PIOSCOMMON)/pios_rcvr.c +SRC += $(PIOSCOMMON)/pios_sbus.c SRC += $(PIOSCOMMON)/pios_flash_jedec.c SRC += $(PIOSCOMMON)/pios_flashfs_objlist.c SRC += $(PIOSCOMMON)/printf-stdarg.c diff --git a/flight/RevoMini/System/inc/pios_config.h b/flight/RevoMini/System/inc/pios_config.h index 2728bae89..a4e18652c 100644 --- a/flight/RevoMini/System/inc/pios_config.h +++ b/flight/RevoMini/System/inc/pios_config.h @@ -82,7 +82,7 @@ /* Supported receiver interfaces */ #define PIOS_INCLUDE_RCVR #define PIOS_INCLUDE_DSM -//#define PIOS_INCLUDE_SBUS +#define PIOS_INCLUDE_SBUS #define PIOS_INCLUDE_PPM #define PIOS_INCLUDE_PWM #define PIOS_INCLUDE_GCSRCVR diff --git a/flight/Revolution/Makefile b/flight/Revolution/Makefile index d074c814d..cdcb3ce39 100644 --- a/flight/Revolution/Makefile +++ b/flight/Revolution/Makefile @@ -190,6 +190,7 @@ SRC += $(PIOSCOMMON)/pios_ms5611.c SRC += $(PIOSCOMMON)/pios_crc.c SRC += $(PIOSCOMMON)/pios_com.c SRC += $(PIOSCOMMON)/pios_rcvr.c +SRC += $(PIOSCOMMON)/pios_sbus.c SRC += $(PIOSCOMMON)/pios_flash_jedec.c SRC += $(PIOSCOMMON)/pios_flashfs_objlist.c SRC += $(PIOSCOMMON)/printf-stdarg.c diff --git a/flight/board_hw_defs/revolution/board_hw_defs.c b/flight/board_hw_defs/revolution/board_hw_defs.c index ffc61f989..7df06e4e9 100644 --- a/flight/board_hw_defs/revolution/board_hw_defs.c +++ b/flight/board_hw_defs/revolution/board_hw_defs.c @@ -997,6 +997,7 @@ static const struct pios_dsm_cfg pios_dsm_flexi_cfg = { static const struct pios_usart_cfg pios_usart_sbus_auxsbus_cfg = { .regs = UART4, + .remap = GPIO_AF_UART4, .init = { .USART_BaudRate = 100000, .USART_WordLength = USART_WordLength_8b, @@ -1046,9 +1047,10 @@ static const struct pios_sbus_cfg pios_sbus_cfg = { .GPIO_Speed = GPIO_Speed_2MHz, }, }, - .gpio_clk_func = RCC_AHB1PeriphClockCmd, - .gpio_clk_periph = RCC_AHB1Periph_GPIOB, .gpio_inv_enable = Bit_SET, + .gpio_inv_disable = Bit_RESET, + .gpio_clk_func = RCC_AHB1PeriphClockCmd, + .gpio_clk_periph = RCC_AHB1Periph_GPIOC, }; #endif /* PIOS_INCLUDE_SBUS */ diff --git a/flight/board_hw_defs/revomini/board_hw_defs.c b/flight/board_hw_defs/revomini/board_hw_defs.c index a16555c98..5c86d6624 100644 --- a/flight/board_hw_defs/revomini/board_hw_defs.c +++ b/flight/board_hw_defs/revomini/board_hw_defs.c @@ -550,11 +550,14 @@ static const struct pios_dsm_cfg pios_dsm_main_cfg = { #include #if defined(PIOS_INCLUDE_SBUS) -/* - * S.Bus USART - */ + /* + * S.Bus USART + */ +#include + static const struct pios_usart_cfg pios_usart_sbus_main_cfg = { .regs = USART1, + .remap = GPIO_AF_USART1, .init = { .USART_BaudRate = 100000, .USART_WordLength = USART_WordLength_8b, @@ -576,7 +579,9 @@ static const struct pios_usart_cfg pios_usart_sbus_main_cfg = { .init = { .GPIO_Pin = GPIO_Pin_10, .GPIO_Speed = GPIO_Speed_2MHz, - .GPIO_Mode = GPIO_Mode_IPU, + .GPIO_Mode = GPIO_Mode_AF, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_UP }, }, .tx = { @@ -584,7 +589,9 @@ static const struct pios_usart_cfg pios_usart_sbus_main_cfg = { .init = { .GPIO_Pin = GPIO_Pin_9, .GPIO_Speed = GPIO_Speed_2MHz, - .GPIO_Mode = GPIO_Mode_IN_FLOATING, + .GPIO_Mode = GPIO_Mode_OUT, + .GPIO_OType = GPIO_OType_PP, + .GPIO_PuPd = GPIO_PuPd_NOPULL }, }, }; @@ -606,6 +613,8 @@ static const struct pios_sbus_cfg pios_sbus_cfg = { }, .gpio_inv_enable = Bit_SET, .gpio_inv_disable = Bit_RESET, + .gpio_clk_func = RCC_AHB1PeriphClockCmd, + .gpio_clk_periph = RCC_AHB1Periph_GPIOC, };