i2c_spi_buses: respect CONFIG_I2C and CONFIG_SPI

- bmp280, dps310, and ms5611 barometers support boards without I2C
This commit is contained in:
Daniel Agar
2021-11-15 15:57:33 -05:00
parent eade2915c1
commit 7b7b7acd36
54 changed files with 529 additions and 282 deletions
+4
View File
@@ -42,6 +42,8 @@
#include "I2C.hpp"
#if defined(CONFIG_I2C)
#include <px4_platform_common/i2c_spi_buses.h>
#include <nuttx/i2c/i2c_master.h>
@@ -236,3 +238,5 @@ I2C::transfer(const uint8_t *send, const unsigned send_len, uint8_t *recv, const
}
} // namespace device
#endif // CONFIG_I2C
+7 -10
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
* Copyright (C) 2012-2021 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
@@ -31,26 +31,23 @@
*
****************************************************************************/
#pragma once
/**
* @file i2c.h
* @file I2C.hpp
*
* Base class for devices connected via I2C.
*/
#ifndef _DEVICE_I2C_H
#define _DEVICE_I2C_H
#include "../CDev.hpp"
#include <px4_platform_common/i2c.h>
#if defined(CONFIG_I2C)
#include <nuttx/i2c/i2c_master.h>
struct I2CSPIDriverConfig;
#if !defined(CONFIG_I2C)
# error I2C support requires CONFIG_I2C
#endif
namespace device __EXPORT
{
@@ -123,4 +120,4 @@ private:
} // namespace device
#endif /* _DEVICE_I2C_H */
#endif // CONFIG_I2C
+5 -9
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (C) 2012-2019, 2021 PX4 Development Team. All rights reserved.
* Copyright (C) 2012-2021 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
@@ -32,21 +32,16 @@
****************************************************************************/
/**
* @file spi.cpp
* @file SPI.cpp
*
* Base class for devices connected via SPI.
*
* @todo Work out if caching the mode/frequency would save any time.
*
* @todo A separate bus/device abstraction would allow for mixed interrupt-mode
* and non-interrupt-mode clients to arbitrate for the bus. As things stand,
* a bus shared between clients of both kinds is vulnerable to races between
* the two, where an interrupt-mode client will ignore the lock held by the
* non-interrupt-mode client.
*/
#include "SPI.hpp"
#if defined(CONFIG_SPI)
#include <px4_platform_common/i2c_spi_buses.h>
#include <px4_platform_common/px4_config.h>
#include <nuttx/arch.h>
@@ -237,3 +232,4 @@ SPI::_transferhword(uint16_t *send, uint16_t *recv, unsigned len)
}
} // namespace device
#endif // CONFIG_SPI
+7 -5
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (C) 2012 PX4 Development Team. All rights reserved.
* Copyright (C) 2012-2021 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
@@ -31,16 +31,18 @@
*
****************************************************************************/
#pragma once
/**
* @file SPI.hpp
*
* Base class for devices connected via SPI.
*/
#ifndef _DEVICE_SPI_H
#define _DEVICE_SPI_H
#include "../CDev.hpp"
#include <px4_platform_common/spi.h>
#if defined(CONFIG_SPI)
#include <nuttx/spi/spi.h>
#include <px4_platform_common/spi.h>
@@ -178,4 +180,4 @@ protected:
} // namespace device
#endif /* _DEVICE_SPI_H */
#endif // CONFIG_SPI
+5 -1
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (c) 2016-2020 PX4 Development Team. All rights reserved.
* Copyright (c) 2016-2021 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
@@ -42,6 +42,8 @@
#include "I2C.hpp"
#if defined(CONFIG_I2C)
#ifdef __PX4_LINUX
#include <linux/i2c.h>
@@ -181,3 +183,5 @@ I2C::transfer(const uint8_t *send, const unsigned send_len, uint8_t *recv, const
} // namespace device
#endif // __PX4_LINUX
#endif // CONFIG_I2C
+6 -5
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (C) 2016-2020 PX4 Development Team. All rights reserved.
* Copyright (C) 2016-2021 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
@@ -31,18 +31,19 @@
*
****************************************************************************/
#pragma once
/**
* @file I2C.hpp
*
* Base class for devices connected via I2C.
*/
#ifndef _DEVICE_I2C_H
#define _DEVICE_I2C_H
#include "../CDev.hpp"
#include <px4_platform_common/i2c.h>
#if defined(CONFIG_I2C)
struct I2CSPIDriverConfig;
namespace device __EXPORT
@@ -112,4 +113,4 @@ private:
} // namespace device
#endif /* _DEVICE_I2C_H */
#endif // CONFIG_I2C
+4 -2
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (C) 2019 PX4 Development Team. All rights reserved.
* Copyright (C) 2019-2021 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
@@ -40,6 +40,8 @@
#include "SPI.hpp"
#if defined(CONFIG_SPI)
#ifdef __PX4_LINUX
#include <fcntl.h>
@@ -73,7 +75,6 @@ SPI::SPI(const I2CSPIDriverConfig &config)
{
}
SPI::~SPI()
{
if (_fd >= 0) {
@@ -197,3 +198,4 @@ SPI::transferhword(uint16_t *send, uint16_t *recv, unsigned len)
} // namespace device
#endif // __PX4_LINUX
#endif // CONFIG_SPI
+6 -5
View File
@@ -1,6 +1,6 @@
/****************************************************************************
*
* Copyright (C) 2019 PX4 Development Team. All rights reserved.
* Copyright (C) 2019-2021 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
@@ -31,18 +31,19 @@
*
****************************************************************************/
#pragma once
/**
* @file SPI.hpp
*
* Base class for devices connected via SPI.
*/
#ifndef _DEVICE_SPI_H
#define _DEVICE_SPI_H
#include "../CDev.hpp"
#include <px4_platform_common/spi.h>
#if defined(CONFIG_SPI)
#ifdef __PX4_LINUX
#include <fcntl.h>
@@ -201,4 +202,4 @@ enum spi_mode_e {
};
#endif // __PX4_LINUX
#endif /* _DEVICE_SPI_H */
#endif // CONFIG_SPI