reprap: c3 update
[simavr] / examples / board_reprap / src / thermistor.h
1 /*
2         thermistor.h
3
4         Copyright 2008-2012 Michel Pollet <buserror@gmail.com>
5
6         This file is part of simavr.
7
8         simavr is free software: you can redistribute it and/or modify
9         it under the terms of the GNU General Public License as published by
10         the Free Software Foundation, either version 3 of the License, or
11         (at your option) any later version.
12
13         simavr is distributed in the hope that it will be useful,
14         but WITHOUT ANY WARRANTY; without even the implied warranty of
15         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16         GNU General Public License for more details.
17
18         You should have received a copy of the GNU General Public License
19         along with simavr.  If not, see <http://www.gnu.org/licenses/>.
20  */
21
22
23 #ifndef __THERMISTOR_H___
24 #define __THERMISTOR_H___
25
26 #include "sim_irq.h"
27
28 enum {
29         IRQ_TERM_ADC_TRIGGER_IN = 0,
30         IRQ_TERM_ADC_VALUE_OUT,
31         IRQ_TERM_TEMP_VALUE_OUT,        // Celcius * 256
32         IRQ_TERM_TEMP_VALUE_IN,         // Celcius * 256
33         IRQ_TERM_COUNT
34 };
35
36 typedef struct thermistor_t {
37         avr_irq_t *     irq;            // irq list
38         struct avr_t *avr;              // keep it around so we can pause it
39         uint8_t         adc_mux_number;
40
41         short *         table;
42         int                     table_entries;
43         int             oversampling;
44
45         float   current;
46 } thermistor_t, *thermistor_p;
47
48 void
49 thermistor_init(
50                 struct avr_t * avr,
51                 thermistor_p t,
52                 int adc_mux_number,
53                 short * table,
54                 int     table_entries,
55                 int oversampling,
56                 float start_temp );
57
58 void
59 thermistor_set_temp(
60                 thermistor_p t,
61                 float temp );
62
63
64 #endif /* __THERMISTOR_H___ */