]> www.fi.muni.cz Git - bike-lights.git/commitdiff
battery.c: priority of operations
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Wed, 27 Feb 2013 22:27:46 +0000 (23:27 +0100)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Wed, 27 Feb 2013 22:27:46 +0000 (23:27 +0100)
... in order to fit to an 8-bit value.

firmware/battery.c

index 284c096b34230b38f53702539d6ed4792f901dcb..01337db1bb8c196fde0d0ff3efa61b1457bce7a8 100644 (file)
@@ -23,8 +23,8 @@ void battery_adc(uint16_t adcval)
         * is coarse (0.1 V).
         */
        battery_100mv = (unsigned char)
-               ((uint16_t)(adcval * 11                              // 1.1V
+               ((uint16_t)(adcval * (11                   // 1.1V
                * (RESISTOR_HI+RESISTOR_LO)/RESISTOR_LO    // resistor ratio
-               / 4) >> 8);                                // divide by 1024
+               / 4)) >> 8);                               // divide by 1024
 }