boards: add new spi+i2c config

Chip-select and SPI initialization uses the new config, whereas the drivers
still use the existing defines.

The configuration in board_config.h can be removed after all drivers are
updated.
This commit is contained in:
Beat Küng
2020-03-10 10:11:43 -04:00
committed by Daniel Agar
parent 06712450a7
commit 1851665fab
142 changed files with 2607 additions and 5655 deletions
+1 -1
View File
@@ -51,7 +51,7 @@ namespace device
* All calls to init() will NOT set the buss frequency
*/
unsigned int I2C::_bus_clocks[BOARD_NUMBER_I2C_BUSES] = BOARD_I2C_BUS_CLOCK_INIT;
unsigned int I2C::_bus_clocks[PX4_NUMBER_I2C_BUSES] = PX4_I2C_BUS_CLOCK_INIT;
I2C::I2C(const char *name, const char *devname, const int bus, const uint16_t address, const uint32_t frequency) :
CDev(name, devname),
+5 -4
View File
@@ -41,6 +41,7 @@
#define _DEVICE_I2C_H
#include "../CDev.hpp"
#include <px4_platform_common/i2c.h>
#include <nuttx/i2c/i2c_master.h>
@@ -69,8 +70,6 @@ public:
static int set_bus_clock(unsigned bus, unsigned clock_hz);
static unsigned int _bus_clocks[BOARD_NUMBER_I2C_BUSES];
protected:
/**
* The number of times a read or write operation will be retried on
@@ -109,10 +108,12 @@ protected:
*/
int transfer(const uint8_t *send, const unsigned send_len, uint8_t *recv, const unsigned recv_len);
virtual bool external() const override { return px4_i2c_bus_external(_device_id.devid_s.bus); }
bool external() const override { return px4_i2c_bus_external(_device_id.devid_s.bus); }
private:
uint32_t _frequency{0};
static unsigned int _bus_clocks[PX4_NUMBER_I2C_BUSES];
const uint32_t _frequency;
i2c_master_s *_dev{nullptr};
};
+4
View File
@@ -70,6 +70,10 @@ SPI::SPI(const char *name, const char *devname, int bus, uint32_t device, enum s
_device_id.devid_s.address = (uint8_t)device;
// devtype needs to be filled in by the driver
_device_id.devid_s.devtype = 0;
if (!px4_spi_bus_requires_locking(bus)) {
_locking_mode = LOCK_NONE;
}
}
SPI::~SPI()
+2 -1
View File
@@ -43,6 +43,7 @@
#include "../CDev.hpp"
#include <nuttx/spi/spi.h>
#include <px4_platform_common/spi.h>
namespace device __EXPORT
{
@@ -166,7 +167,7 @@ protected:
int _transferhword(uint16_t *send, uint16_t *recv, unsigned len);
virtual bool external() const override { return px4_spi_bus_external(get_device_bus()); }
bool external() const override { return px4_spi_bus_external(get_device_bus()); }
};
+1
View File
@@ -41,6 +41,7 @@
#define _DEVICE_I2C_H
#include "../CDev.hpp"
#include <px4_platform_common/i2c.h>
namespace device __EXPORT
{
+1
View File
@@ -41,6 +41,7 @@
#define _DEVICE_SPI_H
#include "../CDev.hpp"
#include <px4_platform_common/spi.h>
#ifdef __PX4_LINUX