drivers/service/MicoTimerService.h

Fri, 13 Aug 2010 10:49:23 +0100

author
Philip Pemberton <philpem@philpem.me.uk>
date
Fri, 13 Aug 2010 10:49:23 +0100
changeset 0
396b0bd970d3
permissions
-rw-r--r--

Initial import, Timer v3.0

     1 /****************************************************************************
     2 **
     3 **  Name: MicoTimerService.h
     4 **
     5 **  Description:
     6 **        Implements timer service functionality:
     7 **               -- registering a timer as a system timer (64-bit)
     8 **                  and retrieving the system tick
     9 **
    10 **               -- registering a timer as a "lookup-able" device
    11 **                  (user does not have to work with these functions)                  
    12 **
    13 **  $Revision: $
    14 **
    15 ** Disclaimer:
    16 **
    17 **   This source code is intended as a design reference which
    18 **   illustrates how these types of functions can be implemented.  It
    19 **   is the user's responsibility to verify their design for
    20 **   consistency and functionality through the use of formal
    21 **   verification methods.  Lattice Semiconductor provides no warranty
    22 **   regarding the use or functionality of this code.
    23 **
    24 ** --------------------------------------------------------------------
    25 **
    26 **                     Lattice Semiconductor Corporation
    27 **                     5555 NE Moore Court
    28 **                     Hillsboro, OR 97214
    29 **                     U.S.A
    30 **
    31 **                     TEL: 1-800-Lattice (USA and Canada)
    32 **                          (503)268-8001 (other locations)
    33 **
    34 **                     web:   http://www.latticesemi.com
    35 **                     email: techsupport@latticesemi.com
    36 **
    37 ** --------------------------------------------------------------------------
    38 **
    39 **  Change History (Latest changes on top)
    40 **
    41 **  Ver    Date        Description
    42 ** --------------------------------------------------------------------------
    43 **
    44 **  3.0   Mar-25-2008  Added Header
    45 **
    46 **---------------------------------------------------------------------------
    47 *****************************************************************************/
    50 #ifndef MICO32_TIMERSERVICE_HEADER_FILE
    51 #define MICO32_TIMERSERVICE_HEADER_FILE
    53 #include "MicoTypes.h"
    54 #include "MicoTimer.h"
    57 #ifdef __cplusplus
    58 extern "C"
    59 {
    60 #endif /* __cplusplus */
    63 /******************************************************************************
    64  * Data Structures/types                                                      *
    65  ******************************************************************************/
    66 typedef void (* MicoSysTimerActivity_t) ( void *);
    70 /******************************************************************************
    71  * functions                                                                  *
    72  ******************************************************************************/
    74 /* 
    75  * Registers system-tick periodic activity
    76  *  Arguments;
    77  *      MicoSysTimerActivity_t: activity function pointer as described
    78  *      by the prototype.
    79  *      void *ctx: pointer to user-data that will be passed back on
    80  *      system-tick.
    81  */
    82 void MicoRegisterActivity(MicoSysTimerActivity_t activity, void *ctx);
    85 /* 
    86  * Retrieves 64-bit tick count, if a system-timer is registered.
    87  * Else, it returns 0.
    88  */
    89 void MicoGetCPUTicks(unsigned long long int *ticks);
    92 /* 
    93  * Registers system-timer if one isn't already registered.  Once registered,
    94  * you cannot register some other timer as a the system timer.  You can
    95  * always stop the timer using LatticeMico32 device-driver routine
    96  * and bring the system-timer to a halt.
    97  *  Arguments:
    98  *      MicoTimerCtx_t *ctx: LatticeMico32 Timer instance information
    99  *      structure (context) that should be used as the system timer.
   100  *      unsigned int TickInMS: system-tick value in milli-seconds.
   101  *  Return Value:
   102  *      MicoTimerCtx_t *: LatticeMico32 timer instance information structure
   103  *      of the timer being used as the system-timer.  If there is no system
   104  *      timer, it returns 0.
   105  */
   106 MicoTimerCtx_t* RegisterSystemTimer(MicoTimerCtx_t *ctx, unsigned int TickInMS);
   110 #ifdef __cplusplus
   111 };
   112 #endif /* __cplusplus */
   115 #endif