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

#include <DS2482.hh>

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 (uint8_t subaddr=0)
 
bool device_reset ()
 
bool device_config (bool apu=true, bool spu=false, bool iws=false)
 
int set_read_pointer (Register addr)
 
bool channel_select (uint8_t chan)
 
bool one_wire_reset ()
 
int one_wire_read_bit ()
 
bool one_wire_write_bit (bool value)
 
bool one_wire_write_byte (uint8_t value)
 
int one_wire_read_byte ()
 
int one_wire_triplet (bool direction=false)
 

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
}
 

Static Protected Attributes

static const int POLL_MAX = 20
 

Private Member Functions

bool is_async () const
 
void sync_request ()
 
void async_request ()
 
virtual void on_completion (uint8_t type, int count)
 

Private Attributes

uint8_t m_addr
 
bool m_async
 

Detailed Description

TWI Device Driver for DS2482 I2C to 1-Wire Bridge. Low level device functions.

References

  1. DS2482-100, Single Channel 1-Wire Master, Rev. 10, 1/15.
  2. DS2482-800, 8-Channel 1-Wire Master, Rev. 5, 12/14.

Definition at line 34 of file DS2482.hh.

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 135 of file DS2482.hh.

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

Enumerator
STATUS_REGISTER 
READ_DATA_REGISTER 
CHANNEL_SELECTION_REGISTER 
CONFIGURATION_REGISTER 

Definition at line 62 of file DS2482.hh.

Constructor & Destructor Documentation

DS2482::DS2482 ( uint8_t  subaddr = 0)
inline

Construct DS2482 TWI device driver.

Parameters
[in]subaddrunit address (0..3, default 0).

Definition at line 40 of file DS2482.hh.

Member Function Documentation

bool DS2482::channel_select ( uint8_t  chan)

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

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

Definition at line 102 of file DS2482.cpp.

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

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 47 of file DS2482.cpp.

bool DS2482::device_reset ( )

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

Returns
bool.

Definition at line 24 of file DS2482.cpp.

int DS2482::one_wire_read_bit ( )

Read a single bit from one wire bus. Returns bit value (0 or 1) or a negative error code.

Returns
bit or negative error code.

Definition at line 146 of file DS2482.cpp.

int DS2482::one_wire_read_byte ( )

Read byte from one wire bus. Returns byte value or a negative error code.

Returns
byte or negative error code.

Definition at line 228 of file DS2482.cpp.

bool DS2482::one_wire_reset ( )

Generates one wire reset/presence detect cycle. Should be used to initiate or end a one wire communication sequence. Return true if successful otherwise false.

Returns
bool.

Definition at line 120 of file DS2482.cpp.

int DS2482::one_wire_triplet ( bool  direction = false)

Generate two read-time slots and one write-time slot. Returns status value (dir.nid.id) or a negative error code.

Returns
status or negative error code.

Definition at line 257 of file DS2482.cpp.

bool DS2482::one_wire_write_bit ( bool  value)

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

Parameters
[in]valuebit to write.
Returns
bool.

Definition at line 174 of file DS2482.cpp.

bool DS2482::one_wire_write_byte ( uint8_t  value)

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

Parameters
[in]valuebyte to write.
Returns
bool.

Definition at line 201 of file DS2482.cpp.

int DS2482::set_read_pointer ( Register  addr)

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

Parameters
[in]addrregister address.
Returns
register value or negative error code.

Definition at line 78 of file DS2482.cpp.

Member Data Documentation

const int DS2482::POLL_MAX = 20
staticprotected

Number of one-wire polls

Definition at line 191 of file DS2482.hh.


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