annotate main.c @ 6:9d538f674ff0

- Some basic ADC code - Turn on -mcall-prologues - Put strings in program space, saves RAM
author Matt Johnston <matt@ucc.asn.au>
date Mon, 14 May 2012 00:22:57 +0800
parents 011160e5b1ce
children 52cb08a01171
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
1 /* Name: main.c
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
2 * Author: <insert your name here>
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
3 * Copyright: <insert your copyright message here>
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
4 * License: <insert your license reference here>
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
5 */
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
6
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
7 #include <stdio.h>
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
8 #include <string.h>
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
9 #include <avr/io.h>
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
10 #include <avr/interrupt.h>
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
11 #include <avr/sleep.h>
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
12 #include <avr/pgmspace.h>
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
13 #include <util/crc16.h>
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
14
3
888be1b234b6 Add FatFS
Matt Johnston <matt@ucc.asn.au>
parents: 2
diff changeset
15 #include "integer.h"
888be1b234b6 Add FatFS
Matt Johnston <matt@ucc.asn.au>
parents: 2
diff changeset
16
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
17 // configuration params
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
18 // - measurement interval
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
19 // - transmit interval
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
20 // - bluetooth params
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
21 // - number of sensors (and range?)
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
22
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
23 // 1 second. we have 1024 prescaler, 32768 crystal.
2
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
24 #define SLEEP_COMPARE 32
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
25 #define MEASURE_WAKE 60
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
26
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
27 #define COMMS_WAKE 3600
2
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
28
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
29 #define BAUD 9600
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
30 #define UBRR ((F_CPU)/16/(BAUD)-1)
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
31
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
32 #define NUM_MEASUREMENTS 300
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
33
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
34 static int uart_putchar(char c, FILE *stream);
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
35 static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL,
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
36 _FDEV_SETUP_WRITE);
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
37
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
38 static uint8_t n_measurements;
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
39 // stored as 1/5 degree above 0
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
40 static uint8_t measurements[NUM_MEASUREMENTS];
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
41 static uint8_t internal_measurements[NUM_MEASUREMENTS];
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
42
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
43 // boolean flags
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
44 static uint8_t need_measurement;
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
45 static uint8_t need_comms;
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
46 static uint8_t comms_done;
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
47
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
48 static uint8_t readpos;
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
49 static char readbuf[30];
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
50
5
011160e5b1ce Fix build
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
51 static uint8_t measure_count;
011160e5b1ce Fix build
Matt Johnston <matt@ucc.asn.au>
parents: 4
diff changeset
52 static uint16_t comms_count;
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
53
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
54 static void deep_sleep();
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
55
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
56 static void
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
57 uart_on(unsigned int ubrr)
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
58 {
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
59 // baud rate
2
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
60 UBRR0H = (unsigned char)(ubrr >> 8);
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
61 UBRR0L = (unsigned char)ubrr;
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
62 UCSR0B = _BV(RXCIE0) | _BV(RXEN0) | _BV(TXEN0);
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
63 //8N1
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
64 UCSR0C = _BV(UMSEL00) | _BV(UCSZ00);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
65
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
66 // Power reduction register
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
67 PRR &= ~_BV(PRUSART0);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
68 }
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
69
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
70 static void
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
71 uart_off()
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
72 {
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
73 // Turn of interrupts and disable tx/rx
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
74 UCSR0B = 0;
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
75
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
76 // Power reduction register
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
77 PRR |= _BV(PRUSART0);
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
78 }
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
79
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
80 static int
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
81 uart_putchar(char c, FILE *stream)
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
82 {
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
83 // XXX should sleep in the loop for power.
2
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
84 loop_until_bit_is_set(UCSR0A, UDRE0);
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
85 UDR0 = c;
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
86 return 0;
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
87 }
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
88
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
89 static void
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
90 cmd_fetch()
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
91 {
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
92 uint16_t crc = 0;
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
93 int i;
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
94 printf_P(PSTR("%d measurements\n"), n_measurements);
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
95 for (i = 0; i < n_measurements; i++)
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
96 {
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
97 printf_P(PSTR("%3d : %d\n"), i, measurements[i]);
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
98 crc = _crc_ccitt_update(crc, measurements[i]);
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
99 }
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
100 printf_P(PSTR("CRC : %d\n"), crc);
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
101 }
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
102
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
103 static void
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
104 cmd_clear()
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
105 {
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
106 }
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
107
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
108 static void
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
109 cmd_btoff()
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
110 {
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
111 comms_done = 1;
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
112 }
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
113
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
114 static void
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
115 read_handler()
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
116 {
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
117 if (strcmp_P(readbuf, PSTR("fetch")) == 0)
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
118 {
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
119 cmd_fetch();
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
120 }
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
121 else if (strcmp_P(readbuf, PSTR("clear")) == 0)
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
122 {
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
123 cmd_clear();
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
124 }
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
125 else if (strcmp_P(readbuf, PSTR("btoff")) == 0)
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
126 {
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
127 cmd_btoff();
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
128 }
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
129 else
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
130 {
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
131 printf_P(PSTR("Bad command\n"));
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
132 }
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
133 }
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
134
2
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
135 ISR(USART_RX_vect)
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
136 {
2
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
137 char c = UDR0;
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
138 if (c == '\n')
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
139 {
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
140 readbuf[readpos] = '\0';
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
141 read_handler();
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
142 readpos = 0;
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
143 }
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
144 else
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
145 {
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
146 readbuf[readpos] = c;
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
147 readpos++;
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
148 if (readpos >= sizeof(readbuf))
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
149 {
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
150 readpos = 0;
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
151 }
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
152 }
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
153 }
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
154
2
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
155 ISR(TIMER2_COMPA_vect)
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
156 {
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
157 measure_count ++;
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
158 comms_count ++;
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
159 if (measure_count == MEASURE_WAKE)
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
160 {
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
161 measure_count = 0;
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
162 need_measurement = 1;
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
163 }
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
164
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
165 if (comms_count == COMMS_WAKE)
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
166 {
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
167 comms_count = 0;
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
168 need_comms = 1;
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
169 }
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
170 }
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
171
3
888be1b234b6 Add FatFS
Matt Johnston <matt@ucc.asn.au>
parents: 2
diff changeset
172 DWORD get_fattime (void)
888be1b234b6 Add FatFS
Matt Johnston <matt@ucc.asn.au>
parents: 2
diff changeset
173 {
888be1b234b6 Add FatFS
Matt Johnston <matt@ucc.asn.au>
parents: 2
diff changeset
174 return 0;
888be1b234b6 Add FatFS
Matt Johnston <matt@ucc.asn.au>
parents: 2
diff changeset
175 }
888be1b234b6 Add FatFS
Matt Johnston <matt@ucc.asn.au>
parents: 2
diff changeset
176
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
177 static void
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
178 deep_sleep()
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
179 {
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
180 // p119 of manual
2
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
181 OCR2A = SLEEP_COMPARE;
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
182 loop_until_bit_is_clear(ASSR, OCR2AUB);
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
183
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
184 set_sleep_mode(SLEEP_MODE_PWR_SAVE);
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
185 sleep_mode();
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
186 }
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
187
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
188 static void
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
189 idle_sleep()
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
190 {
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
191 set_sleep_mode(SLEEP_MODE_IDLE);
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
192 sleep_mode();
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
193 }
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
194
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
195 static void
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
196 do_adc_335()
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
197 {
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
198 PRR &= ~_BV(PRADC);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
199
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
200 ADMUX = _BV(ADLAR);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
201
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
202 // ADPS2 = /16 prescaler, 62khz at 1mhz clock
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
203 ADCSRA = _BV(ADEN) | _BV(ADPS2);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
204
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
205 // measure value
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
206 ADCSRA |= _BV(ADSC);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
207 loop_until_bit_is_clear(ADCSRA, ADSC);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
208 uint8_t low = ADCL;
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
209 uint8_t high = ADCH;
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
210 uint16_t f_measure = low + (high << 8);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
211
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
212 // set to measure 1.1 reference
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
213 ADMUX = _BV(ADLAR) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
214 ADCSRA |= _BV(ADSC);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
215 loop_until_bit_is_clear(ADCSRA, ADSC);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
216 uint8_t low_11 = ADCL;
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
217 uint8_t high_11 = ADCH;
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
218 uint16_t f_11 = low_11 + (high_11 << 8);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
219
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
220 float res_volts = 1.1 * f_measure / f_11;
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
221
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
222 // 10mV/degree
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
223 // scale to 1/5 degree units above 0C
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
224 int temp = (res_volts - 2.73) * 500;
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
225 measurements[n_measurements] = temp;
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
226 // XXX something if it hits the limit
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
227
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
228 // measure AVR internal temperature against 1.1 ref.
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
229 ADMUX = _BV(ADLAR) | _BV(MUX3) | _BV(REFS1) | _BV(REFS0);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
230 ADCSRA |= _BV(ADSC);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
231 loop_until_bit_is_clear(ADCSRA, ADSC);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
232 uint16_t res_internal = ADCL;
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
233 res_internal |= ADCH << 8;
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
234
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
235 float internal_volts = res_internal * (1.1 / 1024.0);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
236
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
237 // 1mV/degree
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
238 int internal_temp = (internal_volts - 2.73) * 5000;
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
239 internal_measurements[n_measurements] = internal_temp;
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
240
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
241 printf_P("measure %d: external %d, internal %d, 1.1 %d\n",
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
242 n_measurements, temp, internal_temp, f_11);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
243
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
244 n_measurements++;
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
245 PRR |= _BV(PRADC);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
246 }
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
247
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
248 static void
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
249 do_measurement()
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
250 {
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
251 need_measurement = 0;
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
252
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
253 do_adc_335();
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
254 }
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
255
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
256 static void
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
257 do_comms()
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
258 {
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
259 need_comms = 0;
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
260
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
261 // turn on bluetooth
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
262 uart_on(UBRR);
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
263
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
264 // write sd card here? same 3.3v regulator...
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
265
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
266 comms_done = 0;
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
267 for (;;)
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
268 {
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
269 if (comms_done)
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
270 {
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
271 break;
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
272 }
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
273
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
274 if (need_measurement)
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
275 {
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
276 do_measurement();
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
277 }
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
278
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
279 idle_sleep();
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
280 }
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
281
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
282 uart_off();
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
283
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
284 // turn off bluetooth
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
285 }
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
286
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
287 int main(void)
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
288 {
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
289 stdout = &mystdout;
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
290 uart_on(UBRR);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
291 fprintf_P(&mystdout, PSTR("hello %d\n"), 12);
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
292 uart_off();
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
293
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
294 // turn off everything except timer2
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
295 PRR = _BV(PRTWI) | _BV(PRTIM0) | _BV(PRTIM1) | _BV(PRSPI) | _BV(PRUSART0) | _BV(PRADC);
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
296
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
297 // set up counter2.
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
298 // COM21 COM20 Set OC2 on Compare Match (p116)
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
299 // WGM21 Clear counter on compare
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
300 // CS22 CS21 CS20 clk/1024
2
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
301 TCCR2A = _BV(COM2A1) | _BV(COM2A0) | _BV(WGM21);
ab0e30c4b344 switch to atmega328
Matt Johnston <matt@ucc.asn.au>
parents: 1
diff changeset
302 TCCR2B = _BV(CS22) | _BV(CS21) | _BV(CS20);
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
303 // set async mode
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
304 ASSR |= _BV(AS2);
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
305
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
306 #ifdef TEST_MODE
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
307 for (;;)
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
308 {
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
309 do_comms()
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
310 }
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
311 #else
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
312 for(;;){
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
313 /* insert your main loop code here */
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
314 if (need_measurement)
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
315 {
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
316 do_measurement();
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
317 continue;
1
1d1897d66b03 Some counter2 bits
Matt Johnston <matt@ucc.asn.au>
parents: 0
diff changeset
318 }
4
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
319
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
320 if (need_comms)
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
321 {
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
322 do_comms();
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
323 continue;
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
324 }
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
325
54d369e3d689 Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents: 3
diff changeset
326 deep_sleep();
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
327 }
6
9d538f674ff0 - Some basic ADC code
Matt Johnston <matt@ucc.asn.au>
parents: 5
diff changeset
328 #endif
0
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
329 return 0; /* never reached */
c8b14b2950b9 Some basic bits
Matt Johnston <matt@ucc.asn.au>
parents:
diff changeset
330 }