diff options
| author | Keith Packard <keithp@keithp.com> | 2015-02-14 08:35:47 -0800 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2015-02-14 08:35:47 -0800 | 
| commit | 9c75faf1ec51eb2f9a8dc9402653490143a784d9 (patch) | |
| tree | c8edadbcdd3b8f3f4f5b11ba2ccb7a79226a182c | |
| parent | cc64e0e9d35e01b349680159a5bbd68d059134cd (diff) | |
altos: embed ao_alarm and ao_clear_alarm in ao_sleep_for
sdcc won't embed these itself, and thus consumes too much flash for
telemetrum-v1.0
Signed-off-by: Keith Packard <keithp@keithp.com>
| -rw-r--r-- | src/kernel/ao_task.c | 54 | 
1 files changed, 22 insertions, 32 deletions
| diff --git a/src/kernel/ao_task.c b/src/kernel/ao_task.c index 1ecdd7dd..55e423bb 100644 --- a/src/kernel/ao_task.c +++ b/src/kernel/ao_task.c @@ -450,48 +450,38 @@ ao_wakeup(__xdata void *wchan) __reentrant  	ao_check_stack();  } -static void -ao_alarm(uint16_t delay) +uint8_t +ao_sleep_for(__xdata void *wchan, uint16_t timeout)  { +	uint8_t	ret; +	if (timeout) {  #if HAS_TASK_QUEUE -	uint32_t flags; -	/* Make sure we sleep *at least* delay ticks, which means adding -	 * one to account for the fact that we may be close to the next tick -	 */ -	flags = ao_arch_irqsave(); +		uint32_t flags; +		/* Make sure we sleep *at least* delay ticks, which means adding +		 * one to account for the fact that we may be close to the next tick +		 */ +		flags = ao_arch_irqsave();  #endif -	if (!(ao_cur_task->alarm = ao_time() + delay + 1)) -		ao_cur_task->alarm = 1; +		if (!(ao_cur_task->alarm = ao_time() + timeout + 1)) +			ao_cur_task->alarm = 1;  #if HAS_TASK_QUEUE -	ao_task_to_alarm_queue(ao_cur_task); -	ao_arch_irqrestore(flags); +		ao_task_to_alarm_queue(ao_cur_task); +		ao_arch_irqrestore(flags);  #endif -} - -static void -ao_clear_alarm(void) -{ +	} +	ret = ao_sleep(wchan); +	if (timeout) {  #if HAS_TASK_QUEUE -	uint32_t flags; +		uint32_t flags; -	flags = ao_arch_irqsave(); +		flags = ao_arch_irqsave();  #endif -	ao_cur_task->alarm = 0; +		ao_cur_task->alarm = 0;  #if HAS_TASK_QUEUE -	ao_task_from_alarm_queue(ao_cur_task); -	ao_arch_irqrestore(flags); +		ao_task_from_alarm_queue(ao_cur_task); +		ao_arch_irqrestore(flags);  #endif -} - -uint8_t -ao_sleep_for(__xdata void *wchan, uint16_t timeout) -{ -	uint8_t	ret; -	if (timeout) -		ao_alarm(timeout); -	ret = ao_sleep(wchan); -	if (timeout) -		ao_clear_alarm(); +	}  	return ret;  } | 
