rb8514_delay.h

00001 /*
00002  * rb8514_delay.cpp - programmable time delay (RB8514).
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: rb8514_delay.h 2 2004-10-12 11:54:15Z moene $
00023  */
00024 
00025 #ifndef __RB8514_DELAY_H
00026 #define __RB8514_DELAY_H
00027 
00028 #ifndef __RULBUSDEVICE_H
00029 #include "RulbusDevice.h"               // for class RulbusDevice
00030 #endif
00031 
00032 namespace Rulbus
00033 {
00034    DECLARE_CLASS( RB8514_delay );       // the delay class type
00035 
00182    class RB8514_delay : public RulbusDevice
00183    {
00184    public:                                              // public methods
00185       typedef Int32 Count;                              
00186 
00189 
00190       RB8514_delay( NameCref aName, Addr aAddr = DEF_ADDR, Rack aRack = DEF_RACK );
00191 
00192       ~RB8514_delay();
00193 
00197 
00198       Freq   clockFrequency       () const;
00199       Time   intrinsicDelayTime   () const;
00200       Time   delayTime            () const;
00201       Count  delayCount           () const;
00202 
00203       char   signalDirection      ( CharCptr signal ) const;    // [t s1 s2 e1 e2] -> [p n i]
00204       bool   isEnabledSignal      ( CharCptr signal ) const;
00205 
00206       char   triggerEdge          () const;
00207       char   start12Direction     () const;
00208       char   end12Direction       () const;
00209 
00210       bool   isEnabledStart1      () const;
00211       bool   isEnabledEnd1        () const;
00212       bool   isEnabledStart2      () const;
00213       bool   isEnabledEnd2        () const;
00214 
00215       bool   isBusy               () const;
00216       bool   isPendingInterrupt   () ;          // non-const: clears pending interrupt
00217       bool   isEnabledInterrupt   () const;
00218 
00222 
00223       void   setClockFrequency    ( Freq freq );
00224       void   setIntrinsicDelayTime( Time time );
00225       void   setDelayTime         ( Time time );
00226       void   setDelayCount        ( Count count );
00227 
00228       void   trigger              ();
00229 
00230       void   setSignalDirection   ( CharCptr signal, char dir    );
00231       void   enableSignal         ( CharCptr signal, bool enable );
00232 
00233       void   setTriggerEdge       ( char edge          );
00234       void   setStart12Direction  ( char dir           );
00235       void   setEnd12Direction    ( char dir           );
00236 
00237       bool   enableStart1         ( bool enable = true );
00238       bool   enableEnd1           ( bool enable = true );
00239       bool   enableStart2         ( bool enable = true );
00240       bool   enableEnd2           ( bool enable = true );
00241 
00242       void   clearInterrupt       ();
00243       bool   enableInterrupt      ( bool enable = true );
00244 
00246 
00247    protected:                                           // protected methods
00250 
00251       RB8514_delay();                                   
00252       RB8514_delay( RB8514_delayCref rhs );             
00253       RB8514_delayRef operator= ( RB8514_delayCref rhs ); 
00254 
00258 
00259       bool   isValidSignalName     ( CharCptr aSignal, CharCptr aExtra ) const;
00260       bool   isValidSignalDirection( Char  aDirection ) const;
00261 
00262       bool   isValidDelayCount     ( Count aCount ) const;
00263       bool   isValidClockFrequency ( Freq  aFreq  ) const;
00264       bool   isValidIntrinsicTime  ( Time  aTime  ) const;
00265 
00267 
00268    private:                                             // private methods
00269       int    countByte2         () const;               // msb
00270       int    countByte1         () const;
00271       int    countByte0         () const;               // lsb
00272 
00273       char   getDirection       ( int  mask ) const;
00274       void   setDirection       ( char dir, int mask, CharCptr description );
00275 
00276       bool   getEnable          ( int  mask ) const;
00277       void   setEnable          ( bool enable, int mask );
00278 
00279    public:                                              // public data
00282 
00283       static const Addr  DEF_ADDR  = 0xC4;              
00284 //      static const Rack  DEF_RACK  = 0;                 ///< default rack
00285 
00286       static const Freq  DEF_FRQ /* = 1.0 */ ;          
00287       static const Time  DEF_IDT /* = 0.0 */ ;          
00288       static const Time  DEF_DLY /* = 1.0 */ ;          
00289       static const Count DEF_CNT /* = (DEF_DLY - DEF_IDT) * DEF_FRQ */ ;  // intrinsic delay count (
00290 
00291       static const bool  DEF_EINT  = false;             
00292       static const char  DEF_ETRG  = 'p';               
00293       static const char  DEF_LS12  = 'p';               
00294       static const char  DEF_LE12  = 'p';               
00295       static const bool  DEF_ES1   = true;              
00296       static const bool  DEF_EE1   = true;              
00297       static const bool  DEF_ES2   = true;              
00298       static const bool  DEF_EE2   = true;              
00299 
00303 
00304       static const Count LIM_CNTMIN  = 0;               
00305       static const Count LIM_CNTMAX  = 16777215;        
00306 
00307       static const Freq  LIM_FRQMIN /* = 1.0   */ ;     
00308       static const Freq  LIM_FRQMAX /* = 100e6 */ ;     
00309 
00310       static const Time  LIM_IDTMIN /*  = 0.0    */ ;   
00311       static const Time  LIM_IDTMAX /*  = 100e-9 */ ;   
00312 
00314 
00315    private:                                             // private data
00318 
00319       Byte   theControlRegister;                        
00320       Count  theDelayRegister;                          
00321       Freq   theClockFrequency;                         
00322       Time   theIntrinsicDelayTime;                     
00323 
00327 
00328       static const int  OFF_BT2     = 0;                
00329       static const int  OFF_BT1     = 1;                
00330       static const int  OFF_BT0     = 2;                
00331       static const int  OFF_CTL     = 3;                
00332       static const int  OFF_STS     = 3;                
00333       static const int  ADR_WIDTH   = OFF_STS + 1;      
00334 
00338 
00339       static const int  MSK_STSINT  = 0x01;             
00340       static const int  MSK_STSBSY  = 0x02;             
00341 
00345 
00346       static const int  MSK_CTLES1  = 0x01;             
00347       static const int  MSK_CTLEE1  = 0x02;             
00348       static const int  MSK_CTLES2  = 0x04;             
00349       static const int  MSK_CTLEE2  = 0x08;             
00350       static const int  MSK_CTLINT  = 0x10;             
00351       static const int  MSK_CTLTRG  = 0x20;             
00352       static const int  MSK_CTLLS12 = 0x40;             
00353       static const int  MSK_CTLLE12 = 0x80;             
00354 
00358 
00359       static const int  MSK_BYTE    = 0xFF;             
00360 
00361       // delay count shifts
00362 
00363       static const int  SHR_BT2     = 16;               
00364       static const int  SHR_BT1     =  8;               
00365       static const int  SHR_BT0     =  0;               
00366 
00368    };
00369 
00371 
00376    inline Freq RB8514_delay::clockFrequency() const
00377    {
00378       return theClockFrequency;
00379    }
00380 
00385    inline Time RB8514_delay::intrinsicDelayTime() const
00386    {
00387       return theIntrinsicDelayTime;
00388    }
00389 
00394    inline RB8514_delayRef to_rb8514( RulbusDevicePtr p )
00395    {
00396       return PROXY_CAST<RB8514_delayRef>( *p );
00397    }
00398 
00403    inline RB8514_delayPtr to_rb8514_ptr( RulbusDevicePtr p )
00404    {
00405       return PROXY_CAST<RB8514_delayPtr>( p );
00406    }
00407 
00408 } // namespace Rulbus
00409 
00410 #endif // __RB8514_DELAY_H
00411 
00412 /*
00413  * end of file
00414  */
00415 

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