diff options
| -rw-r--r-- | src/Makefile | 2 | ||||
| -rw-r--r-- | src/core/ao.h | 2 | ||||
| -rw-r--r-- | src/core/ao_ignite.c | 45 | ||||
| -rw-r--r-- | src/core/ao_pyro.c | 57 | ||||
| -rw-r--r-- | src/core/ao_pyro.h | 6 | ||||
| -rw-r--r-- | src/telemega-v0.1/ao_pins.h | 2 | ||||
| -rw-r--r-- | src/telemega-v0.3/ao_pins.h | 1 | 
7 files changed, 89 insertions, 26 deletions
| diff --git a/src/Makefile b/src/Makefile index 7ffc52d6..ff26ac20 100644 --- a/src/Makefile +++ b/src/Makefile @@ -26,7 +26,7 @@ SDCCDIRS=\  	spiradio-v0.1  AVRDIRS=\ -	telescience-v0.1 telescience-pwm telepyro-v0.1 micropeak +	telescience-v0.1 telescience-pwm micropeak  ARMDIRS=\  	telemega-v0.1 telemega-v0.1/flash-loader \ diff --git a/src/core/ao.h b/src/core/ao.h index 7f344736..0886260f 100644 --- a/src/core/ao.h +++ b/src/core/ao.h @@ -703,6 +703,8 @@ struct ao_ignition {  	uint8_t firing;  }; +extern __code char * __code ao_igniter_status_names[]; +  extern __xdata struct ao_ignition ao_ignition[2];  enum ao_igniter_status diff --git a/src/core/ao_ignite.c b/src/core/ao_ignite.c index 74bd0c5a..9f2ec0a7 100644 --- a/src/core/ao_ignite.c +++ b/src/core/ao_ignite.c @@ -17,7 +17,11 @@  #include "ao.h"  #include <ao_data.h> +#if AO_PYRO_NUM +#include <ao_pyro.h> +#endif +#if HAS_IGNITE  __xdata struct ao_ignition ao_ignition[2];  void @@ -150,6 +154,8 @@ ao_igniter(void)  	}  } +#endif +  void  ao_ignite_manual(void)  { @@ -157,33 +163,50 @@ ao_ignite_manual(void)  	if (!ao_match_word("DoIt"))  		return;  	ao_cmd_white(); -	if (ao_cmd_lex_c == 'm') { -		if(ao_match_word("main")) -			ao_igniter_fire(ao_igniter_main); -	} else { -		if(ao_match_word("drogue")) -			ao_igniter_fire(ao_igniter_drogue); +#if HAS_IGNITE +	if (ao_cmd_lex_c == 'm' && ao_match_word("main")) { +		ao_igniter_fire(ao_igniter_main); +		return; +	} +	if (ao_cmd_lex_c == 'd' && ao_match_word("drogue")) { +		ao_igniter_fire(ao_igniter_drogue); +		return; +	} +#endif +#if AO_PYRO_NUM +	if ('0' <= ao_cmd_lex_c && ao_cmd_lex_c <= '9') { +		ao_pyro_manual(ao_cmd_lex_c - '0'); +		return;  	} +#endif +	ao_cmd_status = ao_cmd_syntax_error;  } -static __code char * __code igniter_status_names[] = { +__code char * __code ao_igniter_status_names[] = {  	"unknown", "ready", "active", "open"  }; +#if HAS_IGNITE  void  ao_ignite_print_status(enum ao_igniter igniter, __code char *name) __reentrant  {  	enum ao_igniter_status status = ao_igniter_status(igniter);  	printf("Igniter: %6s Status: %s\n",  	       name, -	       igniter_status_names[status]); +	       ao_igniter_status_names[status]);  } +#endif  void  ao_ignite_test(void)  { +#if HAS_IGNITE  	ao_ignite_print_status(ao_igniter_drogue, "drogue");  	ao_ignite_print_status(ao_igniter_main, "main"); +#endif +#if AO_PYRO_NUM +	ao_pyro_print_status(); +#endif  }  __code struct ao_cmds ao_ignite_cmds[] = { @@ -192,6 +215,7 @@ __code struct ao_cmds ao_ignite_cmds[] = {  	{ 0,	NULL },  }; +#if HAS_IGNITE  __xdata struct ao_task ao_igniter_task;  void @@ -200,11 +224,14 @@ ao_ignite_set_pins(void)  	ao_enable_output(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, AO_IGNITER_DROGUE, 0);  	ao_enable_output(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, AO_IGNITER_MAIN, 0);  } +#endif  void  ao_igniter_init(void)  { +#if HAS_IGNITE  	ao_ignite_set_pins(); -	ao_cmd_register(&ao_ignite_cmds[0]);  	ao_add_task(&ao_igniter_task, ao_igniter, "igniter"); +#endif +	ao_cmd_register(&ao_ignite_cmds[0]);  } diff --git a/src/core/ao_pyro.c b/src/core/ao_pyro.c index 39f40dfa..531e1f50 100644 --- a/src/core/ao_pyro.c +++ b/src/core/ao_pyro.c @@ -33,6 +33,40 @@  #define ao_lowbit(x)	((x) & (-x)) +#ifndef AO_FLIGHT_TEST +enum ao_igniter_status +ao_pyro_status(uint8_t p) +{ +	__xdata struct ao_data packet; +	__pdata int16_t value; + +	ao_arch_critical( +		ao_data_get(&packet); +		); + +	value = (AO_IGNITER_CLOSED>>1); +	value = AO_SENSE_PYRO(&packet, p); +	if (value < AO_IGNITER_OPEN) +		return ao_igniter_open; +	else if (value > AO_IGNITER_CLOSED) +		return ao_igniter_ready; +	else +		return ao_igniter_unknown; +} + +void +ao_pyro_print_status(void) +{ +	uint8_t	p; + +	for(p = 0; p < AO_PYRO_NUM; p++) { +		enum ao_igniter_status status = ao_pyro_status(p); +		printf("Igniter: %d Status: %s\n", +		       p, ao_igniter_status_names[status]); +	} +} +#endif +  uint16_t	ao_pyro_fired;  /* @@ -441,25 +475,17 @@ ao_pyro_set(void)  	_ao_config_edit_finish();  } -static void -ao_pyro_manual(void) +void +ao_pyro_manual(uint8_t p)  { -	ao_cmd_white(); -	if (!ao_match_word("DoIt")) +	printf ("ao_pyro_manual %d\n", p); +	if (p >= AO_PYRO_NUM) { +		ao_cmd_status = ao_cmd_syntax_error;  		return; -	ao_cmd_white(); -	ao_cmd_decimal(); -	if (ao_cmd_lex_i < 0 || AO_PYRO_NUM <= ao_cmd_lex_i) -		return; -	ao_pyro_pins_fire(1 << ao_cmd_lex_i); - +	} +	ao_pyro_pins_fire(1 << p);  } -const struct ao_cmds ao_pyro_cmds[] = { -	{ ao_pyro_manual,	"P DoIt <n>\0Fire igniter" }, -	{ 0, NULL } -}; -  void  ao_pyro_init(void)  { @@ -487,7 +513,6 @@ ao_pyro_init(void)  #if AO_PYRO_NUM > 7  	ao_enable_output(AO_PYRO_PORT_7, AO_PYRO_PIN_7, AO_PYRO_7, 0);  #endif -	ao_cmd_register(&ao_pyro_cmds[0]);  	ao_add_task(&ao_pyro_task, ao_pyro, "pyro");  }  #endif diff --git a/src/core/ao_pyro.h b/src/core/ao_pyro.h index 1f838542..0c5642d6 100644 --- a/src/core/ao_pyro.h +++ b/src/core/ao_pyro.h @@ -74,4 +74,10 @@ ao_pyro_show(void);  void  ao_pyro_init(void); +void +ao_pyro_manual(uint8_t p); + +void +ao_pyro_print_status(void); +  #endif diff --git a/src/telemega-v0.1/ao_pins.h b/src/telemega-v0.1/ao_pins.h index 4c645871..78e887c3 100644 --- a/src/telemega-v0.1/ao_pins.h +++ b/src/telemega-v0.1/ao_pins.h @@ -146,6 +146,8 @@  /* Number of general purpose pyro channels available */  #define AO_PYRO_NUM	4 +#define AO_SENSE_PYRO(a,p)	((a)->adc.sense[(p) + 2]) +  #define AO_IGNITER_SET_DROGUE(v)	stm_gpio_set(AO_IGNITER_DROGUE_PORT, AO_IGNITER_DROGUE_PIN, v)  #define AO_IGNITER_SET_MAIN(v)		stm_gpio_set(AO_IGNITER_MAIN_PORT, AO_IGNITER_MAIN_PIN, v) diff --git a/src/telemega-v0.3/ao_pins.h b/src/telemega-v0.3/ao_pins.h index bace5853..a5a9eaf4 100644 --- a/src/telemega-v0.3/ao_pins.h +++ b/src/telemega-v0.3/ao_pins.h @@ -121,6 +121,7 @@  #define HAS_IGNITE		1  #define HAS_IGNITE_REPORT	1 +#define AO_SENSE_PYRO(p,n)	((p)->adc.sense[n])  #define AO_SENSE_DROGUE(p)	((p)->adc.sense[4])  #define AO_SENSE_MAIN(p)	((p)->adc.sense[5])  #define AO_IGNITER_CLOSED	400 | 
