Main Page | Class Hierarchy | Alphabetical List | Compound List | File List | Compound Members | File Members | Related Pages

LOW_devDS1820 Class Reference

Device class for DS18S20 High-Precision 1-Wire Digital Thermometer. More...

#include <LOW_devDS1820.h>

Inheritance diagram for LOW_devDS1820:

Inheritance graph
[legend]
Collaboration diagram for LOW_devDS1820:

Collaboration graph
[legend]
List of all members.

Public Types

typedef std::vector< LOW_devDS1820 * > devDS1820PtrVec_t
 Vector type of class device pointers.

typedef LOW_devDS1820::scratchpadDS1820_t scratchpadDS1820_t
 DS1820 internal scratchpad as defined by Dallas.

typedef std::vector< LOW_device * > devPtrVec_t
 Vector type of class device pointers.

typedef std::map< LOW_deviceID,
LOW_device * > 
deviceMap_t
 Map type of devices with LOW_deviceID as key.


Public Member Functions

 class_DERIVE_FROM_EXCEPTION (devDS1820_error, LOW_exception)
 Exception base class for all exceptions thrown by LOW_devDS1820.

 LOW_devDS1820 (LOW_netSegment &inSegment, const LOW_deviceID &inDevID)
 Real constructor corresponding to static pseudo constructor new_Instance().

virtual ~LOW_devDS1820 ()
 Destructor.

virtual const LOW_deviceIDRaw::devFamCode_t getFamilyCode () const
 Get the device's family code.

virtual const std::string getFamilyName () const
 Get the device's family name.

virtual bool getIsExternalPowered () const
 Get whether the device is externally powered.

virtual void cmd_ConvertT () const
 Initiate a single temperature conversion.

void cmd_ReadScratchpad (scratchpadDS1820_t *outScratchpad) const
 Read the contents of the scratchpad.

virtual void cmd_WriteScratchpad (const uint8_t inTL, const uint8_t inTH) const
 Write 2 bytes of data to the DS18S20 scratchpad.

virtual void cmd_CopyScratchpad () const
 Copy the contents of the scratchpad TH and TL registers to EEPROM.

virtual void cmd_RecallE2 () const
 Recall the alarm trigger values (TH and TL) from EEPROM and place the data in bytes 2 and 3, respectively, in the scratchpad memory.

virtual bool cmd_ReadPowerSupply () const
 Determine the device is using parasite power.

virtual LOW_deviceID getID () const
 Get the device's ROM ID.

virtual LOW_netSegmentgetNetSegment () const
 Get the network segment the device is on.

virtual bool verifyDevice (const bool inOnlyAlarm=false, const bool inDoReset=true) const
 Shortcut method to verify the presence of the device on it's network segment.


Static Public Attributes

const LOW_deviceIDRaw::devFamCode_t familyCode = 0x10
 Family code of this specific device.

const std::string familyName = "DS1820"
 Family name of this specific device.

const owCommand_t ConvertT_COMMAND = 0x44
 1-Wire command byte constant

const owCommand_t ReadScratchpad_COMMAND = 0xbe
 1-Wire command byte constant

const owCommand_t WriteScratchpad_COMMAND = 0x4e
 1-Wire command byte constant

const owCommand_t CopyScratchpad_COMMAND = 0x48
 1-Wire command byte constant

const owCommand_t RecallE2_COMMAND = 0xb8
 1-Wire command byte constant

const owCommand_t ReadPowerSupply_COMMAND = 0xb4
 1-Wire command byte constant

const LOW_deviceIDRaw::devFamCode_t anyDev_famCode = 0x00
 Pseudo family code for selecting any/all device types.

const LOW_deviceIDRaw::devFamCode_t unknownDev_famCode = 0xff
 Pseudo family code for unknown device types.

const owCommand_t MatchROM_COMMAND = 0x55
 1-Wire command byte constant

const owCommand_t ReadROM_COMMAND = 0x33
 1-Wire command byte constant

const owCommand_t SkipROM_COMMAND = 0xcc
 1-Wire command byte constant

