当前位置: 代码迷 >> WinCE >> 6410SPI驱动中SPI_IOControl参数的意义,该如何解决
  详细解决方案

6410SPI驱动中SPI_IOControl参数的意义,该如何解决

热度:53   发布时间:2016-04-28 13:11:24.0
6410SPI驱动中SPI_IOControl参数的意义
在6410SPI的驱动中函数SPI_IOControl有以下几个参数:
BOOL SPI_IOControl(
DWORD dwInst,
DWORD dwIoControlCode,
PBYTE lpInBuf,
DWORD nInBufSize,
PBYTE lpOutBuf,
DWORD nOutBufSize,
LPDWORD lpBytesRetruned)
而在6410的ADC驱动中,ADC_IOControl有以下的几个参数:
BOOL ADC_IOControl(DWORD Handle,
DWORD dwIoControlCode,
PDWORD pInBuf,
DWORD nInBufSize,
PDWORD pOutBuf,
DWORD nOutBufSize,
PDWORD pBytesReturned)
SPI_IOControl中的DWORD dwInst和ADC_IOControl中的DWORD Handle是什么意思呀?DeviceIoControl怎么传递参数给这个参数?谁能指导一下呀?

------解决方案--------------------
BOOL XXX_IOControl(
DWORD hOpenContext,
DWORD dwCode,
PBYTE pBufIn,
DWORD dwLenIn,
PBYTE pBufOut,
DWORD dwLenOut,
PDWORD pdwActualOut 
);
hOpenContext 
[in] Handle to the open context of the device. The XXX_Open (Device Manager) function creates and returns this identifier.

dwCode 
[in] I/O control operation to perform. These codes are device-specific and are usually exposed to developers through a header file.

pBufIn 
[in] Pointer to the buffer containing data to transfer to the device.

dwLenIn 
[in] Number of bytes of data in the buffer specified for pBufIn.

pBufOut 
[out] Pointer to the buffer used to transfer the output data from the device.

dwLenOut 
[in] Maximum number of bytes in the buffer specified by pBufOut.

pdwActualOut 
[out] Pointer to the DWORD buffer that this function uses to return the actual number of bytes received from the device.

------解决方案--------------------
BOOL DeviceIoControl(
HANDLE hDevice,
DWORD dwIoControlCode,
LPVOID lpInBuffer,
DWORD nInBufferSize,
LPVOID lpOutBuffer,
DWORD nOutBufferSize,
LPDWORD lpBytesReturned,
LPOVERLAPPED lpOverlapped
);
hDevice 
[in] Handle to the device that is to perform the operation. To obtain a device handle, call the CreateFile function. 

dwIoControlCode 
[in] IOCTL for the operation. This value identifies the specific operation to perform and the type of device on which to perform the operation. There are no specific values defined for the dwIoControlCode parameter. However, you can define custom IOCTL_XXX IOCTLs with the CTL_CODE macro. You can then advertise these IOCTLs and an application can use these IOCTLs with DeviceIoControl to perform the driver-specific functions.


For more information on the CTL_CODE macro, see CTL_CODE.

lpInBuffer 
[in] Long pointer to a buffer that contains the data required to perform the operation. Set to NULL if the dwIoControlCode parameter specifies an operation that does not require input data. 

nInBufferSize 
[in] Size, in bytes, of the buffer pointed to by lpInBuffer. 

lpOutBuffer 
[out] Long pointer to a buffer that receives the output data for the operation. Set to NULL if the dwIoControlCode parameter specifies an operation that does not produce output data. 

nOutBufferSize 
[out] Size, in bytes, of the buffer pointed to by lpOutBuffer. 

lpBytesReturned 
[out] Long pointer to a variable that receives the size, in bytes, of the data stored in lpOutBuffer. The DeviceIoControl function may unnecessarily use this parameter. For example, if an operation does not produce data for lpOutBuffer and lpOutBuffer is NULL, the value of lpBytesReturned is meaningless.

lpOverlapped 
[in] Ignored; set to NULL. 

------解决方案--------------------
  相关解决方案