rb8506_sifu.h

00001 /*
00002  * rb8506_sifu.h -   (RB8506).
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: rb8506_sifu.h 2 2004-10-12 11:54:15Z moene $
00023  */
00024 
00025 #ifndef __RB8506_SIFU_H
00026 #define __RB8506_SIFU_H
00027 
00028 #ifndef __PIAVIA_H
00029 #include "PiaVia.h"
00030 #endif
00031 
00032 namespace Rulbus
00033 {
00034    DECLARE_CLASS( RB8506_Sifu );  //
00035 
00036    /* *
00037     * \example name.cpp
00038     * This is an example that shows ... .
00039     */
00040 
00215    class RB8506_Sifu : public Pia
00216    {
00217    public:                              // public methods
00220 
00221       ~RB8506_Sifu();
00222       RB8506_Sifu( NameCref name, Addr addr = DEF_ADDR, Rack rack = DEF_RACK );
00223 
00227 
00228       int   getInputPortData ();
00229       int   getOutputPortData();
00230 
00231       bool  isChangedInputLine (          );
00232       int   tstInputLineLevel  ( int line );
00233       int   getInputLineLevel  ( int line );
00234       int   getOutputLineLevel ( int line );
00235 
00236       bool  isEnabledPulseOutputs();
00237 
00241 
00242       void  setOutputPortData ( int data );
00243       void  setOutputLineLevel( int line, bool set );
00244 
00245       void  enablePulseOutputs( bool enable = true );
00246 
00248 
00249    protected:                                   // protected methods
00252 
00253       RB8506_Sifu();                                    
00254       RB8506_Sifu( RB8506_SifuCref rhs );               
00255       RB8506_SifuRef operator= ( RB8506_SifuCref rhs ); 
00256 
00260 
00261       void   clearFlipFlops();
00262 
00266 
00267       static int swapNibbles( int byte );
00268       static int swapLines  ( int line );
00269 
00271 
00272    public:                                      // public data
00275 
00276       static const Addr DEF_ADDR = Pia::DEF_ADDR + 4;   
00277 
00278       static const int  DEF_DIRPA   = 0xFF;     
00279       static const int  DEF_DIRPB   = 0x00;     
00280       static const char DEF_EDGECB1 = 'p';      
00281       static const char DEF_DIRCA2  = 'o';      
00282       static const char DEF_DIRCB2  = 'o';      
00283       static const char DEF_LVLCA2  =  0;       
00284       static const char DEF_LVLCB2  =  1;       
00285       static const bool DEF_INTRCB1 = true;     
00286       static const int  DEF_OUTDATA =  0;       
00287 
00289    };
00290 
00292 
00298    inline bool RB8506_Sifu::isChangedInputLine()
00299    {
00300       return getIrqCB1();
00301    }
00302 
00307    inline int RB8506_Sifu::getOutputPortData()
00308    {
00309       return getDataPA();
00310    }
00311 
00316    inline void RB8506_Sifu::setOutputPortData( int data )
00317    {
00318       setDataPA( data );
00319    }
00320 
00325    inline int RB8506_Sifu::getOutputLineLevel( int line )
00326    {
00327       return getLineLevelPA( line );
00328    }
00329 
00334    inline void RB8506_Sifu::setOutputLineLevel( int line, bool set )
00335    {
00336       setLineLevelPA( line, set );
00337    }
00338 
00343    inline bool RB8506_Sifu::isEnabledPulseOutputs()
00344    {
00345       return getLevelCA2();
00346    }
00347 
00352    inline void RB8506_Sifu::enablePulseOutputs( bool enable /* = true */ )
00353    {
00354       setLevelCA2( enable );
00355    }
00356 
00361    inline void RB8506_Sifu::clearFlipFlops()
00362    {
00363       setLevelCB2( 0 );
00364       setLevelCB2( 1 );
00365    }
00366 
00371    inline int RB8506_Sifu::swapNibbles( int byte )
00372    {
00373       return ( byte >> 4 ) | ( ( byte & 0xF ) << 4 );
00374    }
00375 
00380    inline int RB8506_Sifu::swapLines( int line )
00381    {
00382       return ( line < 4 ) ? line + 4 : line - 4;
00383    }
00384 
00389    inline RB8506_SifuRef to_rb8506_sifu( RulbusDevicePtr p )
00390    {
00391       return PROXY_CAST<RB8506_SifuRef>( *p );
00392    }
00393 
00398    inline RB8506_SifuPtr to_rb8506_sifu_ptr( RulbusDevicePtr p )
00399    {
00400       return PROXY_CAST<RB8506_SifuPtr>( p );
00401    }
00402 
00403 } // namespace Rulbus
00404 
00405 #endif  // __RB8506_SIFU_H
00406 
00407 /*
00408  * end of file
00409  */
00410 

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