X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/016a4c068a01b0baf28bc45ec1eba16460689f9a..0ce2950d811b8dc11e46602e7490d795d8ddfb5d:/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c?ds=sidebyside diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c index 07efbb1da..f0ef2b652 100644 --- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c +++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c @@ -1,21 +1,21 @@ /* LUFA Library Copyright (C) Dean Camera, 2010. - + dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com + www.lufa-lib.org */ /* Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - Permission to use, copy, modify, distribute, and sell this + Permission to use, copy, modify, distribute, and sell this software and its documentation for any purpose is hereby granted - without fee, provided that the above copyright notice appear in + without fee, provided that the above copyright notice appear in all copies and that both that the copyright notice and this - permission notice and warranty disclaimer appear in supporting - documentation, and that the name of the author not be used in - advertising or publicity pertaining to distribution of the + permission notice and warranty disclaimer appear in supporting + documentation, and that the name of the author not be used in + advertising or publicity pertaining to distribution of the software without specific, written prior permission. The author disclaim all warranties with regard to this @@ -49,11 +49,11 @@ void XPROGTarget_EnableTargetPDI(void) /* Set Tx and XCK as outputs, Rx as input */ DDRD |= (1 << 5) | (1 << 3); DDRD &= ~(1 << 2); - + /* Set DATA line high for at least 90ns to disable /RESET functionality */ PORTD |= (1 << 3); _delay_us(1); - + /* Set up the synchronous USART for XMEGA communications - 8 data bits, even parity, 2 stop bits */ UBRR1 = (F_CPU / XPROG_HARDWARE_SPEED); UCSR1B = (1 << TXEN1); @@ -77,7 +77,7 @@ void XPROGTarget_EnableTargetTPI(void) /* Set Tx and XCK as outputs, Rx as input */ DDRD |= (1 << 5) | (1 << 3); DDRD &= ~(1 << 2); - + /* Set up the synchronous USART for TINY communications - 8 data bits, even parity, 2 stop bits */ UBRR1 = (F_CPU / XPROG_HARDWARE_SPEED); UCSR1B = (1 << TXEN1); @@ -133,14 +133,11 @@ void XPROGTarget_SendByte(const uint8_t Byte) /* Switch to Tx mode if currently in Rx mode */ if (!(IsSending)) XPROGTarget_SetTxMode(); - + /* Wait until there is space in the hardware Tx buffer before writing */ while (!(UCSR1A & (1 << UDRE1))); UCSR1A |= (1 << TXC1); UDR1 = Byte; - - if (TimeoutMSRemaining) - TimeoutMSRemaining = COMMAND_TIMEOUT_MS; } /** Receives a byte via the software USART, blocking until data is received. @@ -154,10 +151,7 @@ uint8_t XPROGTarget_ReceiveByte(void) XPROGTarget_SetRxMode(); /* Wait until a byte has been received before reading */ - while (!(UCSR1A & (1 << RXC1)) && TimeoutMSRemaining); - - if (TimeoutMSRemaining) - TimeoutMSRemaining = COMMAND_TIMEOUT_MS; + while (!(UCSR1A & (1 << RXC1)) && TimeoutTicksRemaining); return UDR1; } @@ -176,9 +170,6 @@ void XPROGTarget_SendBreak(void) while (PIND & (1 << 5)); while (!(PIND & (1 << 5))); } - - if (TimeoutMSRemaining) - TimeoutMSRemaining = COMMAND_TIMEOUT_MS; } static void XPROGTarget_SetTxMode(void) @@ -193,9 +184,6 @@ static void XPROGTarget_SetTxMode(void) UCSR1B &= ~(1 << RXEN1); UCSR1B |= (1 << TXEN1); - if (TimeoutMSRemaining) - TimeoutMSRemaining = COMMAND_TIMEOUT_MS; - IsSending = true; } @@ -210,10 +198,8 @@ static void XPROGTarget_SetRxMode(void) DDRD &= ~(1 << 3); PORTD &= ~(1 << 3); - if (TimeoutMSRemaining) - TimeoutMSRemaining = COMMAND_TIMEOUT_MS; - IsSending = false; } #endif +