Mercurial > templog
annotate main.c @ 20:878be5e353a0
Untested - calculate crc in uart_putchar
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Tue, 22 May 2012 23:23:38 +0800 |
parents | f1016b151689 |
children | 885532437100 |
rev | line source |
---|---|
0 | 1 /* Name: main.c |
2 * Author: <insert your name here> | |
3 * Copyright: <insert your copyright message here> | |
4 * License: <insert your license reference here> | |
5 */ | |
6 | |
7 #include <stdio.h> | |
8 #include <string.h> | |
13 | 9 #include <stddef.h> |
1 | 10 #include <avr/io.h> |
11 #include <avr/interrupt.h> | |
12 #include <avr/sleep.h> | |
7 | 13 #include <util/delay.h> |
6 | 14 #include <avr/pgmspace.h> |
13 | 15 #include <avr/eeprom.h> |
0 | 16 #include <util/crc16.h> |
17 | |
12 | 18 // for DWORD of get_fattime() |
3 | 19 #include "integer.h" |
12 | 20 |
21 #include "simple_ds18b20.h" | |
13 | 22 #include "onewire.h" |
3 | 23 |
0 | 24 // configuration params |
25 // - measurement interval | |
26 // - transmit interval | |
27 // - bluetooth params | |
28 // - number of sensors (and range?) | |
29 | |
1 | 30 // 1 second. we have 1024 prescaler, 32768 crystal. |
2 | 31 #define SLEEP_COMPARE 32 |
14 | 32 #define MEASURE_WAKE 10 |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
33 |
13 | 34 #define VALUE_NOSENSOR -9000 |
35 #define VALUE_BROKEN -8000 | |
36 | |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
37 #define COMMS_WAKE 3600 |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
38 #define WAKE_SECS 30 |
2 | 39 |
10 | 40 #define BAUD 19200 |
7 | 41 #define UBRR ((F_CPU)/8/(BAUD)-1) |
42 | |
43 #define PORT_LED PORTC | |
44 #define DDR_LED DDRC | |
45 #define PIN_LED PC4 | |
1 | 46 |
15
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
47 #define PORT_SHDN PORTD |
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
48 #define DDR_SHDN DDRD |
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
49 #define PIN_SHDN PD7 |
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
50 |
13 | 51 #define NUM_MEASUREMENTS 100 |
52 #define MAX_SENSORS 5 | |
6 | 53 |
15
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
54 // fixed at 8, have a shorter name |
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
55 #define ID_LEN OW_ROMCODE_SIZE |
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
56 |
10 | 57 int uart_putchar(char c, FILE *stream); |
14 | 58 static void long_delay(int ms); |
59 | |
0 | 60 static FILE mystdout = FDEV_SETUP_STREAM(uart_putchar, NULL, |
61 _FDEV_SETUP_WRITE); | |
62 | |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
63 uint16_t crc_out; |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
64 static FILE _crc_stdout = FDEV_SETUP_STREAM(uart_putchar, NULL, |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
65 _FDEV_SETUP_WRITE); |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
66 // convenience |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
67 static FILE *crc_stdout = &_crc_stdout; |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
68 |
17 | 69 static uint16_t n_measurements; |
13 | 70 // stored as decidegrees |
14 | 71 static int16_t measurements[NUM_MEASUREMENTS][MAX_SENSORS]; |
0 | 72 |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
73 // boolean flags |
17 | 74 static uint8_t need_measurement; |
75 static uint8_t need_comms; | |
1 | 76 |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
77 // counts down from WAKE_SECS to 0, goes to deep sleep when hits 0 |
17 | 78 static uint8_t comms_timeout; |
1 | 79 |
17 | 80 static uint8_t readpos; |
0 | 81 static char readbuf[30]; |
82 | |
17 | 83 static uint8_t measure_count; |
84 static uint16_t comms_count; | |
85 | |
86 static uint32_t clock_epoch; | |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
87 |
13 | 88 // thanks to http://projectgus.com/2010/07/eeprom-access-with-arduino/ |
89 #define eeprom_read_to(dst_p, eeprom_field, dst_size) eeprom_read_block((dst_p), (void *)offsetof(struct __eeprom_data, eeprom_field), (dst_size)) | |
90 #define eeprom_read(dst, eeprom_field) eeprom_read_to((&dst), eeprom_field, sizeof(dst)) | |
91 #define eeprom_write_from(src_p, eeprom_field, src_size) eeprom_write_block((src_p), (void *)offsetof(struct __eeprom_data, eeprom_field), (src_size)) | |
92 #define eeprom_write(src, eeprom_field) { eeprom_write_from(&src, eeprom_field, sizeof(src)); } | |
93 | |
94 #define EXPECT_MAGIC 0x67c9 | |
95 | |
96 struct __attribute__ ((__packed__)) __eeprom_data { | |
97 uint16_t magic; | |
98 uint8_t n_sensors; | |
15
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
99 uint8_t sensor_id[MAX_SENSORS][ID_LEN]; |
13 | 100 }; |
101 | |
8 | 102 #define DEBUG(str) printf_P(PSTR(str)) |
103 | |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
104 static void deep_sleep(); |
1 | 105 |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
106 // Very first setup |
18 | 107 static void |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
108 setup_chip() |
18 | 109 { |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
110 // Set clock to 2mhz |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
111 cli(); |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
112 CLKPR = _BV(CLKPCE); |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
113 // divide by 4 |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
114 CLKPR = _BV(CLKPS1); |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
115 sei(); |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
116 |
19 | 117 // 3.3v power for bluetooth and SD |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
118 DDR_LED |= _BV(PIN_LED); |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
119 DDR_SHDN |= _BV(PIN_SHDN); |
19 | 120 |
18 | 121 // INT0 setup |
122 EIMSK = _BV(INT0); | |
123 // set pullup | |
124 PORTD |= _BV(PD2); | |
125 } | |
126 | |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
127 static void |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
128 set_aux_power(uint8_t on) |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
129 { |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
130 if (on) |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
131 { |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
132 PORT_SHDN &= ~_BV(PIN_SHDN); |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
133 } |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
134 else |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
135 { |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
136 PORT_SHDN |= _BV(PIN_SHDN); |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
137 } |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
138 } |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
139 |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
140 static void |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
141 setup_tick_counter() |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
142 { |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
143 // set up counter2. |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
144 // COM21 COM20 Set OC2 on Compare Match (p116) |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
145 // WGM21 Clear counter on compare |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
146 //TCCR2A = _BV(COM2A1) | _BV(COM2A0) | _BV(WGM21); |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
147 // toggle on match |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
148 TCCR2A = _BV(COM2A0); |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
149 // CS22 CS21 CS20 clk/1024 |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
150 TCCR2B = _BV(CS22) | _BV(CS21) | _BV(CS20); |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
151 // set async mode |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
152 ASSR |= _BV(AS2); |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
153 TCNT2 = 0; |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
154 OCR2A = SLEEP_COMPARE; |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
155 // interrupt |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
156 TIMSK2 = _BV(OCIE2A); |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
157 } |
18 | 158 |
0 | 159 static void |
7 | 160 uart_on() |
0 | 161 { |
8 | 162 // Power reduction register |
163 //PRR &= ~_BV(PRUSART0); | |
164 | |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
165 // All of this needs to be done each time after turning off the PRR |
0 | 166 // baud rate |
7 | 167 UBRR0H = (unsigned char)(UBRR >> 8); |
168 UBRR0L = (unsigned char)UBRR; | |
169 // set 2x clock, improves accuracy of UBRR | |
170 UCSR0A |= _BV(U2X0); | |
6 | 171 UCSR0B = _BV(RXCIE0) | _BV(RXEN0) | _BV(TXEN0); |
0 | 172 //8N1 |
7 | 173 UCSR0C = _BV(UCSZ01) | _BV(UCSZ00); |
6 | 174 } |
175 | |
176 static void | |
177 uart_off() | |
178 { | |
179 // Turn of interrupts and disable tx/rx | |
180 UCSR0B = 0; | |
181 | |
182 // Power reduction register | |
8 | 183 //PRR |= _BV(PRUSART0); |
0 | 184 } |
185 | |
10 | 186 int |
0 | 187 uart_putchar(char c, FILE *stream) |
188 { | |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
189 // XXX could perhaps sleep in the loop for power. |
8 | 190 if (c == '\n') |
191 { | |
10 | 192 loop_until_bit_is_set(UCSR0A, UDRE0); |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
193 UDR0 = '\r'; |
8 | 194 } |
2 | 195 loop_until_bit_is_set(UCSR0A, UDRE0); |
196 UDR0 = c; | |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
197 if (stream == crc_stdout) |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
198 { |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
199 crc_out = _crc_ccitt_update(crc_out, '\n'); |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
200 } |
10 | 201 if (c == '\r') |
202 { | |
203 loop_until_bit_is_set(UCSR0A, UDRE0); | |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
204 UDR0 = '\n'; |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
205 if (stream == crc_stdout) |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
206 { |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
207 crc_out = _crc_ccitt_update(crc_out, '\n'); |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
208 } |
10 | 209 } |
0 | 210 return 0; |
211 } | |
212 | |
213 static void | |
214 cmd_fetch() | |
215 { | |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
216 crc_out = 0; |
15
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
217 uint8_t n_sensors; |
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
218 eeprom_read(n_sensors, n_sensors); |
13 | 219 |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
220 fprintf_P(crc_stdout, PSTR("START\n")); |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
221 fprintf_P(crc_stdout, PSTR("time=%lu\n"), clock_epoch); |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
222 fprintf_P(crc_stdout, PSTR("sensors=%d\n"), n_measurements); |
15
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
223 for (uint8_t s = 0; s < n_sensors; s++) |
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
224 { |
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
225 uint8_t id[ID_LEN]; |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
226 fprintf_P(crc_stdout, PSTR("sensor_id%d="), s); |
15
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
227 eeprom_read_to(id, sensor_id[s], ID_LEN); |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
228 printhex(id, ID_LEN, crc_stdout); |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
229 fputc('\n', crc_stdout); |
15
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
230 } |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
231 fprintf_P(crc_stdout, PSTR("measurements=%d\n"), n_measurements); |
14 | 232 for (uint16_t n = 0; n < n_measurements; n++) |
0 | 233 { |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
234 fprintf_P(crc_stdout, PSTR("meas%3d="), n); |
15
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
235 for (uint8_t s = 0; s < n_sensors; s++) |
13 | 236 { |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
237 fprintf_P(crc_stdout, PSTR(" %6d"), measurements[n][s]); |
13 | 238 } |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
239 fputc('\n', crc_stdout); |
0 | 240 } |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
241 fprintf_P(crc_stdout, PSTR("END\n")); |
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
242 fprintf_P(stdout, PSTR("CRC=%d\n"), crc_out); |
0 | 243 } |
244 | |
245 static void | |
246 cmd_clear() | |
247 { | |
7 | 248 n_measurements = 0; |
249 printf_P(PSTR("Cleared\n")); | |
0 | 250 } |
251 | |
252 static void | |
253 cmd_btoff() | |
254 { | |
7 | 255 printf_P(PSTR("Turning off\n")); |
256 _delay_ms(50); | |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
257 comms_timeout = 0; |
0 | 258 } |
259 | |
260 static void | |
12 | 261 cmd_measure() |
262 { | |
263 printf_P(PSTR("Measuring\n")); | |
264 need_measurement = 1; | |
265 } | |
266 | |
267 static void | |
268 cmd_sensors() | |
269 { | |
270 uint8_t ret = simple_ds18b20_start_meas(NULL); | |
14 | 271 printf_P(PSTR("All sensors, ret %d, waiting...\n"), ret); |
272 long_delay(DS18B20_TCONV_12BIT); | |
12 | 273 simple_ds18b20_read_all(); |
274 } | |
275 | |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
276 #if 0 |
13 | 277 // 0 on success |
278 static uint8_t | |
279 get_hex_string(const char *hex, uint8_t *out, uint8_t size) | |
280 { | |
281 uint8_t upper; | |
282 uint8_t o; | |
283 for (uint8_t i = 0, z = 0; o < size; i++) | |
284 { | |
285 uint8_t h = hex[i]; | |
286 if (h >= 'A' && h <= 'F') | |
287 { | |
288 // lower case | |
289 h += 0x20; | |
290 } | |
291 uint8_t nibble; | |
292 if (h >= '0' && h <= '9') | |
293 { | |
294 nibble = h - '0'; | |
295 } | |
296 else if (h >= 'a' && h <= 'f') | |
297 { | |
298 nibble = 10 + h - 'a'; | |
299 } | |
300 else if (h == ' ' || h == ':') | |
301 { | |
302 continue; | |
303 } | |
304 else | |
305 { | |
306 printf_P(PSTR("Bad hex 0x%x '%c'\n"), hex[i], hex[i]); | |
307 return 1; | |
308 } | |
309 | |
310 if (z % 2 == 0) | |
311 { | |
312 upper = nibble << 4; | |
313 } | |
314 else | |
315 { | |
316 out[o] = upper | nibble; | |
317 o++; | |
318 } | |
319 | |
320 z++; | |
321 } | |
322 | |
323 if (o != size) | |
324 { | |
325 printf_P(PSTR("Short hex\n")); | |
326 return 1; | |
327 } | |
328 return 0; | |
329 } | |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
330 #endif |
13 | 331 |
332 static void | |
333 add_sensor(uint8_t *id) | |
334 { | |
335 uint8_t n; | |
336 eeprom_read(n, n_sensors); | |
337 if (n < MAX_SENSORS) | |
338 { | |
339 cli(); | |
15
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
340 eeprom_write_from(id, sensor_id[n], ID_LEN); |
13 | 341 n++; |
342 eeprom_write(n, n_sensors); | |
343 sei(); | |
344 printf_P(PSTR("Added sensor %d : "), n); | |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
345 printhex(id, ID_LEN, stdout); |
13 | 346 putchar('\n'); |
347 } | |
348 else | |
349 { | |
350 printf_P(PSTR("Too many sensors\n")); | |
351 } | |
352 } | |
353 | |
354 static void | |
355 cmd_add_all() | |
356 { | |
357 uint8_t id[OW_ROMCODE_SIZE]; | |
358 printf_P("Adding all\n"); | |
359 ow_reset(); | |
360 for( uint8_t diff = OW_SEARCH_FIRST; diff != OW_LAST_DEVICE; ) | |
361 { | |
362 diff = ow_rom_search( diff, &id[0] ); | |
363 if( diff == OW_PRESENCE_ERR ) { | |
364 printf_P( PSTR("No Sensor found\r") ); | |
365 return; | |
366 } | |
367 | |
368 if( diff == OW_DATA_ERR ) { | |
369 printf_P( PSTR("Bus Error\r") ); | |
370 return; | |
371 } | |
372 add_sensor(id); | |
373 } | |
374 } | |
375 | |
376 static void | |
377 cmd_init() | |
378 { | |
379 printf_P(PSTR("Resetting sensor list\n")); | |
380 uint8_t zero = 0; | |
381 cli(); | |
382 eeprom_write(zero, n_sensors); | |
383 sei(); | |
384 printf_P(PSTR("Done.\n")); | |
385 } | |
386 | |
387 static void | |
17 | 388 cmd_settime(const char *str) |
389 { | |
390 clock_epoch = strtoul(str, NULL, 10); | |
391 printf_P(PSTR("Time set to %lu\n"), clock_epoch); | |
392 } | |
393 | |
394 static void | |
13 | 395 check_first_startup() |
396 { | |
397 uint16_t magic; | |
398 eeprom_read(magic, magic); | |
399 if (magic != EXPECT_MAGIC) | |
400 { | |
401 printf_P(PSTR("First boot, looking for sensors...\n")); | |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
402 // in case of power fumbles don't want to reset during eeprom write, |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
403 long_delay(2); |
13 | 404 cmd_init(); |
405 cmd_add_all(); | |
14 | 406 cli(); |
407 magic = EXPECT_MAGIC; | |
408 eeprom_write(magic, magic); | |
409 sei(); | |
13 | 410 } |
411 } | |
412 | |
12 | 413 static void |
0 | 414 read_handler() |
415 { | |
6 | 416 if (strcmp_P(readbuf, PSTR("fetch")) == 0) |
0 | 417 { |
418 cmd_fetch(); | |
419 } | |
6 | 420 else if (strcmp_P(readbuf, PSTR("clear")) == 0) |
0 | 421 { |
422 cmd_clear(); | |
423 } | |
6 | 424 else if (strcmp_P(readbuf, PSTR("btoff")) == 0) |
0 | 425 { |
426 cmd_btoff(); | |
427 } | |
12 | 428 else if (strcmp_P(readbuf, PSTR("measure")) == 0) |
429 { | |
430 cmd_measure(); | |
431 } | |
432 else if (strcmp_P(readbuf, PSTR("sensors")) == 0) | |
433 { | |
434 cmd_sensors(); | |
435 } | |
13 | 436 else if (strcmp_P(readbuf, PSTR("addall"))== 0) |
437 { | |
438 cmd_add_all(); | |
439 } | |
17 | 440 else if (strncmp_P(readbuf, PSTR("settime "), |
441 strlen("settime ") == 0)) | |
442 { | |
443 cmd_settime(&readbuf[strlen("settime ")]); | |
444 } | |
13 | 445 else if (strcmp_P(readbuf, PSTR("init")) == 0) |
446 { | |
447 cmd_init(); | |
448 } | |
0 | 449 else |
450 { | |
6 | 451 printf_P(PSTR("Bad command\n")); |
0 | 452 } |
453 } | |
454 | |
20
878be5e353a0
Untested - calculate crc in uart_putchar
Matt Johnston <matt@ucc.asn.au>
parents:
19
diff
changeset
|
455 ISR(INT0_vect) |
18 | 456 { |
457 need_comms = 1; | |
458 } | |
459 | |
460 | |
2 | 461 ISR(USART_RX_vect) |
0 | 462 { |
2 | 463 char c = UDR0; |
12 | 464 uart_putchar(c, NULL); |
465 if (c == '\r') | |
0 | 466 { |
467 readbuf[readpos] = '\0'; | |
468 read_handler(); | |
469 readpos = 0; | |
470 } | |
471 else | |
472 { | |
473 readbuf[readpos] = c; | |
474 readpos++; | |
475 if (readpos >= sizeof(readbuf)) | |
476 { | |
477 readpos = 0; | |
478 } | |
479 } | |
480 } | |
481 | |
2 | 482 ISR(TIMER2_COMPA_vect) |
1 | 483 { |
14 | 484 TCNT2 = 0; |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
485 measure_count ++; |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
486 comms_count ++; |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
487 |
17 | 488 clock_epoch ++; |
489 | |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
490 if (comms_timeout != 0) |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
491 { |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
492 comms_timeout--; |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
493 } |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
494 |
14 | 495 if (measure_count >= MEASURE_WAKE) |
1 | 496 { |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
497 measure_count = 0; |
1 | 498 need_measurement = 1; |
499 } | |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
500 |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
501 if (comms_count >= COMMS_WAKE) |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
502 { |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
503 comms_count = 0; |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
504 need_comms = 1; |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
505 } |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
506 |
1 | 507 } |
508 | |
3 | 509 DWORD get_fattime (void) |
510 { | |
511 return 0; | |
512 } | |
513 | |
1 | 514 static void |
515 deep_sleep() | |
516 { | |
517 // p119 of manual | |
2 | 518 OCR2A = SLEEP_COMPARE; |
519 loop_until_bit_is_clear(ASSR, OCR2AUB); | |
1 | 520 |
521 set_sleep_mode(SLEEP_MODE_PWR_SAVE); | |
522 sleep_mode(); | |
523 } | |
524 | |
525 static void | |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
526 idle_sleep() |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
527 { |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
528 set_sleep_mode(SLEEP_MODE_IDLE); |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
529 sleep_mode(); |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
530 } |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
531 |
14 | 532 #if 0 |
533 // untested | |
6 | 534 static void |
535 do_adc_335() | |
536 { | |
8 | 537 //PRR &= ~_BV(PRADC); |
6 | 538 |
539 ADMUX = _BV(ADLAR); | |
540 | |
541 // ADPS2 = /16 prescaler, 62khz at 1mhz clock | |
542 ADCSRA = _BV(ADEN) | _BV(ADPS2); | |
543 | |
544 // measure value | |
545 ADCSRA |= _BV(ADSC); | |
546 loop_until_bit_is_clear(ADCSRA, ADSC); | |
547 uint8_t low = ADCL; | |
548 uint8_t high = ADCH; | |
549 uint16_t f_measure = low + (high << 8); | |
550 | |
551 // set to measure 1.1 reference | |
552 ADMUX = _BV(ADLAR) | _BV(MUX3) | _BV(MUX2) | _BV(MUX1); | |
553 ADCSRA |= _BV(ADSC); | |
554 loop_until_bit_is_clear(ADCSRA, ADSC); | |
555 uint8_t low_11 = ADCL; | |
556 uint8_t high_11 = ADCH; | |
557 uint16_t f_11 = low_11 + (high_11 << 8); | |
558 | |
559 float res_volts = 1.1 * f_measure / f_11; | |
560 | |
561 // 10mV/degree | |
562 // scale to 1/5 degree units above 0C | |
563 int temp = (res_volts - 2.73) * 500; | |
13 | 564 // XXX fixme |
565 //measurements[n_measurements] = temp; | |
6 | 566 // XXX something if it hits the limit |
567 | |
568 // measure AVR internal temperature against 1.1 ref. | |
569 ADMUX = _BV(ADLAR) | _BV(MUX3) | _BV(REFS1) | _BV(REFS0); | |
570 ADCSRA |= _BV(ADSC); | |
571 loop_until_bit_is_clear(ADCSRA, ADSC); | |
572 uint16_t res_internal = ADCL; | |
573 res_internal |= ADCH << 8; | |
574 | |
575 float internal_volts = res_internal * (1.1 / 1024.0); | |
576 | |
577 // 1mV/degree | |
578 int internal_temp = (internal_volts - 2.73) * 5000; | |
13 | 579 // XXX fixme |
580 //internal_measurements[n_measurements] = internal_temp; | |
6 | 581 |
582 printf_P("measure %d: external %d, internal %d, 1.1 %d\n", | |
583 n_measurements, temp, internal_temp, f_11); | |
584 | |
585 n_measurements++; | |
8 | 586 //PRR |= _BV(PRADC); |
6 | 587 } |
14 | 588 #endif |
6 | 589 |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
590 static void |
1 | 591 do_measurement() |
592 { | |
13 | 593 uint8_t n_sensors; |
14 | 594 printf("do_measurement\n"); |
13 | 595 eeprom_read(n_sensors, n_sensors); |
14 | 596 printf("do_measurement sensors %d\n", n_sensors); |
13 | 597 |
598 uint8_t ret = simple_ds18b20_start_meas(NULL); | |
14 | 599 printf_P(PSTR("Read all sensors, ret %d, waiting...\n"), ret); |
13 | 600 _delay_ms(DS18B20_TCONV_12BIT); |
601 | |
602 if (n_measurements == NUM_MEASUREMENTS) | |
603 { | |
14 | 604 printf_P(PSTR("Measurements .overflow\n")); |
13 | 605 n_measurements = 0; |
606 } | |
6 | 607 |
14 | 608 for (uint8_t s = 0; s < MAX_SENSORS; s++) |
13 | 609 { |
610 int16_t decicelsius; | |
14 | 611 if (s >= n_sensors) |
13 | 612 { |
613 decicelsius = VALUE_NOSENSOR; | |
614 } | |
615 else | |
616 { | |
15
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
617 uint8_t id[ID_LEN]; |
54b0fda9cba7
Add shutdown handling, print sensors in "fetch" output
Matt Johnston <matt@ucc.asn.au>
parents:
14
diff
changeset
|
618 eeprom_read_to(id, sensor_id[s], ID_LEN); |
13 | 619 |
620 uint8_t ret = simple_ds18b20_read_decicelsius(id, &decicelsius); | |
621 if (ret != DS18X20_OK) | |
622 { | |
623 decicelsius = VALUE_BROKEN; | |
624 } | |
625 } | |
14 | 626 measurements[n_measurements][s] = decicelsius; |
13 | 627 } |
14 | 628 n_measurements++; |
12 | 629 //do_adc_335(); |
1 | 630 } |
631 | |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
632 static void |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
633 do_comms() |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
634 { |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
635 // turn on bluetooth |
7 | 636 uart_on(); |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
637 |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
638 // 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
|
639 |
12 | 640 printf("ready> \n"); |
641 | |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
642 for (comms_timeout = WAKE_SECS; comms_timeout > 0; ) |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
643 { |
6 | 644 if (need_measurement) |
645 { | |
14 | 646 need_measurement = 0; |
647 printf("measure from do_comms\n"); | |
6 | 648 do_measurement(); |
649 } | |
650 | |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
651 // wait for commands from the master |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
652 idle_sleep(); |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
653 } |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
654 |
6 | 655 uart_off(); |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
656 set_aux_power(0); |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
657 } |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
658 |
7 | 659 static void |
660 blink() | |
661 { | |
662 PORT_LED &= ~_BV(PIN_LED); | |
9 | 663 _delay_ms(1); |
7 | 664 PORT_LED |= _BV(PIN_LED); |
665 } | |
666 | |
667 static void | |
668 long_delay(int ms) | |
669 { | |
670 int iter = ms / 100; | |
671 | |
672 for (int i = 0; i < iter; i++) | |
673 { | |
674 _delay_ms(100); | |
675 } | |
676 } | |
677 | |
8 | 678 ISR(BADISR_vect) |
679 { | |
14 | 680 //uart_on(); |
8 | 681 printf_P(PSTR("Bad interrupt\n")); |
682 } | |
683 | |
9 | 684 |
0 | 685 int main(void) |
686 { | |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
687 setup_chip(); |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
688 blink(); |
9 | 689 |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
690 set_aux_power(0); |
7 | 691 |
6 | 692 stdout = &mystdout; |
7 | 693 uart_on(); |
694 | |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
695 printf(PSTR("Started.\n")); |
13 | 696 |
697 check_first_startup(); | |
698 | |
8 | 699 uart_off(); |
0 | 700 |
6 | 701 // turn off everything except timer2 |
8 | 702 //PRR = _BV(PRTWI) | _BV(PRTIM0) | _BV(PRTIM1) | _BV(PRSPI) | _BV(PRUSART0) | _BV(PRADC); |
703 | |
704 // for testing | |
705 uart_on(); | |
706 | |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
707 setup_tick_counter(); |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
708 |
12 | 709 sei(); |
8 | 710 |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
711 #if 0 |
6 | 712 for (;;) |
713 { | |
12 | 714 do_comms(); |
6 | 715 } |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
716 #endif |
12 | 717 |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
718 for(;;) |
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
719 { |
1 | 720 if (need_measurement) |
721 { | |
14 | 722 need_measurement = 0; |
1 | 723 do_measurement(); |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
724 continue; |
1 | 725 } |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
726 |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
727 if (need_comms) |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
728 { |
16
5075d8c428bd
untested, add comms timeout code
Matt Johnston <matt@ucc.asn.au>
parents:
15
diff
changeset
|
729 need_comms = 0; |
4
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
730 do_comms(); |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
731 continue; |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
732 } |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
733 |
54d369e3d689
Fill out more main.c structure
Matt Johnston <matt@ucc.asn.au>
parents:
3
diff
changeset
|
734 deep_sleep(); |
9 | 735 blink(); |
10 | 736 printf("."); |
0 | 737 } |
12 | 738 |
0 | 739 return 0; /* never reached */ |
740 } |