]> www.fi.muni.cz Git - bike-lights.git/commitdiff
step-up convertor at PWM 3 working
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Thu, 13 Sep 2012 21:08:13 +0000 (23:08 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Thu, 13 Sep 2012 21:09:24 +0000 (23:09 +0200)
firmware/adc.c
firmware/pwm.c
firmware/pwmled.c

index bef7375e8b54f40167e4c591a10021a0b653360e..dc35d6b8e8b56681c608cd128178f26323e3b5f8 100644 (file)
@@ -9,8 +9,8 @@ static unsigned char adc_mux[] = { // pwmleds should be first
        _BV(REFS1) | _BV(MUX1) | _BV(MUX0),
        // 1: pwmled 1: 1.1V, ADC0,1 (PA0,1), gain 1 or 8
        _BV(REFS1) | _BV(MUX3) | _BV(MUX2),
-       // 2: pwmled 2: 1.1V, ADC2,1 (PA2,1), gain 1 or 8
-       _BV(REFS1) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1) | _BV(MUX0),
+       // 2: pwmled 2: 1.1V, ADC2,1 (PA2,1), gain 20 or 32
+       _BV(REFS1) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1),
        // 3: ambient light: 1.1V, ADC4 (PA5), single-ended
        _BV(REFS1) | _BV(MUX2),
        // 4: batt voltage: 1.1V, ADC5 (PA6), single-ended
index 2df2e6bb8b9abe762c1bb6208a13e6a4dde4cd7c..02992e9a012dcdd6a4451aaf0dbe3e58c1186571 100644 (file)
@@ -4,7 +4,7 @@
 
 #include "lights.h"
 
-#define PWM_MAX 0x1FF
+#define PWM_MAX 0x0FF
 
 void init_pwm()
 {
index 2640dba05bfc05edcd0c1d0f5e02f5c907919922..8dcb7603ab4006434ef833ec7767e81dbd2a22c5 100644 (file)
@@ -9,7 +9,7 @@ static unsigned char adc_vals[N_PWMLEDS*N_PWMLED_MODES] = {
        /* pwmled1 */
        0x04, 0x14, 0x24, 0x38,
        /* pwmled2 */
-       0x04, 0x14, 0x24, 0x38,
+       0x0c, 0x24, 0x48, 0x90,
 };
 
 // TODO: maybe convert this to bitmask to simplify pwmled_needs_adc() ?
@@ -148,7 +148,7 @@ static void inline probing_adc(unsigned char n, uint16_t adcval)
                return;
        }
 
-       if (pwm >= 0x70) { // over the maximum!
+       if (pwm >= 0xE0) { // over the maximum!
                pwm_off(n);
                pwmled_state[n] = ST_DISABLED;
                log_byte(0xF2);
@@ -193,8 +193,8 @@ static void inline on_adc(unsigned char n, uint16_t adcval)
        }
 
        // FIXME: better disconnect detection
-       if (new_pwm > 0x60) { // disconnected?
-               new_pwm = 0x60;
+       if (new_pwm > 0xE0) { // disconnected?
+               new_pwm = 0xE0;
        }
        if (new_pwm < 2) { // short-circuit?
                new_pwm = 2;