Added const where possible to the source functions in the Projects directory.
[pub/USBasp.git] / Projects / AVRISP / Lib / XPROG / XPROGTarget.c
index 708b237..59c85f3 100644 (file)
@@ -174,7 +174,7 @@ void XPROGTarget_EnableTargetTPI(void)
        BITBANG_TPIDATA_PORT |= BITBANG_TPIDATA_MASK;\r
 \r
        /* Fire timer capture ISR every 100 cycles to manage the software USART */\r
-       OCR1A   = 80;\r
+       OCR1A   = 100;\r
        TCCR1B  = (1 << WGM13) | (1 << WGM12) | (1 << CS10);\r
        TIMSK1  = (1 << ICIE1);\r
        \r
@@ -217,7 +217,7 @@ void XPROGTarget_EnableTargetPDI(void)
        asm volatile ("NOP"::);\r
 \r
        /* Fire timer compare ISR every 100 cycles to manage the software USART */\r
-       OCR1A   = 80;\r
+       OCR1A   = 100;\r
        TCCR1B  = (1 << WGM12) | (1 << CS10);\r
        TIMSK1  = (1 << OCIE1A);\r
        \r
@@ -353,7 +353,7 @@ uint8_t XPROGTarget_ReceiveByte(void)
        }\r
 \r
        /* Wait until a byte has been received before reading */\r
-       while (!(UCSR1A & (1 << RXC1)));\r
+       while (!(UCSR1A & (1 << RXC1)) && TimeoutMSRemaining);\r
        return UDR1;\r
 #else\r
        /* Switch to Rx mode if currently in Tx mode */\r
@@ -369,8 +369,8 @@ uint8_t XPROGTarget_ReceiveByte(void)
 \r
        /* Wait until a byte has been received before reading */\r
        SoftUSART_BitCount = BITS_IN_USART_FRAME;\r
-       while (SoftUSART_BitCount);\r
-       \r
+       while (SoftUSART_BitCount && TimeoutMSRemaining);\r
+\r
        /* Throw away the parity and stop bits to leave only the data (start bit is already discarded) */\r
        return (uint8_t)SoftUSART_Data;\r
 #endif\r