diff options
| author | Robert Garbee <robert@gag.com> | 2012-07-17 13:23:48 -0600 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2012-10-16 22:16:13 -0700 | 
| commit | 1d7e6f5dcb29535cde9b7dfd6998d7889baf835b (patch) | |
| tree | 87053a9f7ad38b0b698ba6428cd66e58ca7b23a0 /src | |
| parent | 1747ab07dab6f4e977e0c3e83b57510cd668e369 (diff) | |
first work on PWM input to TeleScience, 'p' command displays timer 1
Diffstat (limited to 'src')
| -rw-r--r-- | src/avr/ao_pwmin.c | 54 | ||||
| -rw-r--r-- | src/avr/ao_pwmin.h | 18 | ||||
| -rw-r--r-- | src/product/ao_telescience.c | 2 | ||||
| -rw-r--r-- | src/telescience-v0.1/Makefile | 1 | 
4 files changed, 75 insertions, 0 deletions
| diff --git a/src/avr/ao_pwmin.c b/src/avr/ao_pwmin.c new file mode 100644 index 00000000..4d96404d --- /dev/null +++ b/src/avr/ao_pwmin.c @@ -0,0 +1,54 @@ +/* + * Copyright © 2012 Robert D. Garbee <robert@gag.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +#include "ao.h" +#include "ao_pwmin.h" + +/*  + * This code implements a PWM input using ICP3.   + * + * The initial use is to measure wind speed in the ULA/Ball summer intern  + * project payload developed at Challenger Middle School.   + */ + +static void +ao_pwmin_display(void) __reentrant +{ +	uint8_t lo = TCNT1L;  +	uint8_t hi = TCNT1H; +	uint16_t value = (hi <<8) | lo; + +	/* now display the value we read */ +	printf("timer 1: %5u",  value); + +} + +__code struct ao_cmds ao_pwmin_cmds[] = { +	{ ao_pwmin_display,	"p\0PWM input" }, +	{ 0, NULL }, +}; + +void +ao_pwmin_init(void) +{ +	/* do hardware setup here */ +		/* set the spike filter bit in the TCCR3B register */ + +	ao_cmd_register(&ao_pwmin_cmds[0]); +} + + diff --git a/src/avr/ao_pwmin.h b/src/avr/ao_pwmin.h new file mode 100644 index 00000000..bbab4ddc --- /dev/null +++ b/src/avr/ao_pwmin.h @@ -0,0 +1,18 @@ +/* + * Copyright © 2012 Robert D. Garbee <robert@gag.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +void ao_pwmin_init(void); diff --git a/src/product/ao_telescience.c b/src/product/ao_telescience.c index 45b6d40e..2d594d7f 100644 --- a/src/product/ao_telescience.c +++ b/src/product/ao_telescience.c @@ -16,6 +16,7 @@   */  #include "ao.h" +#include "ao_pwmin.h"  int  main(void) @@ -34,6 +35,7 @@ main(void)  	ao_usb_init();  	ao_adc_init();  	ao_log_single_init(); +	ao_pwmin_init();  	ao_start_scheduler();  	return 0;  } diff --git a/src/telescience-v0.1/Makefile b/src/telescience-v0.1/Makefile index d24128ef..5542913d 100644 --- a/src/telescience-v0.1/Makefile +++ b/src/telescience-v0.1/Makefile @@ -53,6 +53,7 @@ ALTOS_SRC = \  	ao_adc_avr.c \  	ao_science_slave.c \  	ao_spi_slave.c \ +	ao_pwmin.c \  	$(TELESCIENCE_STORAGE)\  	$(TELESCIENCE_LOG) | 
