pin.h provides a set of very handy macros that allow to use the bit of each port thru symbolic names. This very ingenious header has been written by Josef Pavlik.
The first step to use them is to specify the logical name of each bit to be used. The general form of this specification is:
#define <logical name> <port name><bit number>for example, the following declare LED to be the logical name corresponding to the bit 3 of port C.
#define LED PORTC3Such a logical name can be defined for ports A,B,C,D or E and must be used with the following macros:
Macro | Role |
PIN_SET_INPUT(name) |
declare name as input bit |
PIN_SET_OUTPUT(name) |
declare name as output bit |
PIN_SET_OUTPUT0(name) |
declare name as output bit, and force it to 0 |
PIN_SET_OUTPUT1(name) |
declare name as output bit, and force it to 1 |
PIN_SET(name) |
force name to 1 |
PIN_1(name) |
synonym for PIN_SET |
PIN_CLR(name) |
force name to 0 |
PIN_0(name) |
synonym for PIN_CLR |
PIN_TOGGLE(name) |
toggle name |
PIN_READ(name) |
return 0 when name is clear, else return a non-nul value |
PIN_TST(name) |
synonym for PIN_READ |
PIN_WRITE(name,value) |
clear name when value is 0, else set it |
Alain Gibaud 2015-07-09