aboutsummaryrefslogtreecommitdiff
path: root/Projects/AVRISP-MKII/Lib
diff options
context:
space:
mode:
authorDean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28>2010-11-16 01:37:43 +0000
committerDean <Dean@d5102386-fcda-11dd-9fdb-3debd5008f28>2010-11-16 01:37:43 +0000
commit99353c0c826ba0a2727de0bfce747a47074ca5b7 (patch)
tree2bad7bb012ad3230f7e83944dbfda8c21511556f /Projects/AVRISP-MKII/Lib
parente687bda431c7536c1486601d46f64172328b1a4a (diff)
Added new XCK_RESCUE_CLOCK_ENABLE compile time option to the AVRISP-MKII clone programmer project (thanks to Tom Light).
git-svn-id: http://lufa-lib.googlecode.com/svn/trunk@1580 d5102386-fcda-11dd-9fdb-3debd5008f28
Diffstat (limited to 'Projects/AVRISP-MKII/Lib')
-rw-r--r--Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c32
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c4
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c2
3 files changed, 26 insertions, 12 deletions
diff --git a/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c b/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
index 66a1c256..657c2c99 100644
--- a/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
+++ b/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
@@ -189,19 +189,29 @@ void ISPTarget_DisableTargetISP(void)
*/
void ISPTarget_ConfigureRescueClock(void)
{
- /* Configure OCR1A as an output for the specified AVR model */
- #if defined(USB_SERIES_2_AVR)
- DDRC |= (1 << 6);
+ #if defined(XCK_RESCUE_CLOCK_ENABLE)
+ /* Configure XCK as an output for the specified AVR model */
+ DDRD |= (1 << 5);
+
+ /* Start USART to generate a 4MHz clock on the XCK pin */
+ UBRR1 = ((F_CPU / 2 / ISP_RESCUE_CLOCK_SPEED) - 1);
+ UCSR1B = (1 << TXEN1);
+ UCSR1C = (1 << UMSEL10) | (1 << UPM11) | (1 << USBS1) | (1 << UCSZ11) | (1 << UCSZ10) | (1 << UCPOL1);
#else
- DDRB |= (1 << 5);
+ /* Configure OCR1A as an output for the specified AVR model */
+ #if defined(USB_SERIES_2_AVR)
+ DDRC |= (1 << 6);
+ #else
+ DDRB |= (1 << 5);
+ #endif
+
+ /* Start Timer 1 to generate a 4MHz clock on the OCR1A pin */
+ TIMSK1 = 0;
+ TCNT1 = 0;
+ OCR1A = ((F_CPU / 2 / ISP_RESCUE_CLOCK_SPEED) - 1);
+ TCCR1A = (1 << COM1A0);
+ TCCR1B = ((1 << WGM12) | (1 << CS10));
#endif
-
- /* Start Timer 1 to generate a 4MHz clock on the OCR1A pin */
- TIMSK1 = 0;
- TCNT1 = 0;
- OCR1A = ((F_CPU / 2 / ISP_RESCUE_CLOCK_SPEED) - 1);
- TCCR1A = (1 << COM1A0);
- TCCR1B = ((1 << WGM12) | (1 << CS10));
}
/** Configures the AVR's timer ready to produce software ISP for the slower ISP speeds that
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
index 02fbbf44..276f63e0 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
@@ -196,6 +196,10 @@ static void XPROGProtocol_LeaveXPROGMode(void)
XPROGTarget_DisableTargetTPI();
}
+ #if defined(XCK_RESCUE_CLOCK_ENABLE) && defined(ENABLE_ISP_PROTOCOL)
+ ISPTarget_ConfigureRescueClock();
+ #endif
+
Endpoint_Write_Byte(CMD_XPROG);
Endpoint_Write_Byte(XPRG_CMD_LEAVE_PROGMODE);
Endpoint_Write_Byte(XPRG_ERR_OK);
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
index 8760e62c..f6fff1cf 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
@@ -118,7 +118,7 @@ void XPROGTarget_DisableTargetTPI(void)
/* Set all USART lines as input, tristate */
DDRD &= ~((1 << 5) | (1 << 3));
PORTD &= ~((1 << 5) | (1 << 3) | (1 << 2));
-
+
/* Tristate target /RESET line */
AUX_LINE_DDR &= ~AUX_LINE_MASK;
AUX_LINE_PORT &= ~AUX_LINE_MASK;