Microchip® Advanced Software Framework

timer.c File Reference
#include <stdint.h>
#include <rtc.h>
#include <intc.h>
#include <ports/avr32/timer.h>
#include "lwip/init.h"
#include "lwip/sys.h"

Data Structures

struct  timeout_t
 
struct  timer_t
 

Macros

#define ARRAY_SIZE(a)   sizeof(a) / sizeof(a[0])
 

Functions

static void irq_handler (void)
 
U32 sys_now (void)
 Returns the current time in milliseconds, may be the same as sys_jiffies or at least based on it. More...
 
void timer_cancel_timeout (U32 id)
 
void timer_delay (U32 ms)
 
U32 timer_get_ms (void)
 
void timer_init (void(*tick_isr)(void *ctx), void *ctx)
 
int timer_interval_passed (U32 old, U32 new, U32 diff)
 
U32 timer_mod (U32 id, U32 ms, U8 type, void(*cb)(void *ctx), void *ctx)
 
void timer_poll (void)
 Called from application main loop to invoke any scheduled timeout cbs. More...
 
static U32 timer_sched_timeout (U32 ms, U8 type)
 
U32 timer_sched_timeout_cb (U32 ms, U8 type, void(*cb)(void *ctx), void *ctx)
 

Variables

static struct timer_t TIMER
 

#define ARRAY_SIZE (   a)    sizeof(a) / sizeof(a[0])

static void irq_handler ( void  )
static

References timer_t::ctx, timer_t::tick, timer_t::tick_isr, and TIMER.

Referenced by timer_init().

U32 sys_now ( void  )

Returns the current time in milliseconds, may be the same as sys_jiffies or at least based on it.

Returns the current time in milliseconds.

References timer_get_ms().

void timer_cancel_timeout ( U32  id)

References timeout_t::expired, timer_t::timeout, and TIMER.

Referenced by timer_mod(), and ttcp_destroy().

void timer_delay ( U32  ms)
int timer_interval_passed ( U32  old,
U32  new,
U32  diff 
)
U32 timer_mod ( U32  id,
U32  ms,
U8  type,
void(*)(void *ctx cb,
void *  ctx 
)
void timer_poll ( void  )

Called from application main loop to invoke any scheduled timeout cbs.

This function might be called as often as possible rather than at each tick to support the timeout value '0', e.g a timeout within less than one tick.

References ARRAY_SIZE, timeout_t::cb, timeout_t::ctx, timeout_t::expire_at_tick, timeout_t::expired, i, timeout_t::tick, timer_t::tick, timer_t::timeout, TIMEOUT_PERIODIC, TIMER, and timeout_t::type.

Referenced by main(), and poll().

U32 timer_sched_timeout_cb ( U32  ms,
U8  type,
void(*)(void *ctx cb,
void *  ctx 
)

struct timer_t TIMER
static
Initial value:
= {
.tick = 0,
.MS_PER_TICK = TIMER_HZ,
.timeout = { { 0 } },
}
#define TIMER_HZ
Definition: timer.h:51

Referenced by irq_handler(), timer_cancel_timeout(), timer_delay(), timer_get_ms(), timer_init(), timer_mod(), timer_poll(), timer_sched_timeout(), and timer_sched_timeout_cb().