Stub out more of the TPI programming protocol routines in the AVRISP project.

pull/1469/head
Dean Camera 15 years ago
parent be71f934a4
commit bd5e8f07b7

File diff suppressed because one or more lines are too long

@ -63,7 +63,7 @@ void ISPProtocol_EnterISPMode(void)
CurrentAddress = 0;
V2Protocol_DelayMS(Enter_ISP_Params.ExecutionDelayMS);
ISPProtocol_DelayMS(Enter_ISP_Params.ExecutionDelayMS);
SPI_Init(ISPTarget_GetSPIPrescalerMask() | SPI_SCK_LEAD_RISING | SPI_SAMPLE_LEADING | SPI_MODE_MASTER);
while (Enter_ISP_Params.SynchLoops-- && (ResponseStatus == STATUS_CMD_FAILED))
@ -71,11 +71,11 @@ void ISPProtocol_EnterISPMode(void)
uint8_t ResponseBytes[4];
ISPTarget_ChangeTargetResetLine(true);
V2Protocol_DelayMS(Enter_ISP_Params.PinStabDelayMS);
ISPProtocol_DelayMS(Enter_ISP_Params.PinStabDelayMS);
for (uint8_t RByte = 0; RByte < sizeof(ResponseBytes); RByte++)
{
V2Protocol_DelayMS(Enter_ISP_Params.ByteDelay);
ISPProtocol_DelayMS(Enter_ISP_Params.ByteDelay);
ResponseBytes[RByte] = SPI_TransferByte(Enter_ISP_Params.EnterProgBytes[RByte]);
}
@ -87,7 +87,7 @@ void ISPProtocol_EnterISPMode(void)
else
{
ISPTarget_ChangeTargetResetLine(false);
V2Protocol_DelayMS(Enter_ISP_Params.PinStabDelayMS);
ISPProtocol_DelayMS(Enter_ISP_Params.PinStabDelayMS);
}
}
@ -110,10 +110,10 @@ void ISPProtocol_LeaveISPMode(void)
Endpoint_ClearOUT();
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
V2Protocol_DelayMS(Leave_ISP_Params.PreDelayMS);
ISPProtocol_DelayMS(Leave_ISP_Params.PreDelayMS);
ISPTarget_ChangeTargetResetLine(false);
SPI_ShutDown();
V2Protocol_DelayMS(Leave_ISP_Params.PostDelayMS);
ISPProtocol_DelayMS(Leave_ISP_Params.PostDelayMS);
Endpoint_Write_Byte(CMD_LEAVE_PROGMODE_ISP);
Endpoint_Write_Byte(STATUS_CMD_OK);
@ -357,7 +357,7 @@ void ISPProtocol_ChipErase(void)
SPI_SendByte(Erase_Chip_Params.EraseCommandBytes[SByte]);
if (!(Erase_Chip_Params.PollMethod))
V2Protocol_DelayMS(Erase_Chip_Params.EraseDelayMS);
ISPProtocol_DelayMS(Erase_Chip_Params.EraseDelayMS);
else
ResponseStatus = ISPTarget_WaitWhileTargetBusy();

@ -64,6 +64,26 @@
#define PROG_MODE_PAGED_READYBUSY_MASK (1 << 6)
#define PROG_MODE_COMMIT_PAGE_MASK (1 << 7)
/* Inline Functions: */
/** Blocking delay for a given number of milliseconds, via a hardware timer.
*
* \param[in] DelayMS Number of milliseconds to delay for
*/
static inline void ISPProtocol_DelayMS(uint8_t DelayMS)
{
TCNT0 = 0;
TIFR0 = (1 << OCF1A);
while (DelayMS)
{
if (TIFR0 & (1 << OCF1A))
{
TIFR0 = (1 << OCF1A);
DelayMS--;
}
}
}
/* Function Prototypes: */
void ISPProtocol_EnterISPMode(void);
void ISPProtocol_LeaveISPMode(void);

