APM:Libraries
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
PX4::I2CDevice Class Reference

#include <I2CDevice.h>

Inheritance diagram for PX4::I2CDevice:
[legend]
Collaboration diagram for PX4::I2CDevice:
[legend]

Public Member Functions

 I2CDevice (uint8_t bus, uint8_t address)
 
 ~I2CDevice ()
 
void set_address (uint8_t address) override
 
void set_retries (uint8_t retries) override
 
bool set_speed (enum Device::Speed speed) override
 
bool transfer (const uint8_t *send, uint32_t send_len, uint8_t *recv, uint32_t recv_len) override
 
bool read_registers_multiple (uint8_t first_reg, uint8_t *recv, uint32_t recv_len, uint8_t times) override
 
AP_HAL::Device::PeriodicHandle register_periodic_callback (uint32_t period_usec, AP_HAL::Device::PeriodicCb) override
 
bool adjust_periodic_callback (AP_HAL::Device::PeriodicHandle h, uint32_t period_usec) override
 
AP_HAL::Semaphoreget_semaphore () override
 
void set_split_transfers (bool set) override
 
- Public Member Functions inherited from AP_HAL::I2CDevice
 I2CDevice ()
 
virtual bool set_speed (Device::Speed speed) override=0
 
virtual Device::PeriodicHandle register_periodic_callback (uint32_t period_usec, Device::PeriodicCb) override=0
 
- Public Member Functions inherited from AP_HAL::Device
 FUNCTOR_TYPEDEF (PeriodicCb, void)
 
 Device (enum BusType type)
 
enum BusType bus_type (void) const
 
uint8_t bus_num (void) const
 
uint32_t get_bus_id (void) const
 
uint8_t get_bus_address (void) const
 
void set_device_type (uint8_t devtype)
 
virtual ~Device ()
 
bool read_registers (uint8_t first_reg, uint8_t *recv, uint32_t recv_len)
 
bool write_register (uint8_t reg, uint8_t val, bool checked=false)
 
void set_checked_register (uint8_t reg, uint8_t val)
 
bool setup_checked_registers (uint8_t num_regs, uint8_t frequency=10)
 
bool check_next_register (void)
 
bool read (uint8_t *recv, uint32_t recv_len)
 
virtual PeriodicHandle register_periodic_callback (uint32_t period_usec, PeriodicCb)=0
 
virtual bool unregister_callback (PeriodicHandle h)
 
virtual void register_completion_callback (AP_HAL::MemberProc proc)
 
virtual void register_completion_callback (AP_HAL::Proc proc)
 
virtual bool set_chip_select (bool set)
 
void set_read_flag (uint8_t flag)
 
uint32_t get_bus_id_devtype (uint8_t devtype)
 

Static Public Member Functions

static I2CDevicefrom (AP_HAL::I2CDevice *dev)
 
- Static Public Member Functions inherited from AP_HAL::Device
static uint32_t make_bus_id (enum BusType bus_type, uint8_t bus, uint8_t address, uint8_t devtype)
 
static uint32_t change_bus_id (uint32_t old_id, uint8_t devtype)
 

Private Attributes

uint8_t _busnum
 
PX4_I2C _px4dev
 
uint8_t _address
 
perf_counter_t perf
 
char * pname
 
bool _split_transfers
 

Static Private Attributes

static const uint8_t num_buses = 3
 
static DeviceBus businfo [num_buses]
 

Additional Inherited Members

- Public Types inherited from AP_HAL::Device
enum  BusType { BUS_TYPE_UNKNOWN = 0, BUS_TYPE_I2C = 1, BUS_TYPE_SPI = 2, BUS_TYPE_UAVCAN = 3 }
 
enum  Speed { SPEED_HIGH, SPEED_LOW }
 
typedef void * PeriodicHandle
 
- Protected Member Functions inherited from AP_HAL::Device
void set_device_address (uint8_t address)
 
void set_device_bus (uint8_t bus)
 
- Protected Attributes inherited from AP_HAL::Device
uint8_t _read_flag = 0
 
union DeviceId _bus_id
 

Detailed Description

Definition at line 30 of file I2CDevice.h.

Constructor & Destructor Documentation

◆ I2CDevice()

PX4::I2CDevice::I2CDevice ( uint8_t  bus,
uint8_t  address 
)

Definition at line 119 of file I2CDevice.cpp.

Here is the call graph for this function:

