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

#include <OWI.hh>

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

Classes

class  Driver
 
class  Search
 

Public Types

enum  {
  SEARCH_ROM = 0xF0, READ_ROM = 0x33, MATCH_ROM = 0x55, SKIP_ROM = 0xCC,
  ALARM_SEARCH = 0xEC
}
 

Public Member Functions

 OWI (Board::DigitalPin pin)
 
bool reset ()
 
uint8_t read (uint8_t bits=CHARBITS)
 
bool read (void *buf, uint8_t size)
 
void write (uint8_t value, uint8_t bits=CHARBITS, bool power=false)
 
void write (uint8_t value, void *buf, uint8_t size)
 
void power_off ()
 
Driverlookup (uint8_t *rom)
 
bool alarm_dispatch ()
 

Static Public Attributes

static const uint8_t ROM_MAX = 8
 
static const uint8_t ROMBITS = ROM_MAX * CHARBITS
 

Private Types

enum  Mode { OUTPUT_MODE = 0, INPUT_MODE = 1 }
 
enum  Direction { MSB_FIRST = 0, LSB_FIRST = 1 }
 

Private Member Functions

void mode (Mode mode)
 
Mode mode () const
 
void _set () const
 
void _set (int value) const
 
void set () const
 
void set (int value) const
 
void high () const
 
void on () const
 
void _clear () const
 
void clear () const
 
void low () const
 
void off () const
 
void _toggle () const
 
void toggle () const
 
void _write (int value) const
 
void write (int value) const
 
void write (uint8_t value, OutputPin &clk, Direction order=MSB_FIRST) const
 
void write (uint16_t value, uint8_t bits, uint16_t us) const
 
OutputPinoperator<< (int value)
 
void pulse (uint16_t us) const
 
volatile uint8_t * PIN () const
 
volatile uint8_t * DDR () const
 
volatile uint8_t * PORT () const
 
uint8_t pin () const
 
bool is_set () const
 
bool is_high () const
 
bool is_on () const
 
bool is_clear () const
 
bool is_low () const
 
bool is_off () const
 
bool read () const
 
uint8_t read (OutputPin &clk, Direction order=MSB_FIRST) const
 
 operator bool () const
 
Pinoperator>> (uint8_t &var)
 
volatile uint8_t * PCIMR () const
 

Static Private Member Functions

static void mode (Board::DigitalPin pin, Mode mode)
 
static Mode mode (Board::DigitalPin pin)
 
static void mode (Board::DigitalPin pin, uint8_t initial=0)
 
static void toggle (Board::DigitalPin pin)
 
static void _write (Board::DigitalPin pin, uint8_t value)
 
static void write (Board::DigitalPin pin, int value)
 
static uint8_t MASK (uint8_t pin)
 
static volatile uint8_t * PIN (uint8_t pin)
 
static volatile uint8_t * DDR (uint8_t pin)
 
static volatile uint8_t * PORT (uint8_t pin)
 
static bool read (Board::DigitalPin pin)
 

Private Attributes

volatile uint8_t *const m_sfr
 
const uint8_t m_mask
 
const uint8_t m_pin
 

Detailed Description

1-wire device driver support class. Allows device rom search and connection to multiple devices on one-wire bus.

Limitations

The driver will turn off interrupt handling during data read from the device.

Definition at line 36 of file OWI.hh.

Member Enumeration Documentation

anonymous enum

Standard ROM Commands.

Enumerator
SEARCH_ROM 
READ_ROM 
MATCH_ROM 
SKIP_ROM 
ALARM_SEARCH 

Definition at line 41 of file OWI.hh.

Constructor & Destructor Documentation

OWI::OWI ( Board::DigitalPin  pin)
inline

Construct one wire bus connected to the given pin.

Parameters
[in]pinnumber.

Definition at line 221 of file OWI.hh.

Member Function Documentation

bool OWI::alarm_dispatch ( )

Search drivers with alarm setting and call on_alarm(). Return true(1) if there was at least one driver with an alarm, otherwise when no alarms false(0).

Returns
bool.

Definition at line 137 of file OWI.cpp.

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

Lookup the driver instance with the given rom address.

Returns
driver pointer or null(0).

Definition at line 127 of file OWI.cpp.

void OWI::power_off ( )
inline

Turn off parasite powering of pin. See also write().

Definition at line 274 of file OWI.hh.

uint8_t OWI::read ( uint8_t  bits = CHARBITS)

Read the given number of bits from the one wire bus (slave). Default number of bits is 8. Returns the value read LSB aligned.

Parameters
[in]bitsto be read.
Returns
value read.

Definition at line 50 of file OWI.cpp.

bool OWI::read ( void *  buf,
uint8_t  size 
)

Read given number of bytes from one wire bus (slave) to given buffer. Return true(1) if correctly read otherwise false(0).

Parameters
[in]bufbuffer pointer.
[in]sizenumber of bytes to read.
Returns
bool.

Definition at line 81 of file OWI.cpp.

bool OWI::reset ( )

Reset the one wire bus and check that at least one device is presence.

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

Definition at line 29 of file OWI.cpp.

void OWI::write ( uint8_t  value,
uint8_t  bits = CHARBITS,
bool  power = false 
)

Write the given value to the one wire bus. The bits are written from LSB to MSB. Pass true(1) for power parameter to allow parasite devices to be powered. Should be turned off with power_off().

Parameters
[in]valueto write.
[in]bitsto be written.
[in]poweron for parasite device.

Definition at line 90 of file OWI.cpp.

void OWI::write ( uint8_t  value,
void *  buf,
uint8_t  size 
)

Write the given value and given number of bytes from buffer to the one wire bus (slave).

Parameters
[in]valueto write.
[in]bufbuffer pointer.
[in]sizenumber of bytes to write.

Definition at line 119 of file OWI.cpp.

Member Data Documentation

const uint8_t OWI::ROM_MAX = 8
static

ROM size in bytes.

Definition at line 50 of file OWI.hh.

const uint8_t OWI::ROMBITS = ROM_MAX * CHARBITS
static

ROM size in bits.

Definition at line 53 of file OWI.hh.


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