# hardware setup for V2450, based around FMUv3 but no IO MCU and
# custom config options for ArduCopter

# start with fmuv3 base port
include ../fmuv3/hwdef.dat

# remove some unnecessary features inherited from fmuv3
undef UART8
undef UART8_TX
undef UART8_RX
undef USART3
undef USART3_TX
undef USART3_RX
undef CAN1
undef CAN1_RX
undef CAN1_TX
undef CAN2
undef CAN2_RX
undef CAN2_TX
undef IOMCU_UART
undef AP_FEATURE_SBUS_OUT
undef HAL_OS_FATFS_IO
undef AP_FEATURE_RTSCTS
undef HAL_WITH_RAMTRON
undef IOMCU_UART
undef SDIO
undef HAL_BOARD_LOG_DIRECTORY
undef HAL_BOARD_TERRAIN_DIRECTORY

SERIAL_ORDER OTG1 USART2 EMPTY UART4

# enable AP_Radio support
define HAL_RCINPUT_WITH_AP_RADIO 1

define HAL_GPIO_RADIO_RESET      1 // PB0 GPIO from FMU3

# setup for radio IRQ on PD15
undef PD15
PD15 MPU_DRDY INPUT GPIO(100)
define HAL_GPIO_RADIO_IRQ       100

# setup defines for ArduCopter config
define TOY_MODE_ENABLED ENABLED
define ARMING_DELAY_SEC 0
define LAND_START_ALT 700
define LAND_DETECTOR_ACCEL_MAX 2.0f

# support cypress and cc2500 radios
SPIDEV cypress    SPI2 DEVID11 FRAM_CS     MODE0  2*MHZ  2*MHZ
SPIDEV cc2500     SPI2 DEVID12 FRAM_CS     MODE0  4*MHZ  4*MHZ
SPIDEV pixartflow SPI4 DEVID13 MPU_EXT_CS  MODE3  2*MHZ  2*MHZ

# SPI2 for the cypress needs exclusive access or we will end up with
# lost packets
DMA_PRIORITY SPI2_* SPI* ADC*
DMA_NOSHARE SPI2_*
undef PA1
PA1 UART4_RX UART4 NODMA

# use flash storage
STORAGE_FLASH_PAGE 22

env DEFAULT_PARAMETERS 'Tools/Frame_params/SkyViper-2450GPS/defaults.parm'

# the web UI uses an abin file for firmware uploads
env BUILD_ABIN True

# Disable un-needed hardware drivers
define AP_AIRSPEED_ENABLED 0
define AP_OPTICALFLOW_ENABLED 0
define BEACON_ENABLED 0
define GPS_MOVING_BASELINE 0
define GRIPPER_ENABLED 0
define HAL_ADSB_SAGETECH_ENABLED 0
define HAL_ADSB_UAVIONIX_MAVLINK_ENABLED 0
define AP_AIS_ENABLED 0
define HAL_BATTMON_INA2XX_ENABLED 0
define AP_BATTMON_SMBUS_ENABLE 0
define HAL_CRSF_TELEM_ENABLED 0
define HAL_EFI_ENABLED 0
define HAL_EXTERNAL_AHRS_ENABLED 0
define HAL_GENERATOR_ENABLED 0
define HAL_HOTT_TELEM_ENABLED 0
define HAL_MOUNT_ENABLED 0
define HAL_MSP_SENSORS_ENABLED 0
define HAL_NMEA_OUTPUT_ENABLED 0
define HAL_PARACHUTE_ENABLED 0
define HAL_PICCOLO_CAN_ENABLE 0
define HAL_RUNCAM_ENABLED 0
define HAL_SMARTAUDIO_ENABLED 0
define HAL_SPEKTRUM_TELEM_ENABLED 0
define HAL_SPRAYER_ENABLED 0
define HAL_WITH_ESC_TELEM 0
define LANDING_GEAR_ENABLED 0
define MODE_TURTLE_ENABLED 0
define WINCH_ENABLED 0
define AP_ICENGINE_ENABLED 0

# serially-attached actuators aren't relevant on SkyViper:
define AP_FETTEC_ONEWIRE_ENABLED 0
define AP_ROBOTISSERVO_ENABLED 0
define AP_VOLZ_ENABLED 0
define HAL_SUPPORT_RCOUT_SERIAL 0
define HAL_TORQEEDO_ENABLED 0

# the SkyViper only has a single Baro:
define AP_BARO_BACKEND_DEFAULT_ENABLED 0
define AP_BARO_ICM20789_ENABLED 1

# SkyViper has only one physical GPS but can also take from mavlink:
define AP_GPS_BACKEND_DEFAULT_ENABLED 0
define AP_GPS_UBLOX_ENABLED 1
define AP_GPS_MAV_ENABLED 1

# enable only the QUAD frame
define AP_MOTORS_FRAME_DEFAULT_ENABLED 0
define AP_MOTORS_FRAME_QUAD_ENABLED 1

# SkyViper isn't going to sprout new compasses:
define COMPASS_MAX_SENSORS 1
define BARO_MAX_INSTANCES 1
define INS_MAX_INSTANCES 1

# SkyViper doesn't have any rangefinder, but might get mavlink?
define AP_RANGEFINDER_BACKEND_DEFAULT_ENABLED 0
define AP_RANGEFINDER_MAVLINK_ENABLED 1

AUTOBUILD_TARGETS Copter
