diff options
author | Andreas Auras <yak54@gmx.net> | 2010-03-06 20:26:46 +0100 |
---|---|---|
committer | Andreas Auras <yak54@gmx.net> | 2010-03-06 20:26:46 +0100 |
commit | 6cdccc1f115a8caa5ecf51d5529d37461103c92e (patch) | |
tree | 8e921a33817b09749410588506d57df03ab013b7 | |
parent | 4dfa870b4680a594545a4fd83aeddeeaebc97ec2 (diff) | |
download | df10ch-atmolight-controller-6cdccc1f115a8caa5ecf51d5529d37461103c92e.tar.gz df10ch-atmolight-controller-6cdccc1f115a8caa5ecf51d5529d37461103c92e.tar.bz2 |
Improved error status handling
Fixed watch dog timeout
Set firmware version 2
-rw-r--r-- | usb_appl/Makefile | 2 | ||||
-rw-r--r-- | usb_appl/df10ch_usb_appl.c | 26 |
2 files changed, 16 insertions, 12 deletions
diff --git a/usb_appl/Makefile b/usb_appl/Makefile index 97fad42..053a027 100644 --- a/usb_appl/Makefile +++ b/usb_appl/Makefile @@ -30,7 +30,7 @@ CC = avr-gcc AVRDUDE ?= avrdude -c stk500v2 -P avrdoper USBDRV ?= ../usbdrv F_CPU ?= 16000000UL -FIRMWARE_VERSION ?= 1 +FIRMWARE_VERSION ?= 2 ## Options common to compile, link and assembly rules COMMON = -mmcu=$(MCU) diff --git a/usb_appl/df10ch_usb_appl.c b/usb_appl/df10ch_usb_appl.c index ba0d2c8..c6fa7b1 100644 --- a/usb_appl/df10ch_usb_appl.c +++ b/usb_appl/df10ch_usb_appl.c @@ -191,6 +191,12 @@ static uint16_t reply_timeout = REPLY_TIMEOUT; #define DDRD_INIT (_BV(1)) +// --- +// Watchdogtimer related. +// +#define WDTO_TIMEOUT WDTO_120MS + + #include <usbdrv.c> @@ -216,19 +222,17 @@ ISR(USART_RXC_vect) uint8_t i = rxwpos; uint8_t p = i + 1; CHECK_RXBUF_END(p); + if (p == rxrpos) + set_bit(reply_err_status, COMM_ERR_OVERFLOW); + else + rxwpos = p; // set data valid if (bit_is_set(UCSRA, DOR)) set_bit(reply_err_status, COMM_ERR_OVERRUN); - else if (bit_is_set(UCSRA, FE)) + if (bit_is_set(UCSRA, FE)) set_bit(reply_err_status, COMM_ERR_FRAME); - else if (p == rxrpos) - set_bit(reply_err_status, COMM_ERR_OVERFLOW); - else - { - if (bit_is_set(UCSRB, RXB8)) - rxspos = i; // save reply start position - rxwpos = p; // set data valid - } + if (bit_is_set(UCSRB, RXB8)) + rxspos = i; // save reply start position rxbuf[i] = UDR; // read data } while (bit_is_set(UCSRA, RXC)); @@ -726,7 +730,7 @@ USB_PUBLIC usbMsgLen_t usbFunctionSetup(uint8_t data[8]) void main(void) NORETURN; void main(void) { - wdt_enable(WDTO_120MS); // Set watchdog timeout + wdt_enable(WDTO_TIMEOUT); // Initialize Ports PORTB = PORTB_INIT; @@ -826,7 +830,7 @@ void main(void) sei(); sleep_cpu(); sleep_disable(); - wdt_enable(WDTO_30MS); + wdt_enable(WDTO_TIMEOUT); cli(); TCNT1 = 0; usb_sof_time = 0; |