core: Ensure we can run in >64K flash
[simavr] / examples / board_reprap / 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,
32         IRQ_TERM_COUNT
33 };
34
35 typedef struct thermistor_t {
36         avr_irq_t *     irq;            // irq list
37         struct avr_t *avr;              // keep it around so we can pause it
38         uint8_t         adc_mux_number;
39
40         short *         table;
41         int                     table_entries;
42         int             oversampling;
43
44         float   current;
45         float   target;
46
47 } thermistor_t, *thermistor_p;
48
49 void
50 thermistor_init(
51                 struct avr_t * avr,
52                 thermistor_p t,
53                 int adc_mux_number,
54                 short * table,
55                 int     table_entries,
56                 int oversampling,
57                 float start_temp );
58
59 void
60 thermistor_set_temp(
61                 thermistor_p t,
62                 float temp );
63
64
65 #endif /* __THERMISTOR_H___ */