IO plocana FRDM K64

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?

UserRevisionLine numberNew contents of line
bosko001 7:4aa3dac73b66 1 #include "IOspiprotokol.h"
bosko001 7:4aa3dac73b66 2
bosko001 7:4aa3dac73b66 3 #include <functional>
bosko001 7:4aa3dac73b66 4
bosko001 7:4aa3dac73b66 5 // extern DigitalOut ioTest;
bosko001 7:4aa3dac73b66 6 extern volatile char ext_command, ext_data;
bosko001 7:4aa3dac73b66 7
bosko001 7:4aa3dac73b66 8 extern char verzija, reset_flag;
bosko001 7:4aa3dac73b66 9
bosko001 7:4aa3dac73b66 10 void C_spiProtokol::do_writeCommand( const char command, const char data)
bosko001 7:4aa3dac73b66 11 {
bosko001 7:4aa3dac73b66 12
bosko001 7:4aa3dac73b66 13 //pc_data->set_validity(0x3f);
bosko001 7:4aa3dac73b66 14 //ioTest =! ioTest;
bosko001 7:4aa3dac73b66 15 switch( command )
bosko001 7:4aa3dac73b66 16 {
bosko001 7:4aa3dac73b66 17 case 1: pc_data->set_command(data); /* ioTest =! ioTest;*/ /* ext_command = command; ext_data = data; */ break;
bosko001 7:4aa3dac73b66 18 case 2: pc_data->set_validity(data); set_reset(false); // brisanje reset flaga
bosko001 7:4aa3dac73b66 19 /*ext_command = command; ext_data = data;*/ /*ioTest =! ioTest;*/ break;
bosko001 7:4aa3dac73b66 20 case 3: pc_ledControl->unpack_ledBulb(data); break; // formiranje tabele sijalica
bosko001 7:4aa3dac73b66 21 // prikazi na shift ledove
bosko001 7:4aa3dac73b66 22 case 4: pc_ledControl->set_colorTemplate(); pc_ledControl->set_ledView(komanda);/* set_byte(pc_data->get_command()); */ break;
bosko001 7:4aa3dac73b66 23 case 5: pc_ledControl->set_colorTemplate(); pc_ledControl->set_ledView(indikacija);/*set_byte(pc_data->get_indication());*/ break;
bosko001 7:4aa3dac73b66 24 case 6: pc_ledControl->set_colorTemplate(); pc_ledControl->set_ledView(ispravnost);/*set_byte(pc_data->get_correctness());*/ break;
bosko001 7:4aa3dac73b66 25 case 7: pc_ledControl->set_colorTemplate(); pc_ledControl->set_ledView(mis);/*set_byte(pc_data->get_faultVoltage());*/ break;
bosko001 7:4aa3dac73b66 26 case 8: pc_ledControl->set_colorTemplate(); pc_ledControl->set_ledView(poruka);/* set_byte(pc_data->get_message());*/ break;
bosko001 7:4aa3dac73b66 27 case 9: pc_ledControl->set_colorTemplate_Yellow(); pc_ledControl->set_ledView(validnost);/* set_byte(pc_data->get_validity());*/ break;
bosko001 7:4aa3dac73b66 28 case 10: pc_ledControl->set_colorTemplate_Red(); pc_data->set_data(data); pc_ledControl->set_ledView(podatak);/* set_byte(pc_data->get_data());*/ break;
bosko001 7:4aa3dac73b66 29 case 11: pc_data->clear_correctness( ); pc_data->clear_faultVoltage(); break;
bosko001 7:4aa3dac73b66 30 case 12: pc_ledControl->set_colorTemplate_Green(); pc_ledControl->set_ledView(adresa);/*set_byte(pc_data->get_address());*/ break;
bosko001 7:4aa3dac73b66 31 case 13: pc_ledControl->set_ledView(aktuelna_indikacija);pc_ledControl->set_colorTemplate(); pc_ledControl->set_ledView(aktuelna_indikacija);/* set_byte(pc_data->get_raelIndication());*/ break;
bosko001 7:4aa3dac73b66 32
bosko001 7:4aa3dac73b66 33 case 14: /* brisanje look-up tabele sijalica */ break;
bosko001 7:4aa3dac73b66 34 case 15: /* reset ploce */ break;
bosko001 7:4aa3dac73b66 35 }
bosko001 7:4aa3dac73b66 36 }
bosko001 7:4aa3dac73b66 37
bosko001 7:4aa3dac73b66 38 char C_spiProtokol::do_readCommand( const char command, const char data)
bosko001 7:4aa3dac73b66 39 {
bosko001 7:4aa3dac73b66 40 switch( command )
bosko001 7:4aa3dac73b66 41 {
bosko001 7:4aa3dac73b66 42 case 0: return 0;
bosko001 7:4aa3dac73b66 43 case 1: return data;
bosko001 7:4aa3dac73b66 44 case 2: return pc_data->get_message();
bosko001 7:4aa3dac73b66 45 case 3: return verzija;
bosko001 7:4aa3dac73b66 46 case 4: return pc_data->get_command(); // komanda paljenja sijalica
bosko001 7:4aa3dac73b66 47 case 5: return pc_data->get_indication(); // indikacije sa sijalica
bosko001 7:4aa3dac73b66 48 case 6: return pc_data->get_correctness(); //ispravnost sijalica
bosko001 7:4aa3dac73b66 49 case 7: return pc_data->get_faultVoltage(); //detkcija misa
bosko001 7:4aa3dac73b66 50 case 8: return pc_data->get_validity(); // validni izlazi
bosko001 7:4aa3dac73b66 51 case 9: /* ne znam sta je - neki LED_IND - TREBA PROVERIti !!!! */ return 9;
bosko001 7:4aa3dac73b66 52 case 10: /* bajt sa adrese na koju pokazuje polje data - nemoguce je realizovati */ return 10;
bosko001 7:4aa3dac73b66 53 case 11: return pc_data->get_address(); // POTPUNA GLUPOST !!!
bosko001 7:4aa3dac73b66 54 case 12: return pc_data->get_raelIndication(); // aktuelna indikacija
bosko001 7:4aa3dac73b66 55 case 13: return pc_data->get_roughIndication(); // treba da bude (sirova indikacija | sirovi mis) - nepotrebno
bosko001 7:4aa3dac73b66 56 case 14: return 14; // treba da bude sirova indikacija - Pa_min - nepotrebno
bosko001 7:4aa3dac73b66 57 }
bosko001 7:4aa3dac73b66 58
bosko001 7:4aa3dac73b66 59 return 15;
bosko001 7:4aa3dac73b66 60 }
bosko001 7:4aa3dac73b66 61
bosko001 7:4aa3dac73b66 62 void C_spiProtokol::do_readGroupCommand( const char command)
bosko001 7:4aa3dac73b66 63 {
bosko001 7:4aa3dac73b66 64 switch( command )
bosko001 7:4aa3dac73b66 65 {
bosko001 7:4aa3dac73b66 66 case 1: /* aktiviranje timera na 4 sekunde za gasenja IO */ break;
bosko001 7:4aa3dac73b66 67 case 2: /* gasenje timera */ break;
bosko001 7:4aa3dac73b66 68 }
bosko001 7:4aa3dac73b66 69 }
bosko001 7:4aa3dac73b66 70
bosko001 7:4aa3dac73b66 71
bosko001 7:4aa3dac73b66 72
bosko001 7:4aa3dac73b66 73
bosko001 7:4aa3dac73b66 74
bosko001 7:4aa3dac73b66 75
bosko001 7:4aa3dac73b66 76
bosko001 7:4aa3dac73b66 77