COSA
An Object-Oriented Platform for Arduino Programming
OWI::Driver Class Reference

#include <OWI.hh>

Inheritance diagram for OWI::Driver:
Inheritance graph
Collaboration diagram for OWI::Driver:
Collaboration graph

Public Types

enum  { FIRST = -1, ERROR = -1, LAST = ROMBITS }
 

Public Member Functions

 Driver (OWI *pin, const char *name=NULL)
 
 Driver (OWI *pin, const uint8_t *rom, const char *name=NULL)
 
uint8_t * rom ()
 
bool update_rom ()
 
int8_t search_rom (int8_t last=FIRST)
 
bool read_rom ()
 
bool match_rom ()
 
bool skip_rom ()
 
int8_t alarm_search (int8_t last=FIRST)
 
bool connect (uint8_t family, uint8_t index)
 
virtual void on_alarm ()
 

Public Attributes

str_P NAME
 

Protected Member Functions

int8_t search (int8_t last=FIRST)
 

Protected Attributes

uint8_t m_rom [ROM_MAX]
 
const uint8_t * ROM
 
Driverm_next
 
OWIm_pin
 

Friends

class OWI
 
IOStreamoperator<< (IOStream &outs, OWI &owi)
 
IOStreamoperator<< (IOStream &outs, Driver &dev)
 

Detailed Description

Driver for device connected to a one-wire bus.

Definition at line 58 of file OWI.hh.

Member Enumeration Documentation

anonymous enum
Enumerator
FIRST 
ERROR 
LAST 

Definition at line 60 of file OWI.hh.

Constructor & Destructor Documentation

OWI::Driver::Driver ( OWI pin,
const char *  name = NULL 
)
inline

Construct one wire device driver. Use one wire bus on given pin.

Parameters
[in]pinone wire bus.
[in]nameof device driver instance.

Definition at line 74 of file OWI.hh.

OWI::Driver::Driver ( OWI pin,
const uint8_t *  rom,
const char *  name = NULL 
)

Construct one wire device driver. Use one wire bus on given pin, given rom identity in EEPROM (or null), and device name.

Parameters
[in]pinone wire bus.
[in]romidentity.
[in]nameof device driver instance.

Definition at line 161 of file OWI.cpp.

Member Function Documentation

int8_t OWI::Driver::alarm_search ( int8_t  last = FIRST)

Search alarming device given the last position of discrepancy. Negative value for start from the beginning.

Parameters
[in]lastposition of discrepancy.
Returns
position of difference or negative error code.

Definition at line 264 of file OWI.cpp.

bool OWI::Driver::connect ( uint8_t  family,
uint8_t  index 
)

Connect to one-wire device with given family code and index.

Parameters
[in]familydevice family code.
[in]indexdevice order.
Returns
true(1) if successful otherwise false(0).

Definition at line 272 of file OWI.cpp.

bool OWI::Driver::match_rom ( )

Match device rom. Address the slave device with the rom code. Device specific function command should follow. May be used to verify rom code.

Returns
true(1) if successful otherwise false(0).

Definition at line 244 of file OWI.cpp.

virtual void OWI::Driver::on_alarm ( )
inlinevirtual

Callback on alarm dispatch. Default is empty function.

Definition at line 159 of file OWI.hh.

bool OWI::Driver::read_rom ( )

Read device rom. This can only be used when there is only one slave on the bus.

Returns
true(1) if successful otherwise false(0).

Definition at line 236 of file OWI.cpp.

uint8_t* OWI::Driver::rom ( )
inline

Return pointer to device rom.

Returns
device rom buffer.

Definition at line 96 of file OWI.hh.

int8_t OWI::Driver::search ( int8_t  last = FIRST)
protected

Search device rom given the last position of discrepancy. Negative value for start from the beginning.

Parameters
[in]lastposition of discrepancy.
Returns
position of difference or negative error code.

Definition at line 182 of file OWI.cpp.

int8_t OWI::Driver::search_rom ( int8_t  last = FIRST)

Search device rom given the last position of discrepancy. Negative value for start from the beginning.

Parameters
[in]lastposition of discrepancy.
Returns
position of difference or negative error code.

Definition at line 228 of file OWI.cpp.

bool OWI::Driver::skip_rom ( )

Skip device rom for boardcast or single device access. Device specific function command should follow.

Returns
true(1) if successful otherwise false(0).

Definition at line 256 of file OWI.cpp.

bool OWI::Driver::update_rom ( )

Update the rom identity (in EEPROM). Return true(1) if successful otherwise false(0). Typically used to save configuration after connect(). return bool.

Definition at line 174 of file OWI.cpp.

Friends And Related Function Documentation

IOStream& operator<< ( IOStream outs,
OWI owi 
)
friend

Print list of connected devices on given stream.

Parameters
[in]outsstream to print device information to.
[in]owione-wire bus.
Returns
output stream.

Definition at line 149 of file OWI.cpp.

IOStream& operator<< ( IOStream outs,
Driver dev 
)
friend

Print device driver name and rom to output stream.

Parameters
[in]outsstream to print to.
[in]devowi device driver.
Returns
output stream.

Definition at line 292 of file OWI.cpp.

friend class OWI
friend

Definition at line 175 of file OWI.hh.

Member Data Documentation

Driver* OWI::Driver::m_next
protected

Definition at line 164 of file OWI.hh.

OWI* OWI::Driver::m_pin
protected

Definition at line 165 of file OWI.hh.

uint8_t OWI::Driver::m_rom[ROM_MAX]
protected

Definition at line 162 of file OWI.hh.

str_P OWI::Driver::NAME

Name of device driver instance.

Definition at line 67 of file OWI.hh.

const uint8_t* OWI::Driver::ROM
protected

Definition at line 163 of file OWI.hh.


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