⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ohcdinc.hpp

📁 WinCE 3.0 BSP, 包含Inter SA1110, Intel_815E, Advantech_PCM9574 等
💻 HPP
📖 第 1 页 / 共 2 页
字号:


// Host Controller Communications Area

// Host Controller Communications Area info
const DWORD gcHccaByteSize                  = 256;

inline PULONG HccaInterrupt(PBYTE pHcca, UINT intrNum)
{       return((PULONG)(pHcca + 4 * intrNum));   }

inline PUSHORT HccaFrameNumber(PBYTE pHcca)
{       return((PUSHORT)(pHcca + 0x80));   }

inline PUSHORT HccaPad1(PBYTE pHcca)
{       return((PUSHORT)(pHcca + 0x82));   }

inline PULONG HccaDoneHead(PBYTE pHcca)
{       return((PULONG)(pHcca + 0x84));   }



// Descriptors

const DWORD gcEdHalted          = 0x00000001;
const DWORD gcEdToggleCarry     = 0x00000002;
const DWORD gcEdTdQueueHeadMask = 0xFFFFFFF0;

struct SEndpointDescriptor
{
    DWORD   bfFunctionAddress:7;        // bits 0-6
    DWORD   bfEndpointNumber:4;         // bits 7-10
    DWORD   bfDirection:2;              // bits 11-12
    DWORD   bfIsLowSpeed:1;             // bit 13
    DWORD   bfSkip:1;                   // bit 14
    DWORD   bfIsIsochronous:1;          // bit 15
    DWORD   bfMaxPacketSize:11;         // bits 16-26
    DWORD   bfUnused:5;                 // bits 17-31
    ULONG   paTdQueueTail;
    ULONG   paTdQueueHead;
    ULONG   paNextEd;
};

const DWORD gcOhcdPageSizeAssumption = 0x1000; //4k
const DWORD gcMaxSingleTdDataLength = 0x2000; //8K

const DWORD gcTdPidSetup        = 0x0;
const DWORD gcTdPidOut          = 0x1;
const DWORD gcTdPidIn           = 0x2;
const DWORD gcTdPidTdSetsDir    = 0x0;
const DWORD gcTdNoInterrupt     = 0x7;
const DWORD gcTdToggleUseLocal  = 0x2;
const DWORD gcTdToggleUseCarry  = 0x0;

const DWORD gcTdCCNoError                   = 0x0;
const DWORD gcTdCCCrc                       = 0x1;
const DWORD gcTdCCBitStuffing               = 0x2;
const DWORD gcTdCCDataToggleMismatch        = 0x3;
const DWORD gcTdCCStall                     = 0x4;
const DWORD gcTdCCDeviceNotResponding       = 0x5;
const DWORD gcTdCCPidCheckFailure           = 0x6;
const DWORD gcTdCCUnexpectedPid             = 0x7;
const DWORD gcTdCCDataOverrun               = 0x8;
const DWORD gcTdCCDataUnderrun              = 0x9;
const DWORD gcTdCCReserved1                 = 0xA;
const DWORD gcTdCCReserved2                 = 0xB;
const DWORD gcTdCCBufferOverrun             = 0xC;
const DWORD gcTdCCBufferUnderrun            = 0xD;
// Correct way to check for not accessed is
// if ((cc & gcTdCCNotAccessedMask) == gcTdCCNotAccessedMask)
const DWORD gcTdCCNotAccessedMask           = 0xE;

const DWORD gcITdPageMask                   = 0xFFFFF000;
const DWORD gcITdPswSizeMask                = 0x07FF;
const DWORD gcITdPswConditionCodeMask       = 0xF000;
// These are the low order bits of paBufferPage0
const DWORD gcITdAddrBitSize                = 0x00000007;
const DWORD gcITdAddrMask                   = 0x0000007F;
const DWORD gcITdEndptMask                  = 0x00000F80;

const UINT gcITdNumOffsets                  = 8;
const USHORT gcITdOffsetPageSelectBit       = 0x1000;
const USHORT gcITdOffsetMask                = 0x0FFF;
const USHORT gcITdOffsetNotAccessed         = 0xE000;

struct SGeneralTransferDescriptor
{
    DWORD   bfAddr:7;                       // bits 0-6     OHCD specific
    DWORD   bfEndptArrayNum:5;              // bits 7-11    OHCD specific
    DWORD   bfDataCounted:1;                // bits 12      OHCD specific
    DWORD   bfUnused:2;                     // bits 13-14
    DWORD   bfLastTd:1;                     // bit 15       OHCD specific
    DWORD   bfFastDataCopyRequired:1;       // bits 16      OHCD specific
    DWORD   bfIsIsoch:1;                    // bit 17       OHCD specific
    DWORD   bfShortPacketOk:1;              // bit 18
    DWORD   bfPID:2;                        // bits 19-20
    DWORD   bfDelayInterrupt:3;             // bits 21-23
    DWORD   bfDataToggle:2;                 // bits 24-25
    DWORD   bfErrorCount:2;                 // bits 26-27
    DWORD   bfConditionCode:4;              // bits 28-31
    ULONG   paCurBuffer;
    ULONG   paNextTd;
    ULONG   paBufferEnd;
};

