Mbed OS 2 and Mbed OS 5

This is the handbook for Mbed OS 2. If you’re working with Mbed OS 5, please see the Mbed OS 5 documentation. For the latest BusIn API, please see BusIn.

The BusIn interface is used to create a number of DigitalIn pins that can be read as one value.

Any of the numbered mbed pins can be used as a DigitalIn in the BusIn.

Hello World!

Import program

00001 #include "mbed.h"
00003 BusIn nibble(p5, p6, p18, p11);
00005 int main() {
00006     while(1) {
00007         switch(nibble) {
00008             case 0x3: printf("Hello!\n"); break; // p5 and p6 are 1
00009             case 0x8: printf("World!\n"); break; // p11 is 1
00010         }
00011     }
00012 }


API summary

Import library

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.
  BusIn (PinName pins[16])
  Create an BusIn , connected to the specified pins.
int  read ()
  Read the value of the input bus.
void  mode (PinMode pull)
  Set the input pin mode.
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.
  operator int ()
  A shorthand for read()
DigitalIn operator[] (int index)
  Access to particular bit in random-iterator fashion.

Private Member Functions

  MBED_DEPRECATED ("Invalid copy construction of a NonCopyable resource.") NonCopyable(const NonCopyable &)
  NonCopyable copy constructor.
  MBED_DEPRECATED ("Invalid copy assignment of a NonCopyable resource.") NonCopyable &operator
  NonCopyable copy assignment operator.


The BusIn Interface can use any pins with a blue label.

See the Pinout page for more details