I have been playing around kernel programming for a while and want to create this simple data acquiring interface with some custom hardware. For portability and reusability, I do the whole thing on my Raspberry Pi.
The challenging part of the project is having a high speed ADC (parallel) connected to GPIO's and having a kernel module that uses hardware interrupt from ADC to acquire each sample and store it inside a buffer which is then accessible via chardevice.
My current setup (that works) is as follows:
- I have a userspace C program that is controlling my hardware through SPI. If I send a required command, it starts acquiring analogue data and sends them to the ADC.
- Whenever ADC finishes conversion, it pusts corresponding signal to 'low' on a GPIO and I get interrupt inside the kernel module (bound to that GPIO). The ISR collects the value of 12 other GPIO's (it's a 12-bit ADC) and puts it into a buffer that is then accessed through /dev/mydevice.
- I have another separate userspace program that runs a never-ending while loop, reading from /dev/mydevice and in turn writes into 'out_data.dat' (an userspace file).
- With this crude setup (2 userspace programs and kernel module loaded) I can write over 130 000 samples into my file per second (without missing anything).
I now want to see how much faster I can make it, there are 2 things to consider:
Is the setup I have outline above the 'usual' way how something like this would be done? I read everywhere that direct file I/O is not advised from kernel so I am not doing it. Surely though, it should be possible to write it into some "permanent" location during the ISR. This seems to me like a common problem, trying to get data from some hardware into computer using interrupts.
Without changing my setup above, is there any way how to disable other interrupts to make it as smooth as possible? During the data acquisition I do not really need anything, only some sort of a way how to stop it. Any other interrupts (wireless, monitor refresh etc...) can be disabled as data acquisition is only to be run for a few minutes. Afterwards, everything will resume and more demanding python code can be run to analyze and visualize the data (at least that's my simple view of it).