From f9be3ce38d8a6f71af78a4edd709fb7c741f55d0 Mon Sep 17 00:00:00 2001 From: Gautier Hattenberger Date: Mon, 22 Jul 2013 10:32:13 +0200 Subject: [PATCH] [sbus] code cleaning and comments --- sw/airborne/arch/stm32/mcu_periph/uart_arch.c | 7 +++---- sw/airborne/subsystems/radio_control/sbus.h | 15 +++++++-------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/sw/airborne/arch/stm32/mcu_periph/uart_arch.c b/sw/airborne/arch/stm32/mcu_periph/uart_arch.c index a49bbf32dd2..335a90ed50e 100644 --- a/sw/airborne/arch/stm32/mcu_periph/uart_arch.c +++ b/sw/airborne/arch/stm32/mcu_periph/uart_arch.c @@ -41,11 +41,8 @@ void uart_periph_set_baudrate(struct uart_periph* p, uint32_t baud) { - /* Configure USART */ + /* Configure USART baudrate */ usart_set_baudrate((uint32_t)p->reg_addr, baud); - //usart_set_databits((uint32_t)p->reg_addr, 8); - //usart_set_stopbits((uint32_t)p->reg_addr, USART_STOPBITS_1); - //usart_set_parity((uint32_t)p->reg_addr, USART_PARITY_NONE); /* Disable Idle Line interrupt */ USART_CR1((uint32_t)p->reg_addr) &= ~USART_CR1_IDLEIE; @@ -62,6 +59,7 @@ void uart_periph_set_baudrate(struct uart_periph* p, uint32_t baud) { } void uart_periph_set_bits_stop_parity(struct uart_periph* p, uint8_t bits, uint8_t stop, uint8_t parity) { + /* Configure USART parity and data bits */ if (parity == UPARITY_EVEN) { usart_set_parity((uint32_t)p->reg_addr, USART_PARITY_EVEN); if (bits == UBITS_7) @@ -80,6 +78,7 @@ void uart_periph_set_bits_stop_parity(struct uart_periph* p, uint8_t bits, uint8 usart_set_parity((uint32_t)p->reg_addr, USART_PARITY_NONE); usart_set_databits((uint32_t)p->reg_addr, 8); // is 7bits without parity possible ? } + /* Configure USART stop bits */ if (stop == USTOP_2) usart_set_stopbits((uint32_t)p->reg_addr, USART_STOPBITS_2); else // 1 stop bit by default diff --git a/sw/airborne/subsystems/radio_control/sbus.h b/sw/airborne/subsystems/radio_control/sbus.h index bb2c9efcc3f..3f344194a74 100644 --- a/sw/airborne/subsystems/radio_control/sbus.h +++ b/sw/airborne/subsystems/radio_control/sbus.h @@ -29,13 +29,6 @@ #include "std.h" -///** -// * Architecture dependant code -// */ -//#include "subsystems/radio_control/ppm_arch.h" -///* must be implemented by arch dependant code */ -//extern void ppm_arch_init(void); - /** * Dummy macro to use radio.h file */ @@ -50,7 +43,13 @@ #include "generated/radio.h" /** - * Define number of channels + * Define number of channels. + * + * SBUS frame always have 16 channels + * but only the X first one will be available + * depending of the RC transmitter. + * The radio XML file is used to assign the + * input values to RC channels. */ #define SBUS_BUF_LENGTH 24 #define SBUS_NB_CHANNEL 16