32 template<BOARD::pin_t PIN>
39 static const size_t ROMBITS = ROM_MAX * 8;
47 OWI(
const uint8_t* rom) :
53 for (
size_t i = 0; i < ROM_MAX - 1; i++) {
54 uint8_t data = pgm_read_byte(rom++);
76 for (
size_t i = 1; i < ROM_MAX - 1; i++) {
99 void crc(uint8_t value)
136 if (!
m_pin)
return (
false);
146 delayMicroseconds(100);
164 uint8_t adjust = 8 - bits;
172 delayMicroseconds(20);
184 if (mix & 1)
m_crc ^= 0x8C;
187 while (!
m_pin && --count);
188 if (count == 0)
return (0);
202 bool read(
void* buf,
size_t count)
205 uint8_t* bp = (uint8_t*) buf;
208 uint8_t value =
read();
223 void write(uint8_t value, uint8_t bits = 8)
231 if ((value & 0x01) == 0) {
233 delayMicroseconds(20);
244 if (mix & 1)
m_crc ^= 0x8C;
247 while (!
m_pin && --count);
248 if (count == 0)
return;
258 void write(
const void* buf,
size_t count)
261 const uint8_t* bp = (
const uint8_t*) buf;
264 uint8_t value = *bp++;
296 } __attribute__((packed));
307 if (!
reset())
return (
false);
317 for (
size_t i = 0; i <
ROM_MAX; i++)
329 for (
size_t i = 0; i <
ROM_MAX; i++) {
330 uint8_t value =
m_rom[i];
333 uint8_t bit = (mask & value) != 0;
335 if (dir != bit)
return (
false);
357 uint8_t cmd =
read();
378 __attribute__((always_inline))
static uint8_t crc_update(uint8_t crc, uint8_t data)
Initiate device alarm search.
bool read(void *buf, size_t count)
uint8_t read(uint8_t bits=8)
static const size_t ROM_MAX
Set short address (8-bit).
Select device with 8-bit short address.
static const size_t ROMBITS
Broadcast or single device.
Read device family code and serial number.
void write(const void *buf, size_t count)
Select device with 64-bit rom code.
void write(uint8_t value, uint8_t bits=8)