|
Firmware
|
Fundamental base class for all physical drivers (I2C, SPI). More...
#include <Device.hpp>
Classes | |
| union | DeviceId |
| struct | DeviceStructure |
Public Types | |
| enum | DeviceBusType { DeviceBusType_UNKNOWN = 0, DeviceBusType_I2C = 1, DeviceBusType_SPI = 2, DeviceBusType_UAVCAN = 3 } |
| Device bus types for DEVID. | |
Public Member Functions | |
| virtual | ~Device ()=default |
| Destructor. More... | |
| virtual int | init () |
| Initialise the driver and make it ready for use. More... | |
| virtual int | read (unsigned address, void *data, unsigned count) |
| Read directly from the device. More... | |
| virtual int | write (unsigned address, void *data, unsigned count) |
| Write directly to the device. More... | |
| virtual int | ioctl (unsigned operation, unsigned &arg) |
| Perform a device-specific operation. More... | |
| uint8_t | get_device_bus () const |
| Return the bus ID the device is connected to. More... | |
| uint32_t | get_device_id () const |
| DeviceBusType | get_device_bus_type () const |
| Return the bus type the device is connected to. More... | |
| uint8_t | get_device_address () const |
| Return the bus address of the device. More... | |
| void | set_device_address (int address) |
| void | set_device_type (uint8_t devtype) |
| Set the device type. More... | |
| virtual bool | external () |
Static Public Member Functions | |
| static const char * | get_device_bus_string (DeviceBusType bus) |
| static int | device_id_print_buffer (char *buffer, int length, uint32_t id) |
| Print decoded device id string to a buffer. More... | |
Protected Member Functions | |
| Device (const char *name) | |
| Device (DeviceBusType bus_type, uint8_t bus, uint8_t address, uint8_t devtype=0) | |
| Device (const Device &)=delete | |
| Device & | operator= (const Device &)=delete |
| Device (Device &&)=delete | |
| Device & | operator= (Device &&)=delete |
Protected Attributes | |
| union DeviceId | _device_id |
| device identifier information | |
| const char * | _name |
| driver name | |
| bool | _debug_enabled {false} |
| if true, debug messages are printed | |
Fundamental base class for all physical drivers (I2C, SPI).
This class provides the basic driver template for I2C and SPI devices
|
virtualdefault |
Destructor.
Public so that anonymous devices can be destroyed.
|
inlinestatic |
Print decoded device id string to a buffer.
| buffer | buffer to write to |
| length | buffer length |
| id | The device id. |
| return | number of bytes written |
|
inline |
Return the bus address of the device.
|
inline |
Return the bus ID the device is connected to.
|
inline |
Return the bus type the device is connected to.
|
inlinevirtual |
Initialise the driver and make it ready for use.
Reimplemented in PX4IO_serial, UavcanBarometerBridge, and UavcanMagnetometerBridge.
|
inlinevirtual |
Perform a device-specific operation.
| operation | The operation to perform. |
| arg | An argument to the operation. |
|
inlinevirtual |
Read directly from the device.
The actual size of each unit quantity is device-specific.
| offset | The device address at which to start reading |
| data | The buffer into which the read values should be placed. |
| count | The number of items to read. |
Reimplemented in PX4IO_serial.
|
inline |
Set the device type.
|
inlinevirtual |
Write directly to the device.
The actual size of each unit quantity is device-specific.
| address | The device address at which to start writing. |
| data | The buffer from which values should be read. |
| count | The number of items to write. |
Reimplemented in PX4IO_serial.
1.8.12