const owCommand_t SearchROM_COMMAND = 0xf0
 1-Wire command byte constant

const owCommand_t SearchAlarmROM_COMMAND = 0xec
 1-Wire command byte constant


Protected Member Functions

virtual LOW_linkgetLink () const
 Get the link the device is on.

virtual void cmd_MatchROM () const
 Shortcut for issuing a matchROM command for a device.


Static Protected Member Functions

LOW_devicenew_Instance (LOW_netSegment &inNetSegment, const LOW_deviceID &inDevID)
 Static pseudo constructor for registering with LOW_deviceFactory.


Protected Attributes

bool isExternalPowered
 Indicating wether the device is externally powered.

const LOW_deviceID ID
 1-Wire ROM ID of the device

LOW_netSegmentnetSegment
 Network segment where the device is located.


Static Private Member Functions

int initialize ()
 Static inizializer to register the class with LOW_deviceFactory.


Static Private Attributes

int initHelper = initialize()
 Needed for dirty little C++ hack to force static initialization on application start.


Friends

class linkLock
 Needed to grant access to the protected getLink() method.


Detailed Description

Device class for DS18S20 High-Precision 1-Wire Digital Thermometer.

DS1820 features:

This class is thread-safe.

Author:
Harald Roelle

Parts of the documentation by Dallas Semiconductors / Maxim Integrated Products

Definition at line 51 of file LOW_devDS1820.h.


Member Typedef Documentation

typedef std::vector<LOW_devDS1820*> LOW_devDS1820::devDS1820PtrVec_t
 

Vector type of class device pointers.

Definition at line 90 of file LOW_devDS1820.h.

typedef std::map<LOW_deviceID,LOW_device*> LOW_device::deviceMap_t [inherited]
 

Map type of devices with LOW_deviceID as key.

Definition at line 101 of file LOW_device.h.

typedef std::vector<LOW_device*> LOW_device::devPtrVec_t [inherited]
 

Vector type of class device pointers.

Definition at line 100 of file LOW_device.h.

Referenced by LOW_netSegment::searchDevices().

typedef struct LOW_devDS1820::scratchpadDS1820_t LOW_devDS1820::scratchpadDS1820_t
 

DS1820 internal scratchpad as defined by Dallas.


Constructor & Destructor Documentation

LOW_devDS1820::LOW_devDS1820 LOW_netSegment inSegment,
const LOW_deviceID inDevID
 

Real constructor corresponding to static pseudo constructor new_Instance().

External power supply status is initially detected here.

Parameters:
inSegment Reference to network segment the device is on.
inDevID Reference to device's ID.

Definition at line 61 of file LOW_devDS1820.cpp.

References cmd_ReadPowerSupply(), cmd_RecallE2(), LOW_netSegment::getHasExternalPower(), and isExternalPowered.

Referenced by new_Instance().

LOW_devDS1820::~LOW_devDS1820  )  [virtual]
 

Destructor.

Definition at line 73 of file LOW_devDS1820.cpp.


Member Function Documentation

LOW_devDS1820::class_DERIVE_FROM_EXCEPTION devDS1820_error  ,
LOW_exception 
 

Exception base class for all exceptions thrown by LOW_devDS1820.

void LOW_devDS1820::cmd_ConvertT  )  const [virtual]
 

Initiate a single temperature conversion.

Following the conversion, the resulting thermal data is stored in the 2-byte temperature register in the scratchpad memory and the DS18S20 returns to its low-power idle state.

The method uses different techniquies to detect the end of the conversion:

  • If the device is being used in parasite power mode, a strong pullup is enabled on the 1-Wire bus. Conversion ends when strong pullup ends.

  • If the device is powered by an external supply, the device is actively polled for the end of the conversion.

Definition at line 89 of file LOW_devDS1820.cpp.

References LOW_device::cmd_MatchROM(), ConvertT_COMMAND, LOW_device::getLink(), isExternalPowered, LOW_device::linkLock, LOW_link::pullUp_1048, LOW_link::readDataBit(), and LOW_link::writeData().

