Arduino-OWI
One-Wire Interface (OWI) library for Arduino
Slave::OWI< PIN > Class Template Reference

#include <OWI.h>

Collaboration diagram for Slave::OWI< PIN >:
Collaboration graph

Public Types

enum  {
  SEARCH_ROM = 0xF0, READ_ROM = 0x33, MATCH_ROM = 0x55, SKIP_ROM = 0xCC,
  ALARM_SEARCH = 0xEC, LABEL_ROM = 0x15, READ_LABEL = 0x16, MATCH_LABEL = 0x51
}
 

Public Member Functions

 OWI (const uint8_t *rom)
 
 OWI (uint8_t family)
 
uint8_t crc ()
 
void crc (uint8_t value)
 
bool alarm ()
 
void alarm (bool value)
 
bool reset ()
 
uint8_t read (uint8_t bits=8)
 
bool read (void *buf, size_t count)
 
void write (uint8_t value, uint8_t bits=8)
 
void write (const void *buf, size_t count)
 
bool triplet (bool bit)
 
bool rom_command ()
 
uint8_t read_command ()
 

Static Public Member Functions

static uint8_t crc_update (uint8_t crc, uint8_t data)
 

Static Public Attributes

static const size_t ROM_MAX = 8
 
static const size_t ROMBITS = ROM_MAX * 8
 

Protected Attributes

GPIO< PIN > m_pin
 
uint32_t m_timestamp
 
uint8_t m_rom [ROM_MAX]
 
uint8_t m_label
 
bool m_alarm
 
uint8_t m_crc
 

Detailed Description

template<BOARD::pin_t PIN>
class Slave::OWI< PIN >

Definition at line 33 of file OWI.h.

Member Enumeration Documentation

template<BOARD::pin_t PIN>
anonymous enum

Standard 1-Wire ROM Commands.

Enumerator
SEARCH_ROM 

Initiate device search.

READ_ROM 

Read device family code and serial number.

MATCH_ROM 

Select device with 64-bit rom code.

SKIP_ROM 

Broadcast or single device.

ALARM_SEARCH 

Initiate device alarm search.

LABEL_ROM 

Set short address (8-bit).

READ_LABEL 

Get 8-bit short address.

MATCH_LABEL 

Select device with 8-bit short address.

Definition at line 287 of file OWI.h.

Constructor & Destructor Documentation

template<BOARD::pin_t PIN>
Slave::OWI< PIN >::OWI ( const uint8_t *  rom)
inline

Construct one wire bus slave device connected to the given template pin parameter, and rom identity code. Cyclic redundancy check sum is generated for given rom identity code.

Parameters
[in]romidentity code (program memory).

Definition at line 47 of file OWI.h.

template<BOARD::pin_t PIN>
Slave::OWI< PIN >::OWI ( uint8_t  family)
inline

Construct one wire bus slave device connected to the given template pin parameter, and family code. Random identity code is generated.

Parameters
[in]familycode

Definition at line 68 of file OWI.h.

Member Function Documentation

template<BOARD::pin_t PIN>
bool Slave::OWI< PIN >::alarm ( )
inline

Get alarm setting.

Returns
alarm setting.

Definition at line 108 of file OWI.h.

template<BOARD::pin_t PIN>
void Slave::OWI< PIN >::alarm ( bool  value)
inline

Set alarm to given value.

Parameters
[in]valuealarm setting.

Definition at line 117 of file OWI.h.

template<BOARD::pin_t PIN>
uint8_t Slave::OWI< PIN >::crc ( )
inline

Get cyclic redundancy check sum. Calculated by buffer read() and write().

Returns
crc.

Definition at line 90 of file OWI.h.

template<BOARD::pin_t PIN>
void Slave::OWI< PIN >::crc ( uint8_t  value)
inline

Set cyclic redundancy check sum.

Parameters
[in]valueto set.

Definition at line 99 of file OWI.h.

template<BOARD::pin_t PIN>
static uint8_t Slave::OWI< PIN >::crc_update ( uint8_t  crc,
uint8_t  data 
)
inlinestatic

Optimized Dallas/Maxim iButton 8-bit Cyclic Redundancy Check calculation. Polynomial: x^8 + x^5 + x^4 + 1 (0x8C). See http://www.maxim-ic.com/appnotes.cfm/appnote_number/27

