communication mbed/pld altera lib
Dependents: scooter_mbed_etudiant scooter_mbed_correction_mbed_os scooter_ scooter_mbed_etudiant_fini_1 ... more
bloc_io.h@1:7b4e6771a530, 2015-08-11 (annotated)
- Committer:
- superphil06
- Date:
- Tue Aug 11 15:00:09 2015 +0000
- Revision:
- 1:7b4e6771a530
- Parent:
- 0:49abff3f269a
- Child:
- 2:01a42472c867
version beta1: web, pertistant data on text file
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
superphil06 | 0:49abff3f269a | 1 | #ifndef BLOC_IO_H |
superphil06 | 0:49abff3f269a | 2 | #define BLOC_IO_H |
superphil06 | 1:7b4e6771a530 | 3 | |
superphil06 | 0:49abff3f269a | 4 | #include "mbed.h" |
superphil06 | 0:49abff3f269a | 5 | |
superphil06 | 0:49abff3f269a | 6 | |
superphil06 | 0:49abff3f269a | 7 | /** bloc_io class. |
superphil06 | 0:49abff3f269a | 8 | * Used for exchange byte with altera 7064 PLD. |
superphil06 | 0:49abff3f269a | 9 | * |
superphil06 | 0:49abff3f269a | 10 | * Example: |
superphil06 | 0:49abff3f269a | 11 | * @code |
superphil06 | 0:49abff3f269a | 12 | * #include "mbed.h" |
superphil06 | 0:49abff3f269a | 13 | * #include "bloc_io.h" |
superphil06 | 0:49abff3f269a | 14 | * |
superphil06 | 0:49abff3f269a | 15 | * Bloc_IO My_PLD (pin RD_WRn,pin CS, pin D0......,pin D7); |
superphil06 | 0:49abff3f269a | 16 | * unsigned char byVal; |
superphil06 | 0:49abff3f269a | 17 | * |
superphil06 | 0:49abff3f269a | 18 | * int main() { |
superphil06 | 0:49abff3f269a | 19 | * My_PLD.write (byVal);// send byte from Mbed to PLD |
superphil06 | 0:49abff3f269a | 20 | * byVal=My_PLD.read();// read byre from PLD to Mbed |
superphil06 | 0:49abff3f269a | 21 | * } |
superphil06 | 0:49abff3f269a | 22 | * @endcode |
superphil06 | 0:49abff3f269a | 23 | */ |
superphil06 | 0:49abff3f269a | 24 | |
superphil06 | 0:49abff3f269a | 25 | class Bloc_IO { |
superphil06 | 0:49abff3f269a | 26 | public: |
superphil06 | 0:49abff3f269a | 27 | /** Bloc_IO construct |
superphil06 | 0:49abff3f269a | 28 | * |
superphil06 | 0:49abff3f269a | 29 | * @param RD_WRn pin reserved for R/W control signal on mbed |
superphil06 | 0:49abff3f269a | 30 | * @param CS pin reserved for chip select control signal on mbed |
superphil06 | 0:49abff3f269a | 31 | * @param __D0 pin reserved for lsb on Mbed data bus |
superphil06 | 0:49abff3f269a | 32 | * @param __D7 pin reserved for msb on Mbed data bus |
superphil06 | 0:49abff3f269a | 33 | * @returns |
superphil06 | 0:49abff3f269a | 34 | * no return |
superphil06 | 0:49abff3f269a | 35 | */ |
superphil06 | 0:49abff3f269a | 36 | Bloc_IO(PinName RD_WRn,PinName CS,PinName __D0,PinName __D1,PinName __D2,PinName __D3,PinName __D4,PinName __D5,PinName __D6,PinName __D7); |
superphil06 | 0:49abff3f269a | 37 | |
superphil06 | 0:49abff3f269a | 38 | /** read byte method |
superphil06 | 1:7b4e6771a530 | 39 | * @param : no parameter |
superphil06 | 0:49abff3f269a | 40 | * @returns |
superphil06 | 1:7b4e6771a530 | 41 | * byte red from PLD |
superphil06 | 0:49abff3f269a | 42 | */ |
superphil06 | 0:49abff3f269a | 43 | unsigned char read(void); |
superphil06 | 0:49abff3f269a | 44 | |
superphil06 | 0:49abff3f269a | 45 | /** write byte method |
superphil06 | 0:49abff3f269a | 46 | *@param byWrVal: byte to write to PLD |
superphil06 | 0:49abff3f269a | 47 | * @returns |
superphil06 | 0:49abff3f269a | 48 | * no returns |
superphil06 | 0:49abff3f269a | 49 | */ |
superphil06 | 0:49abff3f269a | 50 | void write (unsigned char byWrVal); |
superphil06 | 0:49abff3f269a | 51 | |
superphil06 | 0:49abff3f269a | 52 | |
superphil06 | 0:49abff3f269a | 53 | private: |
superphil06 | 0:49abff3f269a | 54 | DigitalOut _RD_WRn; |
superphil06 | 0:49abff3f269a | 55 | DigitalOut _CS; |
superphil06 | 0:49abff3f269a | 56 | BusInOut Bloc_IoPort; |
superphil06 | 1:7b4e6771a530 | 57 | |
superphil06 | 0:49abff3f269a | 58 | |
superphil06 | 0:49abff3f269a | 59 | |
superphil06 | 0:49abff3f269a | 60 | }; |
superphil06 | 0:49abff3f269a | 61 | |
superphil06 | 0:49abff3f269a | 62 | |
superphil06 | 1:7b4e6771a530 | 63 | #endif |