Implement WRITE BUFFER and WRITE WITH VERIFY commands
[SCSI2SD-V6.git] / software / SCSI2SD / src / main.c
index 00f9f83..58e4ca8 100755 (executable)
@@ -14,6 +14,8 @@
 //\r
 //     You should have received a copy of the GNU General Public License\r
 //     along with SCSI2SD.  If not, see <http://www.gnu.org/licenses/>.\r
+#pragma GCC push_options\r
+#pragma GCC optimize("-flto")\r
 \r
 #include "device.h"\r
 #include "scsi.h"\r
@@ -59,13 +61,21 @@ int main()
                scsiDiskPoll();\r
                configPoll();\r
 \r
-               uint32_t now = getTime_ms();\r
-               if (diffTime_ms(lastSDPoll, now) > 200)\r
+               if (unlikely(scsiDev.phase == BUS_FREE))\r
                {\r
-                       lastSDPoll = now;\r
-                       sdPoll();\r
+                       if (unlikely(elapsedTime_ms(lastSDPoll) > 200))\r
+                       {\r
+                               lastSDPoll = getTime_ms();\r
+                               sdPoll();\r
+                       }\r
+                       else\r
+                       {\r
+                               // Wait for our 1ms timer to save some power.\r
+                               __WFI();\r
+                       }\r
                }\r
        }\r
        return 0;\r
 }\r
 \r
+#pragma GCC pop_options\r