K22 processor

Committer:
bosko001
Date:
Sun May 16 22:01:47 2021 +0200
Revision:
18:6196688e2a94
Parent:
15:3429cdc6e5f4
korigovan PeripheralPins.c u mbedOS

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