From: Jan "Yenya" Kasprzak Date: Thu, 25 Apr 2013 20:35:36 +0000 (+0200) Subject: pwmled probing modified for tinyboard X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=commitdiff_plain;h=88b18cc5d2263dd948c13f6b7eb0fd1b58fb3cb5;p=tinyboard.git pwmled probing modified for tinyboard --- diff --git a/projects/step-up/Makefile b/projects/step-up/Makefile index 67353fa..a0c7739 100644 --- a/projects/step-up/Makefile +++ b/projects/step-up/Makefile @@ -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) diff --git a/projects/step-up/adc.c b/projects/step-up/adc.c index 9daf991..f06cbc5 100644 --- a/projects/step-up/adc.c +++ b/projects/step-up/adc.c @@ -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; } diff --git a/projects/step-up/main.c b/projects/step-up/main.c index be940a6..55e2ef7 100644 --- a/projects/step-up/main.c +++ b/projects/step-up/main.c @@ -18,7 +18,7 @@ static void hw_setup() //init_tmr(); //init_buttons(); - //init_pwmled(); + init_pwmled(); //init_gpio(); //init_ambient(); //init_pattern(); diff --git a/projects/step-up/pwmled.c b/projects/step-up/pwmled.c index 9aa6d80..5f34c8f 100644 --- a/projects/step-up/pwmled.c +++ b/projects/step-up/pwmled.c @@ -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; }