Thanks for the input Peter, you made me realize I had a mistake:
The idea here is that ONLY the PRU changes the end pointer (write position
pointer) and ONLY the ARM changes the start pointer (read position
pointer). Also, the pointers are updated AFTER the data is read or written
(thus the memory barrier on the ARM side).
When the ARM is reading/updating the start pointer, the PRU could write
messages to fill the buffer, changing the start pointer and corrupting the
buffer. To avoid this, I have changed the PRU code as follows. Note that if
the buffer is full, new messages will be dropped, you can lower the chances
of this happening by making the buffer larger.
inline void buffer_write(unsigned int message){
unsigned int is_full = (*buffer_end == (*buffer_start^buffer_size)); //
^ is orex
if(!is_full){
shared_ram[*buffer_end & (buffer_size-1)] = message;
*buffer_end = (*buffer_end+1) & (2*buffer_size - 1);
}
}
--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups
"BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.