#define ao_mutex_put(m)
void
-ao_delay_until(uint16_t target);
+ao_delay_until(AO_TICK_TYPE target);
/* We can't hit 100 Hz, but we can hit 125 */
#define AO_HERTZ 125
AO_TICK_TYPE
ao_time(void)
{
- uint16_t r;
+ AO_TICK_TYPE r;
cli();
r = ao_tick_count;
}
void
-ao_delay_until(uint16_t target)
+ao_delay_until(AO_TICK_TYPE target)
{
cli();
ao_wakeup_count = target;
}
void
-ao_delay(uint16_t ticks)
+ao_delay(AO_TICK_TYPE ticks)
{
ao_delay_until(ao_time() + ticks);
}
typedef AO_PORT_TYPE ao_port_t;
+#ifndef AO_TICK_TYPE
+#define AO_TICK_TYPE uint32_t
+#define AO_TICK_SIGNED int32_t
+#endif
+
#if HAS_TASK
#include <ao_task.h>
#else
* ao_timer.c
*/
-#ifndef AO_TICK_TYPE
-#define AO_TICK_TYPE uint32_t
-#define AO_TICK_SIGNED int32_t
-#endif
-
extern volatile AO_TICK_TYPE ao_tick_count;
/* Our timer runs at 100Hz */
/* Suspend the current task until ticks time has passed */
void
-ao_delay(uint16_t ticks);
+ao_delay(AO_TICK_TYPE ticks);
/* Set the ADC interval */
void
/* Turn on the beeper for the specified time */
void
-ao_beep_for(uint8_t beep, uint16_t ticks);
+ao_beep_for(uint8_t beep, AO_TICK_TYPE ticks);
/* Initialize the beeper */
void
#if HAS_AO_DELAY
void
-ao_delay(uint16_t ticks)
+ao_delay(AO_TICK_TYPE ticks)
{
AO_TICK_TYPE target;
#define ao_task_validate_alarm_queue()
#endif
-uint16_t ao_task_alarm_tick;
+AO_TICK_TYPE ao_task_alarm_tick;
static void
ao_task_to_alarm_queue(struct ao_task *task)
}
void
-ao_task_check_alarm(uint16_t tick)
+ao_task_check_alarm(AO_TICK_TYPE tick)
{
struct ao_task *alarm, *next;
else
{
#if HAS_SAMPLE_PROFILE
- uint16_t tick = ao_sample_profile_timer_value();
- uint16_t run = tick - ao_cur_task->start;
+ AO_TICK_TYPE tick = ao_sample_profile_timer_value();
+ AO_TICK_TYPE run = tick - ao_cur_task->start;
if (run > ao_cur_task->max_run)
ao_cur_task->max_run = run;
++ao_cur_task->yields;
}
uint8_t
-ao_sleep_for(void *wchan, uint16_t timeout)
+ao_sleep_for(void *wchan, AO_TICK_TYPE timeout)
{
uint8_t ret;
if (timeout) {
static uint8_t ao_forever;
void
-ao_delay(uint16_t ticks)
+ao_delay(AO_TICK_TYPE ticks)
{
if (!ticks)
ticks = 1;
{
uint8_t i;
struct ao_task *task;
- uint16_t now = ao_time();
+ AO_TICK_TYPE now = ao_time();
for (i = 0; i < ao_num_tasks; i++) {
task = ao_tasks[i];
/* An AltOS task */
struct ao_task {
void *wchan; /* current wait channel (NULL if running) */
- uint16_t alarm; /* abort ao_sleep time */
+ AO_TICK_TYPE alarm; /* abort ao_sleep time */
uint16_t task_id; /* unique id */
/* Saved stack pointer */
union {
* 1 on alarm
*/
uint8_t
-ao_sleep_for(void *wchan, uint16_t timeout);
+ao_sleep_for(void *wchan, AO_TICK_TYPE timeout);
/* Wake all tasks sleeping on wchan */
void
#if 0
/* set an alarm to go off in 'delay' ticks */
void
-ao_alarm(uint16_t delay);
+ao_alarm(AO_TICK_TYPE delay);
/* Clear any pending alarm */
void
#if HAS_TASK_QUEUE
/* Called on timer interrupt to check alarms */
-extern uint16_t ao_task_alarm_tick;
+extern AO_TICK_TYPE ao_task_alarm_tick;
void
-ao_task_check_alarm(uint16_t tick);
+ao_task_check_alarm(AO_TICK_TYPE tick);
#endif
/* Terminate the current task */
}
void
-ao_beep_for(uint8_t beep, uint16_t ticks)
+ao_beep_for(uint8_t beep, AO_TICK_TYPE ticks)
{
ao_beep(beep);
ao_delay(ticks);
}
void
-ao_beep_for(uint8_t beep, uint16_t ticks)
+ao_beep_for(uint8_t beep, AO_TICK_TYPE ticks)
{
ao_beep(beep);
ao_delay(ticks);
}
void
-ao_beep_for(uint8_t beep, uint16_t ticks)
+ao_beep_for(uint8_t beep, AO_TICK_TYPE ticks)
{
ao_beep(beep);
ao_delay(ticks);