I have an ADC attached to a SPORT on the BF537, and I can read data just fine. I would like to do some real-time ish signal processing on this data, and am considering having one thread pulling data in from the device buffer into memory, while another thread processes this data. I have some ringbuffer-like operation in mind.
However, to keep track of how much data has been sampled and where to store it, I would like my "sampler"-thread to do a non-blocking read - which I cannot seem to get working. Should a simple call to fcntl as below not do the trick? Or maybe I am on a wrong track entirely?
int flags = fcntl(sportfd, F_GETFL, 0);
fcntl(sportfd, F_SETFL, flags | O_NONBLOCK);
No matter what I seem to do, a call to rbytes = read(sportfd, buffer, SIZE_1M); seems to block, and always returns SIZE_1M (using a large block, hoping to empty the device buffer).
Any feedback and suggestions would also be appreciated, I'm completely new to Blackfin DSPs and linux on embedded systems.
Thanks in advance!
PS: I'm using DMA for the SPORT, exactly what difference does this make? (bear with me)
PPS: How large is the device buffer?