SFBProcessor.h

Go to the documentation of this file.
00001 /*                                              -*- mode:C++; fill-column:100 -*-
00002   SFBProcessor.h CPU speed setting and control routines for the SFB.
00003   Copyright (C) 2010 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 
00032 #ifndef SFBPROCESSOR_H
00033 #define SFBPROCESSOR_H
00034 
00035 #include "SFBTypes.h"     /* For u8 */
00036 #include "lpc/clock.h"    /* For CSC_12MHZ, etc */
00037 
00043 class SFBProcessor {
00044 public:
00045 
00049   void setMaxSpeed() { setCode(CSC_MAX_MHZ); }
00050 
00054   void setMinSpeed() { setCode(CSC_MIN_MHZ); }
00055 
00059   u32 getMHzMin() { return 12*getCodeMin(); }
00060 
00064   u32 getCodeMin() { return CSC_MIN_MHZ; }
00065 
00069   u32 getMHzMax() { return 12*getCodeMax(); }
00070 
00074   u32 getCodeMax() { return CSC_MAX_MHZ; }
00075 
00079   u32 getHz() { return getMHz()*1000000; }
00080 
00084   u32 getMHz() { return getCode()*12; }
00085 
00089   u32 getCode() ;
00090 
00098   void setHz(u32 hz) { setMHz(hz/1000000); }
00099 
00107   void setMHz(u32 mhz) { setCode(mhz/12); }
00108 
00137   void setCode(u32 code);
00138 
00139 };
00140 
00141 typedef void (*SpeedChangeHandler)();
00142 struct SpeedChangeHandlerBlock {
00143   SpeedChangeHandler handler;
00144   SpeedChangeHandlerBlock * next;
00145 };
00146 
00147 extern void registerSpeedChangeHandlerBlock(SpeedChangeHandlerBlock *); // Defined in startup.cpp!
00148 
00153 extern SFBProcessor Processor; 
00154 
00155 #endif /* SFBPROCESSOR_H */

Generated on Fri Apr 22 06:54:12 2011 for SFB by doxygen 1.5.9