altos: Make sure pa to altitude conversion is done with 32 bits
[fw/altos] / src / core / ao_task.h
index 18edd8669e58241019c9a6ccb18f0d345fdb38fd..049f69a7c2fb121d2dbdffd2564d7bb8f989fe4e 100644 (file)
@@ -17,6 +17,9 @@
 
 #ifndef _AO_TASK_H_
 #define _AO_TASK_H_
+#if HAS_TASK_QUEUE
+#include <ao_list.h>
+#endif
 
 /* An AltOS task */
 struct ao_task {
@@ -25,14 +28,26 @@ struct ao_task {
        ao_arch_task_members            /* any architecture-specific fields */
        uint8_t task_id;                /* unique id */
        __code char *name;              /* task name */
+#if HAS_TASK_QUEUE
+       struct ao_list  queue;
+       struct ao_list  alarm_queue;
+#endif
        uint8_t stack[AO_STACK_SIZE];   /* saved stack */
+#if HAS_SAMPLE_PROFILE
+       uint32_t ticks;
+       uint32_t yields;
+       uint16_t start;
+       uint16_t max_run;
+#endif
 };
 
-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 */
 
+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;
+
 /*
  ao_task.c
  */
@@ -65,6 +80,13 @@ ao_yield(void) ao_arch_naked_declare;
 void
 ao_add_task(__xdata struct ao_task * task, void (*start)(void), __code char *name) __reentrant;
 
+#if HAS_TASK_QUEUE
+/* Called on timer interrupt to check alarms */
+extern uint16_t        ao_task_alarm_tick;
+void
+ao_task_check_alarm(uint16_t tick);
+#endif
+
 /* Terminate the current task */
 void
 ao_exit(void);
@@ -77,4 +99,11 @@ ao_task_info(void);
 void
 ao_start_scheduler(void);
 
+#if HAS_TASK_QUEUE
+void
+ao_task_init(void);
+#else
+#define ao_task_init()
+#endif
+
 #endif