Mux 4x2 Library

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers Mux4x2.cpp Source File

Mux4x2.cpp

00001 #include "Mux4x2.h"
00002 
00003 
00004 Mux4x2::Mux4x2(PinName s0, PinName s1)
00005     : _s0(s0), _s1(s1)
00006 {
00007     _s0 = 0;
00008     _s1 = 0;
00009 }
00010 
00011 void  Mux4x2::setMux(int index)
00012 {
00013     if(index > 3 || index < 0) 
00014     {
00015         // index out of range
00016         return;
00017     }    
00018     
00019     _s1 = ((index & 0b0010) >> 1);
00020     _s0 = ((index & 0b0001) >> 0);
00021 }