Referenced by LOW_compTempSensor::checkAlarm(), and LOW_compTempSensor::getTemperature().

void LOW_devDS1820::cmd_CopyScratchpad  )  const [virtual]
 

Copy the contents of the scratchpad TH and TL registers to EEPROM.

If the device is being used in parasite power mode, a strong pullup on the 1-Wire bus is enabled.

Definition at line 140 of file LOW_devDS1820.cpp.

References LOW_device::cmd_MatchROM(), CopyScratchpad_COMMAND, LOW_device::getLink(), isExternalPowered, LOW_device::linkLock, LOW_link::pullUp_1048, and LOW_link::writeData().

Referenced by LOW_compTempSensor::setAlarmLevels().

void LOW_device::cmd_MatchROM  )  const [protected, virtual, inherited]
 

Shortcut for issuing a matchROM command for a device.

Calls the corresponding method in LOW_netSegment.

Definition at line 102 of file LOW_device.cpp.

References LOW_netSegment::cmd_MatchROM(), and LOW_device::netSegment.

Referenced by LOW_devDS2406::cmd_ChannelAccess::cmd_ChannelAccess(), cmd_ConvertT(), cmd_CopyScratchpad(), LOW_devDS2890::cmd_Decrement(), LOW_devDS2890::cmd_Increment(), LOW_devDS2405::cmd_Match(), LOW_devDS2890::cmd_ReadControlRegister(), LOW_devDS2890::cmd_ReadPosition(), cmd_ReadPowerSupply(), cmd_ReadScratchpad(), cmd_RecallE2(), LOW_devDS2890::cmd_WriteControlRegister(), LOW_devDS2890::cmd_WritePosition(), cmd_WriteScratchpad(), LOW_devDS2406::cmd_WriteStatus(), and LOW_devDS2406::readMemUniversal().

bool LOW_devDS1820::cmd_ReadPowerSupply  )  const [virtual]
 

Determine the device is using parasite power.

Returns:
True when device is externally powered. False when on parasite power.

Definition at line 175 of file LOW_devDS1820.cpp.

References LOW_device::cmd_MatchROM(), LOW_device::getLink(), LOW_device::linkLock, LOW_link::readDataBit(), ReadPowerSupply_COMMAND, and LOW_link::writeData().

Referenced by LOW_devDS1820().

void LOW_devDS1820::cmd_ReadScratchpad scratchpadDS1820_t outScratchpad  )  const
 

Read the contents of the scratchpad.

After fully reading the scratchpad a CRC verification is performed.

Parameters:
outScratchpad Pointer to a scratchpad structure which will be filled in.
Exceptions:
LOW_helper_CRC::crc_error Thrown on CRC mismatch in transferred scratchpad.

Definition at line 108 of file LOW_devDS1820.cpp.

References byteVec_t, LOW_helper_CRC::calcCRC8(), LOW_device::cmd_MatchROM(), LOW_device::getLink(), LOW_device::linkLock, LOW_link::readData(), ReadScratchpad_COMMAND, and LOW_link::writeData().

Referenced by LOW_compTempSensor::getAlarmLevels(), and LOW_compTempSensor::getTemperature().

void LOW_devDS1820::cmd_RecallE2  )  const [virtual]
 

Recall the alarm trigger values (TH and TL) from EEPROM and place the data in bytes 2 and 3, respectively, in the scratchpad memory.

The method uses different techniquies to detect the end of reading:

  • If the device is being used in parasite power mode, a strong pullup is enabled on the 1-Wire bus. Reading ends when strong pullup ends.

  • If the device is powered by an external supply, the device is actively polled for the end of reading.

Definition at line 156 of file LOW_devDS1820.cpp.

References LOW_device::cmd_MatchROM(), LOW_device::getLink(), isExternalPowered, LOW_device::linkLock, LOW_link::pullUp_1048, LOW_link::readDataBit(), RecallE2_COMMAND, and LOW_link::writeData().

