#include #include #include "controller.h" #include "bridge.h" static void adc_init(void) { /* Configure the ADC */ ADMUX = (1 << REFS1) | (1 << REFS0); /* select channel x (0 for now) */ ADMUX |= 0x0; ADCSRA = (1 << ADEN) | (1 << ADIE) | (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); } /* Initializes TIMER1 */ static void timer_init(void) { TCCR1B = (1 << WGM12) | (1 << CS12) | (1 << CS10); OCR1A = 7200; TIMSK|=(1< 974) return 1; controller_target_temp = target; controller_num_iterations = 1; controller_active = 1; return 0; } long controller_get(void) { return controller_measured_temp; } void controller_off(void) { controller_active = 0; bridge_off(); } ISR(TIMER1_COMPA_vect) { /* Start adc measurement */ ADCSRA |= (1< controller_target_temp + 20) { /* Heating required */ bridge_on_heat(); return; } /* Temperature is roughly okay, turn bridge off until next * measurement. */ bridge_off(); }