0

I have recently written numerous functions in C for microfluidic pumps which are controlled via I2C on a Raspberry Pi. They work perfectly. I made use of the O_RDWR to write and read from "/dev/i2c-1".

However, I am still wondering how exactly these file changes are implemented on a low level. How is the code, which generates the correct bit sequences to communicate with these pumps, transferred to the PINs? What tells the kernel to change the states of the 2 I2C-PINs accordingly to code?

Thank you!

2
  • /dev/i2c-1 is not an ordinary file, but a device file. Device drivers provide files as an interface to send or receive data or to configure the hardware and/or the driver. Commented Sep 19, 2022 at 15:14
  • /dev/i2c-* are character device files. Calls to these files are handled by i2c-dev driver. i2c-dev dispatches calls to corresponding I2C controller driver. Commented Sep 19, 2022 at 15:29

1 Answer 1

1

In most cases, software is not directly responsible for generating each individual logic level change. Instead, it is a combination of a hardware based I2C controller, that is managed from software by a driver.

In the case of your RPi, you are most likely using this driver: https://elixir.bootlin.com/linux/v5.19/source/drivers/i2c/busses/i2c-bcm2835.c

The hardware block that this driver is controlling is described in section 3 of this reference manual: https://www.raspberrypi.org/app/uploads/2012/02/BCM2835-ARM-Peripherals.pdf

(A side note: the kernel does know how to generate all logic changes in software as well, for cases where no dedicated hardware is available. If you want to know more about that, have a look at the i2c-gpio driver)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.