I have no experience writing kernel modules. I build some examples with gpio interrupts and they worked prety well. Now I want to use SPI from my kernel module and I will explain why I need it.
I am working with a ADC which has a continuous mode, so this device generates a falling edge in a pin warning that there is a new sample available. When this edge is detected, it's necessary to read that sample via SPI. I was trying to do this operation from user space, but I realized that I had not time guarantee.
I wrote a kernel module that when detectes the rising edge, it generates a pulse with the same width that my reading will take. In the interrupt pin I applied a square wave with the same period that my ADC's sample rate. With an oscilloscope I monitored the signals. And the time accuracy results where very good, they fit my application very well.
I follow the same method with a code in user space and the results in oscilloscope where a total disaster. That's why I believe I have to read my SPI bus from kernel space.
I was taking a look at spidev source code, but I am not sure about all the things I have to implement. Does anybody have some example reading and writing to SPI from kernel space?
Thanks in advance.