Pin class to allow access to single pins
What's with the attribute((always_inline))? SRLM found that the forced inlining is essential to performance. Without it GCC would not inline a function (even if marked) if it was used more than two or three times. This has a rather drastic performance impact. It does come at the expense of some space, however. For example, the high() function expands to 5 instructions:
mov r7, OUTA
rdlong r6, r3
or r7, r6
mov OUTA, r7
or DIRA,r6
If you use high() in many places the total could add up. On the other hand, the forced inlining may give the optimizer more chances to make things small. You should try it both ways and compare.
- Hardware: To read 3.3v signals just connect the signal directly to any I/O pin. To read a 5v signal connect it to any I/O pin through a 3.3kOhm (or higher) resistor. To read a higher voltage, use the following equation to determine the proper series voltage: resistance = (voltage - 3.3v - 0.6v) / 500uA
The original source for this class was posted by David Michael Betz, and modified by SRLM.
Definition at line 43 of file pin.h.