mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-05 23:48:31 -04:00
AP_OpticalFlow: support SP01 board
This commit is contained in:
parent
4d0c3b6581
commit
ead72214ac
libraries/AP_OpticalFlow
@ -80,17 +80,17 @@ extern const AP_HAL::HAL& hal;
|
||||
#define PIXART_SROM_CRC_RESULT 0xBEEF
|
||||
|
||||
// constructor
|
||||
AP_OpticalFlow_Pixart::AP_OpticalFlow_Pixart(OpticalFlow &_frontend) :
|
||||
AP_OpticalFlow_Pixart::AP_OpticalFlow_Pixart(const char *devname, OpticalFlow &_frontend) :
|
||||
OpticalFlow_backend(_frontend)
|
||||
{
|
||||
_dev = std::move(hal.spi->get_device("pixartflow"));
|
||||
_dev = std::move(hal.spi->get_device(devname));
|
||||
}
|
||||
|
||||
|
||||
// detect the device
|
||||
AP_OpticalFlow_Pixart *AP_OpticalFlow_Pixart::detect(OpticalFlow &_frontend)
|
||||
AP_OpticalFlow_Pixart *AP_OpticalFlow_Pixart::detect(const char *devname, OpticalFlow &_frontend)
|
||||
{
|
||||
AP_OpticalFlow_Pixart *sensor = new AP_OpticalFlow_Pixart(_frontend);
|
||||
AP_OpticalFlow_Pixart *sensor = new AP_OpticalFlow_Pixart(devname, _frontend);
|
||||
if (!sensor) {
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ class AP_OpticalFlow_Pixart : public OpticalFlow_backend
|
||||
{
|
||||
public:
|
||||
/// constructor
|
||||
AP_OpticalFlow_Pixart(OpticalFlow &_frontend);
|
||||
AP_OpticalFlow_Pixart(const char *devname, OpticalFlow &_frontend);
|
||||
|
||||
// init - initialise the sensor
|
||||
void init() override {}
|
||||
@ -16,7 +16,7 @@ public:
|
||||
void update(void) override;
|
||||
|
||||
// detect if the sensor is available
|
||||
static AP_OpticalFlow_Pixart *detect(OpticalFlow &_frontend);
|
||||
static AP_OpticalFlow_Pixart *detect(const char *devname, OpticalFlow &_frontend);
|
||||
|
||||
private:
|
||||
AP_HAL::OwnPtr<AP_HAL::SPIDevice> _dev;
|
||||
|
@ -91,9 +91,13 @@ void OpticalFlow::init(void)
|
||||
if (!backend) {
|
||||
#if AP_FEATURE_BOARD_DETECT
|
||||
if (AP_BoardConfig::get_board_type() == AP_BoardConfig::PX4_BOARD_PIXHAWK ||
|
||||
AP_BoardConfig::get_board_type() == AP_BoardConfig::PX4_BOARD_PIXHAWK2 ||
|
||||
AP_BoardConfig::get_board_type() == AP_BoardConfig::PX4_BOARD_PCNC1) {
|
||||
// possibly have pixhart on external SPI
|
||||
backend = AP_OpticalFlow_Pixart::detect(*this);
|
||||
backend = AP_OpticalFlow_Pixart::detect("pixartflow", *this);
|
||||
}
|
||||
if (AP_BoardConfig::get_board_type() == AP_BoardConfig::PX4_BOARD_SP01) {
|
||||
backend = AP_OpticalFlow_Pixart::detect("pixartPC15", *this);
|
||||
}
|
||||
if (backend == nullptr) {
|
||||
backend = AP_OpticalFlow_PX4Flow::detect(*this);
|
||||
@ -106,7 +110,7 @@ void OpticalFlow::init(void)
|
||||
#elif CONFIG_HAL_BOARD == HAL_BOARD_LINUX
|
||||
backend = AP_OpticalFlow_PX4Flow::detect(*this);
|
||||
#elif CONFIG_HAL_BOARD_SUBTYPE == HAL_BOARD_SUBTYPE_CHIBIOS_SKYVIPER_F412
|
||||
backend = AP_OpticalFlow_Pixart::detect(*this);
|
||||
backend = AP_OpticalFlow_Pixart::detect("pixartflow", *this);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user