aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP/Lib/V2Protocol.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-12-26 04:13:55 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-12-26 04:13:55 +0000
commitd1608d4af321529f0ddef9defcd97669ae9018c3 (patch)
tree79a2ba0fe2bfa14670a489e77f4c201f380de4f0 /Projects/AVRISP/Lib/V2Protocol.c
parent35dac470f243d234d72f34cbaeb1d6c8a15bc435 (diff)
downloadlufa-d1608d4af321529f0ddef9defcd97669ae9018c3.tar.gz
lufa-d1608d4af321529f0ddef9defcd97669ae9018c3.tar.bz2
lufa-d1608d4af321529f0ddef9defcd97669ae9018c3.zip
Added const where possible to the source functions in the Projects directory.
Added command timeout to the AVRISP project so that incorrectly connected targets no longer freeze the device. Removed string descriptors from the TeensyHID bootloader to reduce its size.
Diffstat (limited to 'Projects/AVRISP/Lib/V2Protocol.c')
-rw-r--r--Projects/AVRISP/Lib/V2Protocol.c14
1 files changed, 13 insertions, 1 deletions
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);
}