我正在尝试将 Arduino 程序移植到 Linux。我被困住了,因为我似乎无法找到Arduino 在“Wire.h”中的I²C功能的等价物。
线头:线库
Linux i2C-dev.h:在 Linux 中使用来自用户空间的 I²C
具体来说,我看不出我该怎么做
Wire.request(address, num_of_bytes); //Request 4 bytes
int a = Wire.receive(); //Receive the four bytes
int b = Wire.receive();
int c = Wire.receive();
int d = Wire.receive();
Linux 似乎没有从 I²C 设备请求特定字节数的等价物。我想“i2c_smbus_read_byte”相当于接收,如果连续调用它会提升可用字节。
Linux 中的 I²C 选项:
i2c_smbus_write_quick( int file, __u8 value)
i2c_smbus_read_byte(int file)
i2c_smbus_write_byte(int file, __u8 value)
i2c_smbus_read_byte_data(int file, __u8 command)
i2c_smbus_write_byte_data(int file, __u8 command, __u8 value)
i2c_smbus_read_word_data(int file, __u8 command)
i2c_smbus_write_word_data(int file, __u8 command, __u16 value)
i2c_smbus_process_call(int file, __u8 command, __u16 value)
i2c_smbus_read_block_data(int file, __u8 command, __u8 *values)
i2c_smbus_write_block_data(int file, __u8 command, __u8 length, __u8 *values)
i2c_smbus_read_i2c_block_data(int file, __u8 command, __u8 *values)
i2c_smbus_write_i2c_block_data(int file, __u8 command, __u8 length, __u8 *values)
i2c_smbus_block_process_call(int file, __u8 command, __u8 length, __u8 *values)