Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add target UAVPNG030MINI for the UAVP-NG HW-0.30-mini board #6781

Merged
merged 6 commits into from Sep 18, 2018
Merged
39 changes: 39 additions & 0 deletions src/main/target/UAVPNG030MINI/target.c
@@ -0,0 +1,39 @@
/*
* This file is part of Cleanflight.
*
* Cleanflight is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Cleanflight is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/

#include <stdint.h>

#include <platform.h>
#include "drivers/io.h"

#include "drivers/dma.h"
#include "drivers/timer.h"
#include "drivers/timer_def.h"

const timerHardware_t timerHardware[USABLE_TIMER_CHANNEL_COUNT] = {
DEF_TIM(TIM3, CH1, PA2, TIM_USE_PPM, 0, 0), // PPM_IN_A
DEF_TIM(TIM3, CH1, PA3, TIM_USE_PPM, 0, 0), // PPM_IN_B
aguindehi marked this conversation as resolved.
Show resolved Hide resolved

DEF_TIM(TIM3, CH3, PA8, TIM_USE_MOTOR, 0, 0), // PPM_OUT_A
DEF_TIM(TIM1, CH2, PE11, TIM_USE_MOTOR, 0, 0), // PPM_OUT_B
DEF_TIM(TIM1, CH3, PE13, TIM_USE_MOTOR, 0, 0), // PPM_OUT_C
DEF_TIM(TIM1, CH4, PE14, TIM_USE_MOTOR, 0, 0), // PPM_OUT_D
DEF_TIM(TIM3, CH3, PB5, TIM_USE_MOTOR, 0, 0), // PPM_OUT_E
DEF_TIM(TIM4, CH2, PD13, TIM_USE_MOTOR, 0, 0), // PPM_OUT_F
DEF_TIM(TIM4, CH3, PD14, TIM_USE_MOTOR, 0, 0), // PPM_OUT_G
DEF_TIM(TIM4, CH4, PD15, TIM_USE_MOTOR, 0, 0), // PPM_OUT_H
};
157 changes: 157 additions & 0 deletions src/main/target/UAVPNG030MINI/target.h
@@ -0,0 +1,157 @@
/*
* This is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma once

#define TARGET_BOARD_IDENTIFIER "UAVP"

#define USBD_PRODUCT_STRING "UAVP-NG HW-0.30-mini"

#define LED0_PIN PE5
#define LED1_PIN PE7
#define LED2_PIN PE6
#define LED3_PIN PE8

#define BEEPER PB0
#define BEEPER_INVERTED

#define MPU6000_CS_PIN PA4
#define MPU6000_SPI_INSTANCE SPI1

#define ACC
#define USE_ACC_SPI_MPU6000

#define GYRO
#define USE_GYRO_SPI_MPU6000

// TODO
#define GYRO_MPU6000_ALIGN CW180_DEG
#define ACC_MPU6000_ALIGN CW180_DEG

// MPU6000 interrupts
#define USE_EXTI
#define MPU_INT_EXTI PE0
#define USE_MPU_DATA_READY_SIGNAL

#define MAG
#define USE_MAG_HMC5883
#define MAG_HMC5883_ALIGN CW90_DEG
#define MAG_I2C_INSTANCE I2CDEV_2
#define HMC5883_I2C_INSTANCE I2CDEV_2
#define MAG_INT_EXTI PE12
#define USE_MAG_DATA_READY_SIGNAL

#define BARO
#define USE_BARO_MS5611
aguindehi marked this conversation as resolved.
Show resolved Hide resolved
#define USE_BARO_SPI_MS5611
#define MS5611_CS_PIN PE1
#define MS5611_SPI_INSTANCE SPI1

#if 0 // TODO: Enable SDCard and blackbox logging
#define ENABLE_BLACKBOX_LOGGING_ON_SDCARD_BY_DEFAULT
#define USE_SDCARD
#define USE_SDCARD_SPI2
#define SDCARD_DETECT_INVERTED
#define SDCARD_DETECT_PIN PE2
#define SDCARD_SPI_INSTANCE SPI2
#define SDCARD_SPI_CS_PIN SPI2_NSS_PIN
// 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_DMA_CHANNEL_TX DMA1_Stream4
#define SDCARD_DMA_CHANNEL_TX_COMPLETE_FLAG DMA_FLAG_TCIF4
#define SDCARD_DMA_CLK RCC_AHB1Periph_DMA1
#define SDCARD_DMA_CHANNEL DMA_Channel_0
#elif defined(LUXF4OSD)
#define ENABLE_BLACKBOX_LOGGING_ON_SPIFLASH_BY_DEFAULT
#define M25P16_CS_PIN PB12
#define M25P16_SPI_INSTANCE SPI2
#define USE_FLASHFS
#define USE_FLASH_M25P16
#endif

#define USE_VCP
//#define VBUS_SENSING_PIN PC5

#define USE_UART1
#define UART1_RX_PIN PB7
#define UART1_TX_PIN PB6
//#define UART1_AHB1_PERIPHERALS RCC_AHB1Periph_DMA2

#define USE_UART2
#define UART2_RX_PIN PD6
#define UART2_TX_PIN PD5

#define USE_UART3
#define UART3_RX_PIN PD9
#define UART3_TX_PIN PD8

#define USE_UART6
#define UART6_RX_PIN PC6
#define UART6_TX_PIN PC7

#define SERIAL_PORT_COUNT 5 //VCP, USART1, USART2, USART3, USART6

// TODO
#define USE_ESCSERIAL
#define ESCSERIAL_TIMER_TX_HARDWARE 0 // PWM 1

#define USE_SPI
#define USE_SPI_DEVICE_1
#define SPI1_NSS_PIN PA4
#define SPI1_SCK_PIN PA5
#define SPI1_MISO_PIN PA6
#define SPI1_MOSI_PIN PA7

/// I2C Configuration
#define USE_I2C
#define USE_I2C_PULLUP
#define USE_I2C_DEVICE_1
#define I2C1_SCL PB8
#define I2C1_SDA PB9

#define USE_I2C_DEVICE_2
#define I2C2_SCL PB10
#define I2C2_SDA PB11

#define I2C_DEVICE (I2CDEV_2)

#define USE_ADC
#define VBAT_ADC_PIN PC1
#define DEFAULT_VOLTAGE_METER_SOURCE VOLTAGE_METER_ADC

//#define TRANSPONDER

#define DEFAULT_RX_FEATURE FEATURE_RX_SERIAL
#define SERIALRX_PROVIDER SERIALRX_SBUS
#define SERIALRX_UART SERIAL_PORT_USART1

#define USE_SERIALRX_SBUS
aguindehi marked this conversation as resolved.
Show resolved Hide resolved
#define USE_SERIALRX_SPEKTRUM

#define DEFAULT_FEATURES 0
aguindehi marked this conversation as resolved.
Show resolved Hide resolved
#define AVOID_UART1_FOR_PWM_PPM
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed, there does not seem to be a pin conflict

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've removed all except AVOID_UART1_FOR_PWM_PPM until I'm sure we don't need that.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AVOID_UART1_FOR_PWM_PPM was introduced to cater for board designs where pins are shared between PPM / PWM input and serial input (to allow for a cleaner design with a 'RX' connector). Unless your design does this, this should not be needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, it does not. It has two dedicated PPM/PWM input pads. The UARTs have separate pads. I will remove this define as you proposed.

#define USE_SERIAL_4WAY_BLHELI_INTERFACE

#define TARGET_IO_PORTA (0xffff & ~(BIT(0)|BIT(1)|BIT(10)|BIT(13)|BIT(14)|BIT(15)))
#define TARGET_IO_PORTB (0xffff & ~(BIT(2)|BIT(3)|BIT(4)))
#define TARGET_IO_PORTC (0xffff & ~(BIT(15)|BIT(14)|BIT(13)))
#define TARGET_IO_PORTD (0xffff & ~(BIT(0)|BIT(1)))
#define TARGET_IO_PORTE (0xffff & ~(BIT(15)))

#define USABLE_TIMER_CHANNEL_COUNT 10
#define USED_TIMERS ( TIM_N(1) | TIM_N(2) | TIM_N(3) | TIM_N(4) | TIM_N(5) | TIM_N(12) | TIM_N(8) | TIM_N(9))
6 changes: 6 additions & 0 deletions src/main/target/UAVPNG030MINI/target.mk
@@ -0,0 +1,6 @@
F405_TARGETS += $(TARGET)
aguindehi marked this conversation as resolved.
Show resolved Hide resolved
FEATURES += VCP
TARGET_SRC = \
drivers/accgyro/accgyro_spi_mpu6000.c \
drivers/barometer/barometer_ms5611.c \
drivers/compass/compass_hmc5883l.c