Ensure TPI enable timing requirements are met in AVRISP-MKII programmer. Remove invalid code in the TPI read/write functions.

pull/1469/head
Dean Camera 15 years ago
parent 2059fd8b1a
commit 1aeb5056d6

@ -33,7 +33,6 @@
* -# Finish MIDI class Bootloader
* -# Finish SideShow demo
* -# Finish StandaloneProgrammer project
* -# Finish Webserver project
* - Ports
* -# AVR32 UC3B series microcontrollers
* -# Atmel ARM7 series microcontrollers

@ -270,14 +270,14 @@ static void XPROGProtocol_WriteMemory(void)
Endpoint_ClearOUT();
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
/* Assume FLASH page programming by default, as it is the common case */
uint8_t WriteCommand = XMEGA_NVM_CMD_WRITEFLASHPAGE;
uint8_t WriteBuffCommand = XMEGA_NVM_CMD_LOADFLASHPAGEBUFF;
uint8_t EraseBuffCommand = XMEGA_NVM_CMD_ERASEFLASHPAGEBUFF;
bool PagedMemory = true;
if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
{
/* Assume FLASH page programming by default, as it is the common case */
uint8_t WriteCommand = XMEGA_NVM_CMD_WRITEFLASHPAGE;
uint8_t WriteBuffCommand = XMEGA_NVM_CMD_LOADFLASHPAGEBUFF;
uint8_t EraseBuffCommand = XMEGA_NVM_CMD_ERASEFLASHPAGEBUFF;
bool PagedMemory = true;
if (WriteMemory_XPROG_Params.MemoryType == XPRG_MEM_TYPE_APPL)
{
WriteCommand = XMEGA_NVM_CMD_WRITEAPPSECPAGE;
@ -321,8 +321,6 @@ static void XPROGProtocol_WriteMemory(void)
}
else
{
Serial_TxByte((uint8_t)WriteMemory_XPROG_Params.Length);
/* Send write command to the TPI device, indicate timeout if occurred */
if (!(TINYNVM_WriteMemory(WriteMemory_XPROG_Params.Address, WriteMemory_XPROG_Params.ProgData,
WriteMemory_XPROG_Params.Length)))
@ -368,8 +366,6 @@ static void XPROGProtocol_ReadMemory(void)
}
else
{
Serial_TxByte((uint8_t)ReadMemory_XPROG_Params.Length);
/* Read the TPI target's memory, indicate timeout if occurred */
if (!(TINYNVM_ReadMemory(ReadMemory_XPROG_Params.Address, ReadBuffer, ReadMemory_XPROG_Params.Length)))
ReturnStatus = XPRG_ERR_TIMEOUT;

@ -71,7 +71,7 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK)
return;
/* Shift in the bit one less than the frame size in position, so that the start bit will eventually
* be discarded leaving the data to be byte-aligned for quick access */
* be discarded leaving the data to be byte-aligned for quick access (subtract 9 as we are ORing to the MSB) */
if (BITBANG_PDIDATA_PIN & BITBANG_PDIDATA_MASK)
((uint8_t*)&SoftUSART_Data)[1] |= (1 << (BITS_IN_USART_FRAME - 9));
@ -117,7 +117,7 @@ ISR(TIMER1_COMPB_vect, ISR_BLOCK)
return;
/* Shift in the bit one less than the frame size in position, so that the start bit will eventually
* be discarded leaving the data to be byte-aligned for quick access */
* be discarded leaving the data to be byte-aligned for quick access (subtract 9 as we are ORing to the MSB) */
if (BITBANG_TPIDATA_PIN & BITBANG_TPIDATA_MASK)
((uint8_t*)&SoftUSART_Data)[1] |= (1 << (BITS_IN_USART_FRAME - 9));
@ -154,8 +154,7 @@ void XPROGTarget_EnableTargetPDI(void)
/* Set DATA line high for at least 90ns to disable /RESET functionality */
PORTD |= (1 << 3);
asm volatile ("NOP"::);
asm volatile ("NOP"::);
_delay_ms(1);
/* Set up the synchronous USART for XMEGA communications -
8 data bits, even parity, 2 stop bits */
@ -169,8 +168,7 @@ void XPROGTarget_EnableTargetPDI(void)
/* Set DATA line high for at least 90ns to disable /RESET functionality */
BITBANG_PDIDATA_PORT |= BITBANG_PDIDATA_MASK;
asm volatile ("NOP"::);
asm volatile ("NOP"::);
_delay_ms(1);
/* Fire timer compare channel A ISR to manage the software USART */
OCR1A = BITS_BETWEEN_USART_CLOCKS;
@ -188,11 +186,10 @@ void XPROGTarget_EnableTargetTPI(void)
{
IsSending = false;
/* Set /RESET line low for at least 90ns to enable TPI functionality */
/* Set /RESET line low for at least 400ns to enable TPI functionality */
AUX_LINE_DDR |= AUX_LINE_MASK;
AUX_LINE_PORT &= ~AUX_LINE_MASK;
asm volatile ("NOP"::);
asm volatile ("NOP"::);
_delay_ms(1);
#if defined(XPROG_VIA_HARDWARE_USART)
/* Set Tx and XCK as outputs, Rx as input */
@ -307,7 +304,7 @@ void XPROGTarget_SendByte(const uint8_t Byte)
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;
uint8_t ParityData = Byte;
while (ParityData)
{
NewUSARTData ^= (1 << 9);

Loading…
Cancel
Save