diff options
| author | Keith Packard <keithp@keithp.com> | 2009-04-14 11:04:09 -0700 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2009-04-14 11:04:09 -0700 | 
| commit | fbd8f4aff5058f4d371596b04715b7cb6d38e729 (patch) | |
| tree | 3dd414019ae882e0a73576c17e351c7075de5861 | |
| parent | fb63262699d3a6fbf347d24efda8b01f75b7d0d3 (diff) | |
Switch from --model-large to --model-small
This shrinks the application quite a bit, and should make it faster as well.
Signed-off-by: Keith Packard <keithp@keithp.com>
| -rw-r--r-- | Makefile | 12 | ||||
| -rw-r--r-- | ao.h | 11 | ||||
| -rw-r--r-- | ao_main.c | 34 | ||||
| -rw-r--r-- | ao_task.c | 9 | ||||
| -rw-r--r-- | ao_test.c | 20 | ||||
| -rw-r--r-- | ao_usb.c | 29 | 
6 files changed, 72 insertions, 43 deletions
| @@ -4,14 +4,9 @@ NO_OPT=--nogcse --noinvariant --noinduction --nojtbound --noloopreverse \  	--nolabelopt --nooverlay --peep-asm  DEBUG=--debug -CFLAGS=--model-large $(DEBUG) --less-pedantic \ -	--no-peep --int-long-reent --float-reent \ +CFLAGS=--model-small $(DEBUG) --less-pedantic  LDFLAGS=--out-fmt-ihx -LDFLAGS_RAM=$(LDFLAGS) --code-loc 0xf000 --code-size 0x800 \ -	--xram-loc 0xf800 --xram-size 0x700 --iram-size 0xff - -  LDFLAGS_FLASH=$(LDFLAGS) --code-loc 0x0000 --code-size 0x8000 \  	--xram-loc 0xf000 --xram-size 0xf00 --iram-size 0xff @@ -22,12 +17,13 @@ INC = \  SRC = \  	ao_adc.c \  	ao_beep.c \ +	ao_cmd.c \  	ao_led.c \ +	ao_panic.c \  	ao_task.c \  	ao_timer.c \  	ao_usb.c \ -	ao_panic.c \ -	ao_test.c \ +	ao_main.c \  	_bp.c  ADB=$(SRC:.c=.adb) @@ -29,7 +29,7 @@  /* Stack runs from above the allocated __data space to 0xfe, which avoids   * writing to 0xff as that triggers the stack overflow indicator   */ -#define AO_STACK_START	0x28 +#define AO_STACK_START	0x4b  #define AO_STACK_END	0xfe  #define AO_STACK_SIZE	(AO_STACK_END - AO_STACK_START + 1) @@ -42,9 +42,6 @@ struct ao_task {  #define AO_NUM_TASKS		10	/* maximum number of tasks */ -#define ao_interrupt_disable()	(EA = 0) -#define ao_interrupt_enable()	(EA = 1) -  /*   ao_task.c   */ @@ -254,4 +251,10 @@ ao_usb_isr(void) interrupt 6;  void  ao_usb_init(void); +/* + * ao_cmd.c + */ +void +ao_cmd_init(void); +  #endif /* _AO_H_ */ diff --git a/ao_main.c b/ao_main.c new file mode 100644 index 00000000..2cf6c80d --- /dev/null +++ b/ao_main.c @@ -0,0 +1,34 @@ +/* + * Copyright © 2009 Keith Packard <keithp@keithp.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" + +void +main(void) +{ +	CLKCON = 0; +	while (!(SLEEP & SLEEP_XOSC_STB)) +		; + +	ao_timer_init(); +	ao_adc_init(); +	ao_beep_init(); +	ao_led_init(); +	ao_usb_init(); +	ao_cmd_init(); +	ao_start_scheduler(); +} @@ -162,9 +162,9 @@ ao_yield(void) _naked  int  ao_sleep(__xdata void *wchan)  { -	ao_interrupt_disable(); +	__critical {  	ao_cur_task->wchan = wchan; -	ao_interrupt_enable(); +	}  	ao_yield();  } @@ -181,11 +181,6 @@ ao_wakeup(__xdata void *wchan)  void  ao_start_scheduler(void)  { -	ao_timer_init(); -	ao_adc_init(); -	ao_beep_init(); -	ao_led_init(); -	ao_usb_init();  	ao_cur_task_id = AO_NO_TASK;  	ao_cur_task = NULL; @@ -50,7 +50,7 @@ blink_0(void)  void  blink_1(void)  { -	static struct ao_adc adc; +	static __xdata struct ao_adc adc;  	for (;;) {  		ao_sleep(&ao_adc_ring); @@ -74,7 +74,7 @@ wakeup(void)  void  beep(void)  { -	static struct ao_adc adc; +	static __xdata struct ao_adc adc;  	for (;;) {  		ao_delay(AO_SEC_TO_TICKS(1)); @@ -89,11 +89,11 @@ echo(void)  {  	uint8_t	c;  	for (;;) { +		ao_usb_flush();  		c = ao_usb_getchar();  		ao_usb_putchar(c);  		if (c == '\r')  			ao_usb_putchar('\n'); -		ao_usb_flush();  	}  } @@ -104,10 +104,16 @@ main(void)  	while (!(SLEEP & SLEEP_XOSC_STB))  		; -	ao_add_task(&blink_0_task, blink_0); -	ao_add_task(&blink_1_task, blink_1); -	ao_add_task(&wakeup_task, wakeup); -	ao_add_task(&beep_task, beep); +//	ao_add_task(&blink_0_task, blink_0); +//	ao_add_task(&blink_1_task, blink_1); +//	ao_add_task(&wakeup_task, wakeup); +//	ao_add_task(&beep_task, beep);  	ao_add_task(&echo_task, echo); +	ao_timer_init(); +	ao_adc_init(); +	ao_beep_init(); +	ao_led_init(); +	ao_usb_init(); +	  	ao_start_scheduler();  } @@ -32,8 +32,8 @@ struct ao_task __xdata ao_usb_task;  #define AO_USB_IN_SIZE		256  #define AO_USB_OUT_SIZE		128 -static uint16_t	ao_usb_in_bytes; -static uint16_t	ao_usb_out_bytes; +static __xdata uint16_t	ao_usb_in_bytes; +static __xdata uint16_t	ao_usb_out_bytes;  static __data uint8_t	ao_usb_iif;  static __data uint8_t	ao_usb_oif; @@ -65,7 +65,7 @@ struct ao_usb_setup {  	uint16_t	value;  	uint16_t	index;  	uint16_t	length; -} ao_usb_setup; +} __xdata ao_usb_setup;  __data uint8_t ao_usb_ep0_state;  uint8_t * __data ao_usb_ep0_in_data; @@ -421,15 +421,13 @@ ao_usb_ep0(void)  	ao_usb_ep0_state = AO_USB_EP0_IDLE;  	for (;;) { -		ao_interrupt_disable(); -		for (;;) { +		__critical for (;;) {  			if (ao_usb_iif & 1) {  				ao_usb_iif &= ~1;  				break;  			}  			ao_sleep(&ao_usb_task);  		} -		ao_interrupt_enable();  		USBINDEX = 0;  		cs0 = USBCS0;  		if (cs0 & USBCS0_SETUP_END) { @@ -466,21 +464,18 @@ ao_usb_ep0(void)  }  void -ao_usb_flush(void) +ao_usb_flush(void) __critical  { -	ao_interrupt_disable();  	if (ao_usb_in_bytes) {  		USBINDEX = AO_USB_IN_EP;  		USBCSIL |= USBCSIL_INPKT_RDY;  		ao_usb_in_bytes = 0;  	} -	ao_interrupt_enable();  }  void -ao_usb_putchar(uint8_t c) +ao_usb_putchar(uint8_t c) __critical  { -	ao_interrupt_disable();  	for (;;) {  		USBINDEX = AO_USB_IN_EP;  		if ((USBCSIL & USBCSIL_INPKT_RDY) == 0) @@ -488,16 +483,17 @@ ao_usb_putchar(uint8_t c)  		ao_sleep(&ao_usb_in_bytes);  	}  	USBFIFO[AO_USB_IN_EP << 1] = c; -	if (++ao_usb_in_bytes == AO_USB_IN_SIZE) -		ao_usb_flush(); -	ao_interrupt_enable(); +	if (++ao_usb_in_bytes == AO_USB_IN_SIZE) { +		USBINDEX = AO_USB_IN_EP; +		USBCSIL |= USBCSIL_INPKT_RDY; +		ao_usb_in_bytes = 0; +	}  }  uint8_t -ao_usb_getchar(void) +ao_usb_getchar(void) __critical  {  	uint8_t	c; -	ao_interrupt_disable();  	while (ao_usb_out_bytes == 0) {  		for (;;) {  			USBINDEX = AO_USB_OUT_EP; @@ -513,7 +509,6 @@ ao_usb_getchar(void)  		USBINDEX = AO_USB_OUT_EP;  		USBCSOL &= ~USBCSOL_OUTPKT_RDY;  	} -	ao_interrupt_enable();  	return c;  } | 
