aboutsummaryrefslogtreecommitdiffstats
path: root/Projects/AVRISP-MKII/Lib/V2Protocol.c
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2010-01-19 05:27:58 +0000
committerDean Camera <dean@fourwalledcubicle.com>2010-01-19 05:27:58 +0000
commit60fd0ff418566d85224f9841037ba01b77acc0d8 (patch)
treec97d59c17a21b467c0fe0c989437c2ff9fcae5a2 /Projects/AVRISP-MKII/Lib/V2Protocol.c
parent27461546523862a3a76ee41f615f7ec2eed2195f (diff)
downloadlufa-60fd0ff418566d85224f9841037ba01b77acc0d8.tar.gz
lufa-60fd0ff418566d85224f9841037ba01b77acc0d8.tar.bz2
lufa-60fd0ff418566d85224f9841037ba01b77acc0d8.zip
Changed XPLAINBridge project to be both a USB to USART bridge and a PDI programmer, based on the state of a mode select pin.
Diffstat (limited to 'Projects/AVRISP-MKII/Lib/V2Protocol.c')
-rw-r--r--Projects/AVRISP-MKII/Lib/V2Protocol.c22
1 files changed, 20 insertions, 2 deletions
diff --git a/Projects/AVRISP-MKII/Lib/V2Protocol.c b/Projects/AVRISP-MKII/Lib/V2Protocol.c
index 976f24b9e..d6de77404 100644
--- a/Projects/AVRISP-MKII/Lib/V2Protocol.c
+++ b/Projects/AVRISP-MKII/Lib/V2Protocol.c
@@ -50,6 +50,24 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
TimeoutMSRemaining--;
}
+/** Initializes the hardware and software associated with the V2 protocol command handling. */
+void V2Protocol_Init(void)
+{
+ #if defined(ADC)
+ /* Initialize the ADC converter for VTARGET level detection on supported AVR models */
+ ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128);
+ ADC_SetupChannel(VTARGET_ADC_CHANNEL);
+ ADC_StartReading(VTARGET_ADC_CHANNEL | ADC_RIGHT_ADJUSTED | ADC_REFERENCE_AVCC);
+ #endif
+
+ /* Millisecond timer initialization for managing the command timeout counter */
+ OCR0A = ((F_CPU / 64) / 1000);
+ TCCR0A = (1 << WGM01);
+ TCCR0B = ((1 << CS01) | (1 << CS00));
+
+ V2Params_LoadNonVolatileParamValues();
+}
+
/** 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.
@@ -160,7 +178,7 @@ static void V2Protocol_SignOn(void)
Endpoint_Write_Byte(CMD_SIGN_ON);
Endpoint_Write_Byte(STATUS_CMD_OK);
Endpoint_Write_Byte(sizeof(PROGRAMMER_ID) - 1);
- Endpoint_Write_Stream_LE(PROGRAMMER_ID, (sizeof(PROGRAMMER_ID) - 1));
+ Endpoint_Write_Stream_LE(PROGRAMMER_ID, (sizeof(PROGRAMMER_ID) - 1), NO_STREAM_CALLBACK);
Endpoint_ClearIN();
}
@@ -222,7 +240,7 @@ static void V2Protocol_GetSetParam(const uint8_t V2Command)
*/
static void V2Protocol_LoadAddress(void)
{
- Endpoint_Read_Stream_BE(&CurrentAddress, sizeof(CurrentAddress));
+ Endpoint_Read_Stream_BE(&CurrentAddress, sizeof(CurrentAddress), NO_STREAM_CALLBACK);
Endpoint_ClearOUT();
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);