//! \file timer.h
//! \author tkl
//! \date Jul 4, 2012
//! \brief Header file of the architecture independent timer implementation.
#ifndef TIMER_H_
#define TIMER_H_

typedef int (*timer_fp_open_t)(const void*);		//!< callback for the open function of the arch depended timer driver.
typedef int (*timer_fp_close_t)(const void*);		//!< callback for the close function of the arch depended timer driver.
typedef int (*timer_fp_set_cb_t)(const void*, const void *, const void *);	//!< callback for set_callback function of the arch depended timer driver.

//! \brief The access function pointer for the timer.
struct timer_fp {
	const timer_fp_open_t		open;	//!< Function pointer to the open function.
	const timer_fp_close_t		close;	//!< Function pointer to the close function.
	const timer_fp_set_cb_t		set_cb;	//!< Function pointer to the set_callback function.
};

//! \brief Contains the architecture depended device informations.
struct loki_timer {
	const void  *arch_dep_device;	//!< Architecture depended timer device (i.e. msp430_timer).
	const struct timer_fp *fp;		//!< Function pointer to the architectur depended timer driver access.
};

//! \brief Open a timer timer
//! \param device The timer device to open.
//! \retval -1 in error case.
int timer_open(const struct loki_timer *device);

//! \brief Close a timer timer
//! \param device The timer device to close.
//! \retval -1 in error case.
int timer_close(const struct loki_timer *device);

//! \brief Set the callback for a sys tick timer
//! \param device The timer device to set the callback for.
//! \param callback The function pointer to call back.
//! \param param The parameter for the call back.
//! \retval -1 in error case.
int timer_set_it_callback(const struct loki_timer *device, const void *callback,
		const void *param);

#endif /* TIMER_H_ */
