communication mbed/pld altera lib

Dependents:   scooter_mbed_etudiant scooter_mbed_correction_mbed_os scooter_ scooter_mbed_etudiant_fini_1 ... more

Committer:
superphil06
Date:
Sun Aug 23 14:16:56 2015 +0000
Revision:
2:01a42472c867
Parent:
1:7b4e6771a530
update documentation

Who changed what in which revision?

UserRevisionLine numberNew contents of line
superphil06 0:49abff3f269a 1 #include "bloc_io.h"
superphil06 0:49abff3f269a 2 #include "mbed.h"
superphil06 0:49abff3f269a 3
superphil06 0:49abff3f269a 4 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) {
superphil06 0:49abff3f269a 5
superphil06 0:49abff3f269a 6 _RD_WRn = 1;// default read mode
superphil06 0:49abff3f269a 7 _CS=1;// default no selected
superphil06 0:49abff3f269a 8
superphil06 0:49abff3f269a 9 }
superphil06 0:49abff3f269a 10
superphil06 0:49abff3f269a 11 void Bloc_IO::write(unsigned char byWrVal) {
superphil06 0:49abff3f269a 12
superphil06 0:49abff3f269a 13 _CS=1;
superphil06 0:49abff3f269a 14 _RD_WRn=0; //Write Mode
superphil06 1:7b4e6771a530 15 Bloc_IoPort.output();// set bus as output
superphil06 0:49abff3f269a 16 Bloc_IoPort.write((int)byWrVal);// update Bloc_Io port
superphil06 0:49abff3f269a 17 _CS=0;// enable write
superphil06 0:49abff3f269a 18 _CS=1;// disable write
superphil06 0:49abff3f269a 19 _RD_WRn=1;// read mode
superphil06 0:49abff3f269a 20
superphil06 0:49abff3f269a 21
superphil06 0:49abff3f269a 22 }
superphil06 0:49abff3f269a 23
superphil06 0:49abff3f269a 24 unsigned char Bloc_IO::read(void) {
superphil06 0:49abff3f269a 25 unsigned char byRedVal ;
superphil06 0:49abff3f269a 26 _CS=1;
superphil06 0:49abff3f269a 27 _RD_WRn=1; //Read Mode
superphil06 1:7b4e6771a530 28
superphil06 1:7b4e6771a530 29 Bloc_IoPort.input(); // set bus as input
superphil06 1:7b4e6771a530 30
superphil06 0:49abff3f269a 31 _CS=0;// enable read
superphil06 1:7b4e6771a530 32 byRedVal=(unsigned char) Bloc_IoPort.read();// update Bloc_Io port
superphil06 0:49abff3f269a 33 _CS=1;// disable read
superphil06 0:49abff3f269a 34 _RD_WRn=1;// read mode
superphil06 0:49abff3f269a 35 return byRedVal;
superphil06 0:49abff3f269a 36 }
superphil06 0:49abff3f269a 37
superphil06 0:49abff3f269a 38