Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions
PortIn Class Reference

A multiple pin digital input. More...

#include <PortIn.h>

Public Member Functions

 PortIn (PortName port, int mask=0xFFFFFFFF)
 Create a PortIn, connected to the specified port. More...
 
int read ()
 Read the value input to the port. More...
 
void mode (PinMode mode)
 Set the input pin mode. More...
 
 operator int ()
 A shorthand for read() More...
 

Detailed Description

A multiple pin digital input.

Note
Synchronization level: Interrupt safe

Example:

// Turn on an LED if any pins of Port2[0:5] are high
#include "mbed.h"
PortIn p(Port2, 0x0000003F); // Port2 pins [0:5] only
DigitalOut led(LED4);
int main() {
while(1) {
int pins = p.read();
if(pins) {
led = 1;
} else {
led = 0;
}
}
}

Definition at line 56 of file PortIn.h.

Constructor & Destructor Documentation

PortIn ( PortName  port,
int  mask = 0xFFFFFFFF 
)

Create a PortIn, connected to the specified port.

Parameters
portPort to connect to (as defined in target's PortNames.h)
maskBitmask defines which port pins should be an input (0 - ignore, 1 - include)

Definition at line 64 of file PortIn.h.

Member Function Documentation

void mode ( PinMode  mode)

Set the input pin mode.

Parameters
modePullUp, PullDown, PullNone, OpenDrain

Definition at line 85 of file PortIn.h.

operator int ( )

A shorthand for read()

Definition at line 94 of file PortIn.h.

int read ( void  )

Read the value input to the port.

Returns
An integer with each bit corresponding to the associated pin value

Definition at line 76 of file PortIn.h.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.