|
DS2482-RK
|
Low-level class to send a 1-wire command and read a number of bytes back. You won't need to call this directly. More...
#include <DS2482-RK.h>
Public Member Functions | |
| size_t | getSize () const |
| Get the number of bytes that have been saved in the buffer so far. | |
| const uint8_t * | getBuffer () const |
| Gets a pointer to the buffer. | |
| DS24821WireAddress | getAddress () const |
| Gets the buffer as a 1-wire address. More... | |
| bool | checkCRC () const |
| Checks the CRC of the buffer. More... | |
Public Member Functions inherited from DS2482Command | |
| DS2482Command (DS2482 &parent) | |
| Construct a command object. More... | |
| virtual | ~DS2482Command () |
| Destructor. | |
Protected Member Functions | |
| DS24821WireCommand (DS2482 &parent, uint8_t cmd, size_t readSize, std::function< void(DS24821WireCommand &, int status)> completion) | |
| Sends a 1-wire command and reads bytes back. Used internally. | |
| virtual | ~DS24821WireCommand () |
| Destructor. | |
| virtual int | loop () |
| Used to provide allow the command to executed. | |
Protected Member Functions inherited from DS2482Command | |
| void | pushCommand () |
| Add this command to the parent queue. | |
| void | pushCommandList () |
| Pushes a command list onto the command list stack. This is done when a command needs their own sequence of commands to run. | |
| void | popCommandList () |
| Pops a command list off the command list stack. This is done when a command needs their own sequence of commands to run. | |
| int | readStatus (uint8_t &value, bool setReadPointerFirst=true) |
| Reads the status DS2482 status register. | |
| int | readData (uint8_t &value, bool setReadPointerFirst=true) |
| Reads the status DS2482 data register. | |
| int | setReadPointer (uint8_t reg) |
| Sets the DS2482 read pointer to a specific register (CONFIG_REG, READ_DATA_REG, READ_DATA_REG) | |
| int | readConfig (uint8_t &value) |
| Reads the DS2482 config register. Always sets the data pointer first. | |
| int | writeConfig (bool speed, bool spu, bool apu) |
| Writes the DS2482 config register. | |
| int | writeReg0 (uint8_t reg) |
| Writes a DS2482 register. | |
| int | writeReg1 (uint8_t reg, uint8_t value) |
| Writes the DS2482 config register and a value. | |
| int | strongPullUp (bool on) |
| Enables or disables strong pull-up mode. Used by parasitic power mode. | |
| void | beginTransmission () |
| Reflects to DS2482 parent to do an I2C operation. | |
| uint8_t | endTransmission (bool stop=true) |
| Reflects to DS2482 parent to do an I2C operation. | |
| uint8_t | requestFrom (uint8_t numBytes, bool stop=true) |
| Reflects to DS2482 parent to do an I2C operation. | |
| size_t | write (uint8_t val) |
| Reflects to DS2482 parent to do an I2C operation. | |
| size_t | write (const uint8_t *buf, size_t count) |
| Reflects to DS2482 parent to do an I2C operation. | |
| int | available (void) |
| Reflects to DS2482 parent to do an I2C operation. | |
| int | read (void) |
| Reflects to DS2482 parent to do an I2C operation. | |
Friends | |
| class | DS2482 |
Additional Inherited Members | |
Static Public Attributes inherited from DS2482Command | |
| static const int | RESULT_WORKING = 0 |
| Asynchronous call still in progress. | |
| static const int | RESULT_DONE = 1 |
| Asynchronous call completed successfully. | |
| static const int | RESULT_I2C_ENDTRANSMISSION_BUSY_ERROR = -1 |
| Busy timeout upon entering endTransmission (I2C error) | |
| static const int | RESULT_I2C_ENDTRANSMISSION_START_ERROR = -2 |
| Start bit generation timeout (I2C error) | |
| static const int | RESULT_I2C_ENDTRANSMISSION_ADDRESS_ERROR = -3 |
| End of address transmission timeout (I2C error) | |
| static const int | RESULT_I2C_ENDTRANSMISSION_TRANSFER_ERROR = -4 |
| Data byte transfer timeout (I2C error) | |
| static const int | RESULT_I2C_ENDTRANSMISSION_AFTER_TRANSFER_ERROR = -5 |
| Data byte transfer succeeded, busy timeout immediately after (I2C error) | |
| static const int | RESULT_I2C_READ_TIMEOUT = -100 |
| I2C requestFrom did not return bytes. | |
| static const int | RESULT_I2C_COMMAND_TIMEOUT = -101 |
| An I2C command timed out. | |
| static const int | RESULT_1WIRE_SHORT = -200 |
| On a 1-wire bus reset, a short was detected (SD flag set) | |
| static const int | RESULT_1WIRE_BUSY = -201 |
| The previous 1-wire command had not completed yet. | |
| static const int | RESULT_1WIRE_NO_DEVICE = -202 |
| No device on the 1-wire bus when doing a 1-wire send address (no presence pulse detected) | |
| static const int | RESULT_TOO_MANY_RETRIES = -300 |
| Specified number of retries exceeded without getting a response with a valid CRC. | |
| static const int | RESULT_SEARCH_FAILED = -301 |
| During a 1-wire search bus, got an invalid set of bits returned. | |
| static const int | RESULT_SET_CHANNEL_FAILED = -303 |
| A DS2482-800 set channel operation failed to set the channel. | |
| static const uint8_t | TRIPLET_CMD = 0x78 |
| DS2482 I2C command code. | |
| static const uint8_t | SINGLE_1WIRE_BIT_CMD = 0x87 |
| DS2482 I2C command code. | |
| static const uint8_t | WRITE_BYTE_CMD = 0xa5 |
| DS2482 I2C command code. | |
| static const uint8_t | READ_BYTE_CMD = 0x96 |
| DS2482 I2C command code. | |
| static const uint8_t | RESET_1WIRE_CMD = 0xb4 |
| DS2482 I2C command code. | |
| static const uint8_t | CHANNEL_SELECT_CMD = 0xc3 |
| DS2482 I2C command code. | |
| static const uint8_t | WRITE_CONFIG_CMD = 0xd2 |
| DS2482 I2C command code. | |
| static const uint8_t | SET_READ_PTR_CMD = 0xe1 |
| DS2482 I2C command code. | |
| static const uint8_t | DEVICE_RESET_CMD = 0xf0 |
| DS2482 I2C command code. | |
| static const uint8_t | CONFIG_REG = 0xc3 |
| DS2482 register code. | |
| static const uint8_t | READ_DATA_REG = 0xe1 |
| DS2482 register code. | |
| static const uint8_t | STATUS_REG = 0xf0 |
| DS2482 register code. | |
| static const uint8_t | STATUS_DIR_MASK = 0b10000000 |
| DS2482 status register bit. | |
| static const uint8_t | STATUS_TSB_MASK = 0b01000000 |
| DS2482 status register bit. | |
| static const uint8_t | STATUS_SBR_MASK = 0b00100000 |
| DS2482 status register bit. | |
| static const uint8_t | STATUS_RST_MASK = 0b00010000 |
| DS2482 status register bit. | |
| static const uint8_t | STATUS_LL_MASK = 0b00001000 |
| DS2482 status register bit. | |
| static const uint8_t | STATUS_SD_MASK = 0b00000100 |
| DS2482 status register bit. | |
| static const uint8_t | STATUS_PPD_MASK = 0b00000010 |
| DS2482 status register bit. | |
| static const uint8_t | STATUS_1WB_MASK = 0b00000001 |
| DS2482 status register bit. | |
| static const uint8_t | CONFIG_1WS_MASK = 0b1000 |
| DS2482 config register bit. | |
| static const uint8_t | CONFIG_SPU_MASK = 0b0100 |
| DS2482 config register bit. | |
| static const uint8_t | CONFIG_APU_MASK = 0b0001 |
| DS2482 config register bit. | |
| static const uint8_t | SEARCH_ROM = 0xf0 |
| 1-wire ROM select command | |
| static const uint8_t | READ_ROM = 0x33 |
| 1-wire ROM select command | |
| static const uint8_t | MATCH_ROM = 0x55 |
| 1-wire ROM select command | |
| static const uint8_t | SKIP_ROM = 0xcc |
| 1-wire ROM select command | |
| static const uint8_t | ALARM_SEARCH = 0xec |
| DS18B20 command. | |
| static const uint8_t | CONVERT_T = 0x44 |
| DS18B20 command. | |
| static const uint8_t | WRITE_SCRATCHPAD = 0x4e |
| DS18B20 command. | |
| static const uint8_t | READ_SCRATCHPAD = 0xbe |
| DS18B20 command. | |
| static const uint8_t | COPY_SCRATCHPAD = 0x48 |
| DS18B20 command. | |
| static const uint8_t | RECALL_E2 = 0xb8 |
| DS18B20 command. | |
| static const uint8_t | READ_POWER_SUPPLY = 0xb4 |
| DS18B20 command. | |
| static const int | CONVERSION_9BIT = 0 |
| 9-bit conversion size, resolution of 1/2 degree C, conversion time 94 ms | |
| static const int | CONVERSION_10BIT = 1 |
| 10-bit conversion size, resolution of 1/4 degree C, conversion time 188 ms | |
| static const int | CONVERSION_11BIT = 2 |
| 11-bit conversion size, resolution of 1/8 degree C, conversion time 375 ms | |
| static const int | CONVERSION_12BIT = 3 |
| 12-bit conversion size, resolution of 1/16 degree C, conversion time 750 ms (default) | |
| static const int | RETRIES_DEFAULT = 3 |
| Default numnber of retries if you don't override it with withRetries() | |
Protected Attributes inherited from DS2482Command | |
| DS2482 & | parent |
| The DS2482 that this command is being run on. | |
Low-level class to send a 1-wire command and read a number of bytes back. You won't need to call this directly.
There is no run method in this class as it's only subclassed by specific commands.
| bool DS24821WireCommand::checkCRC | ( | ) | const |
Checks the CRC of the buffer.
The assumption is that the CRC value will be at (offset - 1). It will calculate the CRC of the bytes from 0 to (offset - 2) inclusive.
| DS24821WireAddress DS24821WireCommand::getAddress | ( | ) | const |
Gets the buffer as a 1-wire address.
A copy is returned as a DS24821WireAddress object.
1.8.14