Atmel Software Framework

timeout.h File Reference

Timeout service for XMEGA.

Copyright (C) 2011-2015 Atmel Corporation. All rights reserved.

#include <compiler.h>
#include <asf.h>
#include "conf_timeout.h"

Macros

#define TIMEOUT_COMP   TIMEOUT_CLOCK_SOURCE_HZ / TIMEOUT_TICK_HZ
 

Typedefs

typedef uint8_t timeout_id_t
 Timeout identifier. More...
 

Functions

void timeout_init (void)
 Initialize timeout. More...
 
void timeout_start_offset (timeout_id_t id, uint16_t period, uint16_t start_offset)
 Start periodic timeout with a specific start timeout. More...
 
void timeout_start_periodic (timeout_id_t id, uint16_t period)
 Start periodic timeout. More...
 
void timeout_start_singleshot (timeout_id_t id, uint16_t timeout)
 Start singleshot timeout. More...
 
void timeout_stop (timeout_id_t id)
 Stop running timeout. More...
 
bool timeout_test_and_clear_expired (timeout_id_t id)
 Test and clear expired flag for running timeout. More...
 

#define TIMEOUT_COMP   TIMEOUT_CLOCK_SOURCE_HZ / TIMEOUT_TICK_HZ

Referenced by tick_handler(), and timeout_init().

typedef uint8_t timeout_id_t

Timeout identifier.

Index for timeout channel to use. Limited by max value configured with TIMEOUT_COUNT.

void timeout_init ( void  )

Initialize timeout.

Initializes timeout counter for desired tick rate and starts it. The device interrupt controller should be initialized prior to calling this function, and global interrupts must be enabled.

Note
If the service is configured to use the asynchronous RTC32 module, there are restrictions on the timeout period that can be used - see to Minimum allowed alarm time for details.

References rtc_init(), rtc_set_alarm(), rtc_set_callback(), rtc_set_time(), tick_handler(), and TIMEOUT_COMP.

Referenced by main().

void timeout_start_offset ( timeout_id_t  id,
uint16_t  period,
uint16_t  offset 
)

Start periodic timeout with a specific start timeout.

Parameters
idtimeout_id_t
periodTime period in number of ticks
offsetTime to first timeout in number of ticks

References timeout_struct::count, cpu_irq_restore(), cpu_irq_save(), timeout_struct::period, timeout_active, timeout_array, and timeout_expired.

Referenced by timeout_start_periodic(), and timeout_start_singleshot().

void timeout_start_periodic ( timeout_id_t  id,
uint16_t  period 
)

Start periodic timeout.

Parameters
idtimeout_id_t
periodTime period in number of ticks

References timeout_start_offset().

Referenced by main().

void timeout_start_singleshot ( timeout_id_t  id,
uint16_t  timeout 
)

Start singleshot timeout.

Parameters
idtimeout_id_t
timeoutTimeout in number of ticks

References timeout_start_offset().

Referenced by main().

void timeout_stop ( timeout_id_t  id)

Stop running timeout.

Parameters
idtimeout_id_t

References cpu_irq_restore(), cpu_irq_save(), and timeout_active.

bool timeout_test_and_clear_expired ( timeout_id_t  id)

Test and clear expired flag for running timeout.

Parameters
idtimeout_id_t
Return values
trueTimer have expired; clearing expired flag
falseTimer still running

References cpu_irq_restore(), cpu_irq_save(), and timeout_expired.

Referenced by main().