aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP/Lib/PDITarget.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-12-23 12:54:15 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-12-23 12:54:15 +0000
commitcda88cf97c63c26229578e17184bedcdc0cabc77 (patch)
treedc6b2659faa8056d039c06b19c10ae023df87d4e /Projects/AVRISP/Lib/PDITarget.c
parentdf31b1fd5b0bfbf02a766d32e23a7af075bf4911 (diff)
downloadlufa-cda88cf97c63c26229578e17184bedcdc0cabc77.tar.gz
lufa-cda88cf97c63c26229578e17184bedcdc0cabc77.tar.bz2
lufa-cda88cf97c63c26229578e17184bedcdc0cabc77.zip
Start of implementation of the low level TPI programming protocol in the AVRISP project.
Diffstat (limited to 'Projects/AVRISP/Lib/PDITarget.c')
-rw-r--r--Projects/AVRISP/Lib/PDITarget.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/Projects/AVRISP/Lib/PDITarget.c b/Projects/AVRISP/Lib/PDITarget.c
index 29bb33985..2c6ffd9a6 100644
--- a/Projects/AVRISP/Lib/PDITarget.c
+++ b/Projects/AVRISP/Lib/PDITarget.c
@@ -67,13 +67,13 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK)
return;
/* Wait for the start bit when receiving */
- if ((SoftUSART_BitCount == BITS_IN_FRAME) && (BITBANG_PDIDATA_PIN & BITBANG_PDIDATA_MASK))
+ if ((SoftUSART_BitCount == BITS_IN_PDI_FRAME) && (BITBANG_PDIDATA_PIN & BITBANG_PDIDATA_MASK))
return;
/* Shift in the bit one less than the frame size in position, so that the start bit will eventually
* be discarded leaving the data to be byte-aligned for quick access */
if (BITBANG_PDIDATA_PIN & BITBANG_PDIDATA_MASK)
- SoftUSART_Data |= (1 << (BITS_IN_FRAME - 1));
+ SoftUSART_Data |= (1 << (BITS_IN_PDI_FRAME - 1));
SoftUSART_Data >>= 1;
SoftUSART_BitCount--;
@@ -133,6 +133,7 @@ void PDITarget_EnableTargetPDI(void)
TCCR1B = (1 << WGM12) | (1 << CS10);
TIMSK1 = (1 << OCIE1A);
+ /* Send two BREAKs of 12 bits each to enable TPI interface (need at least 16 idle bits) */
PDITarget_SendBreak();
PDITarget_SendBreak();
#endif
@@ -158,8 +159,6 @@ void PDITarget_DisableTargetPDI(void)
/* Tristate DATA and CLOCK lines */
BITBANG_PDIDATA_PORT &= ~BITBANG_PDIDATA_MASK;
BITBANG_PDICLOCK_PORT &= ~BITBANG_PDICLOCK_MASK;
-
- TCCR0B = 0;
#endif
}
@@ -212,7 +211,7 @@ void PDITarget_SendByte(const uint8_t Byte)
/* Data shifted out LSB first, START DATA PARITY STOP STOP */
SoftUSART_Data = NewUSARTData;
- SoftUSART_BitCount = BITS_IN_FRAME;
+ SoftUSART_BitCount = BITS_IN_PDI_FRAME;
#endif
}
@@ -254,7 +253,7 @@ uint8_t PDITarget_ReceiveByte(void)
}
/* Wait until a byte has been received before reading */
- SoftUSART_BitCount = BITS_IN_FRAME;
+ SoftUSART_BitCount = BITS_IN_PDI_FRAME;
while (SoftUSART_BitCount);
/* Throw away the parity and stop bits to leave only the data (start bit is already discarded) */
@@ -279,7 +278,7 @@ void PDITarget_SendBreak(void)
}
/* Need to do nothing for a full frame to send a BREAK */
- for (uint8_t i = 0; i < BITS_IN_FRAME; i++)
+ for (uint8_t i = 0; i < BITS_IN_PDI_FRAME; i++)
{
/* Wait for a full cycle of the clock */
while (PIND & (1 << 5));
@@ -299,7 +298,7 @@ void PDITarget_SendBreak(void)
/* Need to do nothing for a full frame to send a BREAK */
SoftUSART_Data = 0x0FFF;
- SoftUSART_BitCount = BITS_IN_FRAME;
+ SoftUSART_BitCount = BITS_IN_PDI_FRAME;
#endif
}