board support add px4_i2c_bus_external/px4_spi_bus_external

This commit is contained in:
Daniel Agar
2017-11-20 23:44:31 +01:00
committed by Lorenz Meier
parent 2aeb4aa55f
commit 53595bac0e
54 changed files with 232 additions and 312 deletions
+40
View File
@@ -869,4 +869,44 @@ static inline int board_register_power_state_notification_cb(power_button_state_
static inline int board_shutdown(void) { return -EINVAL; }
#endif
/************************************************************************************
* Name: px4_i2c_bus_external
*
************************************************************************************/
#if defined(BOARD_HAS_SIMPLE_HW_VERSIONING)
__EXPORT bool px4_i2c_bus_external(int bus);
#else
#ifdef PX4_I2C_BUS_ONBOARD
#define px4_i2c_bus_external(bus) (bus != PX4_I2C_BUS_ONBOARD)
#else
#define px4_i2c_bus_external(bus) true
#endif /* PX4_I2C_BUS_ONBOARD */
#endif /* BOARD_HAS_SIMPLE_HW_VERSIONING */
/************************************************************************************
* Name: px4_spi_bus_external
*
************************************************************************************/
#if defined(BOARD_HAS_SIMPLE_HW_VERSIONING)
__EXPORT bool px4_spi_bus_external(int bus);
#else
#ifdef PX4_SPI_BUS_EXT
#define px4_spi_bus_external(bus) (bus == PX4_SPI_BUS_EXT)
#else
#define px4_spi_bus_external(bus) false
#endif /* PX4_SPI_BUS_EXT */
#endif /* BOARD_HAS_SIMPLE_HW_VERSIONING */
#include "board_internal_common.h"
@@ -424,7 +424,6 @@ extern void board_peripheral_reset(int ms);
extern void stm32_usbinitialize(void);
#include "../common/board_common.h"
#endif /* __ASSEMBLY__ */
@@ -34,6 +34,7 @@ px4_add_module(
MODULE drivers__boards__px4fmu-v3
SRCS
px4fmu_can.c
px4fmu_i2c.c
px4fmu_init.c
px4fmu_led.c
px4fmu_spi.c
+55
View File
@@ -0,0 +1,55 @@
/****************************************************************************
*
* Copyright (C) 2017 PX4 Development Team. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
* 3. Neither the name PX4 nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
****************************************************************************/
/**
* @file px4fmu_i2c.c
*
* Board-specific I2C functions.
*/
#include "board_config.h"
__EXPORT bool px4_i2c_bus_external(int bus)
{
if (HW_VER_FMUV3 == board_get_hw_version()) {
/* All FMUV3 2.1 i2c buses are external */
return true;
} else {
if (bus != PX4_I2C_BUS_ONBOARD) {
return true;
}
}
return false;
}
+15
View File
@@ -451,3 +451,18 @@ __EXPORT void board_spi_reset(int ms)
stm32_spi1_initialize();
}
__EXPORT bool px4_spi_bus_external(int bus)
{
if (HW_VER_FMUV3 == board_get_hw_version()) {
/* all FMUv3 2.1 spi buses are internal */
return false;
} else {
if (bus == PX4_SPI_BUS_EXT) {
return true;
}
}
return false;
}
@@ -157,7 +157,6 @@
/* I2C busses */
#define PX4_I2C_BUS_EXPANSION 1
#define PX4_I2C_BUS_LED PX4_I2C_BUS_EXPANSION
#define PX4_I2C_BUS_BMM150 PX4_I2C_BUS_EXPANSION
/* Devices on the external bus.
*
+1
View File
@@ -51,6 +51,7 @@
#define CONFIG_ARCH_BOARD_SITL 1
#define PX4_I2C_BUS_EXPANSION 1
#define PX4_I2C_BUS_ONBOARD 2
#define PX4_NUMBER_I2C_BUSES 1
#include <system_config.h>