aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP-MKII/Lib/V2Protocol.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2012-04-01 13:39:04 +0000
committerDean Camera <dean@fourwalledcubicle.com>2012-04-01 13:39:04 +0000
commit25ac76a2517a23510831fa8a849585747f04d688 (patch)
tree834ac63cbc1d483d12305f65a1b376b1241eebfd /Projects/AVRISP-MKII/Lib/V2Protocol.c
parent89f16f5d7f411f31f85bc289fadcd7b15980303d (diff)
downloadlufa-25ac76a2517a23510831fa8a849585747f04d688.tar.gz
lufa-25ac76a2517a23510831fa8a849585747f04d688.tar.bz2
lufa-25ac76a2517a23510831fa8a849585747f04d688.zip
Reverted AVRISP-MKII clone project watchdog based command timeout patch in favour of a hardware timer, to allow for use in devices with WDTRST fuse programmed.
Diffstat (limited to 'Projects/AVRISP-MKII/Lib/V2Protocol.c')
-rw-r--r--Projects/AVRISP-MKII/Lib/V2Protocol.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/Projects/AVRISP-MKII/Lib/V2Protocol.c b/Projects/AVRISP-MKII/Lib/V2Protocol.c
index 780c48af4..f48581051 100644
--- a/Projects/AVRISP-MKII/Lib/V2Protocol.c
+++ b/Projects/AVRISP-MKII/Lib/V2Protocol.c
@@ -44,10 +44,12 @@ bool MustLoadExtendedAddress;
/** ISR to manage timeouts whilst processing a V2Protocol command */
-ISR(WDT_vect, ISR_BLOCK)
+ISR(TIMER0_COMPA_vect, ISR_NOBLOCK)
{
- TimeoutExpired = true;
- wdt_disable();
+ if (TimeoutTicksRemaining)
+ TimeoutTicksRemaining--;
+ else
+ TCCR0B = 0;
}
/** Initializes the hardware and software associated with the V2 protocol command handling. */
@@ -60,6 +62,11 @@ void V2Protocol_Init(void)
ADC_StartReading(VTARGET_REF_MASK | ADC_RIGHT_ADJUSTED | VTARGET_ADC_CHANNEL_MASK);
#endif
+ /* Timeout timer initialization (~10ms period) */
+ OCR0A = (((F_CPU / 1024) / 100) - 1);
+ TCCR0A = (1 << WGM01);
+ TIMSK0 = (1 << OCIE0A);
+
V2Params_LoadNonVolatileParamValues();
#if defined(ENABLE_ISP_PROTOCOL)
@@ -75,10 +82,9 @@ void V2Protocol_ProcessCommand(void)
{
uint8_t V2Command = Endpoint_Read_8();
- /* Start the watchdog with timeout interrupt enabled to manage the timeout */
- TimeoutExpired = false;
- wdt_enable(WDTO_1S);
- WDTCSR |= (1 << WDIE);
+ /* Reset timeout counter duration and start the timer */
+ TimeoutTicksRemaining = COMMAND_TIMEOUT_TICKS;
+ TCCR0B = ((1 << CS02) | (1 << CS00));
switch (V2Command)
{
@@ -140,8 +146,8 @@ void V2Protocol_ProcessCommand(void)
break;
}
- /* Disable the timeout management watchdog timer */
- wdt_disable();
+ /* Disable the timeout management timer */
+ TCCR0B = 0;
Endpoint_WaitUntilReady();
Endpoint_SelectEndpoint(AVRISP_DATA_OUT_EPNUM);