I have a device and it sends simple binary data which I have to capture. But the above code uses CPU a lot (is it normal for PRU if it causes 40% CPU usage, I thought it is independent from the main CPU?). Any help is appreciated.
The PRUSS don’t cause any CPU usage. You can reduce CPU usage by adding a nsleep() call to your while loop. Anyway, the max. speed of pulling the GPIO state (as in your while loop) is limited to approx. 140 kHz.
An alternative is to configure a GPIO interrupt
Map an interrupt to any channel (except /dev/uio5, which is used by libpruio).
Write a callback to handle the interrupt and install it.
Configure the GPIO interrupt controller.
Download the configuration (pruio_config(), RB and MM mode need a further start command).
As you can see this isn’t trivial and needs advanced programming skills. You’ve to find a way to reset the interrupt status flag, which isn’t supported by libpruio ATM.
Your problem description isn’t very detailed. It may also be an option to use the General-Purpose Inputs (R31) of the free PRUSS in 28-bit shift mode to capture the signal at high frequencies.