Public Member Functions
bosch_drivers_common::bosch_hardware_interface Class Reference

Abstract base class for interfaces between sensors and computers. More...

#include <bosch_drivers_hardware_interface.hpp>

List of all members.

Public Member Functions

 bosch_hardware_interface ()
virtual std::string getID ()=0
 Return an identifier for this hardware interface.
virtual bool initialize ()=0
 Initialize the hardware interface.
virtual ssize_t read (int device_address, interface_protocol protocol, int frequency, int *flags, uint8_t reg_address, uint8_t *data, size_t num_bytes)=0
 Read a given number of bytes.
virtual bool supportedProtocol (interface_protocol protocol)=0
 Check if a communication protocol is supported by this hardware interface.
virtual ssize_t write (int device_address, interface_protocol protocol, int frequency, int *flags, uint8_t reg_address, uint8_t *data, size_t num_bytes)=0
 Write the provided data, as bytes.
virtual ~bosch_hardware_interface ()

Detailed Description

Abstract base class for interfaces between sensors and computers.

This abstract class provides the generic format so that devices and drivers can communicate over different physical hardware adapters. For example, if gumstix, Sub20, and Arduino all derive from this class, then a single sensor driver can be written independently of all. Concrete implementations of this class provide the actual commands to read and write from the specific hardware interface. Since most interfaces are 8-bit, we use the 8-bit byte as the fundamental unit or size. Commands ask for data in number of bytes.

Definition at line 60 of file bosch_drivers_hardware_interface.hpp.


Constructor & Destructor Documentation

Definition at line 66 of file bosch_drivers_hardware_interface.hpp.

Definition at line 68 of file bosch_drivers_hardware_interface.hpp.


Member Function Documentation

virtual std::string bosch_drivers_common::bosch_hardware_interface::getID ( ) [pure virtual]

Return an identifier for this hardware interface.

This identifier should be able to uniquely identify this interface when multiple copies of this interface exist.

Initialize the hardware interface.

Any initialization steps that need to be performed by the hardware interface and cannot be done in the constructor should be done here. Some things to configure include the clock/data polarity for SPI and the byte order: little endian or big endian.

virtual ssize_t bosch_drivers_common::bosch_hardware_interface::read ( int  device_address,
interface_protocol  protocol,
int  frequency,
int *  flags,
uint8_t  reg_address,
uint8_t *  data,
size_t  num_bytes 
) [pure virtual]

Read a given number of bytes.

Communication with a device requires reading from locations in that device's memory. This function retrieves a number of bytes starting at a known address in a device. If the particular device does not store measurements in memory then it needs to be properly configured in the initialize() function.

Parameters:
device_addressThe starting register address in the device's memory.
protocol
frequencyThe protocol frequency
flags
reg_addressThe register address
dataA pointer to the memory location in the host where the data will be stored. The user must make sure space is available. This data should be an array.
num_bytesThe requested number of bytes to read from the device.
Returns:
The number of bytes actually read from the device or an error code.
Note:
For SPI transactions, the device_address is the chip select. If the device address is NULL_DEVICE, then the hardware interface should read from the bus without changing any chip select lines.
For GPIO transactions, the device_address is the pin or port.

Check if a communication protocol is supported by this hardware interface.

virtual ssize_t bosch_drivers_common::bosch_hardware_interface::write ( int  device_address,
interface_protocol  protocol,
int  frequency,
int *  flags,
uint8_t  reg_address,
uint8_t *  data,
size_t  num_bytes 
) [pure virtual]

Write the provided data, as bytes.

Communication with a device requires writing to locations in that device's memory. This function sends a number of bytes starting at a known address in a device. If the particular device does not store commands in memory then it needs to be properly configured in the initialize() function.

Parameters:
device_addressThe starting register address in the device's memory.
protocol
frequencyThe protocol frequency
flags
reg_addressThe register address
dataA pointer to the memory location in the host where the data will be stored. The user must make sure space is available. This data should be an array.
num_bytesThe requested number of bytes to read from the device.
Returns:
The number of bytes actually read from the device or an error code.
Note:
If num_bytes is zero, then the hardware should just write the register as a single byte. In this case, the pointer data is irrelevant. This can be used to write single bytes.
For SPI transactions, the device_address is the chip select. If the device address is NULL_DEVICE, then the hardware interface should read from the bus without changing any chip select lines.
For GPIO transactions, the device_address is the pin or port.

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


bosch_drivers_common
Author(s): Joshua Vasquez, Philip Roan. Maintained by Philip Roan
autogenerated on Mon Oct 6 2014 10:09:38