Arduino-TWI
Two-Wire Interface (TWI) library for Arduino
DS2482 Class Reference

#include <DS2482.h>

Inheritance diagram for DS2482:
Inheritance graph
Collaboration diagram for DS2482:
Collaboration graph

Classes

union  config_t
 
union  status_t
 

Public Types

enum  Register { STATUS_REGISTER = 0xf0, READ_DATA_REGISTER = 0xe1, CHANNEL_SELECTION_REGISTER = 0xd2, CONFIGURATION_REGISTER = 0xc3 }
 

Public Member Functions

 DS2482 (TWI &twi, uint8_t subaddr=0)
 
bool one_wire_reset ()
 
bool one_wire_read_bit (bool &value)
 
bool one_wire_write_bit (bool value)
 
virtual bool one_wire_read_byte (uint8_t &value)
 
bool one_wire_write_byte (uint8_t value)
 
int8_t one_wire_triplet (uint8_t &dir)
 
bool device_reset ()
 
bool write_configuration (bool apu=true, bool spu=false, bool iws=false)
 
bool set_read_pointer (Register addr, uint8_t &value)
 
bool channel_select (uint8_t chan)
 

Protected Types

enum  {
  DEVICE_RESET = 0xf0, SET_READ_POINTER = 0xe1, WRITE_CONGIFURATION = 0xd2, CHANNEL_SELECT = 0xc3,
  ONE_WIRE_RESET = 0xb4, ONE_WIRE_SINGLE_BIT = 0x87, ONE_WIRE_WRITE_BYTE = 0xa5, ONE_WIRE_READ_BYTE = 0x96,
  ONE_WIRE_TRIPLET = 0x78
}
 

Protected Member Functions

bool one_wire_await (status_t &status)
 
bool acquire ()
 
bool release ()
 
int read (void *buf, size_t count)
 
int write (const void *buf, size_t count)
 
int write (iovec_t *vp)
 

Protected Attributes

TWIm_twi
 
uint8_t m_addr
 

Static Protected Attributes

static const int POLL_MAX = 20
 

Detailed Description

TWI Device Driver for DS2482, Single-Channel 1-Wire Master, TWI to OWI Bridge Device.

Definition at line 28 of file DS2482.h.

Member Enumeration Documentation

anonymous enum
protected

Function Commands, pp. 9-15.

Enumerator
DEVICE_RESET 

Device Reset.

SET_READ_POINTER 

Set Read Pointer.

WRITE_CONGIFURATION 

Write Configuration.

CHANNEL_SELECT 

Channel Select.

ONE_WIRE_RESET 

1-Wire Reset.

ONE_WIRE_SINGLE_BIT 

1-Wire Single Bit.

ONE_WIRE_WRITE_BYTE 

1-Wire Write Byte.

ONE_WIRE_READ_BYTE 

1-Wire Read Byte.

ONE_WIRE_TRIPLET 

1-Wire Triplet.

Definition at line 338 of file DS2482.h.

Device Registers, pp. 5. Valid Pointer Codes, pp. 10.

Enumerator
STATUS_REGISTER 
READ_DATA_REGISTER 
CHANNEL_SELECTION_REGISTER 
CONFIGURATION_REGISTER 

Definition at line 275 of file DS2482.h.

Constructor & Destructor Documentation

DS2482::DS2482 ( TWI twi,
uint8_t  subaddr = 0 
)
inline

Construct one wire bus manager for DS2482.

Parameters
[in]twibus manager.
[in]subaddrsub-address for device (0..3).

Definition at line 35 of file DS2482.h.

Member Function Documentation

bool TWI::Device::acquire ( )
inlineinherited

Start transaction. Return true(1) if successful otherwise false(0).

Returns
bool.

Definition at line 52 of file TWI.h.

bool DS2482::channel_select ( uint8_t  chan)
inline

Select given channel (DS2482-800). Return true if successful otherwise false.

Parameters
[in]chanchannel number (0..7).
Returns
bool.

Definition at line 317 of file DS2482.h.

bool DS2482::device_reset ( )
inline

Global reset of device state machine logic. Returns true if successful otherwise false.

