aboutsummaryrefslogtreecommitdiff
path: root/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
diff options
context:
space:
mode:
authorDean Camera <[email protected]>2011-10-12 05:31:35 +0000
committerDean Camera <[email protected]>2011-10-12 05:31:35 +0000
commitc6d6bdae0a6fa5604174428787ff3c415ca73fad (patch)
treedbe01c236feef19ec75fec2f7c2d04451eaf02b5 /Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
parentc15eaa5dae5b8913d9401f0ad508494a6b66744a (diff)
downloadqmk_firmware-c6d6bdae0a6fa5604174428787ff3c415ca73fad.tar.gz
qmk_firmware-c6d6bdae0a6fa5604174428787ff3c415ca73fad.zip
Added reliability patches to the AVRISP-MKII Clone project's PDI/TPI protocols (thanks to Justin Mattair).
Diffstat (limited to 'Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c')
-rw-r--r--Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c19
1 files changed, 9 insertions, 10 deletions
diff --git a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
index 065cd09658..58df785596 100644
--- a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
+++ b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
@@ -92,7 +92,8 @@ void XPROGTarget_EnableTargetTPI(void)
void XPROGTarget_DisableTargetPDI(void)
{
/* Switch to Rx mode to ensure that all pending transmissions are complete */
- XPROGTarget_SetRxMode();
+ if (IsSending)
+ XPROGTarget_SetRxMode();
/* Turn off receiver and transmitter of the USART, clear settings */
UCSR1A = ((1 << TXC1) | (1 << RXC1));
@@ -108,7 +109,8 @@ void XPROGTarget_DisableTargetPDI(void)
void XPROGTarget_DisableTargetTPI(void)
{
/* Switch to Rx mode to ensure that all pending transmissions are complete */
- XPROGTarget_SetRxMode();
+ if (IsSending)
+ XPROGTarget_SetRxMode();
/* Turn off receiver and transmitter of the USART, clear settings */
UCSR1A |= (1 << TXC1) | (1 << RXC1);
@@ -169,19 +171,16 @@ void XPROGTarget_SendIdle(void)
/* Wait for a full cycle of the clock */
while (PIND & (1 << 5));
while (!(PIND & (1 << 5)));
+ while (PIND & (1 << 5));
}
}
static void XPROGTarget_SetTxMode(void)
{
- /* Need to do nothing for a full frame to send a BREAK - only one cycle should be needed, however
- * there are reports that sometimes the interface will get stuck in some environments. */
- for (uint8_t i = 0; i < BITS_IN_USART_FRAME; i++)
- {
- /* Wait for a full cycle of the clock */
- while (PIND & (1 << 5));
- while (!(PIND & (1 << 5)));
- }
+ /* Wait for a full cycle of the clock */
+ while (PIND & (1 << 5));
+ while (!(PIND & (1 << 5)));
+ while (PIND & (1 << 5));
PORTD |= (1 << 3);
DDRD |= (1 << 3);