BusIn HelloWorld

Fork of BusIn_HelloWorld by Mbed

Use

BusIn is an abstraction that takes any pins and makes them appear as though they are linearly memory mapped for ease of use. This abstraction is useful for checking multiple inputs in a single pass. In general this abstraction can be used to make code less cluttered, clearer, and take less time to write.

Note

Please pay attention to the ordering of pins in the initialization. The order pins are initialized in are the reverse order that bits are OR'd together.

API

API reference.

Import librarymbed

No documentation found.
Revision:
6:e1f4151bb580
Parent:
5:81a0449aa2d5
diff -r 81a0449aa2d5 -r e1f4151bb580 main.cpp
--- a/main.cpp	Tue Mar 31 00:45:43 2015 +0000
+++ b/main.cpp	Tue Mar 31 01:04:41 2015 +0000
@@ -25,16 +25,18 @@
     
     while(1) {
         // check bits set in nibble
-        switch(~nibble & nibble.mask()) { // read the bus and mask out bits not being used
-            case 0x0: printf("0b0000, D3,D2,D1,D0 are low \n\r");break;
-            case 0x1: printf("0b0001,          D0 is high \n\r");break;
-            case 0x2: printf("0b0010,       D1    is high \n\r");break; 
-            case 0x3: printf("0b0011,       D1,D0 are high\n\r");break;
-            case 0x4: printf("0b0100,    D2       is high \n\r");break;
+        switch(nibble & nibble.mask()) { // read the bus and mask out bits not being used
+            case 0x0: printf("0b0000, D3,D2,D1,D0 are low  \n\r");break;
+            case 0x1: printf("0b0001,          D0  is high \n\r");break;
+            case 0x2: printf("0b0010,       D1     is high \n\r");break; 
+            case 0x3: printf("0b0011,       D1,D0 are high \n\r");break;
+            case 0x4: printf("0b0100,    D2        is high \n\r");break;
+            case 0x5: printf("0b0101,    D2,  ,D0 are high \n\r");break;
+            case 0x6: printf("0b0110,    D2,D1    are high \n\r");break;
+            case 0x7: printf("0b0111,    D2,D1,D0 are high \n\r");break;
+            case 0x8: printf("0b1000, D3           is high \n\r");break; 
             // ...
-            case 0x8: printf("0b1000, D3          is high \n\r");break; 
-            // ...
-            case 0xF: printf("0b1111, D3,D2,D1,D0 are high\n\r");break;
+            case 0xF: printf("0b1111, D3,D2,D1,D0 are high \n\r");break;
         }
         wait(1);
     }