Returns
bool.

Definition at line 212 of file DS2482.h.

bool DS2482::one_wire_await ( status_t status)
inlineprotected

Wait for the one wire operation to complete. Poll the device status.

Parameters
[out]statusdevice status on completion.
Returns
true(1) if successful otherwise false(0).

Definition at line 402 of file DS2482.h.

bool DS2482::one_wire_read_bit ( bool &  value)
inline

Read a single bit from one wire bus. Returns value and true(1) if successful otherwise false(0).

Parameters
[out]valuebit read.
Returns
true(1) if successful otherwise false(0).

Definition at line 70 of file DS2482.h.

virtual bool DS2482::one_wire_read_byte ( uint8_t &  value)
inlinevirtual

Read byte (8-bits) from one wire bus. Returns value and true(1) if successful otherwise false(0).

Parameters
[out]valuebit read.
Returns
true(1) if successful otherwise false(0).

Definition at line 125 of file DS2482.h.

bool DS2482::one_wire_reset ( )
inline

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 45 of file DS2482.h.

int8_t DS2482::one_wire_triplet ( uint8_t &  dir)
inline

Search (rom and alarm) support function. Reads 2-bits and writes given direction 1-bit value when discrepancy 0b00 read. Writes one(1) when 0b01 read, zero(0) on 0b10. Reading 0b11 is an error state.

Parameters
[in,out]dirbit to write when discrepancy read.
Returns
2-bits read and bit written.

Definition at line 183 of file DS2482.h.

bool DS2482::one_wire_write_bit ( bool  value)
inline

Write a single bit to one wire bus. Returns true if successful otherwise false.

Parameters
[in]valuebit to write.
Returns
bool.

Definition at line 99 of file DS2482.h.

bool DS2482::one_wire_write_byte ( uint8_t  value)
inline

Write byte (8-bits) to one wire bus. Returns true(1) if successful otherwise false(0).

Parameters
[in]valuebyte write.
Returns
true(1) if successful otherwise false(0).

Definition at line 155 of file DS2482.h.

int TWI::Device::read ( void *  buf,
size_t  count 
)
inlineinherited

Read data from device to given buffer.

Parameters
[in]bufbuffer pointer.
[in]countbuffer size in bytes.
Returns
number of bytes read or negative error code.

Definition at line 73 of file TWI.h.

bool TWI::Device::release ( )
inlineinherited

Stop transaction. Return true(1) if successful otherwise false(0).

Returns
bool.

Definition at line 62 of file TWI.h.

bool DS2482::set_read_pointer ( Register  addr,
uint8_t &  value 
)
inline

Set the read pointer to the specified register. Return register value or negative error code.

Parameters
[in]addrregister address.
[out]valueread.
Returns
true(1) if successful otherwise false(0).

Definition at line 289 of file DS2482.h.

int TWI::Device::write ( const void *  buf,
size_t  count 
)
inlineinherited

Write data from the given buffer to device.

Parameters
[in]bufbuffer pointer.
[in]countbuffer size in bytes.
Returns
number of bytes written or negative error code.

Definition at line 84 of file TWI.h.

int TWI::Device::write ( iovec_t *  vp)
inlineinherited

Write data to device with from given io vector.

Parameters
[in]vpio vector pointer.
Returns
number of bytes written or negative error code.

Definition at line 94 of file TWI.h.

bool DS2482::write_configuration ( bool  apu = true,
bool  spu = false,
bool  iws = false 
)
inline

Configure one wire bus master with given parameters. Returns true if successful otherwise false.

Parameters
[in]apuactive pull-up (default true).
[in]spustrong pull-up (default false).
[in]iwsone wire speed (default false).
Returns
bool.

Definition at line 242 of file DS2482.h.

Member Data Documentation

uint8_t TWI::Device::m_addr
protectedinherited

Device address.

Definition at line 104 of file TWI.h.

TWI& TWI::Device::m_twi
protectedinherited

Two-Wire Interface Manager.

Definition at line 101 of file TWI.h.

const int DS2482::POLL_MAX = 20
staticprotected

Number of one-wire polls

Definition at line 394 of file DS2482.h.


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