From a5e79333e5769f92558bf20458c165e2582a0cb6 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sun, 2 May 2010 06:02:54 +0000 Subject: [PATCH] Switch back to C based timeout ISR in the AVRISP project - assembly version was failing, and only one or two cycles could be shaved off the compiler generated code. --- LUFA.pnproj | 2 +- Projects/AVRISP-MKII/Lib/Timeout.S | 23 -------------------- Projects/AVRISP-MKII/Lib/V2Protocol.c | 6 +++++ Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c | 13 +++++++++++ Projects/AVRISP-MKII/makefile | 4 ++-- 5 files changed, 22 insertions(+), 26 deletions(-) delete mode 100644 Projects/AVRISP-MKII/Lib/Timeout.S diff --git a/LUFA.pnproj b/LUFA.pnproj index dc9ab7db23..a3cb469e28 100644 --- a/LUFA.pnproj +++ b/LUFA.pnproj @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/Projects/AVRISP-MKII/Lib/Timeout.S b/Projects/AVRISP-MKII/Lib/Timeout.S deleted file mode 100644 index ad56d1d215..0000000000 --- a/Projects/AVRISP-MKII/Lib/Timeout.S +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include "V2Protocol.h" - -.global TIMER0_COMPA_vect -TIMER0_COMPA_vect: - sei - push r24 - in r24, 0x3f - push r24 - - in r24, TimeoutMSRemaining - and r24, r24 - breq Epilogue - subi r24, 0x01 - out TimeoutMSRemaining, r24 - -Epilogue: - pop r24 - out 0x3f, r24 - pop r24 - reti - - \ No newline at end of file diff --git a/Projects/AVRISP-MKII/Lib/V2Protocol.c b/Projects/AVRISP-MKII/Lib/V2Protocol.c index 63b7294c0a..035c8a5b39 100644 --- a/Projects/AVRISP-MKII/Lib/V2Protocol.c +++ b/Projects/AVRISP-MKII/Lib/V2Protocol.c @@ -43,6 +43,12 @@ uint32_t CurrentAddress; bool MustSetAddress; +ISR(TIMER0_COMPA_vect, ISR_NOBLOCK) +{ + if (TimeoutMSRemaining) + TimeoutMSRemaining--; +} + /** Initializes the hardware and software associated with the V2 protocol command handling. */ void V2Protocol_Init(void) { diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c index 228a895468..6adb24f16f 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c +++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c @@ -165,6 +165,10 @@ void XPROGTarget_EnableTargetPDI(void) BITBANG_PDIDATA_DDR |= BITBANG_PDIDATA_MASK; BITBANG_PDICLOCK_DDR |= BITBANG_PDICLOCK_MASK; + /* Set DATA line low for at least 90ns to ensure that the device is ready for PDI mode to be entered */ + BITBANG_PDIDATA_PORT &= ~BITBANG_PDIDATA_MASK; + _delay_us(1); + /* Set DATA line high for at least 90ns to disable /RESET functionality */ BITBANG_PDIDATA_PORT |= BITBANG_PDIDATA_MASK; _delay_us(1); @@ -314,6 +318,9 @@ void XPROGTarget_SendByte(const uint8_t Byte) SoftUSART_Data = NewUSARTData; SoftUSART_BitCount = BITS_IN_USART_FRAME; #endif + + if (TimeoutMSRemaining) + TimeoutMSRemaining = COMMAND_TIMEOUT_MS; } /** Receives a byte via the software USART, blocking until data is received. @@ -369,6 +376,9 @@ void XPROGTarget_SendBreak(void) SoftUSART_Data = 0x0FFF; SoftUSART_BitCount = BITS_IN_USART_FRAME; #endif + + if (TimeoutMSRemaining) + TimeoutMSRemaining = COMMAND_TIMEOUT_MS; } static void XPROGTarget_SetTxMode(void) @@ -405,6 +415,9 @@ static void XPROGTarget_SetTxMode(void) } #endif + if (TimeoutMSRemaining) + TimeoutMSRemaining = COMMAND_TIMEOUT_MS; + IsSending = true; } diff --git a/Projects/AVRISP-MKII/makefile b/Projects/AVRISP-MKII/makefile index cbc46ce50c..44ca465de4 100644 --- a/Projects/AVRISP-MKII/makefile +++ b/Projects/AVRISP-MKII/makefile @@ -66,7 +66,7 @@ MCU = at90usb1287 # Target board (see library "Board Types" documentation, NONE for projects not requiring # LUFA board drivers). If USER is selected, put custom board drivers in a directory called # "Board" inside the application directory. -BOARD = USBKEY +BOARD = XPLAIN # Processor frequency. @@ -157,7 +157,7 @@ CPPSRC = # Even though the DOS/Win* filesystem matches both .s and .S the same, # it will preserve the spelling of the filenames, and gcc itself does # care about how the name is spelled on its command-line. -ASRC = Lib/Timeout.S +ASRC = # Optimization level, can be [0, 1, 2, 3, s].