bosko lekovic
/
IO_board_K22
K22 processor
SPIprotokol/IOspiConnect.h@7:4aa3dac73b66, 2021-03-21 (annotated)
- Committer:
- bosko001
- Date:
- Sun Mar 21 18:20:15 2021 +0100
- Revision:
- 7:4aa3dac73b66
- Child:
- 15:3429cdc6e5f4
novi pocetak
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bosko001 | 7:4aa3dac73b66 | 1 | #ifndef IOSPICONNECT_H |
bosko001 | 7:4aa3dac73b66 | 2 | #define IOSPICONNECT_H |
bosko001 | 7:4aa3dac73b66 | 3 | |
bosko001 | 7:4aa3dac73b66 | 4 | #include "IOgpiospi.h" |
bosko001 | 7:4aa3dac73b66 | 5 | #include "SlaveSpi.h" |
bosko001 | 7:4aa3dac73b66 | 6 | |
bosko001 | 7:4aa3dac73b66 | 7 | #include "IOspitelegram.h" |
bosko001 | 7:4aa3dac73b66 | 8 | |
bosko001 | 7:4aa3dac73b66 | 9 | /****************************** C_spiConnect ******************************************* */ |
bosko001 | 7:4aa3dac73b66 | 10 | |
bosko001 | 7:4aa3dac73b66 | 11 | class C_spiConnect: /*public C_gpioSpi// */ public C_slaveSpi// public C_gpioSpi |
bosko001 | 7:4aa3dac73b66 | 12 | { |
bosko001 | 7:4aa3dac73b66 | 13 | C_telegram c_tx, c_rx; |
bosko001 | 7:4aa3dac73b66 | 14 | char byteCount = 0; |
bosko001 | 7:4aa3dac73b66 | 15 | Timeout t_out; |
bosko001 | 7:4aa3dac73b66 | 16 | |
bosko001 | 7:4aa3dac73b66 | 17 | public: |
bosko001 | 7:4aa3dac73b66 | 18 | |
bosko001 | 7:4aa3dac73b66 | 19 | // C_spiConnect( ): C_gpioSpi( PTD6, PTD7, PTD5){ byteCount = 0; clear_bitCount(); } |
bosko001 | 7:4aa3dac73b66 | 20 | C_spiConnect( /*PinName mosi, PinName miso, PinName clock*/);//: C_gpioSpi::C_gpioSpi{ PTD6, PTD7, PTD5}; |
bosko001 | 7:4aa3dac73b66 | 21 | void spiByteTransfer( char *tx, char rx) override; |
bosko001 | 7:4aa3dac73b66 | 22 | |
bosko001 | 7:4aa3dac73b66 | 23 | void bytecountTimeout( void ){ t_out.attach( [this](){clear_byteCount();}, 100ms);} |
bosko001 | 7:4aa3dac73b66 | 24 | |
bosko001 | 7:4aa3dac73b66 | 25 | virtual void do_writeCommand( char writeCommand, char data) = 0; |
bosko001 | 7:4aa3dac73b66 | 26 | virtual char do_readCommand( char readCommand , char data) = 0; |
bosko001 | 7:4aa3dac73b66 | 27 | |
bosko001 | 7:4aa3dac73b66 | 28 | char get_byteCount( void) {return byteCount;} |
bosko001 | 7:4aa3dac73b66 | 29 | void clear_byteCount( void ) { byteCount = 0;} |
bosko001 | 7:4aa3dac73b66 | 30 | |
bosko001 | 7:4aa3dac73b66 | 31 | void make_TxTelegram( char txcmnd, char rxcmnd, char data); |
bosko001 | 7:4aa3dac73b66 | 32 | char push_byte( char b ); |
bosko001 | 7:4aa3dac73b66 | 33 | |
bosko001 | 7:4aa3dac73b66 | 34 | void set_myAddress( char a) { C_telegram::set_myAddress(a);} |
bosko001 | 7:4aa3dac73b66 | 35 | char get_myAddress( void) { return C_telegram::get_myAddress(); } |
bosko001 | 7:4aa3dac73b66 | 36 | |
bosko001 | 7:4aa3dac73b66 | 37 | void set_reset( bool r ) { c_tx.set_reset(r); } |
bosko001 | 7:4aa3dac73b66 | 38 | |
bosko001 | 7:4aa3dac73b66 | 39 | // ako je zero crossing signal dobar (true) vracamo zero crossing bit u telegramu 0 (false nema greske - inverzna logika) |
bosko001 | 7:4aa3dac73b66 | 40 | void set_zeroCrossing( bool z ) { c_tx.set_zeroCrossing( z==true? false: true ); } |
bosko001 | 7:4aa3dac73b66 | 41 | |
bosko001 | 7:4aa3dac73b66 | 42 | |
bosko001 | 7:4aa3dac73b66 | 43 | }; |
bosko001 | 7:4aa3dac73b66 | 44 | /************************************************************************* */ |
bosko001 | 7:4aa3dac73b66 | 45 | |
bosko001 | 7:4aa3dac73b66 | 46 | |
bosko001 | 7:4aa3dac73b66 | 47 | |
bosko001 | 7:4aa3dac73b66 | 48 | |
bosko001 | 7:4aa3dac73b66 | 49 | |
bosko001 | 7:4aa3dac73b66 | 50 | #endif |