mirror of
https://gitee.com/xiaohuolufeihua/bizhang_-obav.git
synced 2026-05-21 01:12:11 +00:00
px4:platform support SPI configuration selection on HW REV
This commit is contained in:
@@ -262,6 +262,7 @@
|
|||||||
|
|
||||||
#if defined(BOARD_HAS_HW_VERSIONING)
|
#if defined(BOARD_HAS_HW_VERSIONING)
|
||||||
# define BOARD_HAS_VERSIONING 1
|
# define BOARD_HAS_VERSIONING 1
|
||||||
|
# define HW_VER_REV(v,r) ((uint32_t)((v) & 0xff) << 8) | ((uint32_t)(r) & 0xff)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Default LED logical to color mapping */
|
/* Default LED logical to color mapping */
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ struct px4_spi_bus_t {
|
|||||||
|
|
||||||
struct px4_spi_bus_all_hw_t {
|
struct px4_spi_bus_all_hw_t {
|
||||||
px4_spi_bus_t buses[SPI_BUS_MAX_BUS_ITEMS];
|
px4_spi_bus_t buses[SPI_BUS_MAX_BUS_ITEMS];
|
||||||
int board_hw_version{-1}; ///< 0=default, >0 for a specific revision (see board_get_hw_version), -1=unused
|
int board_hw_version_revision{-1}; ///< 0=default, >0 for a specific revision (see board_get_hw_version & board_get_hw_revision), -1=unused
|
||||||
};
|
};
|
||||||
|
|
||||||
#if BOARD_NUM_SPI_CFG_HW_VERSIONS > 1
|
#if BOARD_NUM_SPI_CFG_HW_VERSIONS > 1
|
||||||
|
|||||||
@@ -39,14 +39,19 @@
|
|||||||
#if BOARD_NUM_SPI_CFG_HW_VERSIONS > 1
|
#if BOARD_NUM_SPI_CFG_HW_VERSIONS > 1
|
||||||
void px4_set_spi_buses_from_hw_version()
|
void px4_set_spi_buses_from_hw_version()
|
||||||
{
|
{
|
||||||
int hw_version = board_get_hw_version();
|
#if defined(BOARD_HAS_SIMPLE_HW_VERSIONING)
|
||||||
|
int hw_version_revision = board_get_hw_version();
|
||||||
|
#else
|
||||||
|
int hw_version_revision = board_get_hw_revision();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < BOARD_NUM_SPI_CFG_HW_VERSIONS; ++i) {
|
for (int i = 0; i < BOARD_NUM_SPI_CFG_HW_VERSIONS; ++i) {
|
||||||
if (!px4_spi_buses && px4_spi_buses_all_hw[i].board_hw_version == 0) {
|
if (!px4_spi_buses && px4_spi_buses_all_hw[i].board_hw_version_revision == 0) {
|
||||||
px4_spi_buses = px4_spi_buses_all_hw[i].buses;
|
px4_spi_buses = px4_spi_buses_all_hw[i].buses;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (px4_spi_buses_all_hw[i].board_hw_version == hw_version) {
|
if (px4_spi_buses_all_hw[i].board_hw_version_revision == hw_version_revision) {
|
||||||
px4_spi_buses = px4_spi_buses_all_hw[i].buses;
|
px4_spi_buses = px4_spi_buses_all_hw[i].buses;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -129,7 +129,8 @@ static inline constexpr SPI::bus_device_external_cfg_t initSPIConfigExternal(SPI
|
|||||||
struct px4_spi_bus_array_t {
|
struct px4_spi_bus_array_t {
|
||||||
px4_spi_bus_t item[SPI_BUS_MAX_BUS_ITEMS];
|
px4_spi_bus_t item[SPI_BUS_MAX_BUS_ITEMS];
|
||||||
};
|
};
|
||||||
static inline constexpr px4_spi_bus_all_hw_t initSPIHWVersion(int hw_version, const px4_spi_bus_array_t &bus_items)
|
static inline constexpr px4_spi_bus_all_hw_t initSPIHWVersion(int hw_version_revision,
|
||||||
|
const px4_spi_bus_array_t &bus_items)
|
||||||
{
|
{
|
||||||
px4_spi_bus_all_hw_t ret{};
|
px4_spi_bus_all_hw_t ret{};
|
||||||
|
|
||||||
@@ -137,7 +138,7 @@ static inline constexpr px4_spi_bus_all_hw_t initSPIHWVersion(int hw_version, co
|
|||||||
ret.buses[i] = bus_items.item[i];
|
ret.buses[i] = bus_items.item[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
ret.board_hw_version = hw_version;
|
ret.board_hw_version_revision = hw_version_revision;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
constexpr bool validateSPIConfig(const px4_spi_bus_t spi_buses_conf[SPI_BUS_MAX_BUS_ITEMS]);
|
constexpr bool validateSPIConfig(const px4_spi_bus_t spi_buses_conf[SPI_BUS_MAX_BUS_ITEMS]);
|
||||||
|
|||||||
Reference in New Issue
Block a user