Fix terrible performance
[SCSI2SD-V6.git] / src / firmware / config.c
index a19087d..eb6b369 100755 (executable)
@@ -16,7 +16,6 @@
 //     along with SCSI2SD.  If not, see <http://www.gnu.org/licenses/>.\r
 \r
 #include "config.h"\r
-#include "debug.h"\r
 #include "led.h"\r
 \r
 #include "scsi.h"\r
@@ -38,7 +37,7 @@
 \r
 #include <string.h>\r
 \r
-static const uint16_t FIRMWARE_VERSION = 0x0601;\r
+static const uint16_t FIRMWARE_VERSION = 0x0606;\r
 \r
 // 1 flash row\r
 static const uint8_t DEFAULT_CONFIG[128] =\r
@@ -141,7 +140,7 @@ sdInfoCommand()
 static void\r
 scsiTestCommand()\r
 {\r
-       int resultCode = 0; // TODO scsiSelfTest();\r
+       int resultCode = scsiSelfTest();\r
        uint8_t response[] =\r
        {\r
                resultCode == 0 ? S2S_CFG_STATUS_GOOD : S2S_CFG_STATUS_ERR,\r
@@ -176,7 +175,7 @@ debugCommand()
        response[15] = scsiDev.lastSense;\r
        response[16] = scsiDev.phase;\r
        response[17] = scsiStatusBSY();\r
-       response[18] = *SCSI_STS_SELECTED;\r
+       response[18] = scsiStatusSEL();\r
        response[19] = scsiStatusATN();\r
        response[20] = scsiStatusRST();\r
        response[21] = scsiDev.rstCount;\r
@@ -189,6 +188,7 @@ debugCommand()
        response[28] = scsiDev.lastSenseASC;\r
        response[29] = *SCSI_STS_DBX;\r
        response[30] = LastTrace;\r
+       response[31] = scsiStatusACK();\r
        hidPacket_send(response, sizeof(response));\r
 }\r
 \r
@@ -330,116 +330,7 @@ void s2s_configPoll()
 \r
 }\r
 \r
-void debugPoll()\r
-{\r
-#if 0\r
-       if (!usbReady)\r
-       {\r
-               return;\r
-       }\r
-\r
-       if(USBFS_GetEPState(USB_EP_COMMAND) == USBFS_OUT_BUFFER_FULL)\r
-       {\r
-               // The host sent us some data!\r
-               int byteCount = USBFS_GetEPCount(USB_EP_COMMAND);\r
-               USBFS_ReadOutEP(USB_EP_COMMAND, (uint8 *)&hidBuffer, byteCount);\r
-\r
-               if (byteCount >= 1 &&\r
-                       hidBuffer[0] == 0x01)\r
-               {\r
-                       // Reboot command.\r
-                       Bootloadable_1_Load();\r
-               }\r
-\r
-               // Allow the host to send us another command.\r
-               // (assuming we didn't reboot outselves)\r
-               USBFS_EnableOutEP(USB_EP_COMMAND);\r
-       }\r
-\r
-       switch (usbDebugEpState)\r
-       {\r
-       case USB_IDLE:\r
-               memcpy(&hidBuffer, &scsiDev.cdb, 12);\r
-               hidBuffer[12] = scsiDev.msgIn;\r
-               hidBuffer[13] = scsiDev.msgOut;\r
-               hidBuffer[14] = scsiDev.lastStatus;\r
-               hidBuffer[15] = scsiDev.lastSense;\r
-               hidBuffer[16] = scsiDev.phase;\r
-               hidBuffer[17] = SCSI_ReadFilt(SCSI_Filt_BSY);\r
-               hidBuffer[18] = SCSI_ReadFilt(SCSI_Filt_SEL);\r
-               hidBuffer[19] = SCSI_ReadFilt(SCSI_Filt_ATN);\r
-               hidBuffer[20] = SCSI_ReadFilt(SCSI_Filt_RST);\r
-               hidBuffer[21] = scsiDev.rstCount;\r
-               hidBuffer[22] = scsiDev.selCount;\r
-               hidBuffer[23] = scsiDev.msgCount;\r
-               hidBuffer[24] = scsiDev.cmdCount;\r
-               hidBuffer[25] = scsiDev.watchdogTick;\r
-               hidBuffer[26] = blockDev.state;\r
-               hidBuffer[27] = scsiDev.lastSenseASC >> 8;\r
-               hidBuffer[28] = scsiDev.lastSenseASC;\r
-               hidBuffer[29] = scsiReadDBxPins();\r
-               hidBuffer[30] = LastTrace;\r
-\r
-               hidBuffer[58] = sdDev.capacity >> 24;\r
-               hidBuffer[59] = sdDev.capacity >> 16;\r
-               hidBuffer[60] = sdDev.capacity >> 8;\r
-               hidBuffer[61] = sdDev.capacity;\r
-\r
-               hidBuffer[62] = FIRMWARE_VERSION >> 8;\r
-               hidBuffer[63] = FIRMWARE_VERSION;\r
-\r
-               USBFS_LoadInEP(USB_EP_DEBUG, (uint8 *)&hidBuffer, sizeof(hidBuffer));\r
-               usbDebugEpState = USB_DATA_SENT;\r
-               break;\r
-\r
-       case USB_DATA_SENT:\r
-               if (USBFS_bGetEPAckState(USB_EP_DEBUG))\r
-               {\r
-                       // Data accepted.\r
-                       usbDebugEpState = USB_IDLE;\r
-               }\r
-               break;\r
-       }\r
-#endif\r
-}\r
-\r
-#if 0\r
-CY_ISR(debugTimerISR)\r
-{\r
-       Debug_Timer_ReadStatusRegister();\r
-       Debug_Timer_Interrupt_ClearPending();\r
-       uint8 savedIntrStatus = CyEnterCriticalSection();\r
-       debugPoll();\r
-       CyExitCriticalSection(savedIntrStatus);\r
-}\r
-#endif\r
-\r
-void s2s_debugInit()\r
-{\r
-#if 0\r
-       Debug_Timer_Interrupt_StartEx(debugTimerISR);\r
-       Debug_Timer_Start();\r
-#endif\r
-}\r
 \r
-void debugPause()\r
-{\r
-#if 0\r
-       Debug_Timer_Stop();\r
-#endif\r
-}\r
-\r
-void debugResume()\r
-{\r
-#if 0\r
-       Debug_Timer_Start();\r
-#endif\r
-}\r
-\r
-int isDebugEnabled()\r
-{\r
-       return usbReady;\r
-}\r
 \r
 // Public method for storing MODE SELECT results.\r
 void s2s_configSave(int scsiId, uint16_t bytesPerSector)\r