From 2dcbf0b5efca4725ba06150a7236e3756e340813 Mon Sep 17 00:00:00 2001 From: Nidan Date: Mon, 14 Jan 2013 16:15:17 +0100 Subject: [PATCH] sei() might be useful... --- firmware/cup.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/firmware/cup.c b/firmware/cup.c index a302d13..412968f 100644 --- a/firmware/cup.c +++ b/firmware/cup.c @@ -73,7 +73,7 @@ ISR(PCINT0_vect) input_state = new_state; } -uint8_t control_output() +inline uint8_t control_output(void) { if (temperature > target) { @@ -86,7 +86,7 @@ uint8_t control_output() // Measure: 5V --- 10k --- --- PTY81-121 -- GND // | // uC ADC pin (with 1.11V reference) -uint16_t linearize_temp(uint16_t temp_in) +inline uint16_t linearize_temp(uint16_t temp_in) { uint16_t temp_out = TARGET_TEMP_MAX; //burning // made from datasheet by: @@ -126,7 +126,7 @@ uint16_t linearize_temp(uint16_t temp_in) return temp_out; } -void io_init(void) +inline void io_init(void) { PORTA = (1 << TAST_PIN) | (1 << IMPULS1_PIN) | (1 << IMPULS0_PIN);/* enable pullups on inputs */ PORTB = 0; @@ -135,14 +135,14 @@ void io_init(void) input_state = PORTA & ((1 << IMPULS1_PIN) | (1 << IMPULS0_PIN) | (1 << TAST_PIN)); } -void led_init(void) +inline void led_init(void) { TCCR0A = (1 << COM0A1) | (1 << COM0B1) | (1 << COM0B0) | (1 << WGM01) | (1 << WGM00);/* pwm enable: fast, A not inverted, B inverted */ TCCR0B = (1 << CS02) | (1 << CS00);/* prescaler / 1024 */ OCR0A = OCR0B = led_color; } -void led_set(uint16_t value) +inline void led_set(uint16_t value) { if (LED_GREEN_TEMP < value && value < LED_RED_TEMP) { value = (value-LED_GREEN_TEMP) * 255/(LED_RED_TEMP-LED_GREEN_TEMP); @@ -154,22 +154,22 @@ void led_set(uint16_t value) OCR0A = OCR0B = (uint8_t)value; } -void led_off(void) +inline void led_off(void) { OCR0A = 0; OCR0B = 255; } -void adc_init(void) +inline void adc_init(void) { ADMUX = (1 << REFS1) | (TEMP_PIN << MUX0);/* Vref = 1.1, pin selection */ ADCSRA = (1 << ADEN) | (1 << ADATE);/* adc enable, triggered */ ADCSRB = (1 << ADTS2);/* trigger on counter 0 overflow */ DIDR0 = (1 << TEMP_PIN);/* disable digital input on adc pin */ - /* result in (ADCH << 8) | ADCL, accessable as ADC? */ + /* result in (ADCH << 8) | ADCL, accessable as ADC */ } -void heat_init(void) +inline void heat_init(void) { TCCR1B = (1 << WGM12) | (1 << CS10);/* some mode allowing to set timer TOP, no prescaler */ TIMSK1 = (1 << TOIE1);/* interupt on overflow */ @@ -177,7 +177,7 @@ void heat_init(void) /* insert loading of heat setting here */ } -void input_init(void) +inline void input_init(void) { GIMSK = (1 << PCIE0);/* interrupt on change on PORT A */ PCMSK0 = (1 << TAST_PIN) | (1 << IMPULS1_PIN) | (1 << IMPULS0_PIN); @@ -192,6 +192,7 @@ int main(void) adc_init(); heat_init(); input_init(); + sei(); for(;;) {