|
IIC驱动中的结构如下:
typedef struct _I2C_IO_DESC {
DWORD SlaveAddr; // Target Slave Address
UCHAR WordAddr; // Starting Slave Word Address
PUCHAR Data; // pBuffer
DWORD Count; // nBytes to read/write
} I2C_IO_DESC, *PI2C_IO_DESC;
---
这个是接口原型:
BOOL
I2C_IOControl(
PI2C_CONTEXT pI2C,
DWORD dwCode,
PBYTE pBufIn,
DWORD dwLenIn,
PBYTE pBufOut,
DWORD dwLenOut,
PDWORD pdwActualOut
)
---
这是实际的写操作:(是在I2C_IOControl函数里面的)
dwErr = HW_Write(pI2C,
((PI2C_IO_DESC)pBufIn)->SlaveAddr,
((PI2C_IO_DESC)pBufIn)->WordAddr,
puc,
((PI2C_IO_DESC)pBufIn)->Count);
---
(PI2C_IO_DESC)pBufIn) 转换后,调用数据包中的各种数据
--------
问题:
在应用层用怎么通过DeviceIoControl来传递数据
DeviceIoControl(hFile,
IOCTL_I2C_WRITE,
xxx,
xxx,
0,
0,
0,
0);
我要将slaveraddr、WordAddr、写入数据的地址、写入数据的数量 通过结构体送入驱动
|
|