BusIn

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 new handbook and API References. 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"
00002 
00003 BusIn nibble(p5, p6, p18, p11);
00004 
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

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.
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.

Protected Attributes

int  _nc_mask
  Mask of bus's NC pins If bit[n] is set to 1 - pin is connected if bit[n] is cleared - pin is not connected (NC)

Interface

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

/media/uploads/chris/pinout-thumbnails.jpg
See the Pinout page for more details