◆ ~I2CDevice()

PX4::I2CDevice::~I2CDevice ( )
virtual

Reimplemented from AP_HAL::I2CDevice.

Definition at line 131 of file I2CDevice.cpp.

Referenced by from().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Function Documentation

◆ adjust_periodic_callback()

bool PX4::I2CDevice::adjust_periodic_callback ( AP_HAL::Device::PeriodicHandle  h,
uint32_t  period_usec 
)
overridevirtual

Implements AP_HAL::I2CDevice.

Definition at line 171 of file I2CDevice.cpp.

Referenced by set_speed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ from()

static I2CDevice* PX4::I2CDevice::from ( AP_HAL::I2CDevice dev)
inlinestatic

Definition at line 32 of file I2CDevice.h.

Here is the call graph for this function:

◆ get_semaphore()

AP_HAL::Semaphore* PX4::I2CDevice::get_semaphore ( )
inlineoverridevirtual

Implements AP_HAL::I2CDevice.

Definition at line 63 of file I2CDevice.h.

◆ read_registers_multiple()

bool PX4::I2CDevice::read_registers_multiple ( uint8_t  first_reg,
uint8_t *  recv,
uint32_t  recv_len,
uint8_t  times 
)
overridevirtual

Implements AP_HAL::I2CDevice.

Definition at line 148 of file I2CDevice.cpp.

Referenced by set_speed().

Here is the caller graph for this function:

◆ register_periodic_callback()

AP_HAL::Device::PeriodicHandle PX4::I2CDevice::register_periodic_callback ( uint32_t  period_usec,
AP_HAL::Device::PeriodicCb  cb 
)
override

Definition at line 158 of file I2CDevice.cpp.

Referenced by set_speed().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_address()

void PX4::I2CDevice::set_address ( uint8_t  address)
inlineoverridevirtual

Reimplemented from AP_HAL::Device.

Definition at line 41 of file I2CDevice.h.

◆ set_retries()

void PX4::I2CDevice::set_retries ( uint8_t  retries)
inlineoverridevirtual

Reimplemented from AP_HAL::Device.

Definition at line 44 of file I2CDevice.h.

Here is the call graph for this function:

◆ set_speed()

bool PX4::I2CDevice::set_speed ( enum Device::Speed  speed)
inlineoverride

Definition at line 47 of file I2CDevice.h.

Here is the call graph for this function:

◆ set_split_transfers()

void PX4::I2CDevice::set_split_transfers ( bool  set)
inlineoverridevirtual

Reimplemented from AP_HAL::I2CDevice.

Definition at line 68 of file I2CDevice.h.

◆ transfer()

bool PX4::I2CDevice::transfer ( const uint8_t *  send,
uint32_t  send_len,
uint8_t *  recv,
uint32_t  recv_len 
)
overridevirtual

Implements AP_HAL::I2CDevice.

Definition at line 139 of file I2CDevice.cpp.

Referenced by set_speed().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _address

uint8_t PX4::I2CDevice::_address
private

Definition at line 78 of file I2CDevice.h.

Referenced by set_address(), transfer(), and ~I2CDevice().

◆ _busnum

uint8_t PX4::I2CDevice::_busnum
private

◆ _px4dev

PX4_I2C PX4::I2CDevice::_px4dev
private

Definition at line 77 of file I2CDevice.h.

Referenced by set_retries(), and transfer().

◆ _split_transfers

bool PX4::I2CDevice::_split_transfers
private

Definition at line 81 of file I2CDevice.h.

Referenced by set_split_transfers(), and transfer().

◆ businfo

DeviceBus PX4::I2CDevice::businfo
staticprivate

Definition at line 74 of file I2CDevice.h.

Referenced by adjust_periodic_callback(), get_semaphore(), and register_periodic_callback().

◆ num_buses

const uint8_t PX4::I2CDevice::num_buses = 3
staticprivate

Definition at line 73 of file I2CDevice.h.

Referenced by adjust_periodic_callback(), get_semaphore(), and register_periodic_callback().

◆ perf

perf_counter_t PX4::I2CDevice::perf
private

Definition at line 79 of file I2CDevice.h.

Referenced by I2CDevice(), transfer(), and ~I2CDevice().

◆ pname

char* PX4::I2CDevice::pname
private

Definition at line 80 of file I2CDevice.h.

Referenced by I2CDevice(), and ~I2CDevice().


The documentation for this class was generated from the following files: