More speed and quality improvements to the software USART in the AVRISP project.

pull/1469/head
Dean Camera 15 years ago
parent f0b4d79629
commit 021b1b567e

@ -48,23 +48,7 @@ void NVMTarget_SendNVMRegAddress(uint8_t Register)
uint32_t Address = XPROG_Param_NVMBase | Register;
/* Send the calculated 32-bit address to the target, LSB first */
PDITarget_SendByte(Address & 0xFF);
PDITarget_SendByte(Address >> 8);
PDITarget_SendByte(Address >> 16);
PDITarget_SendByte(Address >> 24);
}
/** Sends the given 32-bit absolute address to the target.
*
* \param[in] AbsoluteAddress Absolute address to send to the target
*/
void NVMTarget_SendAddress(uint32_t AbsoluteAddress)
{
/* Send the given 32-bit address to the target, LSB first */
PDITarget_SendByte(AbsoluteAddress & 0xFF);
PDITarget_SendByte(AbsoluteAddress >> 8);
PDITarget_SendByte(AbsoluteAddress >> 16);
PDITarget_SendByte(AbsoluteAddress >> 24);
NVMTarget_SendAddress(Address);
}
/** Waits while the target's NVM controller is busy performing an operation, exiting if the

@ -105,6 +105,20 @@
#define NVM_CMD_ERASEWRITEEEPROMPAGE 0x35
#define NVM_CMD_READEEPROM 0x06
/* Inline Functions: */
/** Sends the given 32-bit absolute address to the target.
*
* \param[in] AbsoluteAddress Absolute address to send to the target
*/
static inline void NVMTarget_SendAddress(uint32_t AbsoluteAddress)
{
/* Send the given 32-bit address to the target, LSB first */
PDITarget_SendByte(AbsoluteAddress & 0xFF);
PDITarget_SendByte(AbsoluteAddress >> 8);
PDITarget_SendByte(AbsoluteAddress >> 16);
PDITarget_SendByte(AbsoluteAddress >> 24);
}
/* Function Prototypes: */
void NVMTarget_SendNVMRegAddress(uint8_t Register);
void NVMTarget_SendAddress(uint32_t AbsoluteAddress);

@ -196,19 +196,18 @@ void PDITarget_SendByte(uint8_t Byte)
IsSending = true;
}
bool EvenParityBit = false;
uint8_t ParityData = Byte;
/* Calculate the new USART frame data here while while we wait for a previous byte (if any) to finish sending */
uint16_t NewUSARTData = ((1 << 11) | (1 << 10) | (0 << 9) | ((uint16_t)Byte << 1) | (0 << 0));
/* Compute Even parity - while a bit is still set, chop off lowest bit and toggle parity bit */
uint8_t ParityData = Byte;
while (ParityData)
{
EvenParityBit ^= true;
NewUSARTData ^= (1 << 9);
ParityData &= (ParityData - 1);
}
/* Calculate the new USART frame data here while while we wait for a previous byte (if any) to finish sending */
uint16_t NewUSARTData = ((1 << 11) | (1 << 10) | ((uint16_t)EvenParityBit << 9) | ((uint16_t)Byte << 1) | (0 << 0));
/* Wait until transmitter is idle before writing new data */
while (SoftUSART_BitCount);
/* Data shifted out LSB first, START DATA PARITY STOP STOP */
@ -258,7 +257,7 @@ uint8_t PDITarget_ReceiveByte(void)
SoftUSART_BitCount = BITS_IN_FRAME;
while (SoftUSART_BitCount);
/* Throw away the start, parity and stop bits to leave only the data */
/* Throw away the parity and stop bits to leave only the data (start bit is already discarded) */
return (uint8_t)SoftUSART_Data;
#endif
}
@ -280,7 +279,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_FRAME; i++)
{
/* Wait for a full cycle of the clock */
while (PIND & (1 << 5));

@ -54,17 +54,7 @@
/* Defines: */
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
// #define PDI_VIA_HARDWARE_USART
#define BITBANG_PDIDATA_PORT PORTD
#define BITBANG_PDIDATA_DDR DDRD
#define BITBANG_PDIDATA_PIN PIND
#define BITBANG_PDIDATA_MASK (1 << 3)
#define BITBANG_PDICLOCK_PORT PORTD
#define BITBANG_PDICLOCK_DDR DDRD
#define BITBANG_PDICLOCK_PIN PIND
#define BITBANG_PDICLOCK_MASK (1 << 5)
#define PDI_VIA_HARDWARE_USART
#else
#define BITBANG_PDIDATA_PORT PORTB
#define BITBANG_PDIDATA_DDR DDRB

@ -66,7 +66,7 @@ MCU = at90usb1287
# Target board (see library "Board Types" documentation, USER or blank for projects not requiring
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
# "Board" inside the application directory.
BOARD = XPLAIN
BOARD = USBKEY
# Processor frequency.

Loading…
Cancel
Save