IO plocana FRDM K64

Committer:
bosko001
Date:
Sun Mar 21 18:20:15 2021 +0100
Revision:
7:4aa3dac73b66
novi pocetak

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bosko001 7:4aa3dac73b66 1
bosko001 7:4aa3dac73b66 2 #include "mbed.h"
bosko001 7:4aa3dac73b66 3 #include <vector>
bosko001 7:4aa3dac73b66 4
bosko001 7:4aa3dac73b66 5 //#include "thread_class.h"
bosko001 7:4aa3dac73b66 6 #include "IOspitelegram.h"
bosko001 7:4aa3dac73b66 7 #include "Pinovi.h"
bosko001 7:4aa3dac73b66 8
bosko001 7:4aa3dac73b66 9
bosko001 7:4aa3dac73b66 10 /*
bosko001 7:4aa3dac73b66 11 ok - inicijalni test set telegram
bosko001 7:4aa3dac73b66 12 ok - povezati sa spibyte
bosko001 7:4aa3dac73b66 13 odustao - uneti thread u class-u
bosko001 7:4aa3dac73b66 14 */
bosko001 7:4aa3dac73b66 15
bosko001 7:4aa3dac73b66 16
bosko001 7:4aa3dac73b66 17
bosko001 7:4aa3dac73b66 18 vector< S_logTelegram> s_log;
bosko001 7:4aa3dac73b66 19
bosko001 7:4aa3dac73b66 20 void loguj_telegram( const char* opis, const char *niz )
bosko001 7:4aa3dac73b66 21 {
bosko001 7:4aa3dac73b66 22 S_logTelegram s_l;
bosko001 7:4aa3dac73b66 23 sprintf(s_l.poruka,"%s %10ld %2x %2x %2x %2x", opis, (long)Kernel::get_ms_count(), niz[0], niz[1], niz[2], niz[3]);
bosko001 7:4aa3dac73b66 24
bosko001 7:4aa3dac73b66 25 if( s_log.size() < 150 )
bosko001 7:4aa3dac73b66 26 {
bosko001 7:4aa3dac73b66 27 // u_log.push_back( u_l);
bosko001 7:4aa3dac73b66 28 s_log.insert(s_log.begin(), s_l);
bosko001 7:4aa3dac73b66 29 }
bosko001 7:4aa3dac73b66 30 }
bosko001 7:4aa3dac73b66 31 void loguj_poruku( const char *p )
bosko001 7:4aa3dac73b66 32 {
bosko001 7:4aa3dac73b66 33 S_logTelegram s_l;
bosko001 7:4aa3dac73b66 34 memcpy(s_l.poruka, p, strlen(p) );
bosko001 7:4aa3dac73b66 35
bosko001 7:4aa3dac73b66 36 if( s_log.size() < 150 )
bosko001 7:4aa3dac73b66 37 {
bosko001 7:4aa3dac73b66 38 s_log.insert(s_log.begin(), s_l);
bosko001 7:4aa3dac73b66 39 }
bosko001 7:4aa3dac73b66 40 }
bosko001 7:4aa3dac73b66 41
bosko001 7:4aa3dac73b66 42 void loguj_broj( int i)
bosko001 7:4aa3dac73b66 43 {
bosko001 7:4aa3dac73b66 44 S_logTelegram s_l;
bosko001 7:4aa3dac73b66 45 sprintf(s_l.poruka," %10ld %x", (long)Kernel::get_ms_count(), i );
bosko001 7:4aa3dac73b66 46
bosko001 7:4aa3dac73b66 47 if( s_log.size() < 150 )
bosko001 7:4aa3dac73b66 48 {
bosko001 7:4aa3dac73b66 49 // u_log.push_back( u_l);
bosko001 7:4aa3dac73b66 50 s_log.insert(s_log.begin(), s_l);
bosko001 7:4aa3dac73b66 51 }
bosko001 7:4aa3dac73b66 52
bosko001 7:4aa3dac73b66 53 }
bosko001 7:4aa3dac73b66 54
bosko001 7:4aa3dac73b66 55 void loguj_string_broj( char *s,int i)
bosko001 7:4aa3dac73b66 56 {
bosko001 7:4aa3dac73b66 57 S_logTelegram s_l;
bosko001 7:4aa3dac73b66 58 sprintf(s_l.poruka,"%s %10ld %x", s, (long)Kernel::get_ms_count(), i );
bosko001 7:4aa3dac73b66 59
bosko001 7:4aa3dac73b66 60 if( s_log.size() < 150 )
bosko001 7:4aa3dac73b66 61 {
bosko001 7:4aa3dac73b66 62 // u_log.push_back( u_l);
bosko001 7:4aa3dac73b66 63 s_log.insert(s_log.begin(), s_l);
bosko001 7:4aa3dac73b66 64 }
bosko001 7:4aa3dac73b66 65
bosko001 7:4aa3dac73b66 66 }
bosko001 7:4aa3dac73b66 67
bosko001 7:4aa3dac73b66 68 /************************************** C_telegram ************************************************ */
bosko001 7:4aa3dac73b66 69
bosko001 7:4aa3dac73b66 70 C_telegram::C_telegram( )
bosko001 7:4aa3dac73b66 71 {
bosko001 7:4aa3dac73b66 72 reset = 1; // desio se reset
bosko001 7:4aa3dac73b66 73 zero_crossing = 1; // zero crossing po resetu dobar, by default; Ovo je sporno ???/
bosko001 7:4aa3dac73b66 74 cmd_read = cmd_write = data = 0;
bosko001 7:4aa3dac73b66 75 }
bosko001 7:4aa3dac73b66 76
bosko001 7:4aa3dac73b66 77 bool C_telegram::check_addressValidy( void ) { return (( myAddress == (unsigned char)address)||(niz[0]==BROADCASTADDRESS)) ? true : false; }
bosko001 7:4aa3dac73b66 78 bool C_telegram::check_groupAddressValidy( void ) { return (niz[0]==BROADCASTADDRESS) ? true : false; }
bosko001 7:4aa3dac73b66 79
bosko001 7:4aa3dac73b66 80 const char *C_telegram::get_telegram( void ) { return (char*)niz; }
bosko001 7:4aa3dac73b66 81 const char * C_telegram::make_telegram( char cmd_write, char cmd_read, char data )
bosko001 7:4aa3dac73b66 82 {
bosko001 7:4aa3dac73b66 83 this->address = myAddress;
bosko001 7:4aa3dac73b66 84 this->cmd_read = cmd_read;
bosko001 7:4aa3dac73b66 85 this->cmd_write = cmd_write;
bosko001 7:4aa3dac73b66 86 this->data = data;
bosko001 7:4aa3dac73b66 87 set_sum();
bosko001 7:4aa3dac73b66 88 return get_telegram();
bosko001 7:4aa3dac73b66 89 }
bosko001 7:4aa3dac73b66 90
bosko001 7:4aa3dac73b66 91 char C_telegram::myAddress = 1;
bosko001 7:4aa3dac73b66 92 /************************************************************************* */