00001 /****************************************************************************** 00002 * 00003 * $RCSfile: $ 00004 * $Revision: $ 00005 * 00006 * This module provides the interface definitions for sysTime.c 00007 * Copyright 2004, R O SoftWare 00008 * No guarantees, warrantees, or promises, implied or otherwise. 00009 * May be used for hobby or commercial purposes provided copyright 00010 * notice remains intact. 00011 * 00012 *****************************************************************************/ 00013 #ifndef INC_SYS_TIME_H 00014 #define INC_SYS_TIME_H 00015 00016 #include "types.h" 00017 //#include "LPC210x.h" 00018 #include "config.h" 00019 00020 // Note: with a PCLK = CCLK/2 = 60MHz/2 and a Prescale divider of 3, we 00021 // have a resolution of 100nSec. Given the timer's counter register is 00022 // 32-bits, we must make a call to one of the sysTime functions at least 00023 // every ~430 sec. 00024 00025 // setup parameters 00026 #define T0_PCLK_DIV 5 00027 #define sysTICSperSEC (PCLK / T0_PCLK_DIV) 00028 00029 // some helpful times for pause() 00030 #define ONE_US (uint32_t)(( 1e-6 * sysTICSperSEC) + .5) 00031 #define ONE_MS (uint32_t)(( 1e-3 * sysTICSperSEC) + .5) 00032 #define TWO_MS (uint32_t)(( 2e-3 * sysTICSperSEC) + .5) 00033 #define FIVE_MS (uint32_t)(( 5e-3 * sysTICSperSEC) + .5) 00034 #define TEN_MS (uint32_t)(( 10e-3 * sysTICSperSEC) + .5) 00035 #define TWENTY_MS (uint32_t)(( 20e-3 * sysTICSperSEC) + .5) 00036 #define THIRTY_MS (uint32_t)(( 30e-3 * sysTICSperSEC) + .5) 00037 #define FIFTY_MS (uint32_t)(( 50e-3 * sysTICSperSEC) + .5) 00038 #define HUNDRED_MS (uint32_t)((100e-3 * sysTICSperSEC) + .5) 00039 #define ONE_FIFTY_MS (uint32_t)((150e-3 * sysTICSperSEC) + .5) 00040 #define QUARTER_SEC (uint32_t)((250e-3 * sysTICSperSEC) + .5) 00041 #define HALF_SEC (uint32_t)((500e-3 * sysTICSperSEC) + .5) 00042 #define ONE_SEC (uint32_t)(( 1.0 * sysTICSperSEC) + .5) 00043 #define TWO_SEC (uint32_t)(( 2.0 * sysTICSperSEC) + .5) 00044 #define FIVE_SEC (uint32_t)(( 5.0 * sysTICSperSEC) + .5) 00045 #define TEN_SEC (uint32_t)((10.0 * sysTICSperSEC) + .5) 00046 00047 00048 /****************************************************************************** 00049 * 00050 * Function Name: initSysTime() 00051 * 00052 * Description: 00053 * This function initializes the LPC's Timer 0 for use as the system 00054 * timer. 00055 * 00056 * Calling Sequence: 00057 * void 00058 * 00059 * Returns: 00060 * void 00061 * 00062 *****************************************************************************/ 00063 void initSysTime(void); 00064 00065 /****************************************************************************** 00066 * 00067 * Function Name: getSysTICs() 00068 * 00069 * Description: 00070 * This function returns the current system time in TICs. 00071 * 00072 * Calling Sequence: 00073 * void 00074 * 00075 * Returns: 00076 * The current time in TICs 00077 * 00078 *****************************************************************************/ 00079 uint32_t getSysTICs(void); 00080 00081 /****************************************************************************** 00082 * 00083 * Function Name: getElapsedSysTICs() 00084 * 00085 * Description: 00086 * This function then returns the difference in TICs between the 00087 * given starting time and the current system time. 00088 * 00089 * Calling Sequence: 00090 * The starting time. 00091 * 00092 * Returns: 00093 * The time difference. 00094 * 00095 *****************************************************************************/ 00096 uint32_t getElapsedSysTICs(uint32_t startTime); 00097 00098 /****************************************************************************** 00099 * 00100 * Function Name: pause() 00101 * 00102 * Description: 00103 * This function does not return until the specified 'duration' in 00104 * TICs has elapsed. 00105 * 00106 * Calling Sequence: 00107 * duration - length of time in TICs to wait before returning 00108 * 00109 * Returns: 00110 * void 00111 * 00112 *****************************************************************************/ 00113 void pause(uint32_t duration); 00114 00115 #endif
1.4.7