@ -118,7 +118,7 @@ uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, const uint1
{
case PROG_MODE_WORD_TIMEDELAY_MASK:
case PROG_MODE_PAGED_TIMEDELAY_MASK:
V2Protocol_DelayMS(DelayMS);
ISPProtocol_DelayMS(DelayMS);
break;
case PROG_MODE_WORD_VALUE_MASK:
case PROG_MODE_PAGED_VALUE_MASK:

@ -0,0 +1,44 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2009.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
/** \file
*
* TPI Protocol handler, to process V2 Protocol wrapped TPI commands used in Atmel programmer devices.
*/
#define INCLUDE_FROM_TPIPROTOCOL_C
#include "TPIProtocol.h"
#if defined(ENABLE_TPI_PROTOCOL) || defined(__DOXYGEN__)
#warning TPI Programming Protocol is currently incomplete and is not suitable for general use.
// TODO
#endif

@ -0,0 +1,58 @@
/*
LUFA Library
Copyright (C) Dean Camera, 2009.
dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com
*/
/*
Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, and distribute this software
and its documentation for any purpose and without fee is hereby
granted, provided that the above copyright notice appear in all
copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of
this software.
*/
/** \file
*
* Header file for TPIProtocol.c.
*/
#ifndef _TPI_PROTOCOL_
#define _TPI_PROTOCOL_
/* Includes: */
#include <avr/io.h>
#include <util/delay.h>
#include <stdio.h>
#include "V2Protocol.h"
#include "TPITarget.h"
#include "TINYNVM.h"
/* Preprocessor Checks: */
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
#undef ENABLE_ISP_PROTOCOL
#undef ENABLE_TPI_PROTOCOL
#if !defined(ENABLE_PDI_PROTOCOL)
#define ENABLE_PDI_PROTOCOL
#endif
#endif
#endif

@ -312,8 +312,26 @@ void TPITarget_SendBreak(void)
*/
bool TPITarget_WaitWhileNVMBusBusy(void)
{
// TODO
TCNT0 = 0;
TIFR0 = (1 << OCF1A);
uint8_t TimeoutMS = TPI_NVM_TIMEOUT_MS;
/* Poll the STATUS register to check to see if NVM access has been enabled */
while (TimeoutMS)
{
/* Send the LDCS command to read the TPI STATUS register to see the NVM bus is active */
TPITarget_SendByte(TPI_CMD_SLDCS | TPI_STATUS_REG);
if (TPITarget_ReceiveByte() & TPI_STATUS_NVM)
return true;
if (TIFR0 & (1 << OCF1A))
{
TIFR0 = (1 << OCF1A);
TimeoutMS--;
}
}
return false;
}

@ -68,7 +68,25 @@
#define TPI_NVM_TIMEOUT_MS 200
#define TPI_CMD_SLD 0x20
#define TPI_CMD_SST 0x60
#define TPI_CMD_SSTPR 0x68
#define TPI_CMD_SIN 0x10
#define TPI_CMD_SOUT 0x90
#define TPI_CMD_SLDCS 0x80
#define TPI_CMD_SSTCS 0xC0
#define TPI_CMD_SKEY 0xE0
#define TPI_STATUS_REG 0x00
#define TPI_CTRL_REG 0x02
#define TPI_ID_REG 0x0F
#define TPI_STATUS_NVM (1 << 1)
#define TPI_NVMENABLE_KEY (uint8_t[]){0x12, 0x89, 0xAB, 0x45, 0xCD, 0xD8, 0x88, 0xFF}
#define TPI_POINTER_INDIRECT 0
#define TPI_POINTER_INDIRECT_PI (1 << 2)
/* Function Prototypes: */
void TPITarget_EnableTargetTPI(void);

@ -105,6 +105,9 @@ void V2Protocol_ProcessCommand(void)
case CMD_XPROG:
PDIProtocol_XPROG_Command();
break;
#endif
#if defined(ENABLE_TPI_PROTOCOL)
// TODO
#endif
default:
V2Protocol_UnknownCommand(V2Command);

@ -45,6 +45,7 @@
#include "V2ProtocolParams.h"
#include "ISPProtocol.h"
#include "PDIProtocol.h"
#include "TPIProtocol.h"
/* Preprocessor Checks: */
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
@ -61,27 +62,7 @@
#define PROGRAMMER_ID "AVRISP_MK2"
/** Timeout in milliseconds of target busy-wait loops waiting for a command to complete */
#define TARGET_BUSY_TIMEOUT_MS 240
/* Inline Functions: */
/** Blocking delay for a given number of milliseconds, via a hardware timer.
*
* \param[in] DelayMS Number of milliseconds to delay for
*/
static inline void V2Protocol_DelayMS(uint8_t DelayMS)
{
TCNT0 = 0;
TIFR0 = (1 << OCF1A);
while (DelayMS)
{
if (TIFR0 & (1 << OCF1A))
{
TIFR0 = (1 << OCF1A);
DelayMS--;
}
}
}
#define TARGET_BUSY_TIMEOUT_MS 240
/* External Variables: */
extern uint32_t CurrentAddress;

@ -134,6 +134,7 @@ SRC = $(TARGET).c \
Lib/PDIProtocol.c \
Lib/PDITarget.c \
Lib/XMEGANVM.c \
Lib/TPIProtocol.c \
Lib/TPITarget.c \
Lib/TINYNVM.c \
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/DevChapter9.c \

Loading…
Cancel
Save