Mercurial > templog
comparison main.c @ 44:96c336896201
mostly works for testing
author | Matt Johnston <matt@ucc.asn.au> |
---|---|
date | Sat, 23 Jun 2012 23:37:29 +0800 |
parents | 1701457e6007 |
children | 9ccd965d938a |
comparison
equal
deleted
inserted
replaced
42:26c8ab2ba3f1 | 44:96c336896201 |
---|---|
22 // - number of sensors (and range?) | 22 // - number of sensors (and range?) |
23 | 23 |
24 // 1 second. we have 1024 prescaler, 32768 crystal. | 24 // 1 second. we have 1024 prescaler, 32768 crystal. |
25 #define SLEEP_COMPARE 32 | 25 #define SLEEP_COMPARE 32 |
26 // limited to uint16_t | 26 // limited to uint16_t |
27 #define MEASURE_WAKE 20 | 27 #define MEASURE_WAKE 5 // testing |
28 | 28 |
29 #define VALUE_NOSENSOR -9000 | 29 #define VALUE_NOSENSOR -9000 |
30 #define VALUE_BROKEN -8000 | 30 #define VALUE_BROKEN -8000 |
31 | 31 |
32 // limited to uint16_t | 32 // limited to uint16_t |
33 #define COMMS_WAKE 3600 | 33 #define COMMS_WAKE 40 // XXX testing |
34 // limited to uint8_t | 34 // limited to uint8_t |
35 #define WAKE_SECS 250 // XXX testing | 35 #define WAKE_SECS 30 // XXX testing |
36 | 36 |
37 #define BAUD 19200 | 37 #define BAUD 19200 |
38 #define UBRR ((F_CPU)/8/(BAUD)-1) | 38 #define UBRR ((F_CPU)/8/(BAUD)-1) |
39 | 39 |
40 #define PORT_LED PORTC | 40 #define PORT_LED PORTC |
139 { | 139 { |
140 PORT_SHDN &= ~_BV(PIN_SHDN); | 140 PORT_SHDN &= ~_BV(PIN_SHDN); |
141 } | 141 } |
142 else | 142 else |
143 { | 143 { |
144 //PORT_SHDN |= _BV(PIN_SHDN); | 144 PORT_SHDN |= _BV(PIN_SHDN); |
145 } | 145 } |
146 } | 146 } |
147 | 147 |
148 static void | 148 static void |
149 setup_tick_counter() | 149 setup_tick_counter() |
466 { | 466 { |
467 need_comms = 1; | 467 need_comms = 1; |
468 blink(); | 468 blink(); |
469 _delay_ms(100); | 469 _delay_ms(100); |
470 blink(); | 470 blink(); |
471 _delay_ms(100); | |
472 blink(); | |
473 _delay_ms(100); | |
474 blink(); | |
475 _delay_ms(100); | |
476 blink(); | |
477 _delay_ms(100); | |
478 blink(); | |
479 _delay_ms(100); | |
480 blink(); | |
481 _delay_ms(100); | |
482 } | 471 } |
483 | 472 |
484 | 473 |
485 ISR(USART_RX_vect) | 474 ISR(USART_RX_vect) |
486 { | 475 { |
516 | 505 |
517 clock_epoch ++; | 506 clock_epoch ++; |
518 | 507 |
519 if (comms_timeout != 0) | 508 if (comms_timeout != 0) |
520 { | 509 { |
521 // XXX testing | 510 comms_timeout--; |
522 //comms_timeout--; | |
523 } | 511 } |
524 | 512 |
525 if (measure_count >= MEASURE_WAKE) | 513 if (measure_count >= MEASURE_WAKE) |
526 { | 514 { |
527 measure_count = 0; | 515 measure_count = 0; |
679 { | 667 { |
680 if (need_measurement) | 668 if (need_measurement) |
681 { | 669 { |
682 need_measurement = 0; | 670 need_measurement = 0; |
683 do_measurement(); | 671 do_measurement(); |
672 continue; | |
684 } | 673 } |
685 | 674 |
686 if (have_cmd) | 675 if (have_cmd) |
687 { | 676 { |
688 have_cmd = 0; | 677 have_cmd = 0; |
689 read_handler(); | 678 read_handler(); |
679 continue; | |
690 } | 680 } |
691 | 681 |
692 // wait for commands from the master | 682 // wait for commands from the master |
693 idle_sleep(); | 683 idle_sleep(); |
694 } | 684 } |