mirror of
https://github.com/boschsensortec/BME280_SensorAPI.git
synced 2024-10-05 20:47:48 -04:00
Always use ioctl to set device address
This commit is contained in:
parent
1df746c9fa
commit
b6d402ff6a
@ -20,10 +20,8 @@
|
|||||||
* \include linux_userspace.c
|
* \include linux_userspace.c
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
|
||||||
#include <linux/i2c-dev.h>
|
#include <linux/i2c-dev.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#endif
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/*! System header files */
|
/*! System header files */
|
||||||
@ -154,18 +152,15 @@ int main(int argc, char* argv[])
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __KERNEL__
|
/* Make sure to select BME280_I2C_ADDR_PRIM or BME280_I2C_ADDR_SEC as needed */
|
||||||
|
id.dev_addr = BME280_I2C_ADDR_PRIM;
|
||||||
|
|
||||||
if (ioctl(id.fd, I2C_SLAVE, id.dev_addr) < 0)
|
if (ioctl(id.fd, I2C_SLAVE, id.dev_addr) < 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to acquire bus access and/or talk to slave.\n");
|
fprintf(stderr, "Failed to acquire bus access and/or talk to slave.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Make sure to select BME280_I2C_ADDR_PRIM or BME280_I2C_ADDR_SEC as needed */
|
|
||||||
id.dev_addr = BME280_I2C_ADDR_PRIM;
|
|
||||||
|
|
||||||
dev.intf = BME280_I2C_INTF;
|
dev.intf = BME280_I2C_INTF;
|
||||||
dev.read = user_i2c_read;
|
dev.read = user_i2c_read;
|
||||||
dev.write = user_i2c_write;
|
dev.write = user_i2c_write;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user