www.pudn.com > PROFIBUS_DP_protocol_source.ZIP > profim.h, change:2004-03-17,size:5338b


//----------------------------------------------------------------------------- 
// $Id: ProfiM.h,v 1.0.0                                            2004/01/13 
//----------------------------------------------------------------------------- 
// 
//      ProfiM - PROFIBUS MASTER DRIVER FOR WINDOWS NT/2000 
// 
// Author:   
//      Pavel Trnka, CTU FEE 
//      trnkap@seznam.cz 
// With help and advices from: 
//      Ing. Petr Smolik, CTU FEE 
//      Ing. Pavel Pisa, CTU FEE 
//      Ing. Pavel Burget, CTU FEE 
// 
//----------------------------------------------------------------------------- 
 
 
#define DEF_PORT_ADDRESS    0x2F8 
#define DEF_PORT_RANGE      0x07 
#define DEF_IRQ_LINE        0x03 
 
 
//--------------------------------------------------------------------------- 
//  Deklarace struktury TProfibus 
// 
struct  TProfibus;   
 
 
enum TModemIntStatus 
{ 
  MI_Enabled, 
  MI_Disabled, 
  MI_JustDisabled 
}; 
 
 
//--------------------------------------------------------------------------- 
// 
// *Note* 
// ALL variables and data storage should be placed in  
// the following data structure. 
// 
 
typedef struct _PROFIM_DEVICE_EXTENSION 
{ 
    int                   magic;      // structure control identificator 
    PDEVICE_OBJECT        DeviceObject; 
    PKINTERRUPT           InterruptObject; 
    KIRQL                 Irql; 
    ULONG                 InterruptCount; 
    ULONG                 RcvError; 
    ULONG                 ioCtlCode; 
    PUCHAR                PortAddress; 
    KIRQL                 IRQLine; 
    ULONG                 BaudRate; 
    COMPORT               ComPort; 
    KEVENT                XmitDone; 
 
     
    int                   BufferSize; 
     
    PUCHAR                XmitBuffer; 
     
    // ke kazdemu znaku z bufferu urcuje jeho typ 
    PUCHAR                XmitTypeBuffer;  
     
    // index prvniho bytu pro vysilani 
    int                   XmitFirst;     
     
    // index poslendiho prazdneho mista v bufferu - o jeden znak  
    // za poslednim pridanym bytem 
    int                   XmitLast;    
     
    // Indikuje nastaveni smeru na vysilani 
    BOOLEAN               Sending;     
     
    // typ znaku, ktery je prave vysilan (DATA/TIMING/SYN) 
    int                   ActualType;    
     
    // odpocitavadlo RX preruseni - po vynulovani zmena smeru vysilani 
    int                   RXCountDown;   
 
    TProfibus             PB; 
 
    // Flusch Timing Chars - priznak k vymazani vsech casovacich 
    // znaku ze zacatku vysilaci fronty 
    BOOLEAN               FlushTCH;        
 
#ifdef PISA_IO 
    enum TModemIntStatus  ModemInterruptState; 
    __int64               MIEnabledTime; 
#endif 
 
//#ifdef PnP 
    // <PnP> 
    ULONG                 State;            // State for PnP Purposes 
    PDEVICE_OBJECT        PhysicalDeviceObject; 
    PDEVICE_OBJECT        DeviceToSendIrpsTo; 
    UNICODE_STRING        ntdev_name;       // NT Device Name 
    UNICODE_STRING        link_name;        // DOS Link Name 
    KEVENT                RemoveEvent;      // Set when no PnP IRP pending 
    long                  port;             // base port number 
    int                   irq;              // irq number 
    BOOLEAN               MappedPorts;      // Ports mapped into memory space 
    ULONG                 InterruptAffinity; 
    ULONG                 InterruptMode;   
    LONG                  OutstandingIO;    // Number of unfinished IRPs   
    // </PnP>     
//#endif 
 
    // citac pro generovani Handle ID - identifikacni cislo prirazene kazdemu 
    // nove oteviranemu handle k ProfiMu 
    int                   HIDCounter;    
    TIrpBuffer            IrpB; 
     
    int                   ChipOptions; 
    unsigned              chip_temp;    // temporary variable for chip driver  
    unsigned              chip_buff[6]; // buffer for chip driver  
    int                   baud_div;     // used baud divisor  
    int                   baud_val;     // selected speed  
    long                  baud_base;    // XTAL base clocks  
    int                   chip_options; // additional chip minor diferences  
     
     
    BOOLEAN               Buffering; 
    BOOLEAN               ContinueBuffering;  // unused? 
 
    int                   RTL;          // Receiver Interrupt Trigger Level 
    char                  FrameHeader[3]; 
    BOOLEAN               ContinueFrame; 
         
    // WatchDog Trigger - zustane-li =1 pri vyvolani WatchDogRoutine (perioda 1s) 
    // je proveden restart mastera. Nulovani je zajisteno v kazdem pruchodu ISR. 
    int                   WatchDogTrigger;   
     
    KSPIN_LOCK            InterruptSpinLock; 
    PIRP                  TempIrp; 
     
    KDPC                  CompleteDPC; 
     
    BOOLEAN               CompleteIrp; 
     
    BOOLEAN               InterruptRunning; /*DEBUG*/ 
    BOOLEAN               SecondInterrupt; /*DEBUG*/ 
    UCHAR                 LastIIR; /*DEBUG*/ 
     
    BOOLEAN               PiKRON; 
     
} PROFIM_DEVICE_EXTENSION, *PPROFIM_DEVICE_EXTENSION; 
 
 
void                  StoreHIDinRB( fdl_rb *rb, int HID ); 
void                  StoreIRPinRB( fdl_rb *rb, PIRP IRP ); 
int                   ReadHIDfromRB( fdl_rb *rb ); 
PIRP                  ReadIRPfromRB( fdl_rb *rb );