PiaVia.h

00001 /*
00002  * piavia.h - PIA/VIA.
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: PiaVia.h 2 2004-10-12 11:54:15Z moene $
00023  */
00024 
00025 #ifndef __PIAVIA_H
00026 #define __PIAVIA_H
00027 
00028 #ifndef __RULBUSDEVICE_H
00029 #include "RulbusDevice.h"       // for class RulbusDevice
00030 #endif
00031 
00032 namespace Rulbus
00033 {
00034    DECLARE_CLASS( Pia    );    // Pia class
00035    DECLARE_CLASS( Via    );    // Via class
00036    DECLARE_CLASS( PiaVia );    // abstract base class
00037 
00181    class PiaVia: public RulbusDevice
00182    {
00183    public:
00186 
00187       PiaVia( NameCref aName, Addr aAddr, Addr aWidth, Rack aRack ):
00188          RulbusDevice( aName, aAddr, aWidth, aRack )    
00189       {
00190          ; // do nothing
00191       }
00192 
00193       virtual ~PiaVia() { ; }                           
00194 
00198 
00199       virtual   int   getPortDir    ( CharCptr prt );   
00200       virtual   int   getPortData   ( CharCptr ptr );   
00201 
00202       virtual   char  getLineDir    ( CharCptr lin );   
00203       virtual   int   getLineLevel  ( CharCptr lin );   
00204 
00208 
00209       virtual   int   getDirPA      (         );        
00210       virtual   int   getDataPA     (         );        
00211 
00212       virtual   char  getLineDirPA  ( int pin );        
00213       virtual   int   getLineLevelPA( int pin );        
00214 
00218 
00219       virtual   int   getDirPB      (         );        
00220       virtual   int   getDataPB     (         );        
00221 
00222       virtual   char  getLineDirPB  ( int pin );        
00223       virtual   int   getLineLevelPB( int pin );        
00224 
00228 
00229       // control port A, CA1 (input only):
00230       virtual   int   getIrqCA1     (         ) = 0;    
00231       virtual   char  getEdgeCA1    (         ) = 0;    
00232       virtual   int   getIntrCA1    (         ) = 0;    
00233 
00234       // control port A, CA2 (input and output):
00235       virtual   char  getDirCA2     (         ) = 0;    
00236       virtual   int   getLevelCA2   (         ) = 0;    
00237 
00241 
00242       // control port B, CB1 (input only):
00243       virtual   int   getIrqCB1     (         ) = 0;    
00244       virtual   char  getEdgeCB1    (         ) = 0;    
00245       virtual   int   getIntrCB1    (         ) = 0;    
00246 
00247       // control port B, CB2 (input and output):
00248       virtual   char  getDirCB2     (         ) = 0;    
00249       virtual   int   getLevelCB2   (         ) = 0;    
00250 
00254 
00255       virtual   void  setPortDir    ( CharCptr prt, int msk  ); 
00256       virtual   void  setPortData   ( CharCptr prt, int dat  ); 
00257 
00258       virtual   void  setLineDir    ( CharCptr lin, char dir ); 
00259       virtual   void  setLineLevel  ( CharCptr lin, int  lvl ); 
00260 
00264 
00265       virtual   void  setDirPA      ( int msk );                
00266       virtual   void  setDataPA     ( int dat );                
00267 
00268       virtual   void  setLineDirPA  ( int pin, char dir );      
00269       virtual   void  setLineLevelPA( int pin, int  lvl );      
00270 
00274 
00275       virtual   void  setDirPB      ( int msk );                
00276       virtual   void  setDataPB     ( int dat );                
00277 
00278       virtual   void  setLineDirPB  ( int pin, char dir );      
00279       virtual   void  setLineLevelPB( int pin, int  lvl );      
00280 
00284 
00285       virtual   void  setEdgeCA1    ( char edge  ) = 0;         
00286       virtual   int   setIntrCA1    ( int enable ) = 0;         
00287 
00288       virtual   void  setDirCA2     ( char dir   ) = 0;         
00289       virtual   void  setLevelCA2   ( int  lvl   ) = 0;         
00290 
00294 
00295       virtual   void  setEdgeCB1    ( char edge  ) = 0;         
00296       virtual   int   setIntrCB1    ( int enable ) = 0;         
00297 
00298       virtual   void  setDirCB2     ( char dir   ) = 0;         
00299       virtual   void  setLevelCB2   ( int  lvl   ) = 0;         
00300 
00302 
00303    protected:
00306 
00307       void            checkPin      ( int  pin );               
00308       void            checkDir      ( char dir );               
00309       void            checkData     ( int  dat );               
00310       void            checkMask     ( int  msk );               
00311 
00315 
00316       virtual   int   getDDRA       (          ) = 0;           
00317       virtual   int   getPDRA       (          ) = 0;           
00318 
00319       virtual   int   getDDRB       (          ) = 0;           
00320       virtual   int   getPDRB       (          ) = 0;           
00321 
00325 
00326       virtual   void  setDDRA       ( int dir  ) = 0;           
00327       virtual   void  setPDRA       ( int dat  ) = 0;           
00328 
00329       virtual   void  setDDRB       ( int dir  ) = 0;           
00330       virtual   void  setPDRB       ( int dat  ) = 0;           
00331 
00333 
00334    private:
00335    };
00336 
00423    class Pia : public PiaVia
00424    {
00425    public:
00428 
00430       Pia ( NameCref aName, Addr aAddr = DEF_ADDR, Rack aRack = DEF_RACK ):
00431          PiaVia( aName, aAddr, ADR_WIDTH, aRack ) { ; }
00432 
00433       virtual  ~Pia() { ; }                     
00434 
00435 
00439 
00440       // control port A, CA1 (input only):
00441       int          getIrqCA1  (            );   
00442       char         getEdgeCA1 (            );   
00443       int          getIntrCA1 (            );   
00444 
00445       // control port A, CA2 (input and output):
00446       char         getDirCA2  (            );   
00447       int          getLevelCA2(            );   
00448 
00452 
00453       // control port B, CB1 (input only):
00454       int          getIrqCB1  (            );   
00455       char         getEdgeCB1 (            );   
00456       int          getIntrCB1 (            );   
00457 
00458       // control port B, CB2 (input and output):
00459       char         getDirCB2  (            );   
00460       int          getLevelCB2(            );   
00461 
00465 
00466       void         setEdgeCA1 ( char edge  );   
00467       int          setIntrCA1 ( int enable );   
00468 
00469       void         setDirCA2  ( char dir   );   
00470       void         setLevelCA2( int  lvl   );   
00471 
00475 
00476       void         setEdgeCB1 ( char edge  );   
00477       int          setIntrCB1 ( int enable );   
00478 
00479       void         setDirCB2  ( char dir   );   
00480       void         setLevelCB2( int  lvl   );   
00481 
00483 
00484    protected:
00487 
00488       int          getDDRA    (            );   
00489       int          getPDRA    (            );   
00490 
00491       int          getDDRB    (            );   
00492       int          getPDRB    (            );   
00493 
00497 
00498       void         setDDRA    ( int dir    );   
00499       void         setPDRA    ( int dat    );   
00500 
00501       void         setDDRB    ( int dir    );   
00502       void         setPDRB    ( int dat    );   
00503 
00505 
00506    private:
00509 
00510       void         select_ddra();               
00511       void         select_pdra();               
00512       void         select_ddrb();               
00513       void         select_pdrb();               
00514 
00518 
00519       int          getIrqC1   ( int offset );                      
00520       char         getEdgeC1  ( int offset );                      
00521       void         setEdgeC1  ( int offset, char edge, char port); 
00522       int          getIntrC1  ( int offset );                      
00523       int          setIntrC1  ( int offset, int enable);           
00524 
00528 
00529       char         getDirC2   ( int offset );                      
00530       void         setDirC2   ( int offset, char dir, char port ); 
00531       int          getLevelC2 ( int offset );                      
00532       void         setLevelC2 ( int offset, int  lvl, char port ); 
00533 
00535 
00536    public:
00539 
00540       static const int DEF_ADDR = 0x90;         
00541       static const int DEF_RACK = 0;            
00542 
00544 
00545    private:
00548 
00549       static const int OFF_DDRA = 0;            
00550       static const int OFF_PDRA = 0;            
00551       static const int OFF_CRA  = 1;            
00552       static const int OFF_DDRB = 2;            
00553       static const int OFF_PDRB = 2;            
00554       static const int OFF_CRB  = 3;            
00555       static const int ADR_WIDTH= OFF_CRB + 1;  
00556 
00560 
00561       static const int MSK_EIC1 = 0x01;         
00562       static const int MSK_ATC1 = 0x02;         
00563       static const int MSK_SPDR = 0x04;         
00564 
00568 
00569       static const int MSK_DIRC2= 0x20;         
00570 
00574 
00575       static const int MSK_ATC2 = 0x10;         
00576       static const int MSK_EIC2 = 0x08;         
00577 
00581 
00582       static const int MSK_POC2 = 0x10;         
00583       static const int MSK_OLC2 = 0x08;         
00584 
00588 
00589       static const int MSK_IRQ1 = 0x80;         
00590       static const int MSK_IRQ2 = 0x40;         
00591 
00593    };
00594 
00712    class Via : public PiaVia
00713    {
00714    public:
00717 
00719       Via ( NameCref aName, Addr aAddr = DEF_ADDR, Rack aRack = DEF_RACK ):
00720          PiaVia( aName, aAddr, ADR_WIDTH, aRack ) { ; }
00721 
00722       virtual  ~Via() { ; }                     
00723 
00727 
00728       // control port A, CA1 (input only):
00729       int          getIrqCA1  (            );   
00730       char         getEdgeCA1 (            );   
00731       int          getIntrCA1 (            );   
00732 
00733       // control port A, CA2 (input and output):
00734       char         getDirCA2  (            );   
00735       int          getLevelCA2(            );   
00736 
00740 
00741       // control port B, CB1 (input only):
00742       int          getIrqCB1  (            );   
00743       char         getEdgeCB1 (            );   
00744       int          getIntrCB1 (            );   
00745 
00746       // control port B, CB2 (input and output):
00747       char         getDirCB2  (            );   
00748       int          getLevelCB2(            );   
00749 
00753 
00754       // control port A, CA1 (input only):
00755       void         setEdgeCA1 ( char edge  );   
00756       int          setIntrCA1 ( int enable );   
00757 
00758       // control port A, CA2 (input and output):
00759       void         setDirCA2  ( char dir   );   
00760       void         setLevelCA2( int  lvl   );   
00761 
00765 
00766       // control port B, CB1 (input only):
00767       void         setEdgeCB1 ( char edge  );   
00768       int          setIntrCB1 ( int enable );   
00769 
00770       // control port B, CB2 (input and output):
00771       void         setDirCB2  ( char dir   );   
00772       void         setLevelCB2( int  lvl   );   
00773 
00775 
00776    protected:
00779 
00780       int          getDDRA    (            );   
00781       int          getPDRA    (            );   
00782 
00783       int          getDDRB    (            );   
00784       int          getPDRB    (            );   
00785 
00789 
00790       void         setDDRA    ( int dir    );   
00791       void         setPDRA    ( int dat    );   
00792 
00793       void         setDDRB    ( int dir    );   
00794       void         setPDRB    ( int dat    );   
00795 
00797 
00798    private:
00801 
00802       // control ports A/B, C1 (input only):
00803       int          getIrqC1   ( int mask   );                       
00804       char         getEdgeC1  ( int shift  );                       
00805       void         setEdgeC1  ( int shift, char edge, char port );  
00806       int          getIntrC1  ( int mask   );                       
00807       int          setIntrC1  ( int mask, int enable);              
00808 
00812 
00813       // control port A/B, C2 (input and output):
00814       char         getDirC2   ( int shift  );                       
00815       void         setDirC2   ( int shift, char dir, char port );   
00816       int          getLevelC2 ( int shift,           char port );   
00817       void         setLevelC2 ( int shift, int  lvl, char port );   
00818 
00820 
00821    public:
00824 
00825       static const int DEF_ADDR = 0x90;         
00826       static const int DEF_RACK = 0;            
00827 
00829 
00830    private:
00833 
00834       static const int OFF_PDRB    =  0;        
00835       static const int OFF_PDRA    =  1;        
00836       static const int OFF_DDRB    =  2;        
00837       static const int OFF_DDRA    =  3;        
00838       static const int OFF_T1CL    =  4;        
00839       static const int OFF_T1CH    =  5;        
00840       static const int OFF_T1LL    =  6;        
00841       static const int OFF_T1LH    =  7;        
00842       static const int OFF_T2CL    =  8;        
00843       static const int OFF_T2CH    =  9;        
00844       static const int OFF_SR      = 10;        
00845       static const int OFF_ACR     = 11;        
00846       static const int OFF_PCR     = 12;        
00847       static const int OFF_IFR     = 13;        
00848       static const int OFF_IER     = 14;        
00849       static const int OFF_PDRA_NH = 15;        
00850       static const int ADR_WIDTH   = OFF_PDRA_NH + 1;   
00851 
00855 
00859 
00860       static const int SHL_CA    = 0;           
00861       static const int SHL_CB    = 4;           
00862 
00866 
00867       static const int MSK_ATC1  = 0x01;        
00868 
00872 
00873       static const int MSK_DIRC2 = 0x08;        
00874       static const int MSK_POC2  = 0x04;        
00875       static const int MSK_OLC2  = 0x02;        
00876 
00880 
00881       static const int MSK_IFCA2 = 0x01;        
00882       static const int MSK_IFCA1 = 0x02;        
00883       static const int MSK_IFSR  = 0x04;        
00884       static const int MSK_IFCB2 = 0x08;        
00885       static const int MSK_IFCB1 = 0x10;        
00886       static const int MSK_IFCT2 = 0x20;        
00887       static const int MSK_IFCT1 = 0x40;        
00888       static const int MSK_IFIRQ = 0x80;        
00889 
00893 
00894       static const int MSK_IECA2 = 0x01;        
00895       static const int MSK_IECA1 = 0x02;        
00896       static const int MSK_IESR  = 0x04;        
00897       static const int MSK_IECB2 = 0x08;        
00898       static const int MSK_IECB1 = 0x10;        
00899       static const int MSK_IECT2 = 0x20;        
00900       static const int MSK_IECT1 = 0x40;        
00901       static const int MSK_IESC  = 0x80;        
00902 
00904    };
00905 
00908 }       // namespace Rulbus
00909 
00910 #endif // __PIAVIA_H
00911 
00912 /*
00913  * end of file
00914  */
00915 

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