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