uint32_t Address = XPROG_Param_NVMBase | Register;\r
\r
/* Send the calculated 32-bit address to the target, LSB first */\r
- PDITarget_SendByte(Address & 0xFF);\r
- PDITarget_SendByte(Address >> 8);\r
- PDITarget_SendByte(Address >> 16);\r
- PDITarget_SendByte(Address >> 24);\r
-}\r
-\r
-/** Sends the given 32-bit absolute address to the target.\r
- *\r
- * \param[in] AbsoluteAddress Absolute address to send to the target\r
- */\r
-void NVMTarget_SendAddress(uint32_t AbsoluteAddress)\r
-{\r
- /* Send the given 32-bit address to the target, LSB first */\r
- PDITarget_SendByte(AbsoluteAddress & 0xFF);\r
- PDITarget_SendByte(AbsoluteAddress >> 8);\r
- PDITarget_SendByte(AbsoluteAddress >> 16);\r
- PDITarget_SendByte(AbsoluteAddress >> 24);\r
+ NVMTarget_SendAddress(Address);\r
}\r
\r
/** Waits while the target's NVM controller is busy performing an operation, exiting if the\r
#define NVM_CMD_ERASEWRITEEEPROMPAGE 0x35\r
#define NVM_CMD_READEEPROM 0x06\r
\r
+ /* Inline Functions: */\r
+ /** Sends the given 32-bit absolute address to the target.\r
+ *\r
+ * \param[in] AbsoluteAddress Absolute address to send to the target\r
+ */\r
+ static inline void NVMTarget_SendAddress(uint32_t AbsoluteAddress)\r
+ {\r
+ /* Send the given 32-bit address to the target, LSB first */\r
+ PDITarget_SendByte(AbsoluteAddress & 0xFF);\r
+ PDITarget_SendByte(AbsoluteAddress >> 8);\r
+ PDITarget_SendByte(AbsoluteAddress >> 16);\r
+ PDITarget_SendByte(AbsoluteAddress >> 24);\r
+ }\r
+\r
/* Function Prototypes: */\r
void NVMTarget_SendNVMRegAddress(uint8_t Register);\r
void NVMTarget_SendAddress(uint32_t AbsoluteAddress);\r
IsSending = true;\r
}\r
\r
- bool EvenParityBit = false;\r
- uint8_t ParityData = Byte;\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
- EvenParityBit ^= true;\r
- ParityData &= (ParityData - 1);\r
+ NewUSARTData ^= (1 << 9);\r
+ ParityData &= (ParityData - 1);\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) | ((uint16_t)EvenParityBit << 9) | ((uint16_t)Byte << 1) | (0 << 0));\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_BitCount = BITS_IN_FRAME;\r
while (SoftUSART_BitCount);\r
\r
- /* Throw away the start, parity and stop bits to leave only the data */\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
}\r
}\r
\r
/* Need to do nothing for a full frame to send a BREAK */\r
- for (uint8_t i = 0; i <= BITS_IN_FRAME; i++)\r
+ for (uint8_t i = 0; i < BITS_IN_FRAME; i++)\r
{\r
/* Wait for a full cycle of the clock */\r
while (PIND & (1 << 5));\r
\r
/* Defines: */\r
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))\r
-// #define PDI_VIA_HARDWARE_USART\r
-\r
- #define BITBANG_PDIDATA_PORT PORTD\r
- #define BITBANG_PDIDATA_DDR DDRD\r
- #define BITBANG_PDIDATA_PIN PIND\r
- #define BITBANG_PDIDATA_MASK (1 << 3)\r
- \r
- #define BITBANG_PDICLOCK_PORT PORTD\r
- #define BITBANG_PDICLOCK_DDR DDRD\r
- #define BITBANG_PDICLOCK_PIN PIND\r
- #define BITBANG_PDICLOCK_MASK (1 << 5)\r
+ #define PDI_VIA_HARDWARE_USART\r
#else\r
#define BITBANG_PDIDATA_PORT PORTB\r
#define BITBANG_PDIDATA_DDR DDRB\r
# Target board (see library "Board Types" documentation, USER or blank for projects not requiring\r
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called \r
# "Board" inside the application directory.\r
-BOARD = XPLAIN\r
+BOARD = USBKEY\r
\r
\r
# Processor frequency.\r