device.h 5.52 KB
Newer Older
Alexander Steffens's avatar
Alexander Steffens committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
#ifndef DEVICE_H
#define DEVICE_H

#include <QList>
#include "device_def.h"

class Device
{

public:
//    explicit    Device(int vendor, int nr, bool *ok);
    explicit    Device(int vendor, int nr, DEVICE_DATA *devdata, bool *ok);
    virtual     ~Device();

    bool        CloseDevice();

    void        GetPlxInfo(DEV_PLX_INFO *info);
    void        GetLinkInfo(DEV_LINK_INFO *info);
    void        GetBaseInfo(DEV_BASE_INFO *info);

    bool        CheckPlxError();
    bool        CheckLinkError();

    DEVICE_DATA *GetDeviceDataPtr();

    bool        IsCentralClockAvail();
    bool        IsClkResetAvailable();

    void        SyncReset();
    void        SyncStart();
    void        SyncStop();
    void        SyncStartReset();
    quint32     CCS_Read(quint32 addr, bool b32);
    void        CCS_Write(quint32 addr, quint32 val, bool b32);

    qint32      I2C_Read(quint32 regI2CData, quint8 *buf, quint32 len, int hw);
    qint32      I2C_Write( quint32 regI2CData, quint8 *buf, quint32 len, int hw);
    qint32      I2C_Wait_Rdy(quint32 regI2CData, int hw);

virtual quint32             ReadEEProm( quint32 regI2CAdr,
                                        quint32 regI2CData,
                                        quint32 i2cDevAdr,
                                        quint32 fromAdr,
                                        bool *ok,
                                        int hw);

virtual bool                WriteEEProm(quint32 regI2CAdr,
                                        quint32 regI2CData,
                                        quint32 i2cDevAdr,
                                        quint32 toAdr,
                                        quint32 data,
                                        int hw);

virtual bool                WriteEEPromStr( quint32 regI2CAdr,      // I2C Adress Register
                                            quint32 regI2CData,     // I2C Data Register
                                            quint32 i2cDevAdr,      // I2C Adresse des Bausteins EEPRom = 0x50
                                            quint32 toAdr,          // Adresse innerhalb des Bausteins
                                            QString StrData,           // zu schreibende Daten
                                            int hw);                // Hardware, CCS oder Maroc/Concentrator

virtual QString             ReadEEPromStr(  quint32 regI2CAdr,      // I2C Adress Register
                                            quint32 regI2CData,     // I2C Data Register
                                            quint32 i2cDevAdr,      // I2C Adresse des Bausteins EEPRom = 0x50
                                            quint32 fromAdr,        // Adresse innerhalb des Bausteins
                                            bool    *ok,            // true wenn erfolgreich
                                            int     hw);            // Hardware, CCS oder Maroc/Concentrator

virtual quint32             ReadLinkMemReg(quint32 regno, bool *ok = 0, bool check = true);    // Register im Memory Bereich > 0x800
virtual bool                WriteLinkMemReg(quint32 regno, quint32 value, bool check = true);
virtual bool                DMA_DataAvail(quint32 FifoReadAllData, quint32 *sr);

    quint32             ReadBaseReg(quint32 regno, bool *ok = 0, bool check=true);       // Register auf der "SIS" Karte
    bool                WriteBaseReg(quint32 regno, quint32 value, bool check=true);


    quint8              ReadPlxRegByte(quint32 regno, bool *ok, bool check);
    bool                WritePlxRegByte(quint32 regno, quint8 value, bool check);


//    quint32             ReadExtBaseReg(quint32 regno, bool *ok = 0);    // Register im Register Bereich am Link
//    bool                WriteExtBaseReg(quint32 regno, quint32 value);

    bool                PlxEEpromWriteSRNumber(quint32 data);
    bool                PlxEEPromReadSRNumber(quint32 *data);

    bool                PlxEEpromWriteSegmentNumber(quint32 data);
    bool                PlxEEPromReadSegmentNumber(quint32 *data);


    int                 DMA_Init();
    int                 DMA_Exit();
    int                 DMA_ReadFifo(quint32 *anz, quint32 FifoRegAdr);
    quint32             DMA_CopyData(quint32 anz, quint32 *Data);

    void                ClearProtocolError();


    DEVICE_DATA         _DeviceData;

//protected:


//signals:

//public slots:

private:



    PLX_STATUS          FindDevice();
    PLX_STATUS          OpenDevice();
    PLX_STATUS          GetPciBars();

    bool                InitLink();

    int                 CheckProtocolError(int mark, QString info);


    // DMA gedönse...
    int                 DMA_GetDriverMemSize();
    int                 DMA_FreeMemory();


    bool                _ClkResetAvail;
    bool                _CentralClockAvail;
    void                CheckClkResetAvailable();

    quint32             I2C_ReadReg(quint32 reg, bool *ok, int hw = HW_MAROC);
    bool                I2C_WriteReg(quint32 reg, quint32 val, int hw = HW_MAROC);


    quint8              _getValue();
    void                _setValue(quint8 v);

    void                ee9656_clock(quint32 d);		// 0 or EEP_DI
    void                ee9656_deselect(void);
    void                ee9656_setup(quint32 len, quint32 val);	// # of bits, bit pattern
    int                 ee9656_read(quint32 adr, quint32 *val);
    int                 ee9656_write(quint32 adr, quint32 val);

};

#endif // DEVICE_H