1
votes

I am working on a user application, which depends on I2C or SPI device connected with the beaglebone board. My app is running in userspace. Now whenever an interrupt occurs from I2c device, My application should get the data from I2c device.

My question is how to sync all these. Do I need to write a device driver which gets the data from I2c device or trigger another device driver to read the data from I2c and how it can trigger my user app to get the data?

1
There may be some generic drivers you can include into the kernel build or load later which come with Beaglebone Board. If that is the case then there should be a file under /dev which is the character device driver to access. You can create a thread to poll for an interrupt. If this doesn't exist then you'll have to write your own device driver.user2205930
You need i2c or spi driver and also look at input subsystem in linux kernelbytefire

1 Answers

1
votes

You'll need to know about three things: i2c drivers, spi drivers and input subsystem.

For i2c drivers, search kernel code for struct i2c_driver and module_i2c_driver helper macro for registering and unregistering the driver.

Similarly, struct spi_driver and module_spi_driver for spi.

For input subsystem, search for struct input_dev. Among other things, you'll need to "hook" into interesting events by setting relevant event bits and implement input_event event handler.

UPDATE: Forgot to mention, aim of input subsystem is to help take care of input events coming in from i2c or spi device.