IO plocana FRDM K64

Committer:
bosko001
Date:
Fri Apr 30 00:08:07 2021 +0200
Revision:
16:a3085300cac3
Parent:
15:3429cdc6e5f4
i zero crossing dodat

Who changed what in which revision?

UserRevisionLine numberNew 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 15:3429cdc6e5f4 27 virtual void do_readGroupCommand( const char command) = 0;
bosko001 7:4aa3dac73b66 28
bosko001 7:4aa3dac73b66 29 char get_byteCount( void) {return byteCount;}
bosko001 7:4aa3dac73b66 30 void clear_byteCount( void ) { byteCount = 0;}
bosko001 7:4aa3dac73b66 31
bosko001 7:4aa3dac73b66 32 void make_TxTelegram( char txcmnd, char rxcmnd, char data);
bosko001 7:4aa3dac73b66 33 char push_byte( char b );
bosko001 7:4aa3dac73b66 34
bosko001 7:4aa3dac73b66 35 void set_myAddress( char a) { C_telegram::set_myAddress(a);}
bosko001 7:4aa3dac73b66 36 char get_myAddress( void) { return C_telegram::get_myAddress(); }
bosko001 7:4aa3dac73b66 37
bosko001 7:4aa3dac73b66 38 void set_reset( bool r ) { c_tx.set_reset(r); }
bosko001 7:4aa3dac73b66 39
bosko001 7:4aa3dac73b66 40 // ako je zero crossing signal dobar (true) vracamo zero crossing bit u telegramu 0 (false nema greske - inverzna logika)
bosko001 7:4aa3dac73b66 41 void set_zeroCrossing( bool z ) { c_tx.set_zeroCrossing( z==true? false: true ); }
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
bosko001 7:4aa3dac73b66 51 #endif