projects
/
pub
/
USBasp.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
ef44b8c
)
Changed AVRISP-MKII project to use the Watchdog interrupt for command timeouts, to...
author
Dean Camera
<dean@fourwalledcubicle.com>
Sat, 22 Jan 2011 17:48:06 +0000
(17:48 +0000)
committer
Dean Camera
<dean@fourwalledcubicle.com>
Sat, 22 Jan 2011 17:48:06 +0000
(17:48 +0000)
LUFA/ManPages/ChangeLog.txt
patch
|
blob
|
blame
|
history
LUFA/ManPages/LUFAPoweredProjects.txt
patch
|
blob
|
blame
|
history
Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
patch
|
blob
|
blame
|
history
Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
patch
|
blob
|
blame
|
history
Projects/AVRISP-MKII/Lib/V2Protocol.c
patch
|
blob
|
blame
|
history
Projects/AVRISP-MKII/Lib/V2Protocol.h
patch
|
blob
|
blame
|
history
Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
patch
|
blob
|
blame
|
history
Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
patch
|
blob
|
blame
|
history
Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
patch
|
blob
|
blame
|
history
Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
patch
|
blob
|
blame
|
history
diff --git
a/LUFA/ManPages/ChangeLog.txt
b/LUFA/ManPages/ChangeLog.txt
index
c708b3e
..
df74a7c
100644
(file)
--- a/
LUFA/ManPages/ChangeLog.txt
+++ b/
LUFA/ManPages/ChangeLog.txt
@@
-43,6
+43,8
@@
* - Changed over library projects to use the new general ring buffer library driver module
* - Added new high level TWI packet read/write commands, altered behaviour of the TWI_StartTransmission() function
* - Changed TempDataLogger project's DS1307 driver to simplify the function interface and prevent a possible race condition
* - Changed over library projects to use the new general ring buffer library driver module
* - Added new high level TWI packet read/write commands, altered behaviour of the TWI_StartTransmission() function
* - Changed TempDataLogger project's DS1307 driver to simplify the function interface and prevent a possible race condition
+ * - Changed AVRISP-MKII project to use the Watchdog interrupt for command timeouts, to reduce CPU usage and free timer 0
+ * for other uses
*
* <b>Fixed:</b>
* - Core:
*
* <b>Fixed:</b>
* - Core:
diff --git
a/LUFA/ManPages/LUFAPoweredProjects.txt
b/LUFA/ManPages/LUFAPoweredProjects.txt
index
285252c
..
52ec135
100644
(file)
--- a/
LUFA/ManPages/LUFAPoweredProjects.txt
+++ b/
LUFA/ManPages/LUFAPoweredProjects.txt
@@
-88,6
+88,7
@@
* - Retrode, a USB Games Console Cartridge Reader: http://www.retrode.org
* - USBTINY-MKII, an AVRISP-MKII Clone AVR Programmer: http://tom-itx.dyndns.org:81/~webpage/boards/USBTiny_Mkii/USBTiny_Mkii_index.php
* - XMEGA Development Board, using LUFA as an On-Board Programmer: http://xmega.mattair.net/
* - Retrode, a USB Games Console Cartridge Reader: http://www.retrode.org
* - USBTINY-MKII, an AVRISP-MKII Clone AVR Programmer: http://tom-itx.dyndns.org:81/~webpage/boards/USBTiny_Mkii/USBTiny_Mkii_index.php
* - XMEGA Development Board, using LUFA as an On-Board Programmer: http://xmega.mattair.net/
+ * - Zeptoprog, a multifunction AVR programmer: http://www.mattairtech.com/index.php/featured/zeptoprog.html
*
* \section Sec_LUFAPublications Publications Mentioning LUFA
* - Elektor Magazine, "My First AVR-USB" by Antoine Authier (feature), January 2010 Issue
*
* \section Sec_LUFAPublications Publications Mentioning LUFA
* - Elektor Magazine, "My First AVR-USB" by Antoine Authier (feature), January 2010 Issue
diff --git
a/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
b/Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
index
9a732de
..
27e1cc9
100644
(file)
--- a/
Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
+++ b/
Projects/AVRISP-MKII/Lib/ISP/ISPProtocol.c
@@
-68,15
+68,14
@@
void ISPProtocol_EnterISPMode(void)
ISPProtocol_DelayMS(Enter_ISP_Params.ExecutionDelayMS);
ISPTarget_EnableTargetISP();
ISPProtocol_DelayMS(Enter_ISP_Params.ExecutionDelayMS);
ISPTarget_EnableTargetISP();
+ ISPTarget_ChangeTargetResetLine(true);
+
/* Continuously attempt to synchronize with the target until either the number of attempts specified
* by the host has exceeded, or the the device sends back the expected response values */
/* Continuously attempt to synchronize with the target until either the number of attempts specified
* by the host has exceeded, or the the device sends back the expected response values */
- while (Enter_ISP_Params.SynchLoops-- && (ResponseStatus != STATUS_CMD_OK) &&
TimeoutTicksRemaining
)
+ while (Enter_ISP_Params.SynchLoops-- && (ResponseStatus != STATUS_CMD_OK) &&
!(TimeoutExpired)
)
{
uint8_t ResponseBytes[4];
{
uint8_t ResponseBytes[4];
- ISPTarget_ChangeTargetResetLine(true);
- ISPProtocol_DelayMS(Enter_ISP_Params.PinStabDelayMS);
-
for (uint8_t RByte = 0; RByte < sizeof(ResponseBytes); RByte++)
{
ISPProtocol_DelayMS(Enter_ISP_Params.ByteDelay);
for (uint8_t RByte = 0; RByte < sizeof(ResponseBytes); RByte++)
{
ISPProtocol_DelayMS(Enter_ISP_Params.ByteDelay);
@@
-92,6
+91,7
@@
void ISPProtocol_EnterISPMode(void)
{
ISPTarget_ChangeTargetResetLine(false);
ISPProtocol_DelayMS(Enter_ISP_Params.PinStabDelayMS);
{
ISPTarget_ChangeTargetResetLine(false);
ISPProtocol_DelayMS(Enter_ISP_Params.PinStabDelayMS);
+ ISPTarget_ChangeTargetResetLine(true);
}
}
}
}
@@
-509,7
+509,7
@@
void ISPProtocol_SPIMulti(void)
*/
void ISPProtocol_DelayMS(uint8_t DelayMS)
{
*/
void ISPProtocol_DelayMS(uint8_t DelayMS)
{
- while (DelayMS-- &&
TimeoutTicksRemaining
)
+ while (DelayMS-- &&
!(TimeoutExpired)
)
_delay_ms(1);
}
_delay_ms(1);
}
diff --git
a/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
b/Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
index
624d591
..
88b33fc
100644
(file)
--- a/
Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
+++ b/
Projects/AVRISP-MKII/Lib/ISP/ISPTarget.c
@@
-250,7
+250,7
@@
uint8_t ISPTarget_TransferSoftSPIByte(const uint8_t Byte)
TCNT1 = 0;
TCCR1B = ((1 << WGM12) | (1 << CS11));
TCNT1 = 0;
TCCR1B = ((1 << WGM12) | (1 << CS11));
- while (SoftSPI_BitsRemaining &&
TimeoutTicksRemaining
);
+ while (SoftSPI_BitsRemaining &&
!(TimeoutExpired)
);
TCCR1B = 0;
return SoftSPI_Data;
TCCR1B = 0;
return SoftSPI_Data;
@@
-292,9
+292,9
@@
uint8_t ISPTarget_WaitWhileTargetBusy(void)
ISPTarget_SendByte(0x00);
ISPTarget_SendByte(0x00);
}
ISPTarget_SendByte(0x00);
ISPTarget_SendByte(0x00);
}
- while ((ISPTarget_ReceiveByte() & 0x01) &&
TimeoutTicksRemaining
);
+ while ((ISPTarget_ReceiveByte() & 0x01) &&
!(TimeoutExpired)
);
- return
TimeoutTicksRemaining ? STATUS_CMD_OK : STATUS_RDY_BSY_TOUT
;
+ return
(TimeoutExpired) ? STATUS_RDY_BSY_TOUT : STATUS_CMD_OK
;
}
/** Sends a low-level LOAD EXTENDED ADDRESS command to the target, for addressing of memory beyond the
}
/** Sends a low-level LOAD EXTENDED ADDRESS command to the target, for addressing of memory beyond the
@@
-344,9
+344,9
@@
uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode,
ISPTarget_SendByte(PollAddress >> 8);
ISPTarget_SendByte(PollAddress & 0xFF);
}
ISPTarget_SendByte(PollAddress >> 8);
ISPTarget_SendByte(PollAddress & 0xFF);
}
- while ((ISPTarget_TransferByte(0x00) == PollValue) &&
TimeoutTicksRemaining
);
+ while ((ISPTarget_TransferByte(0x00) == PollValue) &&
!(TimeoutExpired)
);
- if (
!(TimeoutTicksRemaining)
)
+ if (
TimeoutExpired
)
ProgrammingStatus = STATUS_CMD_TOUT;
break;
ProgrammingStatus = STATUS_CMD_TOUT;
break;
diff --git
a/Projects/AVRISP-MKII/Lib/V2Protocol.c
b/Projects/AVRISP-MKII/Lib/V2Protocol.c
index
f6ea477
..
b510d43
100644
(file)
--- a/
Projects/AVRISP-MKII/Lib/V2Protocol.c
+++ b/
Projects/AVRISP-MKII/Lib/V2Protocol.c
@@
-44,10
+44,10
@@
bool MustLoadExtendedAddress;
/** ISR to manage timeouts whilst processing a V2Protocol command */
/** ISR to manage timeouts whilst processing a V2Protocol command */
-ISR(
TIMER0_COMPA_vect, ISR_NO
BLOCK)
+ISR(
WDT_vect, ISR_
BLOCK)
{
{
- if (TimeoutTicksRemaining)
-
TimeoutTicksRemaining--
;
+ TimeoutExpired = true;
+
wdt_disable()
;
}
/** Initialises the hardware and software associated with the V2 protocol command handling. */
}
/** Initialises the hardware and software associated with the V2 protocol command handling. */
@@
-60,11
+60,6
@@
void V2Protocol_Init(void)
ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | VTARGET_ADC_CHANNEL_MASK);
#endif
ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | VTARGET_ADC_CHANNEL_MASK);
#endif
- /* Timeout timer initialization (10ms period) */
- OCR0A = (((F_CPU / 1024) / 100) - 1);
- TCCR0A = (1 << WGM01);
- TIMSK0 = (1 << OCIE0A);
-
V2Params_LoadNonVolatileParamValues();
#if defined(ENABLE_ISP_PROTOCOL)
V2Params_LoadNonVolatileParamValues();
#if defined(ENABLE_ISP_PROTOCOL)
@@
-80,9
+75,10
@@
void V2Protocol_ProcessCommand(void)
{
uint8_t V2Command = Endpoint_Read_Byte();
{
uint8_t V2Command = Endpoint_Read_Byte();
- /* Start the timeout management timer */
- TimeoutTicksRemaining = COMMAND_TIMEOUT_TICKS;
- TCCR0B = ((1 << CS02) | (1 << CS00));
+ /* Start the watchdog with timeout interrupt enabled to manage the timeout */
+ TimeoutExpired = false;
+ wdt_enable(WDTO_1S);
+ WDTCSR |= (1 << WDIE);
switch (V2Command)
{
switch (V2Command)
{
@@
-144,8
+140,8
@@
void V2Protocol_ProcessCommand(void)
break;
}
break;
}
- /* Disable the timeout management timer */
-
TCCR0B = 0
;
+ /* Disable the timeout management
watchdog
timer */
+
wdt_disable()
;
Endpoint_WaitUntilReady();
Endpoint_SelectEndpoint(AVRISP_DATA_OUT_EPNUM);
Endpoint_WaitUntilReady();
Endpoint_SelectEndpoint(AVRISP_DATA_OUT_EPNUM);
diff --git
a/Projects/AVRISP-MKII/Lib/V2Protocol.h
b/Projects/AVRISP-MKII/Lib/V2Protocol.h
index
ed42de9
..
8e9e6ff
100644
(file)
--- a/
Projects/AVRISP-MKII/Lib/V2Protocol.h
+++ b/
Projects/AVRISP-MKII/Lib/V2Protocol.h
@@
-39,6
+39,7
@@
/* Includes: */
#include <avr/io.h>
#include <avr/interrupt.h>
/* Includes: */
#include <avr/io.h>
#include <avr/interrupt.h>
+ #include <avr/wdt.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/USB/USB.h>
@@
-68,8
+69,8
@@
/** Timeout period for each issued command from the host before it is aborted (in 10ms ticks). */
#define COMMAND_TIMEOUT_TICKS 100
/** Timeout period for each issued command from the host before it is aborted (in 10ms ticks). */
#define COMMAND_TIMEOUT_TICKS 100
- /** Command timeout
counter register
, GPIOR for speed. */
- #define Timeout
TicksRemaining
GPIOR1
+ /** Command timeout
expiration flag
, GPIOR for speed. */
+ #define Timeout
Expired
GPIOR1
/** MUX mask for the VTARGET ADC channel number. */
#define VTARGET_ADC_CHANNEL_MASK ADC_GET_CHANNEL_MASK(VTARGET_ADC_CHANNEL)
/** MUX mask for the VTARGET ADC channel number. */
#define VTARGET_ADC_CHANNEL_MASK ADC_GET_CHANNEL_MASK(VTARGET_ADC_CHANNEL)
diff --git
a/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
b/Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
index
0322a6e
..
49d5766
100644
(file)
--- a/
Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
+++ b/
Projects/AVRISP-MKII/Lib/XPROG/TINYNVM.c
@@
-85,7
+85,7
@@
bool TINYNVM_WaitWhileNVMBusBusy(void)
uint8_t StatusRegister = XPROGTarget_ReceiveByte();
/* We might have timed out waiting for the status register read response, check here */
uint8_t StatusRegister = XPROGTarget_ReceiveByte();
/* We might have timed out waiting for the status register read response, check here */
- if (
!(TimeoutTicksRemaining)
)
+ if (
TimeoutExpired
)
return false;
/* Check the status register read response to see if the NVM bus is enabled */
return false;
/* Check the status register read response to see if the NVM bus is enabled */
@@
-110,7
+110,7
@@
bool TINYNVM_WaitWhileNVMControllerBusy(void)
uint8_t StatusRegister = XPROGTarget_ReceiveByte();
/* We might have timed out waiting for the status register read response, check here */
uint8_t StatusRegister = XPROGTarget_ReceiveByte();
/* We might have timed out waiting for the status register read response, check here */
- if (
!(TimeoutTicksRemaining)
)
+ if (
TimeoutExpired
)
return false;
/* Check to see if the BUSY flag is still set */
return false;
/* Check to see if the BUSY flag is still set */
@@
-176,14
+176,14
@@
bool TINYNVM_ReadMemory(const uint16_t ReadAddress,
/* Send the address of the location to read from */
TINYNVM_SendPointerAddress(ReadAddress);
/* Send the address of the location to read from */
TINYNVM_SendPointerAddress(ReadAddress);
- while (ReadSize-- &&
TimeoutTicksRemaining
)
+ while (ReadSize-- &&
!(TimeoutExpired)
)
{
/* Read the byte of data from the target */
XPROGTarget_SendByte(TPI_CMD_SLD | TPI_POINTER_INDIRECT_PI);
*(ReadBuffer++) = XPROGTarget_ReceiveByte();
}
{
/* Read the byte of data from the target */
XPROGTarget_SendByte(TPI_CMD_SLD | TPI_POINTER_INDIRECT_PI);
*(ReadBuffer++) = XPROGTarget_ReceiveByte();
}
- return (Timeout
TicksRemaining != 0
);
+ return (Timeout
Expired == false
);
}
/** Writes word addressed memory to the target's memory spaces.
}
/** Writes word addressed memory to the target's memory spaces.
diff --git
a/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
b/Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
index
eb9d063
..
b1fea59
100644
(file)
--- a/
Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
+++ b/
Projects/AVRISP-MKII/Lib/XPROG/XMEGANVM.c
@@
-80,7
+80,7
@@
bool XMEGANVM_WaitWhileNVMBusBusy(void)
uint8_t StatusRegister = XPROGTarget_ReceiveByte();
/* We might have timed out waiting for the status register read response, check here */
uint8_t StatusRegister = XPROGTarget_ReceiveByte();
/* We might have timed out waiting for the status register read response, check here */
- if (
!(TimeoutTicksRemaining)
)
+ if (
TimeoutExpired
)
return false;
/* Check the status register read response to see if the NVM bus is enabled */
return false;
/* Check the status register read response to see if the NVM bus is enabled */
@@
-109,7
+109,7
@@
bool XMEGANVM_WaitWhileNVMControllerBusy(void)
uint8_t StatusRegister = XPROGTarget_ReceiveByte();
/* We might have timed out waiting for the status register read response, check here */
uint8_t StatusRegister = XPROGTarget_ReceiveByte();
/* We might have timed out waiting for the status register read response, check here */
- if (
!(TimeoutTicksRemaining)
)
+ if (
TimeoutExpired
)
return false;
/* Check to see if the BUSY flag is still set */
return false;
/* Check to see if the BUSY flag is still set */
@@
-204,7
+204,7
@@
bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest)
for (uint8_t i = 0; i < XMEGA_CRC_LENGTH; i++)
((uint8_t*)CRCDest)[i] = XPROGTarget_ReceiveByte();
for (uint8_t i = 0; i < XMEGA_CRC_LENGTH; i++)
((uint8_t*)CRCDest)[i] = XPROGTarget_ReceiveByte();
- return (Timeout
TicksRemaining != 0
);
+ return (Timeout
Expired == false
);
}
/** Reads memory from the target's memory spaces.
}
/** Reads memory from the target's memory spaces.
@@
-236,10
+236,10
@@
bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, uint16
/* Send a LD command with indirect access and post-increment to read out the bytes */
XPROGTarget_SendByte(PDI_CMD_LD | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_1BYTE);
/* Send a LD command with indirect access and post-increment to read out the bytes */
XPROGTarget_SendByte(PDI_CMD_LD | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_1BYTE);
- while (ReadSize-- &&
TimeoutTicksRemaining
)
+ while (ReadSize-- &&
!(TimeoutExpired)
)
*(ReadBuffer++) = XPROGTarget_ReceiveByte();
*(ReadBuffer++) = XPROGTarget_ReceiveByte();
- return (Timeout
TicksRemaining != 0
);
+ return (Timeout
Expired == false
);
}
/** Writes byte addressed memory to the target's memory spaces.
}
/** Writes byte addressed memory to the target's memory spaces.
diff --git
a/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
b/Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
index
c89f94f
..
1b105dd
100644
(file)
--- a/
Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
+++ b/
Projects/AVRISP-MKII/Lib/XPROG/XPROGProtocol.c
@@
-143,6
+143,8
@@
static void XPROGProtocol_LeaveXPROGMode(void)
TINYNVM_DisableTPI();
#if defined(XCK_RESCUE_CLOCK_ENABLE) && defined(ENABLE_ISP_PROTOCOL)
TINYNVM_DisableTPI();
#if defined(XCK_RESCUE_CLOCK_ENABLE) && defined(ENABLE_ISP_PROTOCOL)
+ /* If the XCK rescue clock option is enabled, we need to restart it once the
+ * XPROG mode has been exited, since the XPROG protocol stops it after use. */
ISPTarget_ConfigureRescueClock();
#endif
ISPTarget_ConfigureRescueClock();
#endif
diff --git
a/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
b/Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
index
7cf62ff
..
0a2dee7
100644
(file)
--- a/
Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
+++ b/
Projects/AVRISP-MKII/Lib/XPROG/XPROGTarget.c
@@
-151,7
+151,7
@@
uint8_t XPROGTarget_ReceiveByte(void)
XPROGTarget_SetRxMode();
/* Wait until a byte has been received before reading */
XPROGTarget_SetRxMode();
/* Wait until a byte has been received before reading */
- while (!(UCSR1A & (1 << RXC1)) &&
TimeoutTicksRemaining
);
+ while (!(UCSR1A & (1 << RXC1)) &&
!(TimeoutExpired)
);
return UDR1;
}
return UDR1;
}