rb8515_clock.h

00001 /*
00002  * rb8515_clock.h - clock for delay module (RB8515).
00003  *
00004  * This file is part of the Rulbus Device Class Library (RDCL).
00005  *
00006  * Copyright (C) 2003-2004, Leiden University.
00007  *
00008  * This library is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * The library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with mngdriver; if not, write to the Free Software
00020  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00021  *
00022  * $Id: rb8515_clock.h 2 2004-10-12 11:54:15Z moene $
00023  */
00024 
00025 #ifndef __RB8515_CLOCK_H
00026 #define __RB8515_CLOCK_H
00027 
00028 #ifndef __RULBUSDEVICE_H
00029 #include "RulbusDevice.h"       // for class RulbusDevice
00030 #endif
00031 
00032 namespace Rulbus
00033 {
00034    DECLARE_CLASS( RB8515_clock );       // the clock for delay class type
00035 
00166    class RB8515_clock: public RulbusDevice
00167    {
00168    public:
00172 
00173       RB8515_clock( NameCref name, Addr addr = DEF_ADDR, Rack rack = DEF_RACK );
00174 
00175       ~RB8515_clock();
00176 
00180 
00181       Freq   clockFrequency      () const;
00182       Freq   interruptFrequency  () const;
00183 
00184       bool   isPendingInterrupt  () ;     // clears pending interrupt
00185       bool   isEnabledInterrupt  () const;
00186 
00190 
00191       void   setClockFrequency      ( Freq aFrequency );
00192       void   setInterruptFrequency  ( Freq aFrequency );
00193 
00194       void   clearInterrupt         ();
00195 
00196       bool   disableInterrupt       ();
00197       bool   enableInterrupt        ( bool enable = true );
00198 
00200 
00201    protected:                                           // protected methods
00204 
00205       RB8515_clock();                                   
00206       RB8515_clock( RB8515_clockCref rhs );             
00207       RB8515_clockRef operator= ( RB8515_clockCref rhs ); 
00208 
00210 
00211    private:                                             // private data
00214 
00215       Byte   theCtlByte;                                
00216 
00220 
00221       enum // ClockFreq
00222       {
00223         FC_INVALID = -1,        
00224         FC_0Hz = 0,             
00225         FC_100Hz,               
00226         FC_1kHz,                
00227         FC_10kHz,               
00228         FC_100kHz,              
00229         FC_1MHz,                
00230         FC_10MHz,               
00231         FC_100MHz,              
00232       };
00233 
00237 
00238       enum // IntFreq
00239       {
00240          FI_INVALID = -1,       
00241          FI_0Hz = 0,            
00242          FI_1Hz,                
00243          FI_5kHz,               
00244          FI_10Hz,               
00245          FI_50Hz,               
00246          FI_100Hz,              
00247          FI_500Hz,              
00248          FI_1kHz,               
00249       };
00250 
00254 
00255       static const int  OFF_CR      = 0;                
00256       static const int  OFF_SR      = 0;                
00257       static const int  ADR_WIDTH   = OFF_SR + 1;       
00258 
00262 
00263       static const int  MSK_CLKFRQ  = 0x07;             
00264       static const int  MSK_INTFRQ  = 0x38;             
00265       static const int  MSK_INTENA  = 0x40;             
00266       static const int  MSK_INTCLRn = 0x80;             
00267       static const int  MSK_INTSTS  = 0x80;             
00268 
00269       static const int  SHL_CLKFRQ  = 0x00;             
00270       static const int  SHL_INTFRQ  = 0x03;             
00271 
00275 
00276       static const Addr DEF_ADDR = 0xC8;                
00277       static const Freq DEF_CLKFRQ /* = 1e3 */ ;        
00278       static const Freq DEF_INTFRQ /* = 0e0 */ ;        
00279 
00283 
00291       struct FreqTable
00292       {
00293          Freq freq;                                     
00294          Int  code;                                     
00295       };
00296 
00297       static FreqTable   clkTable[];
00298       static FreqTable   intTable[];
00299 
00301 
00302    protected:                                           // protected methods
00303       void   getClkFreqCode( Freq aFrequency, IntPtr pCode ) const;
00304       void   getIntFreqCode( Freq aFrequency, IntPtr pCode ) const;
00305       void   getFreqCode   ( Freq aFrequency, const FreqTable *tablePtr, IntPtr pCode ) const;
00306    };
00307 
00309 
00314    inline RB8515_clockRef to_rb8515( RulbusDevicePtr p )
00315    {
00316       return PROXY_CAST<RB8515_clockRef>( *p );
00317    }
00318 
00323    inline RB8515_clockPtr to_rb8515_ptr( RulbusDevicePtr p )
00324    {
00325       return PROXY_CAST<RB8515_clockPtr>( p );
00326    }
00327 
00328 } // namespace Rulbus
00329 
00330 #endif // __RB8515_CLOCK_H
00331 
00332 /*
00333  * end of file
00334  */
00335 

Generated on Tue Oct 12 14:11:58 2004 for Rulbus Device Class Library for Microsoft Windows by doxygen 1.3.4