Mbed OS Reference
Loading...
Searching...
No Matches
BusIn Class Reference

A digital input bus, used for reading the state of a collection of pins. More...

#include <BusIn.h>

Inheritance diagram for BusIn:
NonCopyable< BusIn >

Public Member Functions

 BusIn (PinName p0, PinName p1=NC, PinName p2=NC, PinName p3=NC, PinName p4=NC, PinName p5=NC, PinName p6=NC, PinName p7=NC, PinName p8=NC, PinName p9=NC, PinName p10=NC, PinName p11=NC, PinName p12=NC, PinName p13=NC, PinName p14=NC, PinName p15=NC)
 Create an BusIn, connected to the specified pins. More...
 
 BusIn (PinName pins[16])
 Create an BusIn, connected to the specified pins. More...
 
int read ()
 Read the value of the input bus. More...
 
void mode (PinMode pull)
 Set the input pin mode. More...
 
int mask ()
 Binary mask of bus pins connected to actual pins (not NC pins) If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1. More...
 
 operator int ()
 A shorthand for read() More...
 
DigitalInoperator[] (int index)
 Access to particular bit in random-iterator fashion. More...
 

Detailed Description

A digital input bus, used for reading the state of a collection of pins.

Note
Synchronization level: Thread safe

Definition at line 36 of file BusIn.h.

Constructor & Destructor Documentation

◆ BusIn() [1/2]

BusIn ( PinName  p0,
PinName  p1 = NC,
PinName  p2 = NC,
PinName  p3 = NC,
PinName  p4 = NC,
PinName  p5 = NC,
PinName  p6 = NC,
PinName  p7 = NC,
PinName  p8 = NC,
PinName  p9 = NC,
PinName  p10 = NC,
PinName  p11 = NC,
PinName  p12 = NC,
PinName  p13 = NC,
PinName  p14 = NC,
PinName  p15 = NC 
)

Create an BusIn, connected to the specified pins.

Parameters
p0DigitalIn pin to connect to bus bit
p1DigitalIn pin to connect to bus bit
p2DigitalIn pin to connect to bus bit
p3DigitalIn pin to connect to bus bit
p4DigitalIn pin to connect to bus bit
p5DigitalIn pin to connect to bus bit
p6DigitalIn pin to connect to bus bit
p7DigitalIn pin to connect to bus bit
p8DigitalIn pin to connect to bus bit
p9DigitalIn pin to connect to bus bit
p10DigitalIn pin to connect to bus bit
p11DigitalIn pin to connect to bus bit
p12DigitalIn pin to connect to bus bit
p13DigitalIn pin to connect to bus bit
p14DigitalIn pin to connect to bus bit
p15DigitalIn pin to connect to bus bit
Note
It is only required to specify as many pin variables as is required for the bus; the rest will default to NC (not connected)

◆ BusIn() [2/2]

BusIn ( PinName  pins[16])

Create an BusIn, connected to the specified pins.

Parameters
pinsAn array of pins to connect to bus bit

Member Function Documentation

◆ read()

int read ( )

Read the value of the input bus.

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

◆ mode()

void mode ( PinMode  pull)

Set the input pin mode.

Parameters
pullPullUp, PullDown, PullNone

◆ mask()

int mask ( )

Binary mask of bus pins connected to actual pins (not NC pins) If bus pin is in NC state make corresponding bit will be cleared (set to 0), else bit will be set to 1.

Returns
Binary mask of connected pins

Definition at line 97 of file BusIn.h.

◆ operator int()

operator int ( )

A shorthand for read()

See also
DigitalIn::read()

◆ operator[]()

DigitalIn & operator[] ( int  index)

Access to particular bit in random-iterator fashion.

Parameters
indexPosition of bit