drivers/service/MicoTimerService.h

changeset 0
396b0bd970d3
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/drivers/service/MicoTimerService.h	Fri Aug 13 10:49:23 2010 +0100
     1.3 @@ -0,0 +1,116 @@
     1.4 +/****************************************************************************
     1.5 +**
     1.6 +**  Name: MicoTimerService.h
     1.7 +**
     1.8 +**  Description:
     1.9 +**        Implements timer service functionality:
    1.10 +**               -- registering a timer as a system timer (64-bit)
    1.11 +**                  and retrieving the system tick
    1.12 +**
    1.13 +**               -- registering a timer as a "lookup-able" device
    1.14 +**                  (user does not have to work with these functions)                  
    1.15 +**
    1.16 +**  $Revision: $
    1.17 +**
    1.18 +** Disclaimer:
    1.19 +**
    1.20 +**   This source code is intended as a design reference which
    1.21 +**   illustrates how these types of functions can be implemented.  It
    1.22 +**   is the user's responsibility to verify their design for
    1.23 +**   consistency and functionality through the use of formal
    1.24 +**   verification methods.  Lattice Semiconductor provides no warranty
    1.25 +**   regarding the use or functionality of this code.
    1.26 +**
    1.27 +** --------------------------------------------------------------------
    1.28 +**
    1.29 +**                     Lattice Semiconductor Corporation
    1.30 +**                     5555 NE Moore Court
    1.31 +**                     Hillsboro, OR 97214
    1.32 +**                     U.S.A
    1.33 +**
    1.34 +**                     TEL: 1-800-Lattice (USA and Canada)
    1.35 +**                          (503)268-8001 (other locations)
    1.36 +**
    1.37 +**                     web:   http://www.latticesemi.com
    1.38 +**                     email: techsupport@latticesemi.com
    1.39 +**
    1.40 +** --------------------------------------------------------------------------
    1.41 +**
    1.42 +**  Change History (Latest changes on top)
    1.43 +**
    1.44 +**  Ver    Date        Description
    1.45 +** --------------------------------------------------------------------------
    1.46 +**
    1.47 +**  3.0   Mar-25-2008  Added Header
    1.48 +**
    1.49 +**---------------------------------------------------------------------------
    1.50 +*****************************************************************************/
    1.51 +
    1.52 +
    1.53 +#ifndef MICO32_TIMERSERVICE_HEADER_FILE
    1.54 +#define MICO32_TIMERSERVICE_HEADER_FILE
    1.55 +
    1.56 +#include "MicoTypes.h"
    1.57 +#include "MicoTimer.h"
    1.58 +
    1.59 +
    1.60 +#ifdef __cplusplus
    1.61 +extern "C"
    1.62 +{
    1.63 +#endif /* __cplusplus */
    1.64 +
    1.65 +
    1.66 +/******************************************************************************
    1.67 + * Data Structures/types                                                      *
    1.68 + ******************************************************************************/
    1.69 +typedef void (* MicoSysTimerActivity_t) ( void *);
    1.70 +
    1.71 +
    1.72 +
    1.73 +/******************************************************************************
    1.74 + * functions                                                                  *
    1.75 + ******************************************************************************/
    1.76 +
    1.77 +/* 
    1.78 + * Registers system-tick periodic activity
    1.79 + *  Arguments;
    1.80 + *      MicoSysTimerActivity_t: activity function pointer as described
    1.81 + *      by the prototype.
    1.82 + *      void *ctx: pointer to user-data that will be passed back on
    1.83 + *      system-tick.
    1.84 + */
    1.85 +void MicoRegisterActivity(MicoSysTimerActivity_t activity, void *ctx);
    1.86 +
    1.87 +
    1.88 +/* 
    1.89 + * Retrieves 64-bit tick count, if a system-timer is registered.
    1.90 + * Else, it returns 0.
    1.91 + */
    1.92 +void MicoGetCPUTicks(unsigned long long int *ticks);
    1.93 +
    1.94 +
    1.95 +/* 
    1.96 + * Registers system-timer if one isn't already registered.  Once registered,
    1.97 + * you cannot register some other timer as a the system timer.  You can
    1.98 + * always stop the timer using LatticeMico32 device-driver routine
    1.99 + * and bring the system-timer to a halt.
   1.100 + *  Arguments:
   1.101 + *      MicoTimerCtx_t *ctx: LatticeMico32 Timer instance information
   1.102 + *      structure (context) that should be used as the system timer.
   1.103 + *      unsigned int TickInMS: system-tick value in milli-seconds.
   1.104 + *  Return Value:
   1.105 + *      MicoTimerCtx_t *: LatticeMico32 timer instance information structure
   1.106 + *      of the timer being used as the system-timer.  If there is no system
   1.107 + *      timer, it returns 0.
   1.108 + */
   1.109 +MicoTimerCtx_t* RegisterSystemTimer(MicoTimerCtx_t *ctx, unsigned int TickInMS);
   1.110 +
   1.111 +
   1.112 +
   1.113 +#ifdef __cplusplus
   1.114 +};
   1.115 +#endif /* __cplusplus */
   1.116 +
   1.117 +
   1.118 +#endif
   1.119 +