X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/df31b1fd5b0bfbf02a766d32e23a7af075bf4911..cda88cf97c63c26229578e17184bedcdc0cabc77:/Projects/AVRISP/Lib/PDITarget.c 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 }