int main(void)\r
{\r
SetupHardware();\r
- \r
- printf("AVRISP-MKII\r\n");\r
+\r
+ V2Params_LoadNonVolatileParamValues();\r
\r
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
\r
for (;;)\r
- {
- Process_AVRISP_Commands();
-\r
+ {\r
+ Process_AVRISP_Commands();\r
+ \r
+ V2Params_UpdateParamValues();\r
+ \r
USB_USBTask();\r
}\r
}\r
clock_prescale_set(clock_div_1);\r
\r
/* Hardware Initialization */\r
- SerialStream_Init(9600, false);\r
LEDs_Init();\r
USB_Init();\r
+\r
+ #if defined(ADC)\r
+ /* Initialize the ADC converter for VTARGET level detection on supported AVR models */\r
+ ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_128);\r
+ ADC_SetupChannel(VTARGET_ADC_CHANNEL);\r
+ ADC_StartReading(VTARGET_ADC_CHANNEL | ADC_RIGHT_ADJUSTED | ADC_REFERENCE_AVCC);\r
+ #endif\r
+ \r
+ /* Millisecond timer initialization for timeouts and delays */\r
+ OCR0A = ((F_CPU / 64) / 1000);\r
+ TCCR0A = (1 << WGM01);\r
+ TCCR0B = ((1 << CS01) | (1 << CS00));\r
}\r
\r
/** Event handler for the library USB Connection event. */\r
}\r
}\r
\r
-void EVENT_USB_Device_UnhandledControlRequest(void)\r
+/** Processes incoming V2 Protocol commands from the host, returning a response when required. */\r
+void Process_AVRISP_Commands(void)\r
{\r
- printf("CONTROL REQUEST\r\n");\r
-}\r
-
-void Process_AVRISP_Commands(void)
-{
/* Device must be connected and configured for the task to run */\r
if (USB_DeviceState != DEVICE_STATE_Configured)\r
- return;
-
- Endpoint_SelectEndpoint(AVRISP_DATA_EPNUM);\r
-
- /* Check to see if a V2 Protocol command has been received - if not, abort */
- if (!(Endpoint_IsOUTReceived()))
return;\r
- \r
- printf("COMMAND\r\n");
-
- /* Pass off processing of the V2 Protocol command to the V2 Protocol handler */
- V2Protocol_ProcessCommand();
-\r
- /* Reset Endpoint direction to OUT ready for next command */\r
- Endpoint_SetEndpointDirection(ENDPOINT_DIR_OUT);\r
-}
-
+\r
+ Endpoint_SelectEndpoint(AVRISP_DATA_EPNUM);\r
+ \r
+ /* Check to see if a V2 Protocol command has been received */\r
+ if (Endpoint_IsOUTReceived())\r
+ {\r
+ LEDs_SetAllLEDs(LEDMASK_BUSY);\r
+\r
+ /* Pass off processing of the V2 Protocol command to the V2 Protocol handler */\r
+ V2Protocol_ProcessCommand();\r
+\r
+ LEDs_SetAllLEDs(LEDMASK_USB_READY);\r
+ }\r
+}\r
+\r