19 #include <avr/interrupt.h>
39 extern volatile uint8_t
bitp;
40 extern volatile uint8_t
bytep;
41 extern volatile uint8_t
cbuf;
55 #error "Which timer should we use?"
60 #if 0 // def DBGPIN // additional overhead for playing with the trace pin
68 #define T_(c) ((F_CPU/PRESCALE)/(1000000/c)-_ADD_T)
69 #define OWT_MIN_RESET T_(410)
70 #define OWT_RESET_PRESENCE (T_(40)-1)
71 #define OWT_PRESENCE (T_(160)-1)
72 #define OWT_READLINE (T_(30)-2)
73 #define OWT_LOWTIME (T_(40)-2)
75 #if (OWT_MIN_RESET>240)
76 #error Reset timing is broken, your clock is too fast
79 #error Read timing is broken, your clock is too slow
82 #if ONEWIRE_IRQNUM == -1
83 #define EN_OWINT() do {IMSK|=(1<<INT0);IFR|=(1<<INTF0);}while(0) //enable interrupt
84 #define DIS_OWINT() do {IMSK&=~(1<<INT0);} while(0) //disable interrupt
85 #define SET_RISING() do {EICRA|=(1<<ISC01)|(1<<ISC00);}while(0) //set interrupt at rising edge
86 #define SET_FALLING() do {EICRA|=(1<<ISC01);EICRA&=~(1<<ISC00);} while(0) //set interrupt at falling edge
87 #define CHK_INT_EN() (IMSK&(1<<INT0)) //test if pin interrupt enabled
88 #define PIN_INT INT0_vect // the interrupt service routine
89 #elif ONEWIRE_IRQNUM == -2
90 #define EN_OWINT() do {IMSK|=(1<<INT1);IFR|=(1<<INTF1);}while(0) //enable interrupt
91 #define DIS_OWINT() do {IMSK&=~(1<<INT1);} while(0) //disable interrupt
92 #define SET_RISING() do {EICRA|=(1<<ISC11)|(1<<ISC10);}while(0) //set interrupt at rising edge
93 #define SET_FALLING() do {EICRA|=(1<<ISC11);EICRA&=~(1<<ISC10);} while(0) //set interrupt at falling edge
94 #define CHK_INT_EN() (IMSK&(1<<INT1)) //test if pin interrupt enabled
95 #define PIN_INT INT1_vect // the interrupt service routine
97 #error generic pin change interrupts are not yet supported
102 #ifdef ONEWIRE_USE_T2
103 #define EN_TIMER() do {TIMSK2 |= (1<<TOIE2); TIFR2|=(1<<TOV2);}while(0) //enable timer interrupt
104 #define DIS_TIMER() do {TIMSK2 &= ~(1<<TOIE2);} while(0) // disable timer interrupt
105 #define SET_TIMER(x) do { GTCCR = (1<<PSRASY); TCNT2=(uint8_t)~(x); } while(0) // reset prescaler
106 #define TIMER_INT ISR(TIMER2_OVF_vect) //the timer interrupt service routine
109 #ifdef __AVR_ATmega8__
112 #define PSRSYNC PSR10
118 #define EN_TIMER() do {TIMSK0 |= (1<<TOIE0); TIFR0|=(1<<TOV0);}while(0) //enable timer interrupt
119 #define DIS_TIMER() do {TIMSK0 &= ~(1<<TOIE0);} while(0) // disable timer interrupt
120 #define SET_TIMER(x) do { GTCCR = (1<<PSRSYNC); TCNT0=(uint8_t)~(x); } while(0) // reset prescaler
121 #define TIMER_INT ISR(TIMER0_OVF_vect) //the timer interrupt service routine
125 #ifndef TIMER0_OVF_vect
126 # define TIMER0_OVF_vect TIM0_OVF_vect
129 #define SET_LOW() do { ONEWIRE_DDR|=ONEWIRE_PBIT;} while(0) //set 1-Wire line to low
130 #define CLEAR_LOW() do {ONEWIRE_DDR&=~ONEWIRE_PBIT;} while(0) //set 1-Wire pin as input
168 extern volatile uint8_t
actbit;
170 static inline void start_reading(uint8_t bits) {
176 #define START_READING(bits) do { \
182 #define wait_complete(c) _wait_complete()
189 void xmit_bit(uint8_t val);
199 uint8_t rx_ready(
void);
211 uint16_t
crc16(uint16_t
r, uint8_t x);
xmode_t
Definition: onewire_internal.h:152
ow_addr_t ow_addr
Definition: onewire.c:22
Definition: onewire_internal.h:163
Definition: onewire_internal.h:165
volatile uint8_t cbuf
Definition: onewire.c:26
#define CFG_DATA(n)
Definition: dev_data.h:9
void onewire_init(void)
Definition: onewire.c:32
Definition: onewire_internal.h:142
uint8_t recv_any_in(void)
Definition: onewire.c:194
void next_command(void) __attribute__((noreturn))
Definition: onewire.c:90
Definition: onewire_internal.h:155
tuple buf
Definition: DeviceGeneric.py:119
wmode_t
Definition: onewire_internal.h:162
Definition: onewire_internal.h:154
Definition: onewire_internal.h:145
byte addr[8]
Definition: OWP_DG_1w-adaptor.ino:104
volatile uint8_t bytep
Definition: onewire.c:25
Definition: onewire_internal.h:164
uint16_t crc16(uint16_t r, uint8_t x)
Definition: crc.c:24
uint16_t xmit_byte_crc(uint16_t crc, uint8_t val)
void set_idle(void)
Definition: onewire.c:369
Definition: onewire_internal.h:139
void xmit_byte(uint8_t val)
Definition: onewire.c:155
void recv_byte(void)
Definition: onewire.c:215
Definition: onewire_internal.h:156
uint16_t recv_bytes_crc(uint16_t crc, uint8_t *buf, uint8_t len)
Definition: onewire.c:220
#define noreturn
Definition: stdnoreturn.h:27
Definition: onewire_internal.h:143
Definition: onewire_internal.h:153
return r
Definition: IMU.cpp:176
Definition: onewire_internal.h:33
char __v64qi __attribute__((__vector_size__(64)))
Definition: avx512bwintrin.h:33
void onewire_poll(void)
Definition: onewire.c:362
Definition: onewire_internal.h:141
Definition: onewire_internal.h:137
Definition: onewire_internal.h:140
Definition: onewire_internal.h:138
volatile xmode_t xmode
Definition: onewire.c:27
volatile uint8_t bitp
Definition: onewire.c:24
volatile wmode_t wmode
Definition: onewire.c:28
Definition: onewire_internal.h:147
uint16_t xmit_bytes_crc(uint16_t crc, uint8_t *buf, uint8_t len)
mode_t
Definition: onewire_internal.h:136
volatile mode_t mode
Definition: onewire_internal.h:149
Definition: onewire_internal.h:146
volatile uint8_t actbit
Definition: onewire.c:29
void _wait_complete(void)
Definition: onewire.c:101