Hello,
Instead of using the bitbang-i2c driver, i would like to use the i2c0-interface with two different i2c-busses/ pin-pairs.
I already tried to reconfigure the pins with the pinctrl_update_states() function, but I didn't get it to work as i wanted.
This is my overlay file: The pressure-sensor is connected to pin 24+25
&i2c0 { label = "i2c0"; status = "okay"; lsm6dso@6a { compatible = "st,lsm6dso"; reg = <0x6a >; accel-pm = <0>; accel-odr = <0>; accel-range = <0>; gyro-odr = <3>; gyro-pm = <0>; gyro-range = < 6 >; label = "LSM6DSO"; //supply-gpios = < &gpio0 16 GPIO_ACTIVE_HIGH >; vin-supply = < &imu_pwr >; //int-pin = < 0 >; Für das Prototypen board }; ms5607@76 { compatible = "meas,ms5607"; reg = <0x76>; label = "MS5607"; //supply-gpios = < &gpio0 20 GPIO_ACTIVE_HIGH >; vin-supply = < &pressure_pwr >; }; }; &pinctrl { ... /* Alternative pin configuration for i2c interface */ i2c0_alt_default: i2c0_alt_default { group1 { psels = <NRF_PSEL(TWIM_SDA, 0, 24)>, <NRF_PSEL(TWIM_SCL, 0, 25)>; }; }; i2c0_alt_sleep:i2c0_alt_sleep { group1 { psels = <NRF_PSEL(TWIM_SDA, 0, 24)>, <NRF_PSEL(TWIM_SCL, 0, 25)>; low-power-enable; }; }; };
then i defined the new pincontrol configurations:
PINCTRL_DT_STATE_PINS_DEFINE(DT_PATH(zephyr_user), i2c0_alt_default); PINCTRL_DT_STATE_PINS_DEFINE(DT_PATH(zephyr_user), i2c0_default); #ifdef CONFIG_PM_DEVICE PINCTRL_DT_STATE_PINS_DEFINE(DT_PATH(zephyr_user), i2c0_alt_sleep); PINCTRL_DT_STATE_PINS_DEFINE(DT_PATH(zephyr_user), i2c0_sleep); #endif PINCTRL_DT_DEV_CONFIG_DECLARE(DT_NODELABEL(i2c0)); struct pinctrl_dev_config *i2c0_config = PINCTRL_DT_DEV_CONFIG_GET(DT_NODELABEL(i2c0)); static const struct pinctrl_state i2c_alt[] = { PINCTRL_DT_STATE_INIT(i2c0_alt_default, PINCTRL_STATE_DEFAULT), #ifdef CONFIG_PM_DEVICE PINCTRL_DT_STATE_INIT(i2c0_alt_sleep, PINCTRL_STATE_SLEEP), #endif }; static const struct pinctrl_state i2c_default[] = { PINCTRL_DT_STATE_INIT(i2c0_default, PINCTRL_STATE_DEFAULT), #ifdef CONFIG_PM_DEVICE PINCTRL_DT_STATE_INIT(i2c0_sleep, PINCTRL_STATE_SLEEP), #endif }; static int remap_pins_imu() { return pinctrl_update_states(i2c0_config, i2c_default, ARRAY_SIZE(i2c_default)); } static int remap_pins_pressure() { return pinctrl_update_states(i2c0_config, i2c_alt, ARRAY_SIZE(i2c_alt)); }
Before I read the sensors i call the rempa_pins_x() Functions to switch the pins. This should work, because I get 0 as return value, but I think the initialization process did not work correctly. How can I do this propperly?
I use nRF Connect SDK 2.1 and an nRF52805