diff options
author | Florian Jung <flo@windfisch.org> | 2016-01-24 18:33:50 +0100 |
---|---|---|
committer | Florian Jung <flo@windfisch.org> | 2016-01-24 18:33:50 +0100 |
commit | c23307d11666127bfd495dba8839d0e54e23f0aa (patch) | |
tree | 30e6604dbe135848aa924ae324e5293d4abc0489 /avr | |
parent | 8482df6feec66b545459de70f43b2ac66f77501e (diff) |
.
Diffstat (limited to 'avr')
-rw-r--r-- | avr/main.c | 22 |
1 files changed, 8 insertions, 14 deletions
@@ -43,6 +43,9 @@ #define FUNC_START_BOOTLOADER 30 #define FUNC_GET_TYPE 0xFE +volatile int got_data = 0; // set to 1, if we get data to write from the PC + + void jump_to_bootloader(void) { cli(); @@ -67,6 +70,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) len = 0; break; case FUNC_READ: + got_data = 1; return USB_NO_MSG; case FUNC_WRITE: @@ -149,7 +153,7 @@ int main(void) wdt_reset(); // keep the watchdog happy usbPoll(); - if (++c % 3000 == 0) + if (++c % (got_data ? 1500 : 3000) == 0) { PORTC^=LED_BLUE; PORTC |= LED_RED | LED_GREEN; @@ -157,27 +161,17 @@ int main(void) if (c % 12000 == 0) { uint8_t result = w1_reset(); - if (result == 0) + if (result == 0) // device detected { PORTC &= ~LED_GREEN; ds1992_read(0, replyBuffer, 128); } - else if (result == 1) + else if (result == 1) // no presence pulse == no device detected PORTC &= ~LED_RED; - else + else // short circuit detected PORTC &= ~(LED_RED | LED_GREEN); } - /*if ( (c / 3000) % 40 == 0) - { - PORTC &= ~LED_RED; - usb_disconnect(); - } - else if ((c / 3000) % 40 == 20) - { - usb_reconnect(); - PORTC |= LED_RED; - }*/ } jump_to_bootloader(); |