communication mbed/pld altera lib
Dependents: scooter_mbed_etudiant scooter_mbed_correction_mbed_os scooter_ scooter_mbed_etudiant_fini_1 ... more
Diff: bloc_io.cpp
- Revision:
- 0:49abff3f269a
- Child:
- 1:7b4e6771a530
diff -r 000000000000 -r 49abff3f269a bloc_io.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bloc_io.cpp Thu Aug 06 06:27:00 2015 +0000 @@ -0,0 +1,34 @@ +#include "bloc_io.h" +#include "mbed.h" + +Bloc_IO::Bloc_IO(PinName RD_WRn,PinName CS,PinName __D0,PinName __D1,PinName __D2,PinName __D3,PinName __D4,PinName __D5,PinName __D6,PinName __D7) : _RD_WRn(RD_WRn), _CS(CS),Bloc_IoPort(__D0,__D1,__D2,__D3,__D4,__D5,__D6,__D7) { + + _RD_WRn = 1;// default read mode + _CS=1;// default no selected + +} + +void Bloc_IO::write(unsigned char byWrVal) { + + _CS=1; + _RD_WRn=0; //Write Mode + Bloc_IoPort.write((int)byWrVal);// update Bloc_Io port + _CS=0;// enable write + _CS=1;// disable write + _RD_WRn=1;// read mode + + +} + +unsigned char Bloc_IO::read(void) { + unsigned char byRedVal ; + _CS=1; + _RD_WRn=1; //Read Mode + byRedVal=(unsigned char) Bloc_IoPort.read();// update Bloc_Io port + _CS=0;// enable read + _CS=1;// disable read + _RD_WRn=1;// read mode + return byRedVal; +} + +