SetPinsDigitalIn | Configure selected pins as digital inputs. | |
Read | Read from a selected port. | |
ReadBits | Read selected bits (pins) from a port. |
Thiese operations are available either as functions or macros. The advantage of the macro format is that it avoids function call overhead.
The macros incorporate the target port into the macro name.
These are the digital input macros associated with Port A.
mPORTASetPinsDigitalIn(unsigned int bits) mPORTARead() mPORTAReadBits(unsigned int bits)
Similar definitions exist for the other ports. For example,
mPORTAReadBits(unsigned int bits); mPORTBReadBits(unsigned int bits); mPORTCReadBits(unsigned int bits); mPORTDReadBits(unsigned int bits); mPORTEReadBits(unsigned int bits); mPORTFReadBits(unsigned int bits); mPORTGReadBits(unsigned int bits);
void PORTSetPinsDigitalOut(IoPortId portId, unsigned int bits); unsigned int PORTRead ( ); unsigned int PORTReadBits (IoPortId portId, unsigned int bits);
where
portID: Enumerated PORT Identifier
typedef enum { IOPORT_A, IOPORT_B, IOPORT_C, IOPORT_D, IOPORT_E, IOPORT_F, IOPORT_G, IOPORT_NUM }IoPortId;
bits: Specified input pins, one or more bit masks bitwise OR’d together
Appropriate bit masks are already defined, e.g. BIT_0 and BIT_6
#define PORT IOPORT_D #define PINS BIT_2 | BIT_0 PORTSetPinsDigitalIn(PORT, PINS);or
mPORTDSetPinsDigitalIn(BIT_2 | BIT_0);
n = PORTReadBits(IO_PORT_B, BIT_2 | BIT_4)or
n = mPORTBToggleBits(BIT_2 | BIT_4);
PIC32 Peripheral Libraries for MPLAB C32
Compiler, Microchip Technology, 2007.
Maintained by John Loomis, last updated 18 July 2008