From e662257a21ecab6bd9421a1d1683a1e757c88241 Mon Sep 17 00:00:00 2001 From: SergDoc Date: Fri, 1 Jul 2016 21:53:09 +0300 Subject: [PATCH] fix target F4BY a new firmware Conflicts: src/main/target/F4BY/target.c src/main/target/F4BY/target.h --- src/main/target/F4BY/target.c | 39 ++++++++------- src/main/target/F4BY/target.h | 91 ++++++++++++++++++----------------- 2 files changed, 68 insertions(+), 62 deletions(-) diff --git a/src/main/target/F4BY/target.c b/src/main/target/F4BY/target.c index 472d1e801..e023d7e96 100644 --- a/src/main/target/F4BY/target.c +++ b/src/main/target/F4BY/target.c @@ -14,6 +14,7 @@ const uint16_t multiPPM[] = { PWM14 | (MAP_TO_MOTOR_OUTPUT << 8), PWM15 | (MAP_TO_MOTOR_OUTPUT << 8), // Swap to servo if needed PWM16 | (MAP_TO_MOTOR_OUTPUT << 8), // Swap to servo if needed + PWM8 | (MAP_TO_SERVO_OUTPUT << 8), // Swap to servo if needed PWM7 | (MAP_TO_SERVO_OUTPUT << 8), // Swap to servo if needed PWM6 | (MAP_TO_SERVO_OUTPUT << 8), // Swap to servo if needed PWM5 | (MAP_TO_SERVO_OUTPUT << 8), // Swap to servo if needed @@ -30,8 +31,8 @@ const uint16_t multiPWM[] = { PWM4 | (MAP_TO_PWM_INPUT << 8), PWM5 | (MAP_TO_PWM_INPUT << 8), PWM6 | (MAP_TO_PWM_INPUT << 8), - PWM7 | (MAP_TO_PWM_INPUT << 8), - PWM8 | (MAP_TO_PWM_INPUT << 8), // input #8 + PWM7 | (MAP_TO_SERVO_OUTPUT << 8), + PWM8 | (MAP_TO_SERVO_OUTPUT << 8), // input #8 PWM9 | (MAP_TO_MOTOR_OUTPUT << 8), // motor #1 PWM10 | (MAP_TO_MOTOR_OUTPUT << 8), // motor #2 PWM11 | (MAP_TO_MOTOR_OUTPUT << 8), @@ -83,22 +84,24 @@ const uint16_t airPWM[] = { }; const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = { - { TIM3, IO_TAG(PC9), TIM_Channel_4, TIM3_IRQn, IOCFG_IPD, GPIO_Mode_AF, GPIO_AF_TIM3, 0}, // S1_IN - { TIM3, IO_TAG(PC8), TIM_Channel_3, TIM3_IRQn, IOCFG_IPD, GPIO_Mode_AF, GPIO_AF_TIM3, 0}, // S2_IN - { TIM3, IO_TAG(PC6), TIM_Channel_1, TIM3_IRQn, IOCFG_IPD, GPIO_Mode_AF, GPIO_AF_TIM3, 0}, // S3_IN - { TIM3, IO_TAG(PC7), TIM_Channel_2, TIM3_IRQn, IOCFG_IPD, GPIO_Mode_AF, GPIO_AF_TIM3, 0}, // S4_IN - { TIM4, IO_TAG(PD15), TIM_Channel_4, TIM4_IRQn, IOCFG_IPD, GPIO_Mode_AF, GPIO_AF_TIM4, 0}, // S5_IN - { TIM4, IO_TAG(PD14), TIM_Channel_3, TIM4_IRQn, IOCFG_IPD, GPIO_Mode_AF, GPIO_AF_TIM4, 0}, // S6_IN - { TIM4, IO_TAG(PD13), TIM_Channel_2, TIM4_IRQn, IOCFG_IPD, GPIO_Mode_AF, GPIO_AF_TIM4, 0}, // S7_IN - { TIM4, IO_TAG(PD12), TIM_Channel_1, TIM4_IRQn, IOCFG_IPD, GPIO_Mode_AF, GPIO_AF_TIM4, 0}, // S8_IN + { TIM3, IO_TAG(PC9), TIM_Channel_4, TIM3_IRQn, 0, IOCFG_AF_PP, GPIO_AF_TIM3}, // S1_IN + { TIM3, IO_TAG(PC8), TIM_Channel_3, TIM3_IRQn, 0, IOCFG_AF_PP, GPIO_AF_TIM3}, // S2_IN + { TIM3, IO_TAG(PC6), TIM_Channel_1, TIM3_IRQn, 0, IOCFG_AF_PP, GPIO_AF_TIM3}, // S3_IN + { TIM3, IO_TAG(PC7), TIM_Channel_2, TIM3_IRQn, 0, IOCFG_AF_PP, GPIO_AF_TIM3}, // S4_IN + { TIM4, IO_TAG(PD15), TIM_Channel_4, TIM4_IRQn, 0, IOCFG_AF_PP, GPIO_AF_TIM4}, // S5_IN + { TIM4, IO_TAG(PD14), TIM_Channel_3, TIM4_IRQn, 0, IOCFG_AF_PP, GPIO_AF_TIM4}, // S6_IN + { TIM4, IO_TAG(PD13), TIM_Channel_2, TIM4_IRQn, 0, IOCFG_AF_PP, GPIO_AF_TIM4}, // S7_IN + { TIM4, IO_TAG(PD12), TIM_Channel_1, TIM4_IRQn, 0, IOCFG_AF_PP, GPIO_AF_TIM4}, // S8_IN - { TIM2, IO_TAG(PA0), TIM_Channel_1, TIM2_IRQn, IOCFG_AF_PP_PD, GPIO_Mode_AF, GPIO_AF_TIM2, 0}, // S1_OUT - { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM2_IRQn, IOCFG_AF_PP_PD, GPIO_Mode_AF, GPIO_AF_TIM2, 0}, // S2_OUT - { TIM5, IO_TAG(PA2), TIM_Channel_3, TIM5_IRQn, IOCFG_AF_PP_PD, GPIO_Mode_AF, GPIO_AF_TIM5, 0}, // S3_OUT - { TIM5, IO_TAG(PA3), TIM_Channel_4, TIM5_IRQn, IOCFG_AF_PP_PD, GPIO_Mode_AF, GPIO_AF_TIM5, 0}, // S4_OUT - { TIM1, IO_TAG(PE9), TIM_Channel_1, TIM1_CC_IRQn, IOCFG_AF_PP_PD, GPIO_Mode_AF, GPIO_AF_TIM1, 0}, // S5_OUT - { TIM1, IO_TAG(PE11), TIM_Channel_2, TIM1_CC_IRQn, IOCFG_AF_PP_PD, GPIO_Mode_AF, GPIO_AF_TIM1, 0}, // S6_OUT - { TIM1, IO_TAG(PE13), TIM_Channel_3, TIM1_CC_IRQn, IOCFG_AF_PP_PD, GPIO_Mode_AF, GPIO_AF_TIM1, 0}, // S7_OUT - { TIM1, IO_TAG(PE14), TIM_Channel_4, TIM1_CC_IRQn, IOCFG_AF_PP_PD, GPIO_Mode_AF, GPIO_AF_TIM1, 0}, // S8_OUT + { TIM2, IO_TAG(PA0), TIM_Channel_1, TIM2_IRQn, 1, IOCFG_AF_PP, GPIO_AF_TIM2}, // S1_OUT + { TIM2, IO_TAG(PA1), TIM_Channel_2, TIM2_IRQn, 1, IOCFG_AF_PP, GPIO_AF_TIM2}, // S2_OUT + { TIM5, IO_TAG(PA2), TIM_Channel_3, TIM5_IRQn, 1, IOCFG_AF_PP, GPIO_AF_TIM5}, // S3_OUT + { TIM5, IO_TAG(PA3), TIM_Channel_4, TIM5_IRQn, 1, IOCFG_AF_PP, GPIO_AF_TIM5}, // S4_OUT + { TIM1, IO_TAG(PE9), TIM_Channel_1, TIM1_CC_IRQn, 1, IOCFG_AF_PP, GPIO_AF_TIM1}, // S5_OUT + { TIM1, IO_TAG(PE11), TIM_Channel_2, TIM1_CC_IRQn, 1, IOCFG_AF_PP, GPIO_AF_TIM1}, // S6_OUT + { TIM1, IO_TAG(PE13), TIM_Channel_3, TIM1_CC_IRQn, 1, IOCFG_AF_PP, GPIO_AF_TIM1}, // S7_OUT + { TIM1, IO_TAG(PE14), TIM_Channel_4, TIM1_CC_IRQn, 1, IOCFG_AF_PP, GPIO_AF_TIM1}, // S8_OUT + + { TIM9, IO_TAG(PE6), TIM_Channel_2, TIM1_BRK_TIM9_IRQn, 0, IOCFG_AF_PP, GPIO_AF_TIM9 }, // sonar echo if needed }; diff --git a/src/main/target/F4BY/target.h b/src/main/target/F4BY/target.h index c27aa4a38..127a33d4b 100644 --- a/src/main/target/F4BY/target.h +++ b/src/main/target/F4BY/target.h @@ -58,45 +58,53 @@ #define USE_SDCARD -#define SDCARD_SPI_INSTANCE SPI3 +#define SDCARD_SPI_INSTANCE SPI2 #define SDCARD_SPI_CS_PIN PE15 -// SPI3 is on the APB1 bus whose clock runs at 84MHz. Divide to under 400kHz for init: +// SPI2 is on the APB1 bus whose clock runs at 84MHz. Divide to under 400kHz for init: #define SDCARD_SPI_INITIALIZATION_CLOCK_DIVIDER 256 // 328kHz // Divide to under 25MHz for normal operation: -#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4 // 21MHz +#define SDCARD_SPI_FULL_SPEED_CLOCK_DIVIDER 4 // 21MHz -#define SDCARD_DMA_CHANNEL_TX DMA1_Stream4 -#define SDCARD_DMA_CHANNEL_TX_COMPLETE_FLAG DMA_FLAG_TCIF4 + +#define SDCARD_DMA_CHANNEL_TX DMA1_Stream3 +#define SDCARD_DMA_CHANNEL_TX_COMPLETE_FLAG DMA_FLAG_TCIF3 #define SDCARD_DMA_CLK RCC_AHB1Periph_DMA1 #define SDCARD_DMA_CHANNEL DMA_Channel_0 -// Performance logging for SD card operations: -#define USABLE_TIMER_CHANNEL_COUNT 16 +#define USABLE_TIMER_CHANNEL_COUNT 17 #define USE_VCP #define VBUS_SENSING_PIN PA9 -#define USE_USART1 -#define USART1_RX_PIN PB7 -#define USART1_TX_PIN PB6 -#define USART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2 +#define USE_UART1 +#define UART1_RX_PIN PB7 +#define UART1_TX_PIN PB6 +#define UART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2 -#define USE_USART2 -#define USART2_RX_PIN PD6 -#define USART2_TX_PIN PD5 +#define USE_UART2 +#define UART2_RX_PIN PD6 +#define UART2_TX_PIN PD5 -#define USE_USART3 -#define USART3_RX_PIN PD9 -#define USART3_TX_PIN PD8 +#define USE_UART3 +#define UART3_RX_PIN PD9 +#define UART3_TX_PIN PD8 -#define USE_USART6 -#define USART6_RX_PIN PC7 -#define USART6_TX_PIN PC6 +#define USE_UART4 +#define UART4_RX_PIN PC11 +#define UART4_TX_PIN PC10 + +//#define USE_UART5 - error in DMA!!! +//#define UART5_RX_PIN PD2 +//#define UART5_TX_PIN PC12 + +#define USE_UART6 +#define UART6_RX_PIN PC7 +#define UART6_TX_PIN PC6 -#define SERIAL_PORT_COUNT 5 +#define SERIAL_PORT_COUNT 6 //VCP, UART1, UART2, UART3, UART4, UART5, UART6 #define USE_SPI @@ -106,12 +114,18 @@ #define SPI1_MOSI_PIN PA7 #define SPI1_NSS_PIN NONE +#define USE_SPI_DEVICE_2 +#define SPI2_NSS_PIN NONE +#define SPI2_SCK_PIN PB13 +#define SPI2_MISO_PIN PB14 +#define SPI2_MOSI_PIN PB15 #define USE_SPI_DEVICE_3 -#define SPI3_NSS_PIN NONE -#define SPI2_SCK_PIN PB3 -#define SPI2_MISO_PIN PB4 -#define SPI2_MOSI_PIN PB5 +#define SPI3_NSS_PIN PA15 +#define SPI3_SCK_PIN PB3 +#define SPI3_MISO_PIN PB4 +#define SPI3_MOSI_PIN PB5 + #define USE_I2C @@ -121,31 +135,20 @@ #define I2C2_SDA PB11 #define USE_ADC -//#define BOARD_HAS_VOLTAGE_DIVIDER +#define BOARD_HAS_VOLTAGE_DIVIDER #define VBAT_ADC_PIN PC3 #define CURRENT_METER_ADC_PIN PC2 #define RSSI_ADC_PIN PC1 - -#define SENSORS_SET (SENSOR_ACC) - - -// alternative defaults for F4BY -//#define F4BY - -#define SPEKTRUM_BIND -// USART6, PC7 -#define BIND_PIN PC7 - -#define HARDWARE_BIND_PLUG -// Hardware bind plug at PB2 (Pin 28) -#define BINDPLUG_PIN PB2 +#define DEFAULT_FEATURES (FEATURE_VBAT | FEATURE_BLACKBOX | FEATURE_ONESHOT125) +#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL +#define SERIALRX_PROVIDER SERIALRX_SBUS #define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT -#define BRUSHED_MOTORS -#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL -#define DEFAULT_FEATURES (FEATURE_MOTOR_STOP | FEATURE_BLACKBOX) +#define SPEKTRUM_BIND +// UART6, PC7 +#define BIND_PIN PC7 #define USE_SERIAL_4WAY_BLHELI_INTERFACE @@ -155,5 +158,5 @@ #define TARGET_IO_PORTD 0xffff #define TARGET_IO_PORTE 0xffff -#define USED_TIMERS ( TIM_N(1) |TIM_N(2) | TIM_N(3) | TIM_N(4) | TIM_N(5) | TIM_N(8) ) +#define USED_TIMERS ( TIM_N(1) |TIM_N(2) | TIM_N(3) | TIM_N(4) | TIM_N(5) | TIM_N(8) | TIM_N(9))