+/** Sends a byte via the USART.\r
+ *\r
+ * \param[in] Byte Byte to send through the USART\r
+ */\r
+void PDITarget_SendByte(const uint8_t Byte)\r
+{\r
+#if defined(PDI_VIA_HARDWARE_USART)\r
+ /* Switch to Tx mode if currently in Rx mode */\r
+ if (!(IsSending))\r
+ {\r
+ PORTD |= (1 << 3);\r
+ DDRD |= (1 << 3);\r
+\r
+ UCSR1B |= (1 << TXEN1);\r
+ UCSR1B &= ~(1 << RXEN1);\r
+ \r
+ IsSending = true;\r
+ }\r
+ \r
+ /* Wait until there is space in the hardware Tx buffer before writing */\r
+ while (!(UCSR1A & (1 << UDRE1)));\r
+ UCSR1A |= (1 << TXC1);\r
+ UDR1 = Byte;\r
+#else\r
+ /* Switch to Tx mode if currently in Rx mode */\r
+ if (!(IsSending))\r
+ {\r
+ BITBANG_PDIDATA_PORT |= BITBANG_PDIDATA_MASK;\r
+ BITBANG_PDIDATA_DDR |= BITBANG_PDIDATA_MASK;\r
+\r
+ IsSending = true;\r
+ }\r
+\r
+ /* Calculate the new USART frame data here while while we wait for a previous byte (if any) to finish sending */\r
+ uint16_t NewUSARTData = ((1 << 11) | (1 << 10) | (0 << 9) | ((uint16_t)Byte << 1) | (0 << 0));\r
+\r
+ /* Compute Even parity - while a bit is still set, chop off lowest bit and toggle parity bit */\r
+ uint8_t ParityData = Byte;\r
+ while (ParityData)\r
+ {\r
+ NewUSARTData ^= (1 << 9);\r
+ ParityData &= (ParityData - 1);\r
+ }\r
+\r
+ /* Wait until transmitter is idle before writing new data */\r
+ while (SoftUSART_BitCount);\r
+\r
+ /* Data shifted out LSB first, START DATA PARITY STOP STOP */\r
+ SoftUSART_Data = NewUSARTData;\r
+ SoftUSART_BitCount = BITS_IN_FRAME;\r
+#endif\r
+}\r
+\r
+/** Receives a byte via the software USART, blocking until data is received.\r
+ *\r
+ * \return Received byte from the USART\r
+ */\r