[sbus] use gpio helper functions instead of abusing LED

This commit is contained in:
Felix Ruess
2013-07-23 13:47:05 +02:00
parent a2a3031570
commit 25906237a1
2 changed files with 15 additions and 19 deletions
+4 -11
View File
@@ -112,18 +112,11 @@
#define POWER_SWITCH_LED 9
/* Uart2 RX polarity, on PB13, 1 on LED_ON, 0 on LED_OFF */
#ifndef USE_LED_10
#define USE_LED_10 1
#endif
#define LED_10_GPIO GPIOB
#define LED_10_GPIO_CLK RCC_AHB1ENR_IOPBEN
#define LED_10_GPIO_PIN GPIO13
#define LED_10_GPIO_ON gpio_set
#define LED_10_GPIO_OFF gpio_clear
#define LED_10_AFIO_REMAP ((void)0)
#define RC_POLARITY_LED 10
/* Uart2 RX polarity, on PB13, 1 on LED_ON, 0 on LED_OFF */
#define RC_POLARITY_GPIO_PORT GPIOB
#define RC_POLARITY_GPIO_PIN GPIO13
/* Default actuators driver */
#define DEFAULT_ACTUATORS "subsystems/actuators/actuators_pwm.h"
+11 -8
View File
@@ -28,7 +28,7 @@
#include "subsystems/radio_control/sbus.h"
#include BOARD_CONFIG
#include "mcu_periph/uart.h"
#include "led.h"
#include "mcu_periph/gpio.h"
#include <string.h>
/*
@@ -44,13 +44,15 @@
#define SBUS_STATUS_UNINIT 0
#define SBUS_STATUS_GOT_START 1
/** Set polarity using RC_POLARITY_LED.
* SBUS signal has a reversed polarity compared to normal UART
* this allow to using hardware UART peripheral by changing
* the input signal polarity
/** Set polarity using RC_POLARITY_GPIO.
* SBUS signal has a reversed polarity compared to normal UART
* this allows to using hardware UART peripheral by changing
* the input signal polarity.
* Setting this gpio ouput low inverts the signal,
* output high sets it to normal polarity.
*/
#ifndef RC_SET_POLARITY
#define RC_SET_POLARITY LED_ON
#define RC_SET_POLARITY gpio_output_low
#endif
@@ -67,8 +69,9 @@ void radio_control_impl_init(void) {
uart_periph_set_baudrate(&SBUS_UART_DEV, B100000);
// Set polarity
#ifdef RC_POLARITY_LED
RC_SET_POLARITY(RC_POLARITY_LED);
#ifdef RC_POLARITY_GPIO_PORT
gpio_setup_output(RC_POLARITY_GPIO_PORT, RC_POLARITY_GPIO_PIN);
RC_SET_POLARITY(RC_POLARITY_GPIO_PORT, RC_POLARITY_GPIO_PIN);
#endif
}