sei() might be useful...

master
Nidan 13 years ago
parent 17c241b992
commit 2dcbf0b5ef

@ -73,7 +73,7 @@ ISR(PCINT0_vect)
input_state = new_state; input_state = new_state;
} }
uint8_t control_output() inline uint8_t control_output(void)
{ {
if (temperature > target) if (temperature > target)
{ {
@ -86,7 +86,7 @@ uint8_t control_output()
// Measure: 5V --- 10k --- --- PTY81-121 -- GND // Measure: 5V --- 10k --- --- PTY81-121 -- GND
// | // |
// uC ADC pin (with 1.11V reference) // 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 uint16_t temp_out = TARGET_TEMP_MAX; //burning
// made from datasheet by: // made from datasheet by:
@ -126,7 +126,7 @@ uint16_t linearize_temp(uint16_t temp_in)
return temp_out; 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 */ PORTA = (1 << TAST_PIN) | (1 << IMPULS1_PIN) | (1 << IMPULS0_PIN);/* enable pullups on inputs */
PORTB = 0; PORTB = 0;
@ -135,14 +135,14 @@ void io_init(void)
input_state = PORTA & ((1 << IMPULS1_PIN) | (1 << IMPULS0_PIN) | (1 << TAST_PIN)); 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 */ 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 */ TCCR0B = (1 << CS02) | (1 << CS00);/* prescaler / 1024 */
OCR0A = OCR0B = led_color; 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) { if (LED_GREEN_TEMP < value && value < LED_RED_TEMP) {
value = (value-LED_GREEN_TEMP) * 255/(LED_RED_TEMP-LED_GREEN_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; OCR0A = OCR0B = (uint8_t)value;
} }
void led_off(void) inline void led_off(void)
{ {
OCR0A = 0; OCR0A = 0;
OCR0B = 255; OCR0B = 255;
} }
void adc_init(void) inline void adc_init(void)
{ {
ADMUX = (1 << REFS1) | (TEMP_PIN << MUX0);/* Vref = 1.1, pin selection */ ADMUX = (1 << REFS1) | (TEMP_PIN << MUX0);/* Vref = 1.1, pin selection */
ADCSRA = (1 << ADEN) | (1 << ADATE);/* adc enable, triggered */ ADCSRA = (1 << ADEN) | (1 << ADATE);/* adc enable, triggered */
ADCSRB = (1 << ADTS2);/* trigger on counter 0 overflow */ ADCSRB = (1 << ADTS2);/* trigger on counter 0 overflow */
DIDR0 = (1 << TEMP_PIN);/* disable digital input on adc pin */ 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 */ TCCR1B = (1 << WGM12) | (1 << CS10);/* some mode allowing to set timer TOP, no prescaler */
TIMSK1 = (1 << TOIE1);/* interupt on overflow */ TIMSK1 = (1 << TOIE1);/* interupt on overflow */
@ -177,7 +177,7 @@ void heat_init(void)
/* insert loading of heat setting here */ /* insert loading of heat setting here */
} }
void input_init(void) inline void input_init(void)
{ {
GIMSK = (1 << PCIE0);/* interrupt on change on PORT A */ GIMSK = (1 << PCIE0);/* interrupt on change on PORT A */
PCMSK0 = (1 << TAST_PIN) | (1 << IMPULS1_PIN) | (1 << IMPULS0_PIN); PCMSK0 = (1 << TAST_PIN) | (1 << IMPULS1_PIN) | (1 << IMPULS0_PIN);
@ -192,6 +192,7 @@ int main(void)
adc_init(); adc_init();
heat_init(); heat_init();
input_init(); input_init();
sei();
for(;;) for(;;)
{ {

Loading…
Cancel
Save