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.

Synchronization level: Interrupt safe


// 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 58 of file PortIn.h.

Constructor & Destructor Documentation

PortIn ( PortName  port,
int  mask = 0xFFFFFFFF 

Create a PortIn, connected to the specified port.

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

Member Function Documentation

void mode ( PinMode  mode)

Set the input pin mode.

modePullUp, PullDown, PullNone, OpenDrain
operator int ( )

A shorthand for read()

Definition at line 86 of file PortIn.h.

int read ( void  )

Read the value input to the port.

An integer with each bit corresponding to the associated pin value

Definition at line 73 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.