Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Bit3IO.h

Go to the documentation of this file.
00001 
00002 //  Title     : Bit3IO.h
00003 //  Project   : OSCAR
00004 //  Created   : 7/1/98 2:18:05 PM
00005 //  Author    : Jacy Legault, Chetan Kapoor, Yalei Wang
00006 //  Platforms : WIN32 VC++ (Not UNIX tested)
00007 //  Copyright : copyright1996-1998 The University of Texas at Austin.
00008 //          All rights reserved.
00009 //  Purpose   : Low Level Interface for Mutibus-to-PCI adapter
00010 //          Class default configured for RR2017 Controller
00011 //          Uses two type of Memory access:
00012 //              -Direct virtual memory read/write (FAST)
00013 //               Is more volatile, use for final release
00014 //              -Bit3IO API direct memory read/write (SAFE)
00015 //               Should be used for development
00016 //-----------------------------------------------------------------------------
00017 //  Classes   : <Bit3IO>
00018 //
00019 //  Global      <none>
00020 //  Functions :
00021 //  Global      <none>
00022 //  Variables :
00023 //-----------------------------------------------------------------------------
00024 //  $Revisions$
00025 //
00026 //  $Log: Bit3IO.h,v $
00027 //  Revision 1.11  2005/03/14 21:53:47  pmarch
00028 //  Added to namespace OSCAR and removed "RR" from front of class names.
00029 //
00030 //  Revision 1.10  2005/02/04 22:43:16  pmarch
00031 //  Removed #ifdefs used to remove certain classes from build.  These classes must now be manually removed from the build.
00032 //
00033 //  Revision 1.9  2004/08/03 18:10:26  pmarch
00034 //  Wrapped classes in #ifdef/#endif statements (i.e. _BIT3, _NIDAQ, etc) to build under Linux.
00035 //
00036 //  Revision 1.8  2004/07/27 16:44:18  chetan
00037 //  Made changes to compile with Warning Level 4 and also under the latest C++ standard.  Mostly carriage returns at the end of a file.  For IODevice, VC++ extensions have to be turned on
00038 //
00039 //  Revision 1.7  2004/07/23 22:21:46  chetan
00040 //  Made changes to compile with Warning Level 4 and also under the latest C++ standard
00041 //
00042 //  Revision 1.6  2004/05/27 19:20:09  pmarch
00043 //  Added /defgroup and /ingroup tags.
00044 //
00045 //  Revision 1.5  2004/04/15 16:19:59  eswint
00046 //  - Rebuild, added commenting
00047 //
00048 //  Revision 1.4  2004/02/19 19:10:07  eswint
00049 //  - Rebuilt with Bit3 v3.2
00050 //
00051 //  Revision 1.3  2004/02/19 15:49:43  eswint
00052 //  - Rebuild w/ latest version of Bit3
00053 //
00054 //  Revision 1.2  2003/08/18 21:29:06  eswint
00055 //  Initial Commit
00056 //
00057 //  Revision 1.1  2003/08/18 20:42:00  eswint
00058 //  Initial Commit
00059 //
00060 //
00062 #ifndef Bit3IO_hpp
00063 #define Bit3IO_hpp
00064 
00065 
00066 #define     BT983
00067 #include    "Base/Base.h"
00068 #include    "Math/MathDefs.h"
00069 #include    "Math/VectorNumeric.h"
00070 #include    "Bit3\Bit3toMultibus\V3.2\Header Files\btapi.h"   //Use BIT3 API Provided by Bit3 for Windoes NT
00071 
00073 namespace OSCAR {
00074 
00075   typedef unsigned long           ADDR;         //Register Addrress type
00076   typedef char                    Control8Bit;        //8bit data variable R2017 Controller (Byte)
00077   typedef short                   Control16Bit;       //16bit data variable R2017 Controller (Word & Int)
00078   typedef float                   Control32Bit;     //32bit data variable R2017 Controller (Short-Real)
00079   typedef VectorNumeric<Control8Bit>    Control8BitArray;       //Array of 8bit data variables (Byte)
00080   typedef VectorNumeric<Control16Bit>   Control16BitArray;    //Array of 16bit data variables (Word & Int)
00081   typedef VectorNumeric<Control32Bit>   Control32BitArray;    //Array of 32bit data variables (Short-Real)
00082   static const unsigned int       SizeControl8Bit = 1;  //Number of Bytes in Control8Bit
00083   static const unsigned int       SizeControl16Bit = 2; //Number of Bytes in Control16Bit
00084   static const unsigned int       SizeControl32Bit = 4; //Number of Bytes in Control32Bit
00085 
00086 
00087   //Low Level Interface for Mutibus-to-PCI adapter
00088 
00089 
00094   class Bit3IO{
00095 
00096   public:
00097       enum ACCESS_TYPE{FAST = 0, SAFE = 1};         //Create enumerated types :FAST for virtual access, SAFE for Bit3API
00098 
00099       Bit3IO(OSCARError& err = DUMMY_ERROR(noError), int unitNo = 0, unsigned long defaultAddress = 0x00010000); //Constructor calls Initialize
00100       virtual ~Bit3IO();                  //Virtual destructor calls CloseDevice
00101 
00102       bool ReadData(ADDR regaddr, Control8Bit& readData);     //Read Single (8bit) at ADDR into readData
00103       bool ReadData(ADDR regaddr, Control16Bit& readData);    //Read Single (16bit) at ADDR into readData
00104       bool ReadData(ADDR regaddr, Control32Bit& readData);    //Read Single (32bit) at ADDR into readData
00105       bool ReadData(ADDR regaddr, Control8BitArray& readData);  //Read Block of (8bit) at ADDR into readData
00106       bool ReadData(ADDR regaddr, Control16BitArray& readData); //Read Block of (16bit) at ADDR into readData
00107       bool ReadData(ADDR regaddr, Control32BitArray& readData); //Read Block of (32bit) at ADDR into readData
00108 
00109       bool WriteData(ADDR regaddr, Control8Bit writeData);        //Write Single (8bit) writeData into memory at ADDR
00110       bool WriteData(ADDR regaddr, Control16Bit writeData);       //Write Single (16bit) writeData into memory at ADDR
00111       bool WriteData(ADDR regaddr, Control32Bit writeData);       //Write Single (32bit) writeData into memory at ADDR
00112       bool WriteData(ADDR regaddr, const Control8BitArray& writeData);  //Write Block of (8bit) writeData into memory starting at ADDR
00113       bool WriteData(ADDR regaddr, const Control16BitArray& writeData); //Write Block of (16bit) writeData into memory starting at ADDR
00114       bool WriteData(ADDR regaddr, const Control32BitArray& writeData); //Write Block of (32bit) writeData into memory starting at ADDR
00115 
00116       bool            Close();                      //Public Close, Calls Close Device
00117       int             GetErrorCode() const;               //Public Error
00118       bool            SetAccessType(ACCESS_TYPE aType);         //Public SetAccess Slow=Bit3 API, Fast=Virtual memory
00119       ACCESS_TYPE     GetAccessType() const;                //Public Query Access
00120 
00121 
00122   private:
00123       void*       RemoteStartMap;           //Virtual-memory start remap location
00124       bt_desc_t   Bit3Device;               //Bit3 Adapter ID
00125       bt_error_t  status;                   //Bit3 Error holder
00126       bt_dev_t    type;                     //Bit3 Adapter Type
00127       int         error,unit,length;        //Error Code, Bit3 Adapter number, length of remapped memory space
00128       volatile char*  address_pointer;      //Memory pointer, volatile to prevent compiler optimization
00129       char                DevName;          //Bit3 Device Name
00130       ACCESS_TYPE         aType;            //Access Type, Enumerated SAFE or FAST
00131       unsigned long       remoteAddress;    //Remote Bus memory start location (or offset)
00132       bool Initialize(int unitNo, unsigned long remote_address, void *&remote_start_map, bt_desc_t &btd); //Initialize Device and lock resources
00133       bool CloseDevice(void *remote_start_map, bt_desc_t &btd);     //Close Device and free resources
00134   };
00135 
00136   #include "Bit3IO.ipp"
00137 
00138 }
00139 #endif  //Bit3IO_hpp
00140 
RRG Homepage OSCAR Overview OSCAR Tutorials Simulations