Skip to content

Commit

Permalink
Merge pull request cybergibbons#7 from andypugh/master
Browse files Browse the repository at this point in the history
Add a way to change channels on the DS2482-800
  • Loading branch information
cybergibbons authored Nov 9, 2020
2 parents 2c34e45 + ab200e1 commit 31318b1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
14 changes: 14 additions & 0 deletions OneWire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,20 @@ void OneWire::wireResetSearch()

}

// Set the channel on the DS2482-800
uint8_t OneWire::setChannel(uint8_t ch){
uint8_t w[] = {0xf0, 0xe1, 0xd2, 0xc3, 0xb4, 0xa5, 0x96, 0x87};
uint8_t r[] = {0xb8, 0xb1, 0xaa, 0xa3, 0x9c, 0x95, 0x8e, 0x87};
waitOnBusy();
begin();
writeByte(0xc3);
writeByte(w[ch]);
end();
waitOnBusy();
return readByte() == r[ch];
}


// Perform a search of the 1-Wire bus
uint8_t OneWire::wireSearch(uint8_t *address)
{
Expand Down
5 changes: 4 additions & 1 deletion OneWire.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#ifndef __ONEWIRE_H__
#define __ONEWIRE_H__

#include <stddef.h>
#include <inttypes.h>


// Chose between a table based CRC (flash expensive, fast)
// or a computed CRC (smaller, slow)
#define ONEWIRE_CRC8_TABLE 1
Expand Down Expand Up @@ -59,6 +61,7 @@ class OneWire
uint8_t readConfig();
void writeConfig(uint8_t config);
void setStrongPullup();
uint8_t setChannel(uint8_t ch);
void clearStrongPullup();
uint8_t wireReset();
void wireWriteByte(uint8_t data, uint8_t power = 0);
Expand Down Expand Up @@ -96,4 +99,4 @@ class OneWire
uint8_t searchLastDeviceFlag;
};

#endif
#endif

0 comments on commit 31318b1

Please sign in to comment.