43 virtual bool reset() = 0;
52 virtual uint8_t
read(uint8_t bits = CHARBITS) = 0;
62 bool read(
void* buf,
size_t count)
64 uint8_t* bp = (uint8_t*) buf;
67 uint8_t value =
read();
81 virtual void write(uint8_t value, uint8_t bits = CHARBITS) = 0;
90 void write(uint8_t cmd,
const void* buf,
size_t count)
93 const uint8_t* bp = (
const uint8_t*) buf;
94 while (count--)
write(*bp++);
136 } __attribute__((packed));
147 __attribute__((always_inline))
150 for (uint8_t i = 0; i < 8; i++) {
166 static inline uint8_t
crc(
const void* buf,
size_t count)
168 const uint8_t* bp = (
const uint8_t*) buf;
181 static inline uint8_t
crc_P(
const void* buf,
size_t count)
183 const uint8_t* bp = (
const uint8_t*) buf;
185 while (count--) crc =
crc_update(crc, pgm_read_byte(bp++));
194 } __attribute__((packed));
209 last =
search(code, last);
211 }
while ((last !=
LAST) && (family != 0) && (code[0] != family));
212 if (family != 0 && code[0] != family)
return (
ERROR);
224 if (!
reset())
return (
false);
226 return (
read(code, ROM_MAX));
238 if (!
reset())
return (
false);
250 if (!
reset())
return (
false);
265 return (
search(code, last));
276 if (!
reset())
return (
false);
306 for (
size_t i = 0; i < ROM_MAX - 1; i++) {
307 uint8_t data = *rom++;
321 for (
size_t i = 0; i < ROM_MAX - 1; i++) {
322 uint8_t data = pgm_read_byte(rom++);
361 for (uint8_t i = 0; i < 8; i++) {
363 for (uint8_t j = 0; j < 8; j++) {
364 uint8_t dir = (pos == last) || ((pos < last) && (code[i] & (1 << j)));
369 else if (pos > last || (code[i] & (1 << j)) == 0)
376 if (dir) data |= 0x80;
int8_t alarm_search(uint8_t *code, int8_t last=FIRST)
bool match_label(uint8_t label)
static const size_t ROMBITS
static uint8_t crc_update(uint8_t crc, uint8_t data)
Broadcast or single device.
static const uint8_t RESET_RETRY_MAX
Select device with 8-bit short address.
void rom_P(const uint8_t *rom)
virtual int8_t triplet(uint8_t &dir)
static uint8_t crc(const void *buf, size_t count)
int8_t search_rom(uint8_t family, uint8_t *code, int8_t last=FIRST)
virtual void write(uint8_t value, uint8_t bits=CHARBITS)=0
Software::OWI< BOARD::D7 > owi
Set short address (8-bit).
int8_t search(uint8_t *code, int8_t last=FIRST)
bool read(void *buf, size_t count)
static uint8_t crc_P(const void *buf, size_t count)
void rom(const uint8_t *rom)
Select device with 64-bit rom code.
bool read_rom(uint8_t *code)
void write(uint8_t cmd, const void *buf, size_t count)
Last position, search completed.
bool match_rom(uint8_t *code)
Start position of search.
static const size_t ROM_MAX
virtual uint8_t read(uint8_t bits=CHARBITS)=0
Read device family code and serial number.
Initiate device alarm search.
Device(OWI &owi, const uint8_t *rom=NULL)