On Tue, 13 Apr 2021 11:25:06 -0700 (PDT), in gmane.comp.hardware.beagleboard.user Walter Cromer <walterc-2dFtBuzUeF/tpnmuczy8bueocmrvl...@public.gmane.org> wrote:
>We're designing it the way you suggested. The nice thing is that basically >the control logic has already been written in C on the ARM side. Now, I >just >Here's one more thing I am struggling with though. It's a mental block I >think. I'm used to controlling GPIOs on the ARM side using sysfs. It >appears that on the PRU, we use __R30 instead but I don't understand how >that works. I read through it this morning and it still isn't sinking in. >If anyone can help make this clearer, I'd appreciate it. > More details of what is confusing you would help. R30 (output)/R31 (input) registers are mapped as one GPIO per bit https://elinux.org/Ti_AM33XX_PRUSSv2#Beaglebone_PRU_connections_and_modes and those bits/GPIOs you are using will need to be properly pin-muxed in u-Boot uEnv.txt. As for using the registers... For input it should just be a case of bitwise AND on the register content and test for result of 0/not 0 (assuming you are testing just one input at a time...). {Treat the following as pseudo-code; I've not done any PRU programming, and am getting stale with C] inputX = 0 != (__R31 & (1 << desired_bit)) For output, you likely will need to maintain a copy (can the output register be read by C code? -- if it can, forget the copy). You would AND the inverse of the desired bit (to retain the other bits, but clear the desired bit to 0) then OR the desired bit with the wanted value and write the register with the combined result. to set __R30 = (__R30 & ^(1 << desired_bit)) | (1 << desired_bit) to clear __R30 = __R30 & ^(1 << desired_bit) You'll likely want to prebuild the (1^^desired_bit) as constants for each input/output of interest. -- Dennis L Bieber -- 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 beagleboard+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/8uge7glso7meuilk7p7orm8jnqd5se1866%404ax.com.