Partial Commit: Remove now empty Projects\Incomplete directory and add the new AVRISP...
[pub/lufa.git] / Projects / AVRISP / AVRISP.c
index 9c21af2..f14b654 100644 (file)
  *  the project and is responsible for the initial application hardware configuration.\r
  */\r
 \r
+// TODO: Add in software SPI for lower programming speeds below 125KHz\r
+// TODO: Add in VTARGET detection\r
+// TODO: Add reversed target connector checks\r
+\r
 #include "AVRISP.h"\r
 \r
 /** Main program entry point. This routine contains the overall program flow, including initial\r
@@ -42,8 +46,8 @@
 int main(void)\r
 {\r
        SetupHardware();\r
-       \r
-       printf("AVRISP-MKII\r\n");\r
+\r
+       V2Params_LoadEEPROMParamValues();\r
        \r
        LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);\r
 \r
@@ -66,9 +70,13 @@ void SetupHardware(void)
        clock_prescale_set(clock_div_1);\r
 \r
        /* Hardware Initialization */\r
-       SerialStream_Init(9600, false);\r
        LEDs_Init();\r
        USB_Init();\r
+\r
+       /* Millisecond timer initialization for timeout checking */\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
@@ -98,11 +106,7 @@ void EVENT_USB_Device_ConfigurationChanged(void)
        }\r
 }\r
 \r
-void EVENT_USB_Device_UnhandledControlRequest(void)\r
-{\r
-       printf("CONTROL REQUEST\r\n");\r
-}\r
-
+/** Processes incomming V2 Protocol commands from the host, returning a response when required. */
 void Process_AVRISP_Commands(void)
 {
        /* Device must be connected and configured for the task to run */\r
@@ -113,14 +117,9 @@ void Process_AVRISP_Commands(void)
        
        /* Check to see if a V2 Protocol command has been received - if not, abort */
        if (!(Endpoint_IsOUTReceived()))
-         return;\r
-         \r
-       printf("COMMAND\r\n");
+         return;
 
        /* 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
+       V2Protocol_ProcessCommand();\r
 }