Open
Description
For I2C message you need to pass an array of structs:
struct i2c_msg {
__u16 addr;
__u16 flags;
#define I2C_M_TEN 0x0010
#define I2C_M_RD 0x0001
#define I2C_M_STOP 0x8000
#define I2C_M_NOSTART 0x4000
#define I2C_M_REV_DIR_ADDR 0x2000
#define I2C_M_IGNORE_NAK 0x1000
#define I2C_M_NO_RD_ACK 0x0800
#define I2C_M_RECV_LEN 0x0400
__u16 len;
__u8 *buf;
};
So I defined:
@JniClass(name = "i2c_msg", flags = {STRUCT})
public static class i2cMsg {
static {
LIBRARY.load();
init();
}
@JniMethod(flags = {CONSTANT_INITIALIZER})
private static native void init();
@JniField(flags = {CONSTANT}, accessor = "sizeof(struct i2c_msg)")
public static int SIZEOF;
public short addr;
public short flags;
public short len;
public byte[] buf;
}
And I need 2 messages for a I2C read operation:
@JniMethod(accessor = "memmove")
public static final native void i2cMsgToMem(
@JniArg(cast = "void *") long dest, @JniArg(cast = "const void *", flags = {NO_OUT, CRITICAL}) i2cMsg src, @JniArg(
cast = "size_t") long size);
The above doesn't work for i2cMsg[].
Metadata
Metadata
Assignees
Labels
No labels