diff options
Diffstat (limited to 'src/core')
| -rw-r--r-- | src/core/ao.h | 10 | ||||
| -rw-r--r-- | src/core/ao_cmd.c | 37 | ||||
| -rw-r--r-- | src/core/ao_config.c | 12 | ||||
| -rw-r--r-- | src/core/ao_log_telem.c | 6 | ||||
| -rw-r--r-- | src/core/ao_packet.h | 2 | ||||
| -rw-r--r-- | src/core/ao_send_packet.c | 20 | ||||
| -rw-r--r-- | src/core/ao_serial.h | 28 | ||||
| -rw-r--r-- | src/core/ao_stdio.c | 4 | ||||
| -rw-r--r-- | src/core/ao_task.c | 11 | ||||
| -rw-r--r-- | src/core/ao_task.h | 1 | ||||
| -rw-r--r-- | src/core/ao_usb.h | 2 | 
11 files changed, 89 insertions, 44 deletions
| diff --git a/src/core/ao.h b/src/core/ao.h index 81d92e72..54018b37 100644 --- a/src/core/ao.h +++ b/src/core/ao.h @@ -170,6 +170,10 @@ ao_cmd_hex(void);  void  ao_cmd_decimal(void); +/* Read a single hex nibble off stdin. */ +uint8_t +ao_getnibble(void); +  uint8_t  ao_match_word(__code char *word); @@ -595,10 +599,10 @@ ao_monitor_init(void) __reentrant;   * ao_stdio.c   */ -#define AO_READ_AGAIN	((char) -1) +#define AO_READ_AGAIN	(-1)  struct ao_stdio { -	char	(*pollchar)(void); +	int	(*pollchar)(void);  	void	(*putchar)(char c) __reentrant;  	void	(*flush)(void);  	uint8_t	echo; @@ -617,7 +621,7 @@ uint8_t  ao_echo(void);  int8_t -ao_add_stdio(char (*pollchar)(void), +ao_add_stdio(int (*pollchar)(void),  	     void (*putchar)(char) __reentrant,  	     void (*flush)(void)) __reentrant; diff --git a/src/core/ao_cmd.c b/src/core/ao_cmd.c index 1814cecf..3d086a57 100644 --- a/src/core/ao_cmd.c +++ b/src/core/ao_cmd.c @@ -110,6 +110,22 @@ putnibble(uint8_t v)  		putchar(v + ('a' - 10));  } +uint8_t +ao_getnibble(void) +{ +	char	c; + +	c = getchar(); +	if ('0' <= c && c <= '9') +		return c - '0'; +	if ('a' <= c && c <= 'f') +		return c - ('a' - 10); +	if ('A' <= c && c <= 'F') +		return c - ('A' - 10); +	ao_cmd_status = ao_cmd_lex_error; +	return 0; +} +  void  ao_cmd_put16(uint16_t v)  { @@ -249,12 +265,25 @@ ao_reboot(void)  static void  version(void)  { -	printf("manufacturer     %s\n", ao_manufacturer); -	printf("product          %s\n", ao_product); -	printf("serial-number    %u\n", ao_serial_number); +	printf("manufacturer     %s\n" +	       "product          %s\n" +	       "serial-number    %u\n" +#if HAS_FLIGHT +	       "current-flight   %u\n" +#endif +#if HAS_LOG +	       "log-format       %u\n" +#endif +	       , ao_manufacturer +	       , ao_product +	       , ao_serial_number +#if HAS_FLIGHT +	       , ao_flight_number +#endif  #if HAS_LOG -	printf("log-format       %u\n", ao_log_format); +	       , ao_log_format  #endif +		);  #if HAS_MS5607  	ao_ms5607_info();  #endif diff --git a/src/core/ao_config.c b/src/core/ao_config.c index e85ddcb4..797fe7ec 100644 --- a/src/core/ao_config.c +++ b/src/core/ao_config.c @@ -529,15 +529,15 @@ __code struct ao_config_var ao_config_vars[] = {  	  ao_config_callsign_set,	ao_config_callsign_show },  	{ "e <0 disable, 1 enable>\0Enable telemetry and RDF",  	  ao_config_radio_enable_set, ao_config_radio_enable_show }, +	{ "f <cal>\0Radio calib (cal = rf/(xtal/2^16))", +	  ao_config_radio_cal_set,  	ao_config_radio_cal_show },  #endif /* HAS_RADIO */  #if HAS_ACCEL  	{ "a <+g> <-g>\0Accel calib (0 for auto)",  	  ao_config_accel_calibrate_set,ao_config_accel_calibrate_show }, +	{ "o <0 antenna up, 1 antenna down>\0Set pad orientation", +	  ao_config_pad_orientation_set,ao_config_pad_orientation_show },  #endif /* HAS_ACCEL */ -#if HAS_RADIO -	{ "f <cal>\0Radio calib (cal = rf/(xtal/2^16))", -	  ao_config_radio_cal_set,  	ao_config_radio_cal_show }, -#endif /* HAS_RADIO */  #if HAS_LOG  	{ "l <size>\0Flight log size (kB)",  	  ao_config_log_set,		ao_config_log_show }, @@ -546,10 +546,6 @@ __code struct ao_config_var ao_config_vars[] = {  	{ "i <0 dual, 1 apogee, 2 main>\0Set igniter mode",  	  ao_config_ignite_mode_set,	ao_config_ignite_mode_show },  #endif -#if HAS_ACCEL -	{ "o <0 antenna up, 1 antenna down>\0Set pad orientation", -	  ao_config_pad_orientation_set,ao_config_pad_orientation_show }, -#endif  #if HAS_AES  	{ "k <32 hex digits>\0Set AES encryption key",  	  ao_config_key_set, ao_config_key_show }, diff --git a/src/core/ao_log_telem.c b/src/core/ao_log_telem.c index 18ab85dd..23ebf7dd 100644 --- a/src/core/ao_log_telem.c +++ b/src/core/ao_log_telem.c @@ -102,9 +102,9 @@ ao_log_single(void)  		while (ao_log_running) {  			/* Write samples to EEPROM */  			while (ao_log_monitor_pos != ao_monitor_head) { -				memcpy(&ao_log_single_write_data.telemetry, -				       &ao_monitor_ring[ao_log_monitor_pos], -				       AO_LOG_SINGLE_SIZE); +				ao_xmemcpy(&ao_log_single_write_data.telemetry, +					   &ao_monitor_ring[ao_log_monitor_pos], +					   AO_LOG_SINGLE_SIZE);  				ao_log_single_write();  				ao_log_monitor_pos = ao_monitor_ring_next(ao_log_monitor_pos);  				ao_log_telem_track(); diff --git a/src/core/ao_packet.h b/src/core/ao_packet.h index 0eafd3b2..08b184d6 100644 --- a/src/core/ao_packet.h +++ b/src/core/ao_packet.h @@ -62,7 +62,7 @@ ao_packet_flush(void);  void  ao_packet_putchar(char c) __reentrant; -char +int  ao_packet_pollchar(void);  #if PACKET_HAS_MASTER diff --git a/src/core/ao_send_packet.c b/src/core/ao_send_packet.c index 1a8e74de..66315d22 100644 --- a/src/core/ao_send_packet.c +++ b/src/core/ao_send_packet.c @@ -21,22 +21,6 @@  static __xdata uint8_t ao_send[AO_MAX_SEND]; -static uint8_t -getnibble(void) -{ -	char	c; - -	c = getchar(); -	if ('0' <= c && c <= '9') -		return c - '0'; -	if ('a' <= c && c <= 'f') -		return c - ('a' - 10); -	if ('A' <= c && c <= 'F') -		return c - ('A' - 10); -	ao_cmd_status = ao_cmd_lex_error; -	return 0; -} -  static void  ao_send_packet(void)  { @@ -53,8 +37,8 @@ ao_send_packet(void)  		return;  	}  	for (i = 0; i < count; i++) { -		b = getnibble() << 4; -		b |= getnibble(); +		b = ao_getnibble() << 4; +		b |= ao_getnibble();  		if (ao_cmd_status != ao_cmd_success)  			return;  		ao_send[i] = b; diff --git a/src/core/ao_serial.h b/src/core/ao_serial.h index 53aa8a89..a799bf2c 100644 --- a/src/core/ao_serial.h +++ b/src/core/ao_serial.h @@ -22,6 +22,7 @@  #define AO_SERIAL_SPEED_9600	1  #define AO_SERIAL_SPEED_19200	2  #define AO_SERIAL_SPEED_57600	3 +#define AO_SERIAL_SPEED_115200	4  #if HAS_SERIAL_0  extern volatile __xdata struct ao_fifo	ao_serial0_rx_fifo; @@ -30,6 +31,9 @@ extern volatile __xdata struct ao_fifo	ao_serial0_tx_fifo;  char  ao_serial0_getchar(void); +int +ao_serial0_pollchar(void); +  void  ao_serial0_putchar(char c); @@ -47,7 +51,7 @@ extern volatile __xdata struct ao_fifo	ao_serial1_tx_fifo;  char  ao_serial1_getchar(void); -char +int  ao_serial1_pollchar(void);  void @@ -67,7 +71,7 @@ extern volatile __xdata struct ao_fifo	ao_serial2_tx_fifo;  char  ao_serial2_getchar(void); -char +int  ao_serial2_pollchar(void);  void @@ -80,6 +84,26 @@ void  ao_serial2_set_speed(uint8_t speed);  #endif +#if HAS_SERIAL_3 +extern volatile __xdata struct ao_fifo	ao_serial3_rx_fifo; +extern volatile __xdata struct ao_fifo	ao_serial3_tx_fifo; + +char +ao_serial3_getchar(void); + +int +ao_serial3_pollchar(void); + +void +ao_serial3_putchar(char c); + +void +ao_serial3_drain(void); + +void +ao_serial3_set_speed(uint8_t speed); +#endif +  void  ao_serial_init(void); diff --git a/src/core/ao_stdio.c b/src/core/ao_stdio.c index 8cf66a23..1748dfe8 100644 --- a/src/core/ao_stdio.c +++ b/src/core/ao_stdio.c @@ -98,7 +98,7 @@ __xdata uint8_t ao_stdin_ready;  char  getchar(void) __reentrant  { -	char c; +	int c;  	ao_arch_critical(  		int8_t stdio = ao_cur_stdio; @@ -123,7 +123,7 @@ ao_echo(void)  }  int8_t -ao_add_stdio(char (*pollchar)(void), +ao_add_stdio(int (*pollchar)(void),  	     void (*putchar)(char),  	     void (*flush)(void)) __reentrant  { diff --git a/src/core/ao_task.c b/src/core/ao_task.c index 0411fbdd..9cb074b5 100644 --- a/src/core/ao_task.c +++ b/src/core/ao_task.c @@ -305,6 +305,8 @@ ao_add_task(__xdata struct ao_task * task, void (*start)(void), __code char *nam  		);  } +__data uint8_t	ao_task_minimize_latency; +  /* Task switching function. This must not use any stack variables */  void  ao_yield(void) ao_arch_naked_define @@ -331,7 +333,12 @@ ao_yield(void) ao_arch_naked_define  	}  	ao_arch_isr_stack(); -	ao_arch_block_interrupts(); +#if !HAS_TASK_QUEUE +	if (ao_task_minimize_latency) +		ao_arch_release_interrupts(); +	else +#endif +		ao_arch_block_interrupts();  #if AO_CHECK_STACK  	in_yield = 1; @@ -374,7 +381,7 @@ ao_yield(void) ao_arch_naked_define  				break;  			/* Wait for interrupts when there's nothing ready */ -			if (ao_cur_task_index == ao_last_task_index) +			if (ao_cur_task_index == ao_last_task_index && !ao_task_minimize_latency)  				ao_arch_wait_interrupt();  		}  	} diff --git a/src/core/ao_task.h b/src/core/ao_task.h index 049f69a7..50bfb220 100644 --- a/src/core/ao_task.h +++ b/src/core/ao_task.h @@ -47,6 +47,7 @@ struct ao_task {  extern __xdata struct ao_task * __xdata ao_tasks[AO_NUM_TASKS];  extern __data uint8_t ao_num_tasks;  extern __xdata struct ao_task *__data ao_cur_task; +extern __data uint8_t ao_task_minimize_latency;	/* Reduce IRQ latency */  /*   ao_task.c diff --git a/src/core/ao_usb.h b/src/core/ao_usb.h index e051db93..4476ee6b 100644 --- a/src/core/ao_usb.h +++ b/src/core/ao_usb.h @@ -33,7 +33,7 @@ ao_usb_getchar(void);  /* Poll for a charcter on the USB input queue.   * returns AO_READ_AGAIN if none are available   */ -char +int  ao_usb_pollchar(void);  /* Flush the USB output queue */ | 
