Twilight-Logic / AR488

AR488 Arduino GPIB Interface
GNU General Public License v3.0
215 stars 62 forks source link

wrap setGpibState calls in something easier to read #38

Closed RussellSenior closed 1 year ago

RussellSenior commented 1 year ago

Request For Comment:

I was having trouble following the magic numbers in AR488_GPIBbus.cpp, so I rewrote the setGpibState() calls as simpler, easier to read inputCtrl(), outputCtrl(), assertCtrl() and clearCtrl() calls with defined foo_BIT values OR'd as indicated in the translated setGpibState() calls. I also noted where the values didn't make sense with a WHUT? comment. Setting a value for INPUTs might make sense to activate/disable pullups, but setting the pin as INPUT_PULLUP ought to do that already? More egregious and possibly indicating a logic error is where the bits to set were not including in the mask. Those cases should probably be looked at to confirm they are correct. For now, the new functions just call special cases of the setGpibState(), but could be re-implemented in a microcontroller/board specific way. E.g. the Teensy 3.1 I am working with has special registers available for setting/clearing bits for the various PORTs atomically.

I am interested in feedback on the approach, and any feedback on the apparent logic errors.