Referenced by LOW_devDS1820(), and LOW_compTempSensor::recallAlarmLevels().

void LOW_devDS1820::cmd_WriteScratchpad const uint8_t  inTL,
const uint8_t  inTH
const [virtual]
 

Write 2 bytes of data to the DS18S20 scratchpad.

Parameters:
inTL Byte to write to TL byte of scratchpad.
inTH Byte to write to TH byte of scratchpad.

Definition at line 125 of file LOW_devDS1820.cpp.

References byteVec_t, LOW_device::cmd_MatchROM(), LOW_device::getLink(), LOW_device::linkLock, LOW_link::writeData(), and WriteScratchpad_COMMAND.

Referenced by LOW_compTempSensor::setAlarmLevels().

virtual const LOW_deviceIDRaw::devFamCode_t LOW_devDS1820::getFamilyCode  )  const [inline, virtual]
 

Get the device's family code.

Note: Subclasses must implement this method to return their specific family code.

Returns:
Family name of the device.

Reimplemented from LOW_device.

Definition at line 135 of file LOW_devDS1820.h.

References LOW_deviceIDRaw::devFamCode_t, and familyCode.

virtual const std::string LOW_devDS1820::getFamilyName  )  const [inline, virtual]
 

Get the device's family name.

Note: Subclasses must implement this method to return a clear text name of their family.

Returns:
Family name of the device.

Reimplemented from LOW_device.

Definition at line 142 of file LOW_devDS1820.h.

References familyName.

LOW_deviceID LOW_device::getID  )  const [virtual, inherited]
 

Get the device's ROM ID.

Returns:
ROM ID of the device.

Definition at line 73 of file LOW_device.cpp.

References LOW_device::ID.

Referenced by LOW_netSegment::buryDevice(), LOW_netSegment::cmd_MatchROM(), LOW_compJalousieController::LOW_compJalousieController(), LOW_netSegment::removeDevice(), and LOW_netSegment::revitalizeDevice().

bool LOW_devDS1820::getIsExternalPowered  )  const [virtual]
 

Get whether the device is externally powered.

No real activity on the 1-Wire bus occures.

Returns:
Boolean value indicating status of external power.

Definition at line 83 of file LOW_devDS1820.cpp.

References isExternalPowered.

Referenced by LOW_compTempSensor::getIsExternalPowered().

LOW_link & LOW_device::getLink  )  const [protected, virtual, inherited]
 

Get the link the device is on.

Returns:
Link the device is on.

Definition at line 96 of file LOW_device.cpp.

References LOW_netSegment::getLink(), and LOW_device::netSegment.

Referenced by LOW_devDS2406::cmd_ChannelAccess::cmd_ChannelAccess(), cmd_ConvertT(), cmd_CopyScratchpad(), LOW_devDS2890::cmd_Decrement(), LOW_devDS2890::cmd_Increment(), LOW_devDS2405::cmd_MatchRead(), LOW_devDS2890::cmd_ReadControlRegister(), LOW_devDS2890::cmd_ReadPosition(), cmd_ReadPowerSupply(), cmd_ReadScratchpad(), cmd_RecallE2(), LOW_devDS2405::cmd_SearchRead(), LOW_devDS2890::cmd_WriteControlRegister(), LOW_devDS2890::cmd_WritePosition(), cmd_WriteScratchpad(), LOW_devDS2406::cmd_WriteStatus(), LOW_devDS2406::cmd_ChannelAccess::readData(), LOW_devDS2406::cmd_ChannelAccess::readDataBit(), LOW_devDS2406::cmd_ChannelAccess::readDataByte(), LOW_devDS2406::readMemUniversal(), LOW_devDS2406::cmd_ChannelAccess::writeData(), and LOW_devDS2406::cmd_ChannelAccess::~cmd_ChannelAccess().

LOW_netSegment & LOW_device::getNetSegment  )  const [virtual, inherited]
 

Get the network segment the device is on.

Returns:
Network segment the device is on.

Definition at line 79 of file LOW_device.cpp.

References LOW_device::netSegment.

