Fixed ISP mode in the AVRISP programmer project.
authorDean Camera <dean@fourwalledcubicle.com>
Sat, 26 Dec 2009 05:20:10 +0000 (05:20 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Sat, 26 Dec 2009 05:20:10 +0000 (05:20 +0000)
LUFA/ManPages/ChangeLog.txt
Projects/AVRISP/Lib/ISP/ISPProtocol.h
Projects/AVRISP/Lib/ISP/ISPTarget.c
Projects/AVRISP/Lib/V2ProtocolParams.c
Projects/AVRISP/makefile

index 48361e3..41e82ea 100644 (file)
@@ -17,6 +17,7 @@
   *  - Slowed down bit-banged PDI programming in the AVRISP project slightly to prevent transmission errors\r
   *\r
   *  <b>Fixed:</b>\r
+  *  - Fixed AVRISP project not able to enter programming mode when ISP protocol is used\r
   *\r
   *  \section Sec_ChangeLog091223 Version 091223\r
   *\r
index abbbf56..127c826 100644 (file)
@@ -38,6 +38,7 @@
 \r
        /* Includes: */\r
                #include <avr/io.h>\r
+               #include <util/delay.h>\r
                \r
                #include <LUFA/Drivers/USB/USB.h>\r
 \r
                #define PROG_MODE_COMMIT_PAGE_MASK      (1 << 7)\r
 \r
        /* Inline Functions: */\r
-               /** Blocking delay for a given number of milliseconds, via a hardware timer.\r
+               /** Blocking delay for a given number of milliseconds.\r
                 *\r
                 *  \param[in] DelayMS  Number of milliseconds to delay for\r
                 */\r
                static inline void ISPProtocol_DelayMS(uint8_t DelayMS)\r
                {\r
-                       OCR2A  = ((F_CPU / 64) / 1000);\r
-                       TCCR2A = (1 << WGM01);\r
-                       TCCR2B = ((1 << CS01) | (1 << CS00));                   \r
-\r
-                       while (DelayMS)\r
-                       {\r
-                               if (TIFR2 & (1 << OCF2A))\r
-                               {\r
-                                       TIFR2 = (1 << OCF2A);\r
-                                       DelayMS--;\r
-                               }\r
-                       }\r
-                       \r
-                       TCCR2B = 0;                     \r
+                       while (DelayMS--)\r
+                         _delay_ms(1);\r
                }\r
 \r
        /* Function Prototypes: */\r
index 29cb18e..a3a8b22 100644 (file)
@@ -122,6 +122,9 @@ uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode, const uint1
                        break;\r
                case PROG_MODE_WORD_VALUE_MASK:\r
                case PROG_MODE_PAGED_VALUE_MASK:\r
+                       TCNT0 = 0;\r
+                       TIFR0 = (1 << OCF1A);\r
+                       \r
                        do\r
                        {\r
                                SPI_SendByte(ReadMemCommand);\r
index eacff03..1056335 100644 (file)
@@ -131,7 +131,7 @@ uint8_t V2Params_GetParameterValue(const uint8_t ParamID)
 {\r
        ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);\r
        \r
-       if ((ParamInfo == NULL) || !(ParamInfo->ParamPrivileges & PARAM_PRIV_READ))\r
+       if (ParamInfo == NULL)\r
          return 0;\r
        \r
        return ParamInfo->ParamValue;\r
@@ -148,7 +148,7 @@ void V2Params_SetParameterValue(const uint8_t ParamID, const uint8_t Value)
 {\r
        ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);\r
 \r
-       if ((ParamInfo == NULL) || !(ParamInfo->ParamPrivileges & PARAM_PRIV_WRITE))\r
+       if (ParamInfo == NULL)\r
          return;\r
 \r
        ParamInfo->ParamValue = Value;\r
@@ -167,11 +167,15 @@ void V2Params_SetParameterValue(const uint8_t ParamID, const uint8_t Value)
  */\r
 static ParameterItem_t* V2Params_GetParamFromTable(const uint8_t ParamID)\r
 {\r
+       ParameterItem_t* CurrTableItem = ParameterTable;\r
+\r
        /* Find the parameter in the parameter table if present */\r
        for (uint8_t TableIndex = 0; TableIndex < (sizeof(ParameterTable) / sizeof(ParameterTable[0])); TableIndex++)\r
        {\r
-               if (ParamID == ParameterTable[TableIndex].ParamID)\r
-                 return &ParameterTable[TableIndex];\r
+               if (ParamID == CurrTableItem->ParamID)\r
+                 return CurrTableItem;\r
+               \r
+               CurrTableItem++;\r
        }\r
 \r
        return NULL;\r
index f5bb5b7..823535f 100644 (file)
@@ -60,7 +60,7 @@
 \r
 \r
 # MCU name\r
-MCU = at90usb1287\r
+MCU = at90usb162\r
 \r
 \r
 # Target board (see library "Board Types" documentation, USER or blank for projects not requiring\r