diff options
author | Florian Jung <flo@windfisch.org> | 2016-01-24 16:06:58 +0100 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2016-01-24 16:06:58 +0100 |
commit | 7c2ece0331e0cd9dad9f738698c1d58d04558858 (patch) | |
tree | 96a07570f2c41528b5b2acf3aa3c522ad4dd24ab /avr | |
parent | fe742e35d3fa6d69125e9f463cbbe1c6032969ca (diff) |
tut
Diffstat (limited to 'avr')
-rw-r--r-- | avr/1wire.c | 18 | ||||
-rw-r--r-- | avr/main.c | 5 |
2 files changed, 15 insertions, 8 deletions
diff --git a/avr/1wire.c b/avr/1wire.c index 5dbca82..affd80d 100644 --- a/avr/1wire.c +++ b/avr/1wire.c @@ -79,15 +79,20 @@ uint8_t w1_bit_io( uint8_t b ) _delay_us( 1 ); if( b ) { - //hard_vcc; - //asm volatile("nop" ::: ); + hard_vcc; + _delay_us(7 ); soft_vcc; + _delay_us( 15 - 1 - 7 ); + } + else + { + _delay_us( 15 - 1 ); } - _delay_us( 15 - 1 ); if( (W1_IN & (1<<W1_PIN)) == 0 ) b = 0; _delay_us( 60 - 15 ); - soft_vcc; + //soft_vcc; + hard_vcc; sei(); return b; } @@ -104,6 +109,7 @@ uint8_t w1_byte_wr( uint8_t b ) b |= 0x80; } while( --i ); + soft_vcc; return b; } @@ -113,7 +119,7 @@ uint8_t w1_byte_rd( void ) return w1_byte_wr( 0xFF ); } - +/* uint8_t w1_rom_search( uint8_t diff, uint8_t *id ) { uint8_t i, j, next_diff; @@ -158,7 +164,7 @@ uint8_t w1_rom_search( uint8_t diff, uint8_t *id ) } while( i ); return next_diff; // to continue search -} +}*/ void ds1992_read(uint16_t addr, uint8_t* buf, uint8_t len) { @@ -72,7 +72,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) case FUNC_WRITE: PORTC ^= LED_RED; //strcpy(replyBuffer, "Hello world"); - len = strlen(replyBuffer)+1; + //len = strlen(replyBuffer)+1; + len = 130; break; } @@ -159,7 +160,7 @@ int main(void) if (result == 0) { PORTC &= ~LED_GREEN; - ds1992_read(0x00, replyBuffer, 128); + ds1992_read(42, replyBuffer, 128); } else if (result == 1) PORTC &= ~LED_RED; |