bosko lekovic
/
IO_spi
IO spi
IOdata/IOdata.h@7:4aa3dac73b66, 2021-03-21 (annotated)
- Committer:
- bosko001
- Date:
- Sun Mar 21 18:20:15 2021 +0100
- Revision:
- 7:4aa3dac73b66
novi pocetak
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
bosko001 | 7:4aa3dac73b66 | 1 | #ifndef IODATA_H |
bosko001 | 7:4aa3dac73b66 | 2 | #define IODATA_H |
bosko001 | 7:4aa3dac73b66 | 3 | |
bosko001 | 7:4aa3dac73b66 | 4 | |
bosko001 | 7:4aa3dac73b66 | 5 | |
bosko001 | 7:4aa3dac73b66 | 6 | class C_data |
bosko001 | 7:4aa3dac73b66 | 7 | { |
bosko001 | 7:4aa3dac73b66 | 8 | char komanda = 0, komanda_buf = 0; |
bosko001 | 7:4aa3dac73b66 | 9 | // char portMin=0x0, pMin = 0xff, pMin_buf = 0xff; |
bosko001 | 7:4aa3dac73b66 | 10 | // char portMax, portMax_buf=0, pMax = 0, pMax_buf = 0; |
bosko001 | 7:4aa3dac73b66 | 11 | // char indikacija = 0x0; |
bosko001 | 7:4aa3dac73b66 | 12 | char ispravnost = 0x3f; |
bosko001 | 7:4aa3dac73b66 | 13 | // char mis = 0; |
bosko001 | 7:4aa3dac73b66 | 14 | char poruka; |
bosko001 | 7:4aa3dac73b66 | 15 | char validnost = 0; |
bosko001 | 7:4aa3dac73b66 | 16 | char podatak; |
bosko001 | 7:4aa3dac73b66 | 17 | char adresa; |
bosko001 | 7:4aa3dac73b66 | 18 | char aktuelna_indikacija = 0; |
bosko001 | 7:4aa3dac73b66 | 19 | |
bosko001 | 7:4aa3dac73b66 | 20 | public: |
bosko001 | 7:4aa3dac73b66 | 21 | // volatile char komanda = 0, komanda_buf = 0; |
bosko001 | 7:4aa3dac73b66 | 22 | volatile bool komanda_flag = false; |
bosko001 | 7:4aa3dac73b66 | 23 | volatile char pMin, pMin_buf; |
bosko001 | 7:4aa3dac73b66 | 24 | volatile char pMax, pMax_buf; |
bosko001 | 7:4aa3dac73b66 | 25 | volatile char indikacija = 0x0; |
bosko001 | 7:4aa3dac73b66 | 26 | |
bosko001 | 7:4aa3dac73b66 | 27 | char mis = 0; |
bosko001 | 7:4aa3dac73b66 | 28 | |
bosko001 | 7:4aa3dac73b66 | 29 | C_data() { clear_pMin(); clear_pMax(); } |
bosko001 | 7:4aa3dac73b66 | 30 | |
bosko001 | 7:4aa3dac73b66 | 31 | // void set_command( char cmnd ) |
bosko001 | 7:4aa3dac73b66 | 32 | // { |
bosko001 | 7:4aa3dac73b66 | 33 | // if( (cmnd & validnost) != komanda ) //komanda promenjena |
bosko001 | 7:4aa3dac73b66 | 34 | // { komanda = cmnd & validnost; komanda_flag = true;} |
bosko001 | 7:4aa3dac73b66 | 35 | |
bosko001 | 7:4aa3dac73b66 | 36 | // } |
bosko001 | 7:4aa3dac73b66 | 37 | |
bosko001 | 7:4aa3dac73b66 | 38 | // void set_validity( char val ) |
bosko001 | 7:4aa3dac73b66 | 39 | // { |
bosko001 | 7:4aa3dac73b66 | 40 | // validnost = val; |
bosko001 | 7:4aa3dac73b66 | 41 | // if( (komanda & validnost) != komanda ) { komanda = komanda & validnost; komanda_flag = true; } |
bosko001 | 7:4aa3dac73b66 | 42 | |
bosko001 | 7:4aa3dac73b66 | 43 | // } |
bosko001 | 7:4aa3dac73b66 | 44 | // char get_command( void ) { return komanda;} |
bosko001 | 7:4aa3dac73b66 | 45 | |
bosko001 | 7:4aa3dac73b66 | 46 | void set_command( char cmnd ) |
bosko001 | 7:4aa3dac73b66 | 47 | { |
bosko001 | 7:4aa3dac73b66 | 48 | if( (cmnd & validnost) != (komanda & validnost) ) komanda_flag = true; //komanda promenjena |
bosko001 | 7:4aa3dac73b66 | 49 | |
bosko001 | 7:4aa3dac73b66 | 50 | komanda = cmnd; |
bosko001 | 7:4aa3dac73b66 | 51 | } |
bosko001 | 7:4aa3dac73b66 | 52 | |
bosko001 | 7:4aa3dac73b66 | 53 | void set_validity( char val ) |
bosko001 | 7:4aa3dac73b66 | 54 | { |
bosko001 | 7:4aa3dac73b66 | 55 | if( (komanda & validnost) != (komanda & val) ) { komanda_flag = true; } |
bosko001 | 7:4aa3dac73b66 | 56 | validnost = val; |
bosko001 | 7:4aa3dac73b66 | 57 | |
bosko001 | 7:4aa3dac73b66 | 58 | } |
bosko001 | 7:4aa3dac73b66 | 59 | char get_command( void ) { return komanda & validnost;} |
bosko001 | 7:4aa3dac73b66 | 60 | |
bosko001 | 7:4aa3dac73b66 | 61 | char get_command_uncut( void ) { return komanda;} |
bosko001 | 7:4aa3dac73b66 | 62 | |
bosko001 | 7:4aa3dac73b66 | 63 | |
bosko001 | 7:4aa3dac73b66 | 64 | |
bosko001 | 7:4aa3dac73b66 | 65 | |
bosko001 | 7:4aa3dac73b66 | 66 | bool get_newcommand_flag( void) { bool ret = komanda_flag; komanda_flag = false; return ret;} |
bosko001 | 7:4aa3dac73b66 | 67 | bool check_newcommand_flag( void) { return komanda_flag; } |
bosko001 | 7:4aa3dac73b66 | 68 | |
bosko001 | 7:4aa3dac73b66 | 69 | char get_indication( void ) { return indikacija;} |
bosko001 | 7:4aa3dac73b66 | 70 | char get_roughIndication(void) { return pMax | pMin;} |
bosko001 | 7:4aa3dac73b66 | 71 | char get_raelIndication( void ) { return aktuelna_indikacija;} |
bosko001 | 7:4aa3dac73b66 | 72 | |
bosko001 | 7:4aa3dac73b66 | 73 | |
bosko001 | 7:4aa3dac73b66 | 74 | char get_correctness( void ) { return ispravnost;} |
bosko001 | 7:4aa3dac73b66 | 75 | //void bitset_correctness( char c ) { ispravnost |= c;} |
bosko001 | 7:4aa3dac73b66 | 76 | void clear_correctness( void ) { ispravnost = 0x3f;} |
bosko001 | 7:4aa3dac73b66 | 77 | // void bitset_bulbfaults( char c) { ispravnost &= ~c;} |
bosko001 | 7:4aa3dac73b66 | 78 | char get_bulbfaults( void ) { return ~ispravnost;} |
bosko001 | 7:4aa3dac73b66 | 79 | |
bosko001 | 7:4aa3dac73b66 | 80 | char get_faultVoltage( void ) {return mis; } |
bosko001 | 7:4aa3dac73b66 | 81 | // void bitset_faultVoltage( char c ) { mis |= c; } |
bosko001 | 7:4aa3dac73b66 | 82 | void clear_faultVoltage( void ) { mis= 0; } |
bosko001 | 7:4aa3dac73b66 | 83 | |
bosko001 | 7:4aa3dac73b66 | 84 | |
bosko001 | 7:4aa3dac73b66 | 85 | char get_message( void ) {return poruka; } |
bosko001 | 7:4aa3dac73b66 | 86 | char get_validity( void ) { return validnost;} |
bosko001 | 7:4aa3dac73b66 | 87 | void set_data( char data ) { podatak = data;} |
bosko001 | 7:4aa3dac73b66 | 88 | char get_data( void ) { return podatak;} |
bosko001 | 7:4aa3dac73b66 | 89 | void set_address( char c) { adresa = c; } |
bosko001 | 7:4aa3dac73b66 | 90 | char get_address( void) { return adresa;} |
bosko001 | 7:4aa3dac73b66 | 91 | |
bosko001 | 7:4aa3dac73b66 | 92 | void set_pMin( char p ) { pMin = (~p) & komanda; } |
bosko001 | 7:4aa3dac73b66 | 93 | void clear_pMin( void ) { pMin = pMin_buf = 0xff;} |
bosko001 | 7:4aa3dac73b66 | 94 | |
bosko001 | 7:4aa3dac73b66 | 95 | char set_pMax( char p ) { p |= 0xC0; pMax = (~p) & (~komanda); return pMax;} |
bosko001 | 7:4aa3dac73b66 | 96 | void clear_pMax( void ) { pMax = pMax_buf = 0;} |
bosko001 | 7:4aa3dac73b66 | 97 | |
bosko001 | 7:4aa3dac73b66 | 98 | void set_indication( void ) |
bosko001 | 7:4aa3dac73b66 | 99 | { |
bosko001 | 7:4aa3dac73b66 | 100 | indikacija = (pMin | pMin_buf) & komanda /* FALI!!! & validnost*/; pMin_buf = pMin; |
bosko001 | 7:4aa3dac73b66 | 101 | } |
bosko001 | 7:4aa3dac73b66 | 102 | void set_corectness( void ) { ispravnost = (ispravnost & ~komanda) | indikacija | mis; } |
bosko001 | 7:4aa3dac73b66 | 103 | void set_faultVoltage( void ) { mis = ( (pMax | pMax_buf) | mis ) /* validnost ? */; pMax_buf = pMax; } |
bosko001 | 7:4aa3dac73b66 | 104 | void set_messagge( void ) { poruka = (~komanda & mis) | (komanda & ispravnost);} |
bosko001 | 7:4aa3dac73b66 | 105 | void set_realIndication( void ) { aktuelna_indikacija = (~mis & ispravnost & indikacija) | (~ispravnost & validnost) | mis;} |
bosko001 | 7:4aa3dac73b66 | 106 | |
bosko001 | 7:4aa3dac73b66 | 107 | }; |
bosko001 | 7:4aa3dac73b66 | 108 | |
bosko001 | 7:4aa3dac73b66 | 109 | |
bosko001 | 7:4aa3dac73b66 | 110 | |
bosko001 | 7:4aa3dac73b66 | 111 | #endif |