]> www.fi.muni.cz Git - tinyboard.git/commitdiff
pwmled probing modified for tinyboard
authorJan "Yenya" Kasprzak <kas@fi.muni.cz>
Thu, 25 Apr 2013 20:35:36 +0000 (22:35 +0200)
committerJan "Yenya" Kasprzak <kas@fi.muni.cz>
Thu, 25 Apr 2013 20:35:36 +0000 (22:35 +0200)
projects/step-up/Makefile
projects/step-up/adc.c
projects/step-up/main.c
projects/step-up/pwmled.c

index 67353fafd77cd41f68c41484bf1e4389a8d2583c..a0c773973dc2106e0765e911b3870dfc1229792a 100644 (file)
@@ -1,6 +1,6 @@
 
 PROGRAM=lights
-SRC=main.c logging.c pwm.c adc.c
+SRC=main.c logging.c pwm.c adc.c pwmled.c
 OBJ=$(SRC:.c=.o)
 
 
index 9daf99158ad26aa9391d24f3731409624c2cc9f4..f06cbc5ddba46d0110adfe539fa76d9bfeaa7045 100644 (file)
@@ -202,8 +202,7 @@ ISR(ADC_vect) { // IRQ handler
        switch (current_adc) {
        case 0:
                // pwmled_adc(current_adc, adc_sum);
-               log_word(0x9000+adc_sum);
-               return;
+               pwmled_adc(1, adc_sum);
                break;
        }
 
index be940a689a81f0405adac0c1dcba822fd896d5f6..55e2ef75737cd58e437d7750954ccc7078b393d1 100644 (file)
@@ -18,7 +18,7 @@ static void hw_setup()
        //init_tmr();
        //init_buttons();
 
-       //init_pwmled();
+       init_pwmled();
        //init_gpio();
        //init_ambient();
        //init_pattern();
index 9aa6d8074689dd9b5e08de41e2d0a23e805e4a60..5f34c8f8a5f6b04c8223f2397452f735cef63b63 100644 (file)
@@ -15,9 +15,7 @@ typedef struct {
 
 pwmled_t pwmleds[N_PWMLEDS];
 
-#define PWMLED2_TESTING_WITH_350MA_LED
-
-#define SENSE_MOHM     33      /* 0.033 Ohm */
+#define SENSE_MOHM     1000    /* 1 Ohm */
 /*
  * Voltage in uV at ADC reading == 1 is 1100/gain/1024
  * ADC module returns sum of 1 << PWMLED_ADC_SHIFT measurements
@@ -31,51 +29,21 @@ pwmled_t pwmleds[N_PWMLEDS];
        / (1100000/(gain))))
 
 static uint16_t adc_max[N_PWMLEDS] = {
-#ifdef TESTING_FW
-       MA_GAIN_TO_ADC( 400, 20),
-       MA_GAIN_TO_ADC(  30, 20),
-       MA_GAIN_TO_ADC( 800,  1)
-#else
-       MA_GAIN_TO_ADC( 900, 20),
-       MA_GAIN_TO_ADC(  30, 20),
-       MA_GAIN_TO_ADC(2500,  1)
-#endif
+       MA_GAIN_TO_ADC(  30,  1),
+       MA_GAIN_TO_ADC(  30,  1),
 };
 
 static uint16_t adc_vals[N_PWMLEDS*N_PWMLED_MODES] = {
-#ifdef TESTING_FW
-       /* pwmled0 */
-       MA_GAIN_TO_ADC(  50, 20),
-       MA_GAIN_TO_ADC( 100, 20),
-       MA_GAIN_TO_ADC( 200, 20),
-       MA_GAIN_TO_ADC( 350, 20),
-       /* pwmled1 */
-       MA_GAIN_TO_ADC(   5, 20),
-       MA_GAIN_TO_ADC(  10, 20),
-       MA_GAIN_TO_ADC(  15, 20),
-       MA_GAIN_TO_ADC(  20, 20),
-       /* pwmled2 */
-       MA_GAIN_TO_ADC(  50,  1),
-       MA_GAIN_TO_ADC(  80,  1),
-       MA_GAIN_TO_ADC( 150,  1),
-       MA_GAIN_TO_ADC( 200,  1)
-#else
        /* pwmled0 */
-       MA_GAIN_TO_ADC(  50, 20),
-       MA_GAIN_TO_ADC( 100, 20),
-       MA_GAIN_TO_ADC( 200, 20),
-       MA_GAIN_TO_ADC( 350, 20),
+       MA_GAIN_TO_ADC(   5,  1),
+       MA_GAIN_TO_ADC(  10,  1),
+       MA_GAIN_TO_ADC(  15,  1),
+       MA_GAIN_TO_ADC(  20,  1),
        /* pwmled1 */
-       MA_GAIN_TO_ADC(   5, 20),
-       MA_GAIN_TO_ADC(  10, 20),
-       MA_GAIN_TO_ADC(  18, 20),
-       MA_GAIN_TO_ADC(  23, 20),
-       /* pwmled2 */
-       MA_GAIN_TO_ADC( 150,  1),
-       MA_GAIN_TO_ADC( 300,  1),
-       MA_GAIN_TO_ADC( 800,  1),
-       MA_GAIN_TO_ADC(1500,  1)
-#endif
+       MA_GAIN_TO_ADC(   5,  1),
+       MA_GAIN_TO_ADC(  10,  1),
+       MA_GAIN_TO_ADC(  15,  1),
+       MA_GAIN_TO_ADC(  20,  1),
 };
 
 #define ST_DISABLED 0
@@ -171,14 +139,15 @@ static inline unsigned char pwmled_probed_ok(unsigned char n, uint16_t old_pwm)
 
                log_byte(0xF0);
                log_byte(n);
-               log_word(jiffies);
+               // log_word(jiffies);
 
                for (i = 0; i < N_PWMLED_MODES; i++)
                        log_word(led->mode_pwm[i]);
 
                log_flush();
 
-               pattern_reload();
+               // pattern_reload();
+               // pwmled_set_mode(n, 2);
 
                return 1;
        }
@@ -191,7 +160,7 @@ static inline void pwmled_err(unsigned char n)
 
        log_byte(0xF1);
        log_byte(n);
-       log_word(jiffies);
+       // log_word(jiffies);
        log_flush();
 }
 
@@ -227,7 +196,7 @@ void pwmled_adc(unsigned char n, uint16_t adcval)
        led->err_sum = sum;
 
        if (led->pwm >= PWM_MAX
-               || (n == 1 && led->pwm > PWM_MAX/2 && adcval < 0x08)) {
+               || (led->pwm > (2*PWM_MAX/3) && adcval < 0x08)) {
                pwmled_err(n);
                return;
        }