timer.h

Go to the documentation of this file.
00001 /*                                             -*- mode:C++; fill-column:100 -*- 
00002   timer.h -  LPC2xxx-specific hardware access and configuration routines
00003   Copyright (C) 2009 The Regents of the University of New Mexico.  All rights reserved.
00004 
00005   This library is free software; you can redistribute it and/or
00006   modify it under the terms of the GNU Lesser General Public
00007   License as published by the Free Software Foundation; either
00008   version 2.1 of the License, or (at your option) any later version.
00009 
00010   This library is distributed in the hope that it will be useful,
00011   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013   Lesser General Public License for more details.
00014 
00015   You should have received a copy of the GNU General Public License
00016   along with this library; if not, write to the Free Software
00017   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
00018   USA
00019 
00020   $Id$
00021 */
00022 
00029 #ifndef __TIMER_H 
00030 #define __TIMER_H
00031 
00032 #include "SFBConstants.h"
00033 
00035 #define CCLK_72MHZ (72000000)
00036 #define CCLK_60MHZ (60000000)
00037 
00038 #define CCLK CCLK_72MHZ
00039 
00040 /* 
00041  * For SFB@60MHz: CCLK = 60Mhz, PCLK = 1/4 CCLK, so Fpclk = 15MHz, Fpclk/15000==1KHz.
00042  * so 1ms = Fpclk/15000, less one for the extra cycle in the timer
00043  *
00044  * For SFB@72MHz: CCLK = 72Mhz, PCLK = 1/4 CCLK, so Fpclk = 18MHz, Fpclk/18000==1KHz.
00045  * so 1ms = Fpclk/18000, less one for the extra cycle in the timer
00046  *
00047  * For SFB@72MHz: CCLK = 72Mhz, PCLK = 1/4 CCLK, so Fpclk = 18MHz, Fpclk/18000==1KHz.
00048  * so 500us = Fpclk/9000, less one for the extra cycle in the timer
00049  * so 250us = Fpclk/4500, less one for the extra cycle in the timer
00050  *
00051  */
00053 #define TIME_INTERVAL_1KHZ_AT_60MHZ (15000-1)
00054 
00055 #define TIME_INTERVAL_1KHZ_AT_72MHZ (18000-1)
00056 #define TIME_INTERVAL_2KHZ_AT_72MHZ (9000-1)
00057 #define TIME_INTERVAL_3KHZ_AT_72MHZ (6000-1)
00058 #define TIME_INTERVAL_4KHZ_AT_72MHZ (4500-1)
00059 
00060 extern u32 initTimer0();
00061 extern void enable_timer0();
00062 extern void disable_timer0();
00063 extern void reset_timer0();
00066 #include "lpc/LPC23xx.h"
00067 
00074 #define micros() ((volatile const u32) (T0TC))  
00075 
00078 #define millis() ((volatile const u32) (timer_1msec_counter))
00079 extern uv32 timer_1msec_counter;
00080 
00084 extern u64 microseconds();
00085 
00089 extern u32 milliseconds();
00090 
00093 extern u32 seconds();
00096 #endif /* end __TIMER_H */
00097 /*****************************************************************************
00098 **                            End Of File
00099 ******************************************************************************/

Generated on Sun Oct 18 09:58:55 2009 for SFB by doxygen 1.5.9