📄 drv2user.cpp
字号:
* NxtLeaveCriticalSection
*
* Called by DRV2002 on exit from a critical section
*
* Inputs:
* NxtCSHandle_t cs - handle of the critical section being released
*
* Returns:
* non-zero for failure
* 0 for success
*
**********************************************************************/
Data8 NxtLeaveCriticalSection( PFAST_MUTEX pMutex ) {
#ifdef CSDEBUG
DbgLogInfo(("NxtLeaveCriticalSection, pMutex = %x\n", pMutex));
#endif
if ( !pMutex )
{
return FAILURE;
}
ASSERT( KeGetCurrentIrql() == APC_LEVEL );
ExReleaseFastMutex(pMutex);
return SUCCESS;
} /* NxtLeaveCriticalSection */
/**********************************************************************
*
* NxtAllocateMem
*
* Called by DRV2002 to dynamically allocate memory.
*
* Inputs:
* Data16 byteCount - number of bytes of memory to allocate
*
* Returns:
* void* - pointer to allocated memory, NULL for failure
*
* Notes:
* This function is only used in DRV2CNTX.C to allocate device control
* blocks for multiple NXT2002 instances.
*
**********************************************************************/
/* NxtAllocateMemory -- MACRO defined in drv2user.h
void *NxtAllocateMemory(Data16 byteCount) {
} /* NxtAllocateMemory */
/**********************************************************************
*
* NxtFreeMem
*
* Called by DRV2002 to release dynamically allocated memory.
*
* Inputs:
* void *pBuffer - pointer to allocated memory to be released
*
* Notes:
* This function is only used in DRV2CNTX.C to release device control
* blocks for multiple NXT2002 instances.
*
**********************************************************************/
/* NxtFreeMemory -- MACRO defined in drv2user.h
void NxtFreeMemory(void *pBuffer) {
} /* NxtFreeMemory */
/* Hardware-Specific Functions */
/**********************************************************************
*
* NxtGetDevAddr
*
* Called by DRV2002 to learn the I2C address of the referenced ASIC
*
* Inputs:
* void *pContext - identifies which NXT2002 instance
*
* Returns:
* Data8 - the I2C device address of the referenced NXT2002 instance
*
**********************************************************************/
Data8 NxtGetDevAddr( void *pContext ) {
DbgLogInfo(("NxtGetDevAddr(), iicAddr = %x\n", NXTWAVE_I2C_ADDR));
return (Data8)NXTWAVE_I2C_ADDR;
} /* NxtGetDevAddr */
/**********************************************************************
*
* iicRead (optional)
*
* Called by tuner control software
*
* Inputs:
* Data8 iicAddr - device address
* Data8 byteCount - number of bytes to read
*
* Outputs:
* Data8 *pBuffer - read data bytes are copied to this buffer
*
* Returns:
* 0 for success
* non-zero for failure
*
**********************************************************************/
Data8 iicRead( Data8 iicAddr, Data8 byteCount, Data8 *pBuffer ) {
DbgLogInfo(("iicRead()\n"));
return FAILURE;
} /* iicRead */
/**********************************************************************
*
* iicWrite (optional)
*
* Called by tuner control software
*
* Inputs:
* Data8 iicAddr - device address
* Data8 byteCount - number of bytes to write
* Data8 *pBuffer - write data bytes are copied from this buffer
*
* Returns:
* 0 for success
* non-zero for failure
*
**********************************************************************/
Data8 iicWrite( Data8 iicAddr, Data8 byteCount, Data8 *pBuffer) {
DbgLogInfo(("iicWrite()\n"));
return FAILURE;
} /* iicWrite */
/**********************************************************************
*
* iicRegRead
*
* Called by DRV2002 to read NXT2002 registers
*
* Inputs:
* void *pContext - tuner device/data extension
* Data8 iicAddr - device address
* Data8 regAddr - NXT2002 register to read
* Data8 byteCount - number of bytes to read
*
* Outputs:
* Data8 *pBuffer - read data bytes are copied to this buffer
*
* Returns:
* 0 for success
* non-zero for failure
*
**********************************************************************/
Data8 iicRegRead(
void *pContext,
Data8 iicAddr,
Data8 regAddr,
Data8 byteCount,
Data8 *pBuffer )
{
BOOL hr;
PTUNER_DATA_EXTENSION pTunerDataExt = (PTUNER_DATA_EXTENSION)pContext;
#ifdef I2CDEBUG
char dbuf[512];
DWORD i;
DbgLog(("iicRegRead, iicAddr=%02x regAddr=%02x byteCount=%02x\n", iicAddr, regAddr, byteCount));
#endif
hr = pTunerDataExt->i2c_interface.readRegister(
iicAddr,
regAddr,
pBuffer,
byteCount);
if (!hr)
{
DbgLogWarn(("I2CReadRegister() failed\n"));
return -1;
}
#ifdef I2CDEBUG
for (i = 0;i < byteCount; ++i)
{
DbgLog(("%x\n", pBuffer[i]));
}
#endif
return SUCCESS;
} /* iicRegRead */
/**********************************************************************
*
* iicRegWrite
*
* Called by DRV2002 to write to NXT2002 registers
*
* Inputs:
* void *pContext - tuner device/data extension
* Data8 iicAddr - device address
* Data8 regAddr - NXT2002 register to write
* Data8 byteCount - number of bytes to write
* Data8 *pBuffer - write data bytes are copied from this buffer
*
* Returns:
* 0 for success
* non-zero for failure
*
**********************************************************************/
Data8 iicRegWrite(
void *pContext,
Data8 iicAddr,
Data8 regAddr,
Data8 byteCount,
Data8 *pBuffer)
{
BOOL hr;
DWORD i;
BOOL bGotError;
Data8 pDataVerify[512];
PTUNER_DATA_EXTENSION pTunerDataExt = (PTUNER_DATA_EXTENSION)pContext;
#ifdef I2CDEBUG
DbgLog(("iicRegWrite iicAddr=%02x regAddr=%02x byteCount=%02x\n",
iicAddr, regAddr, byteCount));
for ( i = 0; i < byteCount; ++i )
{
DbgLog(("%x\n", pBuffer[i]));
}
#endif
hr = pTunerDataExt->i2c_interface.writeRegister(
iicAddr,
regAddr,
pBuffer,
byteCount);
if (!hr)
{
DbgLogWarn(("I2CWriteRegister() failed\n"));
return -1;
}
#if 0
hr = pTunerDataExt->i2c_interface.readRegister(
iicAddr,
regAddr,
pDataVerify,
byteCount);
if ( !hr )
{
DbgLogWarn(("I2CReadRegister() for write verify failed\n"));
return FALSE;
}
bGotError = FALSE;
for ( i = 0; i < byteCount; ++i )
{
if (pDataVerify[i] != pBuffer[i])
{
DbgLogWarn(("iicWriteRegister error:base %x, index %x, addr %x, wrote %x, read %x\n",regAddr,i,regAddr+i,pBuffer[i],pDataVerify[i]));
bGotError = TRUE;
}
}
if (!bGotError)
{
DbgLogTrace(("iicWriteRegister verify OK:base %x, count %x\n",regAddr,byteCount));
}
#endif
return SUCCESS;
} /* iicRegWrite */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -