mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-23 13:24:03 +08:00
Pixracer Spektrum fixes
This commit is contained in:
@@ -39,7 +39,7 @@ SYS_TIME_LED ?= 1
|
||||
#
|
||||
# default UART configuration (RC receiver, telemetry modem, GPS)
|
||||
#
|
||||
RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT ?= UART1
|
||||
RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT ?= UART6
|
||||
#RADIO_CONTROL_SPEKTRUM_SECONDARY_PORT ?= UART7
|
||||
|
||||
MODEM_PORT ?= UART2
|
||||
|
||||
@@ -146,7 +146,7 @@
|
||||
* Spektrum
|
||||
*/
|
||||
/* Define power pin */
|
||||
#define RADIO_CONTROL_POWER GPIOC
|
||||
#define RADIO_CONTROL_POWER_PORT GPIOC
|
||||
#define RADIO_CONTROL_POWER_PIN GPIO13
|
||||
#define RADIO_CONTROL_POWER_ON gpio_set
|
||||
#define RADIO_CONTROL_POWER_OFF gpio_clear
|
||||
|
||||
@@ -88,6 +88,11 @@
|
||||
#define UART4_GPIO_PORT_TX GPIOA
|
||||
#define UART4_GPIO_TX GPIO0
|
||||
|
||||
/* Spektrum (only rx)*/
|
||||
#define UART6_GPIO_AF GPIO_AF8
|
||||
#define UART6_GPIO_PORT_RX GPIOC
|
||||
#define UART6_GPIO_RX GPIO7
|
||||
|
||||
/* Serial Debugging Connector, not used with PPRZ, use JTAG, can be put to other good use */
|
||||
#define UART7_GPIO_AF GPIO_AF8
|
||||
#define UART7_GPIO_PORT_RX GPIOE
|
||||
@@ -103,30 +108,31 @@
|
||||
#define UART8_GPIO_TX GPIO1
|
||||
|
||||
/* Soft binding Spektrum */
|
||||
#define RADIO_CONTROL_POWER GPIOB
|
||||
#define RADIO_CONTROL_POWER_PIN GPIO0
|
||||
//ok
|
||||
#define RADIO_CONTROL_POWER_PORT GPIOC
|
||||
#define RADIO_CONTROL_POWER_PIN GPIO5
|
||||
#define RADIO_CONTROL_POWER_ON gpio_set
|
||||
#define RADIO_CONTROL_POWER_OFF gpio_clear
|
||||
|
||||
|
||||
//FIXME Check
|
||||
#define SPEKTRUM_UART1_RCC RCC_USART1
|
||||
#define SPEKTRUM_UART1_BANK GPIOB
|
||||
#define SPEKTRUM_UART1_PIN GPIO0
|
||||
#define SPEKTRUM_UART1_AF GPIO_AF7
|
||||
#define SPEKTRUM_UART1_IRQ NVIC_USART1_IRQ
|
||||
#define SPEKTRUM_UART1_ISR usart1_isr
|
||||
#define SPEKTRUM_UART1_DEV USART1
|
||||
//FIXME Check
|
||||
/*
|
||||
#define SPEKTRUM_UART2_RCC RCC_USART2
|
||||
#define SPEKTRUM_UART2_BANK GPIOC
|
||||
#define SPEKTRUM_UART2_PIN GPIO7
|
||||
#define SPEKTRUM_UART2_AF GPIO_AF7
|
||||
#define SPEKTRUM_UART2_IRQ NVIC_USART2_IRQ
|
||||
#define SPEKTRUM_UART2_ISR usart2_isr
|
||||
#define SPEKTRUM_UART2_DEV USART2
|
||||
*/
|
||||
#define PERIPHERAL3V3_ENABLE_PORT GPIOE
|
||||
#define PERIPHERAL3V3_ENABLE_PIN GPIO4
|
||||
#define PERIPHERAL3V3_ENABLE_ON gpio_clear // yes, inverted
|
||||
#define PERIPHERAL3V3_ENABLE_OFF gpio_set
|
||||
|
||||
/* Turn SBUS invert */
|
||||
//ok
|
||||
#define RC_POLARITY_GPIO_PORT GPIOC
|
||||
#define RC_POLARITY_GPIO_PIN GPIO13
|
||||
|
||||
//ok
|
||||
#define SPEKTRUM_UART6_RCC RCC_USART6
|
||||
#define SPEKTRUM_UART6_BANK GPIOC
|
||||
#define SPEKTRUM_UART6_PIN GPIO7
|
||||
#define SPEKTRUM_UART6_AF GPIO_AF8
|
||||
#define SPEKTRUM_UART6_IRQ NVIC_USART6_IRQ
|
||||
#define SPEKTRUM_UART6_ISR usart6_isr
|
||||
#define SPEKTRUM_UART6_DEV USART6
|
||||
|
||||
/* SPI */
|
||||
|
||||
|
||||
@@ -66,7 +66,7 @@
|
||||
* Spektrum
|
||||
*/
|
||||
/* The line that is pulled low at power up to initiate the bind process */
|
||||
#define RADIO_CONTROL_POWER GPIOC
|
||||
#define RADIO_CONTROL_POWER_PORT GPIOC
|
||||
#define RADIO_CONTROL_POWER_PIN GPIO13
|
||||
#define RADIO_CONTROL_POWER_ON gpio_set
|
||||
#define RADIO_CONTROL_POWER_OFF gpio_clear
|
||||
|
||||
@@ -240,6 +240,7 @@ STATIC_INLINE void main_init(void)
|
||||
|
||||
// Do a failsafe check first
|
||||
failsafe_check();
|
||||
|
||||
}
|
||||
|
||||
STATIC_INLINE void handle_periodic_tasks(void)
|
||||
|
||||
+3
-3
@@ -112,9 +112,9 @@ void mcu_init(void)
|
||||
led_init();
|
||||
#endif
|
||||
/* First enable power of RC */
|
||||
#if defined RADIO_CONTROL_POWER
|
||||
gpio_setup_output(RADIO_CONTROL_POWER, RADIO_CONTROL_POWER_PIN);
|
||||
RADIO_CONTROL_POWER_ON(RADIO_CONTROL_POWER, RADIO_CONTROL_POWER_PIN);
|
||||
#if defined RADIO_CONTROL_POWER_PORT
|
||||
gpio_setup_output(RADIO_CONTROL_POWER_PORT, RADIO_CONTROL_POWER_PIN);
|
||||
RADIO_CONTROL_POWER_ON(RADIO_CONTROL_POWER_PORT, RADIO_CONTROL_POWER_PIN);
|
||||
#endif
|
||||
/* for now this means using spektrum */
|
||||
#if defined RADIO_CONTROL & defined RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT & defined RADIO_CONTROL_BIND_IMPL_FUNC & defined SPEKTRUM_BIND_PIN_PORT
|
||||
|
||||
@@ -71,7 +71,7 @@ void opa_controller_periodic(void) {
|
||||
AP_PWR_OFF(AP_PWR, AP_PWR_PIN);
|
||||
MAIN_PWR_OFF(MAIN_PWR, MAIN_PWR_PIN);
|
||||
BAL_PWR_OFF(BAL_PWR, BAL_PWR_PIN);
|
||||
RADIO_CONTROL_POWER_OFF(RADIO_CONTROL_POWER,RADIO_CONTROL_POWER_PIN);
|
||||
RADIO_CONTROL_POWER_OFF(RADIO_CONTROL_POWER_PORT,RADIO_CONTROL_POWER_PIN);
|
||||
MCU_PWR_OFF(MCU_PWR, MCU_PWR_PIN);
|
||||
arming_led = false;
|
||||
return;
|
||||
@@ -106,7 +106,7 @@ void opa_controller_periodic(void) {
|
||||
MAIN_PWR_ON(MAIN_PWR, MAIN_PWR_PIN);
|
||||
BAL_PWR_ON(BAL_PWR, BAL_PWR_PIN);
|
||||
//AP_PWR_ON(AP_PWR, AP_PWR_PIN);
|
||||
//RADIO_CONTROL_POWER_ON(RADIO_CONTROL_POWER,RADIO_CONTROL_POWER_PIN);
|
||||
//RADIO_CONTROL_POWER_ON(RADIO_CONTROL_POWER_PORT,RADIO_CONTROL_POWER_PIN);
|
||||
} else {
|
||||
arming_cnt++;
|
||||
}
|
||||
|
||||
@@ -33,15 +33,24 @@
|
||||
|
||||
#include "mcu_periph/gpio.h"
|
||||
|
||||
void spektrum_soft_bind_init(void) {}
|
||||
void spektrum_soft_bind_init(void) {
|
||||
gpio_setup_output(RADIO_CONTROL_POWER_PORT, RADIO_CONTROL_POWER_PIN);
|
||||
RADIO_CONTROL_POWER_ON(RADIO_CONTROL_POWER_PORT, RADIO_CONTROL_POWER_PIN);
|
||||
|
||||
#ifdef PERIPHERAL3V3_ENABLE_PORT // px4fmu 4 (pixracer) has this
|
||||
gpio_setup_output(PERIPHERAL3V3_ENABLE_PORT, PERIPHERAL3V3_ENABLE_PIN);
|
||||
PERIPHERAL3V3_ENABLE_ON(PERIPHERAL3V3_ENABLE_PORT, PERIPHERAL3V3_ENABLE_PIN);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
uint8_t bind_soft_value;
|
||||
void spektrum_soft_bind_click(uint8_t val __attribute__((unused)))
|
||||
{
|
||||
#ifndef INTER_MCU_AP
|
||||
send_spektrum_bind();
|
||||
send_spektrum_bind();
|
||||
#else
|
||||
intermcu_send_spektrum_bind();
|
||||
intermcu_send_spektrum_bind();
|
||||
#endif
|
||||
|
||||
}
|
||||
@@ -50,9 +59,11 @@ void spektrum_soft_bind_click(uint8_t val __attribute__((unused)))
|
||||
void send_spektrum_bind(void) {
|
||||
|
||||
//power cycle the spektrum
|
||||
RADIO_CONTROL_POWER_OFF(RADIO_CONTROL_POWER, RADIO_CONTROL_POWER_PIN);
|
||||
sys_time_usleep(100000);
|
||||
RADIO_CONTROL_POWER_ON(RADIO_CONTROL_POWER, RADIO_CONTROL_POWER_PIN);
|
||||
RADIO_CONTROL_POWER_OFF(RADIO_CONTROL_POWER_PORT, RADIO_CONTROL_POWER_PIN);
|
||||
sys_time_usleep(1000000);
|
||||
RADIO_CONTROL_POWER_ON(RADIO_CONTROL_POWER_PORT, RADIO_CONTROL_POWER_PIN);
|
||||
|
||||
|
||||
|
||||
//put to bind mode
|
||||
RADIO_CONTROL_BIND_IMPL_FUNC(); //basically = radio_control_spektrum_try_bind()
|
||||
|
||||
Reference in New Issue
Block a user