summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2011-05-23 11:52:40 -0700
committerKeith Packard <keithp@keithp.com>2011-05-23 16:13:55 -0600
commit41d76a850d7ded2d02c41f5a4b1f1a68936598ac (patch)
treec29cc32fda4c8e3eef4ff7182b56d1f71476f6b7
parent29e59e4a1041e20fb10aac8715191bde4ab178d1 (diff)
src-avr: Control log with pin on companion connector
Use the SPI chip select (SS) which is hooked to port B0. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--src-avr/ao_log_telescience.c54
1 files changed, 38 insertions, 16 deletions
diff --git a/src-avr/ao_log_telescience.c b/src-avr/ao_log_telescience.c
index f092027a..bda89129 100644
--- a/src-avr/ao_log_telescience.c
+++ b/src-avr/ao_log_telescience.c
@@ -86,8 +86,35 @@ ao_log_valid(struct ao_log_telescience *log)
}
void
+ao_log_start(void)
+{
+ printf("Log goes from %ld to %ld\n", ao_log_current_pos, ao_log_end_pos);
+ ao_log_running = 1;
+ ao_wakeup(&ao_log_running);
+}
+
+void
+ao_log_stop(void)
+{
+ printf ("Log stopped at %ld\n", ao_log_current_pos);
+ ao_log_running = 0;
+ ao_wakeup((void *) &ao_adc_head);
+}
+
+void
+ao_log_check_pin(void)
+{
+ if (PINB & (1 << PINB0))
+ ao_log_stop();
+ else
+ ao_log_start();
+}
+
+void
ao_log_telescience(void)
{
+ ao_log_check_pin();
+
ao_storage_setup();
/* Find end of data */
@@ -128,22 +155,6 @@ ao_log_telescience(void)
}
void
-ao_log_start(void)
-{
- printf("Log goes from %ld to %ld\n", ao_log_current_pos, ao_log_end_pos);
- ao_log_running = 1;
- ao_wakeup(&ao_log_running);
-}
-
-void
-ao_log_stop(void)
-{
- printf ("Log stopped at %ld\n", ao_log_current_pos);
- ao_log_running = 0;
- ao_wakeup((void *) &ao_adc_head);
-}
-
-void
ao_log_set(void)
{
ao_cmd_hex();
@@ -214,11 +225,22 @@ const struct ao_cmds ao_log_cmds[] = {
{ 0, NULL },
};
+ISR(PCINT0_vect)
+{
+ ao_log_check_pin();
+}
+
void
ao_log_init(void)
{
ao_log_running = 0;
+ PCMSK0 |= (1 << PCINT0); /* Enable PCINT0 pin change */
+
+ PCICR |= (1 << PCIE0); /* Enable pin change interrupt */
+
+ PORTB &= ~(1 << PORTB0); /* Pull input down; always log if NC */
+
ao_cmd_register(&ao_log_cmds[0]);
ao_add_task(&ao_log_task, ao_log_telescience, "log");