Referenced by LOW_compJalousieController::LOW_compJalousieController(), and LOW_compTwinSwitch::LOW_compTwinSwitch().

int LOW_devDS1820::initialize  )  [static, private]
 

Static inizializer to register the class with LOW_deviceFactory.

See also:
initHelper

Definition at line 36 of file LOW_devDS1820.cpp.

References familyCode, new_Instance(), and LOW_deviceFactory::registerSpecificCtor().

LOW_device * LOW_devDS1820::new_Instance LOW_netSegment inNetSegment,
const LOW_deviceID inDevID
[static, protected]
 

Static pseudo constructor for registering with LOW_deviceFactory.

Parameters:
inSegment Reference to network segment the device is on.
inDevID Reference to device's ID.
Returns:
New dynamic instance of specific device class.

Reimplemented from LOW_device.

Definition at line 49 of file LOW_devDS1820.cpp.

References LOW_devDS1820().

Referenced by initialize().

bool LOW_device::verifyDevice const bool  inOnlyAlarm = false,
const bool  inDoReset = true
const [virtual, inherited]
 

Shortcut method to verify the presence of the device on it's network segment.

See also:
LOW_netSegment::verifyDevice()

Definition at line 85 of file LOW_device.cpp.

References LOW_device::ID, LOW_device::netSegment, and LOW_netSegment::verifyDevice().

Referenced by LOW_compTwinSwitch::alarmPollLoop(), LOW_compTempSensor::checkAlarm(), LOW_devDS2405::cmd_SearchActive(), and LOW_devDS2405::cmd_SearchRead().


Friends And Related Function Documentation

friend class linkLock [friend, inherited]
 

Needed to grant access to the protected getLink() method.

Definition at line 184 of file LOW_device.h.

Referenced by cmd_ConvertT(), cmd_CopyScratchpad(), LOW_devDS2890::cmd_Decrement(), LOW_devDS2890::cmd_Increment(), LOW_devDS2405::cmd_Match(), LOW_devDS2405::cmd_MatchRead(), LOW_devDS2890::cmd_ReadControlRegister(), LOW_devDS2890::cmd_ReadPosition(), cmd_ReadPowerSupply(), cmd_ReadScratchpad(), cmd_RecallE2(), LOW_devDS2405::cmd_SearchActive(), LOW_devDS2405::cmd_SearchRead(), LOW_devDS2890::cmd_WriteControlRegister(), LOW_devDS2890::cmd_WritePosition(), cmd_WriteScratchpad(), LOW_devDS2406::cmd_WriteStatus(), and LOW_devDS2406::readMemUniversal().


Member Data Documentation

const LOW_deviceIDRaw::devFamCode_t LOW_device::anyDev_famCode = 0x00 [static, inherited]
 

Pseudo family code for selecting any/all device types.

Definition at line 73 of file LOW_device.h.

Referenced by LOW_netSegment::cmd_SearchROMVerify(), LOW_netSegment::getDevice(), LOW_netSegment::getDevices(), LOW_deviceFactory::registerSpecificCtor(), LOW_linkDS2490::searchDevices(), and LOW_link::searchDevices().

const owCommand_t LOW_devDS1820::ConvertT_COMMAND = 0x44 [static]
 

1-Wire command byte constant

Definition at line 77 of file LOW_devDS1820.h.

Referenced by cmd_ConvertT().

const owCommand_t LOW_devDS1820::CopyScratchpad_COMMAND = 0x48 [static]
 

1-Wire command byte constant

Definition at line 80 of file LOW_devDS1820.h.

Referenced by cmd_CopyScratchpad().

const LOW_deviceIDRaw::devFamCode_t LOW_devDS1820::familyCode = 0x10 [static]
 

Family code of this specific device.

Reimplemented from LOW_device.

Definition at line 72 of file LOW_devDS1820.h.

Referenced by getFamilyCode(), and initialize().

const std::string LOW_devDS1820::familyName = "DS1820" [static]
 

Family name of this specific device.

Reimplemented from LOW_device.

