bosko lekovic
/
IO_board_K22
K22 processor
main.cpp
- Committer:
- bosko001
- Date:
- 2021-05-16
- Revision:
- 18:6196688e2a94
- Parent:
- 17:f99cdfd01d4e
File content as of revision 18:6196688e2a94:
/* mbed Microcontroller Library * Copyright (c) 2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 */ #include "mbed.h" #include "platform/mbed_thread.h" #include <vector> #include "Pinovi.h" // #include "IOspiLed.h" #include "ledControl.h" // #include "IOgpiospi.h" // #include "IOspitelegram.h" #include "IOspiprotokol.h" #include "ZeroCrossing.h" #include "ZC_CommandIndication.h" #include "IOzcControl.h" extern vector< S_logTelegram> s_log; // Blinking rate in milliseconds #define BLINKING_RATE_MS 200 //DigitalOut ioTest(IO_TEST,0); char verzija = 5; DigitalIn b2(SW2); static DigitalOut ledB(LED3,1); class C_data c_data; C_ledControl c_ledControl(&c_data);//( &c_ledLight); C_spiProtokol c_spiProtokol( &c_data, &c_ledControl ); C_zeroCrossing c_zeroCrossing( &c_data); // C_zeroCrossing& rc_zc = c_zeroCrossing; // C_zcControl c_zcControl( &c_zeroCrossing, &c_spiProtokol); C_ZC_CommandIndication c_zc_ci( &c_data, &c_zeroCrossing); //Ticker test_RasaLed; //DigitalOut RasaLed(PTE0,1); int tz; int main() { // Initialise the digital pin LED1 as an output printf("\n\n\r ____________ POCETAK IOboard_______________\n\r"); // s_log.resize(1000); // s_log.clear(); // printf( " capacity %d max_size %d size %d\n\r", s_log.capacity(), s_log.max_size(), s_log.size()); // //test_RasaLed.attach_us([=]{ RasaLed = !RasaLed;}, 500000 ); // int b = b2; // /* konzolu napraciti kao klasu koja nasledjuje C_thread klasu */ // extern void consolafun( void ); // Thread th_consola; // th_consola.start( consolafun); // /* cekanje da se procita prva ispravna adresa sa dip switch-a */ // do { ThisThread::sleep_for(10ms);;c_spiProtokol.inic_address( ); } // while ( c_data.get_address() == 0 ); // printf(" adresa je = %d\n\r", c_data.get_address()); // // postavljanje sopstvene adrese i prikaz na ledovima // c_spiProtokol.set_myAddress(c_data.get_address()); // c_ledControl.set_colorTemplate_Green(); // c_ledControl.set_ledView(adresa); // while (true) // { // if( b!= b2) // { // b = b2; // if( b ) { ledB = 1;} // else { ledB = 0; //printf( " bitCount = %d, byteCount = %d\n\r", c_spiProtokol.get_bitCount(), c_spiProtokol.get_byteCount()); // printf( " zerocrossing timer on = %d off = %d \n\r", c_zeroCrossing.get_zcTimeON(), c_zeroCrossing.get_zcTimeOFF()); // // printf(" port in %x\n\r", rc_zc.s_portinMin.get_port() ); // printf(" adresa je = %d\n\r", c_data.get_address()); // } // } // c_spiProtokol.spi_monitor(); // thread_sleep_for(BLINKING_RATE_MS); // } while(1); } void consolafun( void ) { while( true ) { char uc = getchar( ); switch( (unsigned char) uc ) { case 'r': case 'R': NVIC_SystemReset(); break; case 'w': case 'W': { printf("\n\rupis registra, unesi broj registra:"); int r; scanf("%x", &r); printf( " %x", r ); printf("\n\runesi vrednost registra:"); int v; scanf("%x", &v); printf( " %x", v ); // printf( "\n\rregistar %x ima vrednost %x\n\r", r, readMiWiReg(r)); } break; case 's': case 'S': // set_shiftspi_signal( ); break; case 'c': s_log.clear(); //break; case 'l': printf( " capacity %d max_size %d size %d\n\r", s_log.capacity(), s_log.max_size(), s_log.size()); break; case 'p': int i=1; if(s_log.size()) { for( auto it = s_log.end()-1; it != s_log.begin(); it--) printf( "%3d %s\n\r", i++, (*it).poruka); auto it = s_log.begin(); printf( "%3d %s\n\r", i++, (*it).poruka ); } break; } ThisThread::yield(); thread_sleep_for(100); } }