From 3079ccda1c6d82058c801bf8192c616230a2ef93 Mon Sep 17 00:00:00 2001 From: "Jan \"Yenya\" Kasprzak" Date: Wed, 1 May 2013 14:47:31 +0200 Subject: [PATCH] Power management - make every module enable power for its own HW. --- projects/step-up/adc.c | 4 ++++ projects/step-up/main.c | 5 ++--- projects/step-up/pwm.c | 3 +++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/projects/step-up/adc.c b/projects/step-up/adc.c index f06cbc5..daf7bfe 100644 --- a/projects/step-up/adc.c +++ b/projects/step-up/adc.c @@ -1,5 +1,6 @@ #include #include +#include #include #include "lights.h" @@ -132,6 +133,9 @@ void init_adc() current_slow_adc = NUM_ADCS; current_adc = 0; + power_adc_enable(); + ACSR |= _BV(ACD); // but disable the analog comparator + ADCSRA = _BV(ADEN) // enable | _BV(ADPS1) | _BV(ADPS0) // CLK/8 = 125 kHz // | _BV(ADPS2) // CLK/16 = 62.5 kHz diff --git a/projects/step-up/main.c b/projects/step-up/main.c index 55e2ef7..20f339e 100644 --- a/projects/step-up/main.c +++ b/projects/step-up/main.c @@ -9,6 +9,8 @@ static void hw_setup() { + power_all_disable(); + wdt_enable(WDTO_1S); //init_battery(); @@ -67,9 +69,6 @@ int main(void) { init_log(); - power_usi_disable(); // Once for lifetime - ACSR |= _BV(ACD); // disable analog comparator - log_set_state(3); hw_setup(); diff --git a/projects/step-up/pwm.c b/projects/step-up/pwm.c index f16aaa3..18a1425 100644 --- a/projects/step-up/pwm.c +++ b/projects/step-up/pwm.c @@ -1,5 +1,6 @@ #include #include +#include #include #include @@ -24,6 +25,8 @@ static void inline enable_pll() void init_pwm() { + power_timer1_enable(); + enable_pll(); TCCR1 = _BV(CTC1) | _BV(CS10); // no clock prescaling -- 2.39.3