From a07b8ba166e05e7d1722c59651ef00e9fb7580d5 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 12 Oct 2012 13:31:17 -0700 Subject: altos: Split task definitions out to ao_task.h And only include them if using tasks Signed-off-by: Keith Packard --- src/core/ao.h | 63 ++++++----------------------------------------------------- 1 file changed, 6 insertions(+), 57 deletions(-) (limited to 'src/core/ao.h') diff --git a/src/core/ao.h b/src/core/ao.h index 31ec4686..711b3533 100644 --- a/src/core/ao.h +++ b/src/core/ao.h @@ -39,64 +39,13 @@ #define CODE_TO_XDATA(a) (a) #endif -/* An AltOS task */ -struct ao_task { - __xdata void *wchan; /* current wait channel (NULL if running) */ - uint16_t alarm; /* abort ao_sleep time */ - ao_arch_task_members /* any architecture-specific fields */ - uint8_t task_id; /* unique id */ - __code char *name; /* task name */ - uint8_t stack[AO_STACK_SIZE]; /* saved stack */ -}; - -extern __xdata struct ao_task *__data ao_cur_task; - -#define AO_NUM_TASKS 16 /* maximum number of tasks */ -#define AO_NO_TASK 0 /* no task id */ - -/* - ao_task.c - */ - -/* Suspend the current task until wchan is awoken. - * returns: - * 0 on normal wake - * 1 on alarm - */ -uint8_t -ao_sleep(__xdata void *wchan); - -/* Wake all tasks sleeping on wchan */ -void -ao_wakeup(__xdata void *wchan); - -/* set an alarm to go off in 'delay' ticks */ -void -ao_alarm(uint16_t delay); - -/* Clear any pending alarm */ -void -ao_clear_alarm(void); - -/* Yield the processor to another task */ -void -ao_yield(void) ao_arch_naked_declare; - -/* Add a task to the run queue */ -void -ao_add_task(__xdata struct ao_task * task, void (*start)(void), __code char *name) __reentrant; - -/* Terminate the current task */ -void -ao_exit(void); - -/* Dump task info to console */ -void -ao_task_info(void); +#ifndef HAS_TASK +#define HAS_TASK 1 +#endif -/* Start the scheduler. This will not return */ -void -ao_start_scheduler(void); +#if HAS_TASK +#include +#endif /* * ao_panic.c -- cgit v1.2.3 From 6a3ee911353291b04e161d50a181ed4211d467a2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 12 Oct 2012 13:54:37 -0700 Subject: altos: Allow projects to specify clock at other than 100Hz Leave the default at 100Hz, but allow it to be overridden Signed-off-by: Keith Packard --- src/core/ao.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core/ao.h') diff --git a/src/core/ao.h b/src/core/ao.h index 711b3533..9d801489 100644 --- a/src/core/ao.h +++ b/src/core/ao.h @@ -85,7 +85,9 @@ ao_panic(uint8_t reason); extern volatile __data AO_TICK_TYPE ao_tick_count; /* Our timer runs at 100Hz */ +#ifndef AO_HERTZ #define AO_HERTZ 100 +#endif #define AO_MS_TO_TICKS(ms) ((ms) / (1000 / AO_HERTZ)) #define AO_SEC_TO_TICKS(s) ((s) * AO_HERTZ) -- cgit v1.2.3 From be0a28ee7a6fbd98fc8113db8501bb791a112fa0 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 12 Oct 2012 13:55:33 -0700 Subject: altos: Allow for other mutex implementations Allow projects to replace ao_mutex_get and ao_mutex_put with macros Signed-off-by: Keith Packard --- src/core/ao.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/core/ao.h') diff --git a/src/core/ao.h b/src/core/ao.h index 9d801489..200d4bc4 100644 --- a/src/core/ao.h +++ b/src/core/ao.h @@ -119,11 +119,13 @@ ao_clock_init(void); * ao_mutex.c */ +#ifndef ao_mutex_get void ao_mutex_get(__xdata uint8_t *ao_mutex) __reentrant; void ao_mutex_put(__xdata uint8_t *ao_mutex) __reentrant; +#endif /* * ao_cmd.c -- cgit v1.2.3 From 175380a436efa35bbfae2ee5e29e12e9ef86fbde Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 12 Oct 2012 13:57:49 -0700 Subject: altos: Use alt_t for all Pascal-based altitude data This allows alt_t to be overridden for systems using the MS5607/MS5611 sensors Signed-off-by: Keith Packard --- src/core/ao.h | 6 ++++-- src/core/ao_convert_pa.c | 6 +++--- src/core/ao_convert_pa_test.c | 1 + src/core/ao_data.h | 11 ++++++++++- 4 files changed, 18 insertions(+), 6 deletions(-) (limited to 'src/core/ao.h') diff --git a/src/core/ao.h b/src/core/ao.h index 200d4bc4..e559e876 100644 --- a/src/core/ao.h +++ b/src/core/ao.h @@ -272,11 +272,13 @@ ao_temp_to_dC(int16_t temp) __reentrant; * Convert between pressure in Pa and altitude in meters */ -int32_t +#include + +alt_t ao_pa_to_altitude(int32_t pa); int32_t -ao_altitude_to_pa(int32_t alt); +ao_altitude_to_pa(alt_t alt); #if HAS_DBG #include diff --git a/src/core/ao_convert_pa.c b/src/core/ao_convert_pa.c index 0c93caea..1413681d 100644 --- a/src/core/ao_convert_pa.c +++ b/src/core/ao_convert_pa.c @@ -26,7 +26,7 @@ static const int32_t altitude_table[] = { #define ALT_SCALE (1 << ALT_SHIFT) #define ALT_MASK (ALT_SCALE - 1) -int32_t +alt_t ao_pa_to_altitude(int32_t pa) { int16_t o; @@ -40,8 +40,8 @@ ao_pa_to_altitude(int32_t pa) o = pa >> ALT_SHIFT; part = pa & ALT_MASK; - low = (int32_t) altitude_table[o] * (ALT_SCALE - part); - high = (int32_t) altitude_table[o+1] * part + (ALT_SCALE >> 1); + low = (alt_t) FETCH_ALT(o) * (ALT_SCALE - part); + high = (alt_t) FETCH_ALT(o+1) * part + (ALT_SCALE >> 1); return (low + high) >> ALT_SHIFT; } diff --git a/src/core/ao_convert_pa_test.c b/src/core/ao_convert_pa_test.c index 972a4d4c..143ce958 100644 --- a/src/core/ao_convert_pa_test.c +++ b/src/core/ao_convert_pa_test.c @@ -17,6 +17,7 @@ #include #define AO_CONVERT_TEST +typedef int32_t alt_t; #include "ao_host.h" #include "ao_convert_pa.c" diff --git a/src/core/ao_data.h b/src/core/ao_data.h index 2b9ef5ac..90182b12 100644 --- a/src/core/ao_data.h +++ b/src/core/ao_data.h @@ -110,7 +110,12 @@ extern volatile __data uint8_t ao_data_count; #define HAS_BARO 1 typedef int32_t pres_t; -typedef int32_t alt_t; + +#ifndef AO_ALT_TYPE +#define AO_ALT_TYPE int32_t +#endif + +typedef AO_ALT_TYPE alt_t; #define ao_data_pres_cook(packet) ao_ms5607_convert(&packet->ms5607_raw, &packet->ms5607_cooked) @@ -135,6 +140,10 @@ typedef int16_t alt_t; #endif +#if !HAS_BARO +typedef int16_t alt_t; +#endif + /* * Need a few macros to pull data from the sensors: * -- cgit v1.2.3