Commit mthomas changes to GCC and port those changes to IAR
[avr_bc100.git] / BaseTinyFirmware / IAR / statefunc.c
index 9dbdde18c4cf8c6bcc5a93b03471ea840d4f048d..e4d5ff64c174469735dfc6378a7a4f84c7ee49cc 100644 (file)
@@ -115,7 +115,7 @@ unsigned char Initialize(unsigned char inp)
        Time_Init();\r
 \r
        // Attempt to get ADC-readings (also gets RID-data) from both batteries.\r
-       for (i = 0; i < 2; i++) {\r
+       for (i = 0; i < BATCONN; i++)   {\r
                EnableBattery(i);\r
                ADC_Wait();\r
                BatteryStatusRefresh();\r
@@ -166,7 +166,7 @@ unsigned char BatteryControl(unsigned char inp)
 \r
        // Get ADC-readings, try to read EPROM, and start prequalification\r
        // of any uncharged battery.\r
-       for (i = 0; i < 2; i++) {\r
+       for (i = 0; i < BATCONN; i++) {\r
                if (BattControl[i].Enabled) {\r
                        EnableBattery(i);\r
                        ADC_Wait();\r
@@ -220,11 +220,13 @@ unsigned char Sleep(unsigned char inp)
 \r
                // If any batteries need charging, go to ST_BATCON.\r
                // Otherwise, keep sleeping.\r
-               for (i = 0; i < 2; i++) {\r
+               for (i = 0; i < BATCONN; i++) {\r
                        EnableBattery(i);\r
                        ADC_Wait();\r
-                       if ((BatteryStatusRefresh()) && (!BattData.Charged)) {\r
-                               return(ST_BATCON);\r
+                       if ( BatteryStatusRefresh() ) {\r
+                               if ( !BattData.Charged ) {\r
+                                  return(ST_BATCON);\r
+                                }\r
                        }\r
                }\r
 \r
@@ -275,6 +277,7 @@ void Doze(void)
                __sleep();                              // Go to sleep, wake up by WDT.\r
        }\r
        else {\r
+               // stay awake if PB6 is pulled low by master\r
                do {\r
                } while ( !(WatchdogFlag) );\r
        }\r