mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-15 23:53:33 +08:00
Voxl2: add qurt i2c driver support and first i2c driver voxlpm
This commit is contained in:
@@ -41,7 +41,7 @@ if (${PX4_PLATFORM} STREQUAL "nuttx")
|
||||
list(APPEND SRCS_PLATFORM nuttx/SPI.cpp)
|
||||
endif()
|
||||
elseif((${PX4_PLATFORM} MATCHES "qurt"))
|
||||
# list(APPEND SRCS_PLATFORM qurt/I2C.cpp)
|
||||
list(APPEND SRCS_PLATFORM qurt/I2C.cpp)
|
||||
list(APPEND SRCS_PLATFORM qurt/SPI.cpp)
|
||||
list(APPEND SRCS_PLATFORM qurt/uart.c)
|
||||
elseif(UNIX AND NOT APPLE) #TODO: add linux PX4 platform type
|
||||
|
||||
@@ -42,8 +42,11 @@
|
||||
|
||||
#include "I2C.hpp"
|
||||
|
||||
#include <dev_fs_lib_i2c.h>
|
||||
#if defined(CONFIG_I2C)
|
||||
|
||||
#include <px4_platform_common/time.h>
|
||||
#include <px4_platform_common/px4_config.h>
|
||||
#include <px4_platform_common/i2c_spi_buses.h>
|
||||
|
||||
namespace device
|
||||
{
|
||||
@@ -69,6 +72,11 @@ I2C::I2C(uint8_t device_type, const char *name, const int bus, const uint16_t ad
|
||||
PX4_INFO("*** I2C Device ID 0x%x %d", _device_id.devid, _device_id.devid);
|
||||
}
|
||||
|
||||
I2C::I2C(const I2CSPIDriverConfig &config)
|
||||
: I2C(config.devid_driver_index, config.module_name, config.bus, config.i2c_address, config.bus_frequency)
|
||||
{
|
||||
}
|
||||
|
||||
I2C::~I2C()
|
||||
{
|
||||
}
|
||||
@@ -157,3 +165,5 @@ I2C::transfer(const uint8_t *send, const unsigned send_len, uint8_t *recv, const
|
||||
}
|
||||
|
||||
} // namespace device
|
||||
|
||||
#endif
|
||||
|
||||
@@ -37,11 +37,14 @@
|
||||
* Base class for devices connected via I2C.
|
||||
*/
|
||||
|
||||
#ifndef _DEVICE_I2C_H
|
||||
#define _DEVICE_I2C_H
|
||||
#pragma once
|
||||
|
||||
#include <px4_arch/i2c_hw_description.h>
|
||||
#include "../CDev.hpp"
|
||||
#include <px4_platform_common/i2c.h>
|
||||
|
||||
#if defined(CONFIG_I2C)
|
||||
|
||||
struct I2CSPIDriverConfig;
|
||||
|
||||
namespace device __EXPORT
|
||||
{
|
||||
@@ -92,6 +95,7 @@ protected:
|
||||
* @param frequency I2C bus frequency for the device (currently not used)
|
||||
*/
|
||||
I2C(uint8_t device_type, const char *name, const int bus, const uint16_t address, const uint32_t frequency);
|
||||
I2C(const I2CSPIDriverConfig &config);
|
||||
virtual ~I2C();
|
||||
|
||||
/**
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#include <drivers/drv_hrt.h>
|
||||
#include <drivers/device/spi.h>
|
||||
#include <drivers/device/i2c.h>
|
||||
#include <drivers/device/qurt/uart.h>
|
||||
#include <pthread.h>
|
||||
#include <px4_platform_common/tasks.h>
|
||||
@@ -280,6 +281,10 @@ int px4muorb_orb_initialize(fc_func_ptrs *func_ptrs, int32_t clock_offset_us)
|
||||
|
||||
uORB::ProtobufChannel::GetInstance()->RegisterSendHandler(muorb_func_ptrs.topic_data_func_ptr);
|
||||
|
||||
// Configure the I2C driver function pointers
|
||||
device::I2C::configure_callbacks(muorb_func_ptrs._config_i2c_bus_func_t, muorb_func_ptrs._set_i2c_address_func_t,
|
||||
muorb_func_ptrs._i2c_transfer_func_t);
|
||||
|
||||
// Configure the SPI driver function pointers
|
||||
device::SPI::configure_callbacks(muorb_func_ptrs._config_spi_bus_func_t, muorb_func_ptrs._spi_transfer_func_t);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user