6410SPI驱动中SPI_IOControl参数的意义

Daniel_li 2012-03-16 03:46:00
在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怎么传递参数给这个参数?谁能指导一下呀?
...全文
198 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
Daniel_li 2012-04-01
  • 打赏
  • 举报
回复
多谢yangxingbo0311 & Arthur_zeng,问题圆满解决!
四极管 2012-03-22
  • 打赏
  • 举报
回复
https://forum.csdn.net/PointForum/ui/scripts/csdn/Plugin/003/monkey/16.gif
四极管 2012-03-22
  • 打赏
  • 举报
回复
DeviceIoControl函数原型
BOOL DeviceIoControl(
HANDLE hDevice, //驱动文件句柄,由CreateFile()获得
DWORD dwIoControlCode, //命令码
LPVOID lpInBuffer, //输入缓冲区
DWORD nInBufferSize, //输入缓冲区大小
LPVOID lpOutBuffer, //输出缓冲区
DWORD nOutBufferSize, //输出缓冲区大小
LPDWORD lpBytesReturned, //实际输出的数据数量
LPOVERLAPPED lpOverlapped //I/O重叠操作,Windows CE5.0中取值为NULL
)
其中,hDevice为驱动文件句柄。该句柄取自CreateFile()函数的返回值。其他输入/输出参数根据功能的不同而不同。说明如下:
本项目中,各参数对应如下:
参数 实现 描述
Hdevice m_hPMIC CreateFile//返回的设备句柄
dwIoControlCode IOCTL_PMU_REGULATOR_ON //自己定义的DCDC/LDO开
lpInBuffer &pmic_data //应用程序传递给驱动程序的数据缓冲区地址
nInBufferSize sizeof(UINT32) //应用程序传递给驱动程序的数据缓冲区大小,字节数
lpOutBuffer &dat //驱动程序返回给应用程序的数据缓冲区地址
nOutBufferSize sizeof(UINT32) //驱动程序返回给应用程序的数据缓冲区大小,字节数
lpBytesReturned &bytes //驱动程序实际返回给应用程序的数据字节数地址
lpOverlapped NULL //I/O重叠操作,Windows CE5.0中取值为NULL
月之海 2012-03-22
  • 打赏
  • 举报
回复
通过CreateFile,获取到设备上下文的句柄
月之海 2012-03-22
  • 打赏
  • 举报
回复
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.
月之海 2012-03-22
  • 打赏
  • 举报
回复
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.

19,502

社区成员

发帖
与我相关
我的任务
社区描述
硬件/嵌入开发 嵌入开发(WinCE)
社区管理员
  • 嵌入开发(WinCE)社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