Definition at line 33 of file LOW_devDS1820.cpp.

Referenced by getFamilyName().

const LOW_deviceID LOW_device::ID [protected, inherited]
 

1-Wire ROM ID of the device

Definition at line 192 of file LOW_device.h.

Referenced by LOW_device::getID(), LOW_device::LOW_device(), and LOW_device::verifyDevice().

int LOW_devDS1820::initHelper = initialize() [static, private]
 

Needed for dirty little C++ hack to force static initialization on application start.

See also:
initialize()

Definition at line 35 of file LOW_devDS1820.cpp.

bool LOW_devDS1820::isExternalPowered [protected]
 

Indicating wether the device is externally powered.

Definition at line 222 of file LOW_devDS1820.h.

Referenced by cmd_ConvertT(), cmd_CopyScratchpad(), cmd_RecallE2(), getIsExternalPowered(), and LOW_devDS1820().

const owCommand_t LOW_device::MatchROM_COMMAND = 0x55 [static, inherited]
 

1-Wire command byte constant

Definition at line 88 of file LOW_device.h.

Referenced by LOW_netSegment::cmd_MatchROM().

LOW_netSegment& LOW_device::netSegment [protected, inherited]
 

Network segment where the device is located.

Definition at line 193 of file LOW_device.h.

Referenced by LOW_device::cmd_MatchROM(), LOW_device::getLink(), LOW_device::getNetSegment(), LOW_device::LOW_device(), LOW_device::verifyDevice(), and LOW_device::~LOW_device().

const owCommand_t LOW_devDS1820::ReadPowerSupply_COMMAND = 0xb4 [static]
 

1-Wire command byte constant

Definition at line 82 of file LOW_devDS1820.h.

Referenced by cmd_ReadPowerSupply().

const owCommand_t LOW_device::ReadROM_COMMAND = 0x33 [static, inherited]
 

1-Wire command byte constant

Definition at line 89 of file LOW_device.h.

Referenced by LOW_netSegment::cmd_ReadROM().

const owCommand_t LOW_devDS1820::ReadScratchpad_COMMAND = 0xbe [static]
 

1-Wire command byte constant

Definition at line 78 of file LOW_devDS1820.h.

Referenced by cmd_ReadScratchpad().

const owCommand_t LOW_devDS1820::RecallE2_COMMAND = 0xb8 [static]
 

1-Wire command byte constant

Definition at line 81 of file LOW_devDS1820.h.

Referenced by cmd_RecallE2().

const owCommand_t LOW_device::SearchAlarmROM_COMMAND = 0xec [static, inherited]
 

1-Wire command byte constant

Definition at line 92 of file LOW_device.h.

Referenced by LOW_linkDS2490::searchDevices(), and LOW_link::searchDevices().

const owCommand_t LOW_device::SearchROM_COMMAND = 0xf0 [static, inherited]
 

1-Wire command byte constant

Definition at line 91 of file LOW_device.h.

Referenced by LOW_linkDS2490::searchDevices(), and LOW_link::searchDevices().

const owCommand_t LOW_device::SkipROM_COMMAND = 0xcc [static, inherited]
 

1-Wire command byte constant

Definition at line 90 of file LOW_device.h.

Referenced by LOW_netSegment::cmd_SkipROM().

const LOW_deviceIDRaw::devFamCode_t LOW_device::unknownDev_famCode = 0xff [static, inherited]
 

Pseudo family code for unknown device types.

Definition at line 76 of file LOW_device.h.

Referenced by LOW_netSegment::getDevice(), LOW_netSegment::getDevices(), and LOW_deviceFactory::registerSpecificCtor().

const owCommand_t LOW_devDS1820::WriteScratchpad_COMMAND = 0x4e [static]
 

1-Wire command byte constant

Definition at line 79 of file LOW_devDS1820.h.

Referenced by cmd_WriteScratchpad().


The documentation for this class was generated from the following files:
Generated on Tue Feb 3 11:30:50 2004 for OneWireLibrary++ by doxygen 1.3.2