From 91910f8045317d8b7fd91c6ad090433d0434cd7d Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sun, 28 Nov 2021 21:47:17 +0100 Subject: posix: configurable i2c bus --- src/arch/posix/Kconfig | 5 +++++ src/arch/posix/driver/i2c.cc | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/arch/posix/Kconfig b/src/arch/posix/Kconfig index 42ed413..492e623 100644 --- a/src/arch/posix/Kconfig +++ b/src/arch/posix/Kconfig @@ -12,6 +12,11 @@ config arch_posix_driver_i2c bool "I2C via /dev/i2c" select meta_driver_i2c +config arch_posix_driver_i2c_bus +string "I2C bus (/dev/i2c-* device)" +default "/dev/i2c-1" +depends on arch_posix_driver_i2c + config arch_posix_driver_uptime bool "Uptime counter" select meta_driver_uptime diff --git a/src/arch/posix/driver/i2c.cc b/src/arch/posix/driver/i2c.cc index b408320..4cfdd35 100644 --- a/src/arch/posix/driver/i2c.cc +++ b/src/arch/posix/driver/i2c.cc @@ -13,6 +13,9 @@ #include #include +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) +#define I2C_BUS TOSTRING(CONFIG_arch_posix_driver_i2c_bus) signed char I2C::setup() { @@ -57,4 +60,4 @@ signed char I2C::xmit(unsigned char address, return 0; } -I2C i2c("/dev/i2c-1"); +I2C i2c(I2C_BUS); -- cgit v1.2.3