/* ******************* ******************************* C HEADER FILE ******************************* ** ******************* ** ** ** ** project : The C Kernel ** ** filename : CKTIMER.H ** ** version : 2 ** ** last revised : August 22, 2004 ** ** ** ***************************************************************************** ** ** ** Copyright (c) 1998-2004, P.K. van der Vlugt ** ** All rights reserved. ** ** ** ***************************************************************************** Timer Resource module. VERSION HISTORY: ---------------- Version : 1 Date : June 01, 2003 Revised by : P.K. van der Vlugt Description : Original version Version : 2 Date : August 22, 2004 Revised by : P.K. van der Vlugt Description : * Changed module name to comply to new kernel module naming convention. */ #ifndef _CKTIMER_INCLUDED #define _CKTIMER_INCLUDED /****************************************************************************/ /** **/ /** MODULES USED **/ /** **/ /****************************************************************************/ #include "ckconfig.h" /****************************************************************************/ /** **/ /** DEFINITIONS AND MACROS **/ /** **/ /****************************************************************************/ /**** Head of timer queue ****/ #define HEAD (NR_OF_TIMERS) /**** Timer queue macro's ****/ #define FirstTimerId() (TimerQ[HEAD].qnext) #define NonEmptyTimerQ() (TimerQ[HEAD].qnext < NR_OF_TIMERS) /****************************************************************************/ /** **/ /** TYPEDEFS AND STRUCTURES **/ /** **/ /****************************************************************************/ typedef struct { bool req; bool running; int32u count; int32u reload; int8u sid; } TimerType; /****************************************************************************/ /** **/ /** EXPORTED VARIABLES **/ /** **/ /****************************************************************************/ #ifndef _CKTIMER_C_SRC #if NR_OF_TIMERS > 0 extern TimerType Timer[NR_OF_TIMERS]; extern QueueType TimerQ[NR_OF_TIMERS + 2]; #endif #endif /****************************************************************************/ /** **/ /** EXPORTED FUNCTIONS **/ /** **/ /****************************************************************************/ /****************************************************************************/ void TimerInit (void); /****************************************************************************/ /* * Initializes all resources in this module. This function must be called * before any other functions of this module are used. */ /****************************************************************************/ int8u TimerAlloc (void); /****************************************************************************/ /* * This function requests one of the available resources. If a resource * is available, the resource id will be returned. If there are no more * resources avaliable, NR_OF_TIMERS will be returned to indicate the * error situation. Other errors also return NR_OF_TIMERS. */ /****************************************************************************/ void TimerFree (int8u id); /****************************************************************************/ /* * This function releases the specified resource id when it is a valid id. * The resource is set back to the initial state. */ /****************************************************************************/ void InsertDeltaTimer (int8u id); /****************************************************************************/ /* * This function inserts a timer in the TimerQ delta-list according to the * count value in the timer structure. */ /****************************************************************************/ void DeleteDeltaTimer (int8u id); /****************************************************************************/ /* * This function deletes a timer from the TimerQ delta-list. The remaining * count is restored. */ /****************************************************************************/ int8u GetFirstTimer (void); /****************************************************************************/ /* * This function removes a timer from the head of the TimerQ delta-list. */ #endif /****************************************************************************/ /** **/ /** EOF **/ /** **/ /****************************************************************************/