Definition at line 377 of file OWI.h.

template<BOARD::pin_t PIN>
uint8_t Slave::OWI< PIN >::read ( uint8_t  bits = 8)
inline

Read bits from one wire bus master. Default number of bits is 8. Calculate intermediate cyclic redundancy check sum.

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

Definition at line 162 of file OWI.h.

template<BOARD::pin_t PIN>
bool Slave::OWI< PIN >::read ( void *  buf,
size_t  count 
)
inline

Read given number of bytes from one wire bus master to given buffer. Calculate intermediate cyclic redundancy check sum, and return validation (should be zero).

Parameters
[in]bufbuffer pointer.
[in]countnumber of bytes to read.
Returns
true(1) if check sum is correct otherwise false(0).

Definition at line 202 of file OWI.h.

template<BOARD::pin_t PIN>
uint8_t Slave::OWI< PIN >::read_command ( )
inline

Read command and filter label sub-commands. Returns command or zero(0).

Returns
command.

Definition at line 355 of file OWI.h.

template<BOARD::pin_t PIN>
bool Slave::OWI< PIN >::reset ( )
inline

Check for reset signal. Return true(1) if reset was detected and presence was signaled, otherwise false(0).

Returns
true(1) on reset and presence, otherwise false(0).

Definition at line 127 of file OWI.h.

template<BOARD::pin_t PIN>
bool Slave::OWI< PIN >::rom_command ( )
inline

Check for reset and standard rom commands. Returns true(1) if the device was selected and extended command will follow, otherwise false(0).

Returns
true(1) on extended command will follow, otherwise false(0).

Definition at line 304 of file OWI.h.

template<BOARD::pin_t PIN>
bool Slave::OWI< PIN >::triplet ( bool  bit)
inline

Write bit and inverse bit. Return read bit.

Parameters
[in]bitto write.
Returns
bit read.

Definition at line 277 of file OWI.h.

template<BOARD::pin_t PIN>
void Slave::OWI< PIN >::write ( uint8_t  value,
uint8_t  bits = 8 
)
inline

Write bits to one wire bus master. The bits are written from LSB to MSB. Default number of bits is 8. Calculate intermediate cyclic redundancy check sum.

Parameters
[in]valueto write.
[in]bitsto be written.

Definition at line 223 of file OWI.h.

template<BOARD::pin_t PIN>
void Slave::OWI< PIN >::write ( const void *  buf,
size_t  count 
)
inline

Write bytes to one wire bus master. Calculates and writes 1-wire cyclic redundancy checksum last.

Parameters
[in]bufbuffer to write.
[in]countnumber of bytes to write.

Definition at line 258 of file OWI.h.

Member Data Documentation

template<BOARD::pin_t PIN>
bool Slave::OWI< PIN >::m_alarm
protected

Alarm setting.

Definition at line 405 of file OWI.h.

template<BOARD::pin_t PIN>
uint8_t Slave::OWI< PIN >::m_crc
protected

Intermediate cyclic redundancy check sum.

Definition at line 408 of file OWI.h.

template<BOARD::pin_t PIN>
uint8_t Slave::OWI< PIN >::m_label
protected

ROM label (short address).

Definition at line 402 of file OWI.h.

template<BOARD::pin_t PIN>
GPIO<PIN> Slave::OWI< PIN >::m_pin
protected

1-Wire bus pin.

Definition at line 393 of file OWI.h.

template<BOARD::pin_t PIN>
uint8_t Slave::OWI< PIN >::m_rom[ROM_MAX]
protected

ROM identity code.

Definition at line 399 of file OWI.h.

template<BOARD::pin_t PIN>
uint32_t Slave::OWI< PIN >::m_timestamp
protected

Reset detect timestamp.

Definition at line 396 of file OWI.h.

template<BOARD::pin_t PIN>
const size_t Slave::OWI< PIN >::ROM_MAX = 8
static

One Wire device identity ROM size in bytes.

Definition at line 36 of file OWI.h.

template<BOARD::pin_t PIN>
const size_t Slave::OWI< PIN >::ROMBITS = ROM_MAX * 8
static

One Wire device identity ROM size in bits.

Definition at line 39 of file OWI.h.


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