struct SIsochTransferDescriptor
{
    DWORD   bfStartFrame:16;                // bits 0-15
    DWORD   bfFastDataCopyRequired:1;       // bits 16      OHCD specific
    DWORD   bfIsIsoch:1;                    // bit 17       OHCD specific
    DWORD   bfUnused:3;                     // bits 18-20
    DWORD   bfDelayInterrupt:3;             // bits 21-23
    DWORD   bfFrameCount:3;                 // bits 24-26
    DWORD   bfLastTd:1;                     // bit 27       OHCD specific
    DWORD   bfConditionCode:4;              // bits 28-31
    DWORD   paBufferPage0;                  // And with gcITdPageMask
    DWORD   paNextTd;
    DWORD   paBufferEnd;
    USHORT  offsetPsw[gcITdNumOffsets];
};


// Helper inline functions.

// Warning!       the following functions can all overwrite eachother
//                because they all access the HcCommandStatus Register!!!

inline void
ClearControlListFilledBit(REGISTER regBase)
{
    ULONG dwValue;
    dwValue = READ_REGISTER_ULONG(HcCommandStatus(regBase));
    dwValue &= ~gcHcCommandStatusCLFmask;
    WRITE_REGISTER_ULONG(HcCommandStatus(regBase), dwValue);
}

inline void
SetControlListFilledBit(REGISTER regBase)
{
    ULONG dwValue;
    dwValue = READ_REGISTER_ULONG(HcCommandStatus(regBase));
    dwValue |= gcHcCommandStatusCLFmask;
    WRITE_REGISTER_ULONG(HcCommandStatus(regBase), dwValue);
}

inline void
ClearBulkListFilledBit(REGISTER regBase)
{
    ULONG dwValue;
    dwValue = READ_REGISTER_ULONG(HcCommandStatus(regBase));
    dwValue &= ~gcHcCommandStatusBLFmask;
    WRITE_REGISTER_ULONG(HcCommandStatus(regBase), dwValue);
}

inline void
SetBulkListFilledBit(REGISTER regBase)
{
    ULONG dwValue;
    dwValue = READ_REGISTER_ULONG(HcCommandStatus(regBase));
    dwValue |= gcHcCommandStatusBLFmask;
    WRITE_REGISTER_ULONG(HcCommandStatus(regBase), dwValue);
}

// WARNING!       the following functions can all overwrite eachother
//                because they all access the HcControl Register!!!
inline void
EnableAllLists(REGISTER regBase)
{
    ULONG dwValue;
    dwValue = READ_REGISTER_ULONG(HcControl(regBase));
    dwValue |=
        gcHcControlPLEmask  |   // Periodic List
        gcHcControlIEmask   |   // Isochronous
        gcHcControlCLEmask  |   // Control List
        gcHcControlBLEmask;     // Bulk List
    WRITE_REGISTER_ULONG(HcControl(regBase), dwValue);
}

inline void
DisableAllLists(REGISTER regBase)
{
    ULONG dwValue;
    dwValue = READ_REGISTER_ULONG(HcControl(regBase));
    dwValue &= ~(gcHcControlPLEmask | gcHcControlIEmask | gcHcControlCLEmask |
        gcHcControlBLEmask);
    WRITE_REGISTER_ULONG(HcControl(regBase), dwValue);
}


inline void
EnableControlList(REGISTER regBase)
{
    ULONG dwValue;
    dwValue = READ_REGISTER_ULONG(HcControl(regBase)) | gcHcControlCLEmask;
    WRITE_REGISTER_ULONG(HcControl(regBase), dwValue);
}

inline void
DisableControlList(REGISTER regBase)
{
    ULONG dwValue;
    dwValue = READ_REGISTER_ULONG(HcControl(regBase)) & ~gcHcControlCLEmask;
    WRITE_REGISTER_ULONG(HcControl(regBase), dwValue);
}


inline void
EnableBulkList(REGISTER regBase)
{
    ULONG dwValue;
    dwValue = READ_REGISTER_ULONG(HcControl(regBase)) | gcHcControlBLEmask;
    WRITE_REGISTER_ULONG(HcControl(regBase), dwValue);
}

inline void
DisableBulkList(REGISTER regBase)
{
    ULONG dwValue;
    dwValue = READ_REGISTER_ULONG(HcControl(regBase)) & ~gcHcControlBLEmask;
    WRITE_REGISTER_ULONG(HcControl(regBase), dwValue);
}


inline void
EnableIntrAndIsochLists(REGISTER regBase)
{
    ULONG dwValue;
    dwValue = READ_REGISTER_ULONG(HcControl(regBase)) |
        gcHcControlPLEmask | gcHcControlIEmask;
    WRITE_REGISTER_ULONG(HcControl(regBase), dwValue);
}

inline void
DisableIntrAndIsochLists(REGISTER regBase)
{
    ULONG dwValue;
    dwValue = READ_REGISTER_ULONG(HcControl(regBase)) &
        ~(gcHcControlPLEmask | gcHcControlIEmask);
    WRITE_REGISTER_ULONG(HcControl(regBase), dwValue);
}




#endif //_OHCDINC_HPP_

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -