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

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