Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void onewire_tx (uint8_t data)
- {
- register uint8_t i=8;
- do
- {
- if (data & 0x80)
- { // one
- DDRB |= (1 << _DATAPIN); // _DATAPIN - pull down
- _delay_us (6);
- DDRB &= ~(1 << _DATAPIN); // _DATAPIN - tri-state
- _delay_us (64);
- }
- else
- { // zero
- DDRB |= (1 << _DATAPIN); // _DATAPIN - pull down
- _delay_us (60);
- DDRB &= ~(1 << _DATAPIN); // _DATAPIN - tri-state
- _delay_us (10);
- }
- data <<= 1;
- }
- while (--i);
- }
- /*
- uint8_t onewire_rx (void)
- {
- uint8_t result = 0x00;
- register uint8_t i=8;
- do
- {
- result <<= 1;
- DDRB |= (1 << _DATAPIN); // _DATAPIN - pull down
- _delay_us (6);
- DDRB &= ~(1 << _DATAPIN); // _DATAPIN - tri-state
- _delay_us (9);
- if (PINB & (1 << _DATAPIN))
- {
- result |= 0x01;
- }
- _delay_us (55);
- }
- while (--i);
- return result;
- }
- */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement