diff options
Diffstat (limited to 'Projects/AVRISP/Lib')
-rw-r--r-- | Projects/AVRISP/Lib/ISP/ISPProtocol.h | 11 | ||||
-rw-r--r-- | Projects/AVRISP/Lib/ISP/ISPTarget.c | 30 | ||||
-rw-r--r-- | Projects/AVRISP/Lib/ISP/ISPTarget.h | 5 | ||||
-rw-r--r-- | Projects/AVRISP/Lib/V2Protocol.c | 14 | ||||
-rw-r--r-- | Projects/AVRISP/Lib/V2Protocol.h | 11 | ||||
-rw-r--r-- | Projects/AVRISP/Lib/V2ProtocolParams.c | 40 | ||||
-rw-r--r-- | Projects/AVRISP/Lib/V2ProtocolParams.h | 2 | ||||
-rw-r--r-- | Projects/AVRISP/Lib/XPROG/TINYNVM.c | 14 | ||||
-rw-r--r-- | Projects/AVRISP/Lib/XPROG/TINYNVM.h | 8 | ||||
-rw-r--r-- | Projects/AVRISP/Lib/XPROG/XMEGANVM.c | 54 | ||||
-rw-r--r-- | Projects/AVRISP/Lib/XPROG/XMEGANVM.h | 6 | ||||
-rw-r--r-- | Projects/AVRISP/Lib/XPROG/XPROGProtocol.c | 3 | ||||
-rw-r--r-- | Projects/AVRISP/Lib/XPROG/XPROGTarget.c | 10 | ||||
-rw-r--r-- | Projects/AVRISP/Lib/XPROG/XPROGTarget.h | 2 |
14 files changed, 90 insertions, 120 deletions
diff --git a/Projects/AVRISP/Lib/ISP/ISPProtocol.h b/Projects/AVRISP/Lib/ISP/ISPProtocol.h index 43c25c4fa..abbbf569d 100644 --- a/Projects/AVRISP/Lib/ISP/ISPProtocol.h +++ b/Projects/AVRISP/Lib/ISP/ISPProtocol.h @@ -72,17 +72,20 @@ */
static inline void ISPProtocol_DelayMS(uint8_t DelayMS)
{
- TCNT0 = 0;
- TIFR0 = (1 << OCF1A);
+ OCR2A = ((F_CPU / 64) / 1000);
+ TCCR2A = (1 << WGM01);
+ TCCR2B = ((1 << CS01) | (1 << CS00));
while (DelayMS)
{
- if (TIFR0 & (1 << OCF1A))
+ if (TIFR2 & (1 << OCF2A))
{
- TIFR0 = (1 << OCF1A);
+ TIFR2 = (1 << OCF2A);
DelayMS--;
}
}
+
+ TCCR2B = 0;
}
/* Function Prototypes: */
diff --git a/Projects/AVRISP/Lib/ISP/ISPTarget.c b/Projects/AVRISP/Lib/ISP/ISPTarget.c index e99e3e53c..29cb18e62 100644 --- a/Projects/AVRISP/Lib/ISP/ISPTarget.c +++ b/Projects/AVRISP/Lib/ISP/ISPTarget.c @@ -122,26 +122,15 @@ uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, const uint1 break;
case PROG_MODE_WORD_VALUE_MASK:
case PROG_MODE_PAGED_VALUE_MASK:
- TCNT0 = 0;
- TIFR0 = (1 << OCF1A);
-
- uint8_t TimeoutMS = TARGET_BUSY_TIMEOUT_MS;
-
do
{
SPI_SendByte(ReadMemCommand);
SPI_SendByte(PollAddress >> 8);
SPI_SendByte(PollAddress & 0xFF);
-
- if (TIFR0 & (1 << OCF1A))
- {
- TIFR0 = (1 << OCF1A);
- TimeoutMS--;
- }
}
- while ((SPI_TransferByte(0x00) != PollValue) && TimeoutMS);
+ while ((SPI_TransferByte(0x00) != PollValue) && TimeoutMSRemaining);
- if (!(TimeoutMS))
+ if (!(TimeoutMSRemaining))
ProgrammingStatus = STATUS_CMD_TOUT;
break;
@@ -161,27 +150,16 @@ uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, const uint1 */
uint8_t ISPTarget_WaitWhileTargetBusy(void)
{
- TCNT0 = 0;
- TIFR0 = (1 << OCF1A);
-
- uint8_t TimeoutMS = TARGET_BUSY_TIMEOUT_MS;
-
do
{
SPI_SendByte(0xF0);
SPI_SendByte(0x00);
SPI_SendByte(0x00);
-
- if (TIFR0 & (1 << OCF1A))
- {
- TIFR0 = (1 << OCF1A);
- TimeoutMS--;
- }
}
- while ((SPI_ReceiveByte() & 0x01) && TimeoutMS);
+ while ((SPI_ReceiveByte() & 0x01) && TimeoutMSRemaining);
- if (!(TimeoutMS))
+ if (!(TimeoutMSRemaining))
return STATUS_RDY_BSY_TOUT;
else
return STATUS_CMD_OK;
diff --git a/Projects/AVRISP/Lib/ISP/ISPTarget.h b/Projects/AVRISP/Lib/ISP/ISPTarget.h index 96f1a6476..c856ddde1 100644 --- a/Projects/AVRISP/Lib/ISP/ISPTarget.h +++ b/Projects/AVRISP/Lib/ISP/ISPTarget.h @@ -57,10 +57,7 @@ /* Macros: */
/** Total number of allowable ISP programming speeds supported by the device */
#define TOTAL_ISP_PROGRAMMING_SPEEDS 7
-
- /** Timeout in milliseconds of target busy-wait loops waiting for a command to complete */
- #define TARGET_BUSY_TIMEOUT_MS 100
-
+
/* Function Prototypes: */
uint8_t ISPTarget_GetSPIPrescalerMask(void);
void ISPTarget_ChangeTargetResetLine(const bool ResetTarget);
diff --git a/Projects/AVRISP/Lib/V2Protocol.c b/Projects/AVRISP/Lib/V2Protocol.c index 4f7904a21..4fcb5aa00 100644 --- a/Projects/AVRISP/Lib/V2Protocol.c +++ b/Projects/AVRISP/Lib/V2Protocol.c @@ -43,6 +43,13 @@ uint32_t CurrentAddress; bool MustSetAddress;
+/** ISR for the management of the command execution timeout counter */
+ISR(TIMER0_COMPA_vect, ISR_BLOCK)
+{
+ if (TimeoutMSRemaining)
+ TimeoutMSRemaining--;
+}
+
/** Master V2 Protocol packet handler, for received V2 Protocol packets from a connected host.
* This routine decodes the issued command and passes off the handling of the command to the
* appropriate function.
@@ -51,6 +58,9 @@ void V2Protocol_ProcessCommand(void) {
uint8_t V2Command = Endpoint_Read_Byte();
+ TimeoutMSRemaining = COMMAND_TIMEOUT_MS;
+ TIMSK0 |= (1 << OCIE0A);
+
switch (V2Command)
{
case CMD_SIGN_ON:
@@ -110,7 +120,9 @@ void V2Protocol_ProcessCommand(void) V2Protocol_UnknownCommand(V2Command);
break;
}
-
+
+ TIMSK0 &= ~(1 << OCIE0A);
+
Endpoint_WaitUntilReady();
Endpoint_SetEndpointDirection(ENDPOINT_DIR_OUT);
}
diff --git a/Projects/AVRISP/Lib/V2Protocol.h b/Projects/AVRISP/Lib/V2Protocol.h index db4d09f0a..76b08b022 100644 --- a/Projects/AVRISP/Lib/V2Protocol.h +++ b/Projects/AVRISP/Lib/V2Protocol.h @@ -49,16 +49,21 @@ /* 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
+ #if !defined(ENABLE_XPROG_PROTOCOL)
+ #define ENABLE_XPROG_PROTOCOL
#endif
#endif
/* Macros: */
/** Programmer ID string, returned to the host during the CMD_SIGN_ON command processing */ #define PROGRAMMER_ID "AVRISP_MK2"
+
+ /** Timeout period for each issued command from the host before it is aborted */
+ #define COMMAND_TIMEOUT_MS 200
+
+ /** Command timeout counter register, GPIOR for speed */
+ #define TimeoutMSRemaining GPIOR1
/* External Variables: */
extern uint32_t CurrentAddress;
diff --git a/Projects/AVRISP/Lib/V2ProtocolParams.c b/Projects/AVRISP/Lib/V2ProtocolParams.c index 6b7f84aa3..eacff0394 100644 --- a/Projects/AVRISP/Lib/V2ProtocolParams.c +++ b/Projects/AVRISP/Lib/V2ProtocolParams.c @@ -43,44 +43,44 @@ uint8_t EEMEM EEPROM_Rest_Polarity = 0x00; static ParameterItem_t ParameterTable[] =
{
{ .ParamID = PARAM_BUILD_NUMBER_LOW,
- .ParamValue = (LUFA_VERSION_INTEGER >> 8),
- .ParamPrivileges = PARAM_PRIV_READ },
+ .ParamPrivileges = PARAM_PRIV_READ,
+ .ParamValue = (LUFA_VERSION_INTEGER >> 8) },
{ .ParamID = PARAM_BUILD_NUMBER_HIGH,
- .ParamValue = (LUFA_VERSION_INTEGER & 0xFF),
- .ParamPrivileges = PARAM_PRIV_READ },
+ .ParamPrivileges = PARAM_PRIV_READ,
+ .ParamValue = (LUFA_VERSION_INTEGER & 0xFF), },
{ .ParamID = PARAM_HW_VER,
- .ParamValue = 0x00,
- .ParamPrivileges = PARAM_PRIV_READ },
+ .ParamPrivileges = PARAM_PRIV_READ,
+ .ParamValue = 0x00 },
{ .ParamID = PARAM_SW_MAJOR,
- .ParamValue = 0x01,
- .ParamPrivileges = PARAM_PRIV_READ },
+ .ParamPrivileges = PARAM_PRIV_READ,
+ .ParamValue = 0x01 },
{ .ParamID = PARAM_SW_MINOR,
- .ParamValue = 0x0D,
- .ParamPrivileges = PARAM_PRIV_READ },
+ .ParamPrivileges = PARAM_PRIV_READ,
+ .ParamValue = 0x0D },
{ .ParamID = PARAM_VTARGET,
- .ParamValue = 0x32,
- .ParamPrivileges = PARAM_PRIV_READ },
+ .ParamPrivileges = PARAM_PRIV_READ,
+ .ParamValue = 0x32 },
{ .ParamID = PARAM_SCK_DURATION,
- .ParamValue = (TOTAL_ISP_PROGRAMMING_SPEEDS - 1),
- .ParamPrivileges = PARAM_PRIV_READ | PARAM_PRIV_WRITE },
+ .ParamPrivileges = PARAM_PRIV_READ | PARAM_PRIV_WRITE,
+ .ParamValue = (TOTAL_ISP_PROGRAMMING_SPEEDS - 1) },
{ .ParamID = PARAM_RESET_POLARITY,
- .ParamValue = 0x00,
- .ParamPrivileges = PARAM_PRIV_WRITE },
+ .ParamPrivileges = PARAM_PRIV_WRITE,
+ .ParamValue = 0x00 },
{ .ParamID = PARAM_STATUS_TGT_CONN,
- .ParamValue = 0x00,
- .ParamPrivileges = PARAM_PRIV_READ },
+ .ParamPrivileges = PARAM_PRIV_READ,
+ .ParamValue = 0x00 },
{ .ParamID = PARAM_DISCHARGEDELAY,
- .ParamValue = 0x00,
- .ParamPrivileges = PARAM_PRIV_WRITE },
+ .ParamPrivileges = PARAM_PRIV_WRITE,
+ .ParamValue = 0x00 },
};
diff --git a/Projects/AVRISP/Lib/V2ProtocolParams.h b/Projects/AVRISP/Lib/V2ProtocolParams.h index 14ff56c71..28d57c80b 100644 --- a/Projects/AVRISP/Lib/V2ProtocolParams.h +++ b/Projects/AVRISP/Lib/V2ProtocolParams.h @@ -62,8 +62,8 @@ typedef struct
{
const uint8_t ParamID; /**< Parameter ID number to uniquely identify the parameter within the device */
+ const uint8_t ParamPrivileges; /**< Parameter privileges to allow the host to read or write the parameter's value */
uint8_t ParamValue; /**< Current parameter's value within the device */
- uint8_t ParamPrivileges; /**< Parameter privileges to allow the host to read or write the parameter's value */
} ParameterItem_t;
/* Function Prototypes: */
diff --git a/Projects/AVRISP/Lib/XPROG/TINYNVM.c b/Projects/AVRISP/Lib/XPROG/TINYNVM.c index f4b90ffa5..3ddd2eda0 100644 --- a/Projects/AVRISP/Lib/XPROG/TINYNVM.c +++ b/Projects/AVRISP/Lib/XPROG/TINYNVM.c @@ -37,6 +37,7 @@ #include "TINYNVM.h"
#if defined(ENABLE_XPROG_PROTOCOL) || defined(__DOXYGEN__)
+#warning TPI Protocol support is currently incomplete and is not suitable for general use.
/** Busy-waits while the NVM controller is busy performing a NVM operation, such as a FLASH page read.
*
@@ -44,24 +45,13 @@ */
bool TINYNVM_WaitWhileNVMBusBusy(void)
{
- TCNT0 = 0;
- TIFR0 = (1 << OCF1A);
-
- uint8_t TimeoutMS = TINY_NVM_BUSY_TIMEOUT_MS;
-
/* Poll the STATUS register to check to see if NVM access has been enabled */
- while (TimeoutMS)
+ while (TimeoutMSRemaining)
{
/* Send the SLDCS command to read the TPI STATUS register to see the NVM bus is active */
XPROGTarget_SendByte(TPI_CMD_SLDCS | TPI_STATUS_REG);
if (XPROGTarget_ReceiveByte() & TPI_STATUS_NVM)
return true;
-
- if (TIFR0 & (1 << OCF1A))
- {
- TIFR0 = (1 << OCF1A);
- TimeoutMS--;
- }
}
return false;
diff --git a/Projects/AVRISP/Lib/XPROG/TINYNVM.h b/Projects/AVRISP/Lib/XPROG/TINYNVM.h index ecf429e77..75d11293d 100644 --- a/Projects/AVRISP/Lib/XPROG/TINYNVM.h +++ b/Projects/AVRISP/Lib/XPROG/TINYNVM.h @@ -56,7 +56,13 @@ #endif
/* Defines: */
- #define TINY_NVM_BUSY_TIMEOUT_MS 100
+ #define TINY_NVM_REG_NVMCSR 0x32
+ #define TINY_NVM_REG_NVMCMD 0x33
+
+ #define TINY_NVM_CMD_NOOP 0x00
+ #define TINY_NVM_CMD_CHIPERASE 0x10
+ #define TINY_NVM_CMD_SECTIONERASE 0x14
+ #define TINY_NVM_CMD_WORDWRITE 0x1D
/* Function Prototypes: */
bool TINYNVM_WaitWhileNVMBusBusy(void);
diff --git a/Projects/AVRISP/Lib/XPROG/XMEGANVM.c b/Projects/AVRISP/Lib/XPROG/XMEGANVM.c index 6280f60fb..c83ae0115 100644 --- a/Projects/AVRISP/Lib/XPROG/XMEGANVM.c +++ b/Projects/AVRISP/Lib/XPROG/XMEGANVM.c @@ -58,10 +58,10 @@ void XMEGANVM_SendNVMRegAddress(const uint8_t Register) void XMEGANVM_SendAddress(const uint32_t AbsoluteAddress)
{
/* Send the given 32-bit address to the target, LSB first */
- XPROGTarget_SendByte(AbsoluteAddress & 0xFF);
- XPROGTarget_SendByte(AbsoluteAddress >> 8);
- XPROGTarget_SendByte(AbsoluteAddress >> 16);
- XPROGTarget_SendByte(AbsoluteAddress >> 24);
+ XPROGTarget_SendByte(((uint8_t*)&AbsoluteAddress)[0]);
+ XPROGTarget_SendByte(((uint8_t*)&AbsoluteAddress)[1]);
+ XPROGTarget_SendByte(((uint8_t*)&AbsoluteAddress)[2]);
+ XPROGTarget_SendByte(((uint8_t*)&AbsoluteAddress)[3]);
}
/** Busy-waits while the NVM controller is busy performing a NVM operation, such as a FLASH page read or CRC
@@ -71,24 +71,13 @@ void XMEGANVM_SendAddress(const uint32_t AbsoluteAddress) */
bool XMEGANVM_WaitWhileNVMBusBusy(void)
{
- TCNT0 = 0;
- TIFR0 = (1 << OCF1A);
-
- uint8_t TimeoutMS = XMEGA_NVM_BUSY_TIMEOUT_MS;
-
/* Poll the STATUS register to check to see if NVM access has been enabled */
- while (TimeoutMS)
+ while (TimeoutMSRemaining)
{
/* Send the LDCS command to read the PDI STATUS register to see the NVM bus is active */
XPROGTarget_SendByte(PDI_CMD_LDCS | PDI_STATUS_REG);
if (XPROGTarget_ReceiveByte() & PDI_STATUS_NVM)
return true;
-
- if (TIFR0 & (1 << OCF1A))
- {
- TIFR0 = (1 << OCF1A);
- TimeoutMS--;
- }
}
return false;
@@ -101,13 +90,8 @@ bool XMEGANVM_WaitWhileNVMBusBusy(void) */
bool XMEGANVM_WaitWhileNVMControllerBusy(void)
{
- TCNT0 = 0;
- TIFR0 = (1 << OCF1A);
-
- uint8_t TimeoutMS = XMEGA_NVM_BUSY_TIMEOUT_MS;
-
/* Poll the NVM STATUS register while the NVM controller is busy */
- while (TimeoutMS)
+ while (TimeoutMSRemaining)
{
/* Send a LDS command to read the NVM STATUS register to check the BUSY flag */
XPROGTarget_SendByte(PDI_CMD_LDS | (PDI_DATSIZE_4BYTES << 2));
@@ -116,12 +100,6 @@ bool XMEGANVM_WaitWhileNVMControllerBusy(void) /* Check to see if the BUSY flag is still set */
if (!(XPROGTarget_ReceiveByte() & (1 << 7)))
return true;
-
- if (TIFR0 & (1 << OCF1A))
- {
- TIFR0 = (1 << OCF1A);
- TimeoutMS--;
- }
}
return false;
@@ -158,22 +136,24 @@ bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest) if (!(XMEGANVM_WaitWhileNVMControllerBusy()))
return false;
- *CRCDest = 0;
+ uint32_t MemoryCRC = 0;
/* Read the first generated CRC byte value */
XPROGTarget_SendByte(PDI_CMD_LDS | (PDI_DATSIZE_4BYTES << 2));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_DAT0);
- *CRCDest = XPROGTarget_ReceiveByte();
+ MemoryCRC = XPROGTarget_ReceiveByte();
/* Read the second generated CRC byte value */
XPROGTarget_SendByte(PDI_CMD_LDS | (PDI_DATSIZE_4BYTES << 2));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_DAT1);
- *CRCDest |= ((uint16_t)XPROGTarget_ReceiveByte() << 8);
+ MemoryCRC |= ((uint16_t)XPROGTarget_ReceiveByte() << 8);
/* Read the third generated CRC byte value */
XPROGTarget_SendByte(PDI_CMD_LDS | (PDI_DATSIZE_4BYTES << 2));
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_DAT2);
- *CRCDest |= ((uint32_t)XPROGTarget_ReceiveByte() << 16);
+ MemoryCRC |= ((uint32_t)XPROGTarget_ReceiveByte() << 16);
+
+ *CRCDest = MemoryCRC;
return true;
}
@@ -186,7 +166,7 @@ bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest) *
* \return Boolean true if the command sequence complete successfully
*/
-bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, const uint16_t ReadSize)
+bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, uint16_t ReadSize)
{
/* Wait until the NVM controller is no longer busy */
if (!(XMEGANVM_WaitWhileNVMControllerBusy()))
@@ -207,7 +187,7 @@ bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, const /* Send a LD command with indirect access and postincrement to read out the bytes */
XPROGTarget_SendByte(PDI_CMD_LD | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_1BYTE);
- for (uint16_t i = 0; i < ReadSize; i++)
+ while (ReadSize--)
*(ReadBuffer++) = XPROGTarget_ReceiveByte();
return true;
@@ -253,8 +233,8 @@ bool XMEGANVM_WriteByteMemory(const uint8_t WriteCommand, const uint32_t WriteAd * \return Boolean true if the command sequence complete successfully
*/
bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand, const uint8_t EraseBuffCommand,
- const uint8_t WritePageCommand, const uint8_t PageMode, const uint32_t WriteAddress,
- const uint8_t* WriteBuffer, const uint16_t WriteSize)
+ const uint8_t WritePageCommand, const uint8_t PageMode, const uint32_t WriteAddress,
+ const uint8_t* WriteBuffer, uint16_t WriteSize)
{
if (PageMode & XPRG_PAGEMODE_ERASE)
{
@@ -294,7 +274,7 @@ bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand, const uint8_t Eras /* Send a ST command with indirect access and postincrement to write the bytes */
XPROGTarget_SendByte(PDI_CMD_ST | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_1BYTE);
- for (uint16_t i = 0; i < WriteSize; i++)
+ while (WriteSize--)
XPROGTarget_SendByte(*(WriteBuffer++));
}
diff --git a/Projects/AVRISP/Lib/XPROG/XMEGANVM.h b/Projects/AVRISP/Lib/XPROG/XMEGANVM.h index 6a4de1fb1..d1a14abda 100644 --- a/Projects/AVRISP/Lib/XPROG/XMEGANVM.h +++ b/Projects/AVRISP/Lib/XPROG/XMEGANVM.h @@ -56,8 +56,6 @@ #endif
/* Defines: */
- #define XMEGA_NVM_BUSY_TIMEOUT_MS 100
-
#define XMEGA_NVM_REG_ADDR0 0x00
#define XMEGA_NVM_REG_ADDR1 0x01
#define XMEGA_NVM_REG_ADDR2 0x02
@@ -111,11 +109,11 @@ bool XMEGANVM_WaitWhileNVMBusBusy(void);
bool XMEGANVM_WaitWhileNVMControllerBusy(void);
bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest);
- bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, const uint16_t ReadSize);
+ bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, uint16_t ReadSize);
bool XMEGANVM_WriteByteMemory(const uint8_t WriteCommand, const uint32_t WriteAddress, const uint8_t* WriteBuffer);
bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand, const uint8_t EraseBuffCommand,
const uint8_t WritePageCommand, const uint8_t PageMode, const uint32_t WriteAddress,
- const uint8_t* WriteBuffer, const uint16_t WriteSize);
+ const uint8_t* WriteBuffer, uint16_t WriteSize);
bool XMEGANVM_EraseMemory(const uint8_t EraseCommand, const uint32_t Address);
#endif
diff --git a/Projects/AVRISP/Lib/XPROG/XPROGProtocol.c b/Projects/AVRISP/Lib/XPROG/XPROGProtocol.c index edcc874d7..bccb96c2c 100644 --- a/Projects/AVRISP/Lib/XPROG/XPROGProtocol.c +++ b/Projects/AVRISP/Lib/XPROG/XPROGProtocol.c @@ -38,7 +38,7 @@ #if defined(ENABLE_XPROG_PROTOCOL) || defined(__DOXYGEN__)
/** Base absolute address for the target's NVM controller */
-uint32_t XPROG_Param_NVMBase = 0x010001C0;
+uint32_t XPROG_Param_NVMBase = 0x010001C0;
/** Size in bytes of the target's EEPROM page */
uint32_t XPROG_Param_EEPageSize;
@@ -46,7 +46,6 @@ uint32_t XPROG_Param_EEPageSize; /** Currently selected XPROG programming protocol */
uint8_t XPROG_SelectedProtocol = XPRG_PROTOCOL_PDI;
-
/** Handler for the CMD_XPROG_SETMODE command, which sets the programmer-to-target protocol used for PDI/TPI
* programming.
*/
diff --git a/Projects/AVRISP/Lib/XPROG/XPROGTarget.c b/Projects/AVRISP/Lib/XPROG/XPROGTarget.c index 708b237ef..59c85f382 100644 --- a/Projects/AVRISP/Lib/XPROG/XPROGTarget.c +++ b/Projects/AVRISP/Lib/XPROG/XPROGTarget.c @@ -174,7 +174,7 @@ void XPROGTarget_EnableTargetTPI(void) BITBANG_TPIDATA_PORT |= BITBANG_TPIDATA_MASK;
/* Fire timer capture ISR every 100 cycles to manage the software USART */
- OCR1A = 80;
+ OCR1A = 100;
TCCR1B = (1 << WGM13) | (1 << WGM12) | (1 << CS10);
TIMSK1 = (1 << ICIE1);
@@ -217,7 +217,7 @@ void XPROGTarget_EnableTargetPDI(void) asm volatile ("NOP"::);
/* Fire timer compare ISR every 100 cycles to manage the software USART */
- OCR1A = 80;
+ OCR1A = 100;
TCCR1B = (1 << WGM12) | (1 << CS10);
TIMSK1 = (1 << OCIE1A);
@@ -353,7 +353,7 @@ uint8_t XPROGTarget_ReceiveByte(void) }
/* Wait until a byte has been received before reading */
- while (!(UCSR1A & (1 << RXC1)));
+ while (!(UCSR1A & (1 << RXC1)) && TimeoutMSRemaining);
return UDR1;
#else
/* Switch to Rx mode if currently in Tx mode */
@@ -369,8 +369,8 @@ uint8_t XPROGTarget_ReceiveByte(void) /* Wait until a byte has been received before reading */
SoftUSART_BitCount = BITS_IN_USART_FRAME;
- while (SoftUSART_BitCount);
-
+ while (SoftUSART_BitCount && TimeoutMSRemaining);
+
/* Throw away the parity and stop bits to leave only the data (start bit is already discarded) */
return (uint8_t)SoftUSART_Data;
#endif
diff --git a/Projects/AVRISP/Lib/XPROG/XPROGTarget.h b/Projects/AVRISP/Lib/XPROG/XPROGTarget.h index 58c1caa37..44602164e 100644 --- a/Projects/AVRISP/Lib/XPROG/XPROGTarget.h +++ b/Projects/AVRISP/Lib/XPROG/XPROGTarget.h @@ -42,6 +42,8 @@ #include <stdbool.h>
#include <LUFA/Common/Common.h>
+
+ #include "../V2Protocol.h"
/* Preprocessor Checks: */
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
|