26 for (uint8_t i =
CHARBITS; i != 0; i--) {
27 uint8_t msb = (crc & 0x80);
42 return (count ==
sizeof(cmd));
52 size = check ?
sizeof(buf) :
sizeof(buf) - 1;
53 for (
int retry = 0; retry < 20; retry++) {
57 if (count != -1)
break;
60 if (count != size)
return (
false);
65 if (crc != buf[2])
return (
false);
67 value = ((buf[0] << 8) | buf[1]);
79 count =
twi.
read(®,
sizeof(reg));
81 if (count !=
sizeof(reg))
return (
false);
100 if (count !=
sizeof(xmd))
goto err;
101 count =
twi.
read(sna,
sizeof(sna));
102 if (count !=
sizeof(sna))
goto err;
105 for (
size_t i = 0; i <
sizeof(sna);) {
108 if (sna[i++] != crc)
goto err;
114 if (count !=
sizeof(xmd))
goto err;
115 count =
twi.
read(&snb,
sizeof(snb));
116 if (count !=
sizeof(snb))
goto err;
118 for (
size_t i = 0; i <
sizeof(snb); ) {
123 if (snb[i++] != crc)
goto err;
137 uint16_t xmd = 0x84B8;
141 count =
twi.
read(&rev,
sizeof(rev));
143 return (count ==
sizeof(rev));
bool read_electronic_serial_number(uint8_t snr[8])
bool read_firmware_revision(uint8_t &rev)
void(* delay)(uint32_t ms)
int read(void *buf, size_t size)
int write(void *buf, size_t size)
void acquire(TWI::Driver *dev)
bool read(uint16_t &value, bool check=true)
static uint8_t crc_update(uint8_t crc, uint8_t data)