56 unsigned char ds2401_id[8];
59 #define SERIAL_ID_PIN_READ PINA
60 #define SERIAL_ID_PIN_MASK _BV(4)
61 #define SERIAL_ID_PxOUT PORTA
62 #define SERIAL_ID_PxDIR DDRA
64 #define SET_PIN_INPUT() (SERIAL_ID_PxDIR &= ~SERIAL_ID_PIN_MASK)
65 #define SET_PIN_OUTPUT() (SERIAL_ID_PxDIR |= SERIAL_ID_PIN_MASK)
67 #define OUTP_0() (SERIAL_ID_PxOUT &= ~SERIAL_ID_PIN_MASK)
68 #define OUTP_1() (SERIAL_ID_PxOUT |= SERIAL_ID_PIN_MASK)
70 #define PIN_INIT() do{ \
77 #define OW_DRIVE() do { \
83 #define OW_RELEASE() do { \
89 #define INP() (SERIAL_ID_PIN_READ & SERIAL_ID_PIN_MASK)
113 delay_loop(uint16_t __count)
115 asm volatile (
"1: sbiw %0,1" "\n\t"
127 #define udelay(u) delay_loop(((7.3728F * u)-1)/4)
143 write_byte(uint8_t byte)
187 crc8_add(
unsigned acc,
unsigned byte)
191 for (i = 0; i < 8; i++)
193 acc = (acc >> 1) ^ 0x8c;
204 uint8_t
volatile sreg;
205 unsigned family, crc, acc;
214 family = read_byte();
215 for (i = 7; i >= 2; i--) {
216 ds2401_id[i] = read_byte();
225 acc = crc8_add(0x0, family);
226 for (i = 7; i >= 2; i--) {
227 acc = crc8_add(acc, ds2401_id[i]);
241 memset(ds2401_id, 0x0,
sizeof(ds2401_id));