X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/229935184b3ca7eda9edd6b7d7851f53b2441a65..d83cc9ac8049f651637dc2d9b8632f3c208bbdf6:/Projects/XPLAINBridge/Lib/SoftUART.c diff --git a/Projects/XPLAINBridge/Lib/SoftUART.c b/Projects/XPLAINBridge/Lib/SoftUART.c index 458a505cd..4ec8dcdc8 100644 --- a/Projects/XPLAINBridge/Lib/SoftUART.c +++ b/Projects/XPLAINBridge/Lib/SoftUART.c @@ -76,15 +76,21 @@ void SoftUART_Init(void) /** ISR to detect the start of a bit being sent to the software UART. */ ISR(INT0_vect, ISR_BLOCK) { - /* Reset and start the reception timer */ - TCNT1 = 0; - TCCR1B = ((1 << CS10) | (1 << WGM12)); - /* Reset the number of reception bits remaining counter */ RX_BitsRemaining = 8; + + /* Reset the bit reception timer */ + TCNT1 = 0; + + /* Check to see that the pin is still low (prevents glitches from starting a frame reception) */ + if (!(SRXPIN & (1 << SRX))) + { + /* Disable start bit detection ISR while the next byte is received */ + EIMSK = 0; - /* Disable start bit detection ISR while the next byte is received */ - EIMSK = 0; + /* Start the reception timer */ + TCCR1B = ((1 << CS10) | (1 << WGM12)); + } } /** ISR to manage the reception of bits to the software UART. */ @@ -118,7 +124,7 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK) } /** ISR to manage the transmission of bits via the software UART. */ -ISR(TIMER3_COMPA_vect, ISR_NOBLOCK) +ISR(TIMER3_COMPA_vect, ISR_BLOCK) { /* Check if transmission has finished */ if (TX_BitsRemaining) @@ -133,7 +139,7 @@ ISR(TIMER3_COMPA_vect, ISR_NOBLOCK) TX_Data >>= 1; TX_BitsRemaining--; } - else if (USBtoUART_Buffer.Count) + else if (USBtoUART_Buffer.Count && !(RX_BitsRemaining)) { /* Start bit - TX line low */ STXPORT &= ~(1 << STX);