QPPortUserLevel.hh

00001 #ifndef _PP_USER_LEV_HH_
00002 #define _PP_USER_LEV_HH_
00003 
00004 namespace QUserLib {
00005 
00006 
00007 /*  Parallel Port Address defintion
00008  *  /dev/lp0 = 0x3bc ---> LPT0
00009  *  /dev/lp1 = 0x378 ---> LPT1
00010  *  /dev/lp2 = 0x278 ---> LPT2
00011  */
00012 
00013 
00014 //#define PPortAddress  0x378 // for /dev/lp1 (LPT1)
00015 
00016 /*
00017    Parallel port bits definition for hardware V2:
00018 
00019    Base address + 0:
00020 
00021    Bit0 = Data0 == D_I2C_SCL_OUT
00022    Bit1 = Data1 == D_I2C_SDA_OUT
00023    Bit2 = Data2 == Enable High
00024    Bit3 = Data3 == Enable Low
00025    Bit4 = Data4 == Enable Low
00026    Bit5 = Data5 == Selector Bit2
00027    Bit6 = Data6 == Selector Bit1
00028    Bit7 = Data7 == Selector Bit0
00029    
00030    Base address + 1
00031    
00032    Bit0 = Reserved
00033    Bit1 = Reserved
00034    Bit2 = IRQ (Not)
00035    Bit3 = nError nFault == D_I2C_SCL_IN
00036    Bit4 = Select In     == D_I2C_SDA_IN
00037    Bit5 = Paper out
00038    Bit6 = Ack
00039    Bit7 = Busy
00040 
00041    Due to these value follows these definition
00042    
00043 */ 
00044 
00045 
00046 // Constant definition for parallel bits modification   
00047 
00048 // costante per il controllo del tipo di hardware I2C
00049 #define Par_I2C_Hw_Ver  1 // Par_I2C_Hw_Ver=0 for hardware V1 
00050                           // Par_I2C_Hw_Ver=1 for hardware V2. 
00051 
00052 
00053 #if(Par_I2C_Hw_Ver)  
00054 
00055 // For hardware version V2
00056 #define SCL_o_H 0x01
00057 #define SCL_o_L 0x00
00058 
00059 #define SDA_o_H 0x02
00060 #define SDA_o_L 0x00
00061 
00062 #define I2C_EN  0x04
00063 #define I2C_DIS 0x14
00064 
00065 #define SCL_i 0x08
00066 #define SDA_i 0x10
00067 
00068 #else
00069 
00070 // For hardware version V1  
00071 #define SCL_o_H 0x04
00072 #define SCL_o_L 0x00
00073 
00074 #define SDA_o_H 0x08 
00075 #define SDA_o_L 0x00
00076 
00077 #define I2C_EN  0x80
00078 #define I2C_DIS 0x00
00079 
00080 #define SCL_i 0x20
00081 #define SDA_i 0x10
00082 
00083 #endif // End of "#if(Par_I2C_Hw_Ver)"
00084 
00085 
00086 // Added by AG
00087 #define TURN_ON        1
00088 #define TURN_OFF       0
00089 
00090 #define TABLE_LENGTH   8
00091 
00092 // costante per il controllo del risveglio microcontrollori in I2C-10WB converter 
00093 #define  STAND_BY_TIME  45 // Espresso in secondi       
00094 #define  WAKE_UP_DELAY  30      
00095 
00096 
00097   struct pp_time {
00098     int SCL_Time;         // To select clock amplitude
00099     int SCL_Time_Out;     // To select clock time out
00100     int Time_Delay;       // To select time between SCL and SDA
00101   };
00102   
00103 
00104   // Functions Prototype
00105   void I2C_Delay (int Time_val);
00106   
00107   int B_Init(unsigned long PPortAddress, QUserLib::pp_time time_tb[8]);
00108   
00109   int B_Close();
00110   
00111   int B_Select(char Channel);
00112   
00113   int B_Sblocco();
00114   
00115   int B_Wakeup();
00116   
00117   int B_Start();  
00118   
00119   int B_Stop();   
00120   
00121   int B_Rstart(); 
00122   
00123   int Wait_Scl();
00124   
00125   int B_Write_H();
00126   
00127   int B_Write_L();
00128   
00129   int B_Read_b(char& bit); 
00130   
00131   int B_Unlock();
00132   
00133   int B_Write(char byte);   // restituisce normalmente 0
00134   // restituisce -12 nel caso di not ACK  
00135   
00136   int B_Write_b(char byte);  // restituisce normalmente 0 
00137   // restituisce -4 nel caso di not ACK */
00138   
00139   int B_Read(char& Data);
00140   
00141   int B_NackRead(char& Data);  
00142   
00143   
00144   // write pport data line
00145   int pp_write(char byte);
00146   
00147   // return pport control line
00148   int pp_read (char& byte);
00149     
00150 };
00151 
00152 #endif // _PP_USER_LEV_HH_

Generated on Tue Nov 16 10:49:54 2010 for CUORE Software by  doxygen 1.5.6