mirror of https://github.com/ArduPilot/ardupilot
HAL_Linux: setup for all 6 SPI devices for PXF cape
This commit is contained in:
parent
9b23921626
commit
03e8e5f2b9
|
@ -23,12 +23,13 @@ extern const AP_HAL::HAL& hal;
|
|||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLE
|
||||
LinuxSPIDeviceDriver LinuxSPIDeviceManager::_device[LINUX_SPI_DEVICE_NUM_DEVICES] = {
|
||||
// different SPI tables per board subtype
|
||||
LinuxSPIDeviceDriver(1, AP_HAL::SPIDevice_MS5611, SPI_MODE_3, 8, BBB_P9_42, 6*MHZ, 6*MHZ),
|
||||
LinuxSPIDeviceDriver(1, AP_HAL::SPIDevice_MPU6000, SPI_MODE_3, 8, BBB_P9_28, 500*1000, 20*MHZ),
|
||||
LinuxSPIDeviceDriver(0, AP_HAL::SPIDevice_LSM9DS0_AM, SPI_MODE_3, 8, BBB_P9_17, 10*MHZ,10*MHZ),
|
||||
LinuxSPIDeviceDriver(0, AP_HAL::SPIDevice_LSM9DS0_G, SPI_MODE_3, 8, BBB_P8_9, 10*MHZ,10*MHZ),
|
||||
LinuxSPIDeviceDriver(1, AP_HAL::SPIDevice_MS5611, SPI_MODE_3, 8, BBB_P9_42, 6*MHZ, 6*MHZ),
|
||||
LinuxSPIDeviceDriver(1, AP_HAL::SPIDevice_MPU6000, SPI_MODE_3, 8, BBB_P9_28, 500*1000, 20*MHZ),
|
||||
/* MPU9250 is restricted to 1MHz for non-data and interrupt registers */
|
||||
LinuxSPIDeviceDriver(1, AP_HAL::SPIDevice_MPU9250, SPI_MODE_3, 8, BBB_P9_23, 1*MHZ, 20*MHZ),
|
||||
LinuxSPIDeviceDriver(0, AP_HAL::SPIDevice_LSM9DS0, SPI_MODE_3, 8, BBB_P9_17, 10*MHZ,10*MHZ),
|
||||
LinuxSPIDeviceDriver(1, AP_HAL::SPIDevice_Dataflash,SPI_MODE_0, 8, BBB_P8_12, 6*MHZ, 6*MHZ)
|
||||
LinuxSPIDeviceDriver(1, AP_HAL::SPIDevice_MPU9250, SPI_MODE_3, 8, BBB_P9_23, 1*MHZ, 20*MHZ),
|
||||
LinuxSPIDeviceDriver(1, AP_HAL::SPIDevice_Dataflash, SPI_MODE_3, 8, BBB_P8_12, 6*MHZ, 6*MHZ),
|
||||
};
|
||||
#else
|
||||
// empty device table
|
||||
|
@ -137,7 +138,8 @@ void LinuxSPIDeviceManager::cs_assert(enum AP_HAL::SPIDevice type)
|
|||
}
|
||||
if (_device[i]._type != type) {
|
||||
if (_device[i]._cs->read() != 1) {
|
||||
hal.scheduler->panic("two CS enabled at once");
|
||||
hal.console->printf("two CS enabled at once i=%u %u and %u\n",
|
||||
(unsigned)i, (unsigned)type, (unsigned)_device[i]._type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#if CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_PXF || CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_LINUX_ERLE
|
||||
#define LINUX_SPI_NUM_BUSES 2
|
||||
#define LINUX_SPI_DEVICE_NUM_DEVICES 5
|
||||
#define LINUX_SPI_DEVICE_NUM_DEVICES 6
|
||||
#else
|
||||
#define LINUX_SPI_NUM_BUSES 0
|
||||
#define LINUX_SPI_DEVICE_NUM_DEVICES 0
|
||||
|
|
|
@ -24,9 +24,12 @@ static struct {
|
|||
enum AP_HAL::SPIDevice dev;
|
||||
uint8_t whoami_reg;
|
||||
} whoami_list[] = {
|
||||
{ "MPU9250", AP_HAL::SPIDevice_MPU9250, 0x75 | 0x80 },
|
||||
{ "LSM9DSO", AP_HAL::SPIDevice_LSM9DS0, 0x0f | 0x80 },
|
||||
{ "MPU6000", AP_HAL::SPIDevice_MPU6000, 0x75 | 0x80 },
|
||||
{ "MS5611", AP_HAL::SPIDevice_MS5611, 0x00 | 0x80 },
|
||||
{ "MPU9250", AP_HAL::SPIDevice_MPU9250, 0x75 | 0x80 },
|
||||
{ "MPU6000", AP_HAL::SPIDevice_MPU6000, 0x75 | 0x80 },
|
||||
{ "FRAM", AP_HAL::SPIDevice_Dataflash, 0x00 | 0x80 },
|
||||
{ "LSM9DS0_AM", AP_HAL::SPIDevice_LSM9DS0_AM, 0x0F | 0x80 },
|
||||
{ "LSM9DS0_G", AP_HAL::SPIDevice_LSM9DS0_G, 0x0F | 0x80 },
|
||||
};
|
||||
|
||||
void loop(void)
|
||||
|
@ -55,7 +58,7 @@ void loop(void)
|
|||
hal.console->printf("WHO_AM_I for %s: 0x%02x\n", whoami_list[i].name, (unsigned)rx[1]);
|
||||
spi_sem->give();
|
||||
}
|
||||
hal.scheduler->delay(2000);
|
||||
hal.scheduler->delay(200);
|
||||
}
|
||||
|
||||
AP_HAL_MAIN();
|
||||
|
|
Loading…
Reference in New Issue