bosko lekovic
/
IO_board
IO plocana FRDM K64
main.cpp
- Committer:
- bosko001
- Date:
- 2020-08-23
- Revision:
- 3:71278c5b7c67
- Parent:
- 2:b188a511819f
- Child:
- 4:fce988d27938
File content as of revision 3:71278c5b7c67:
/* mbed Microcontroller Library * Copyright (c) 2019 ARM Limited * SPDX-License-Identifier: Apache-2.0 */ #include "mbed.h" #include "platform/mbed_thread.h" #include "IOtest.h" #include "IOboard.h" // Blinking rate in milliseconds #define BLINKING_RATE_MS 200 DigitalIn b2(SW2); void consolafun( void ); Thread th_consola( consolafun ); int main() { // Initialise the digital pin LED1 as an output printf("\n\n\r ____________ POCETAK IOspi_______________\n\r"); inic_IOspi( ); // inicIOboard_spi( ); inicIOboard_spi( ); DigitalOut ledB(LED3,1); int b = b2; while (true) { { if( b!= b2) { b = b2; if( b ) { /*ledB = 1;*/} else { /*ledB = 0;*/ static char c = 0; /*writeIOspiData( 0xa0, c++ );*/ transIOspiData( 1, 0xa, c++ ); } } ThisThread::yield(); } thread_sleep_for(BLINKING_RATE_MS); } } void consolafun( void ) { while( true ) { char uc = getchar( ); switch( (unsigned char) uc ) { case 'r': case 'R': printf("\n\rcitanje registra, unesi broj:\n\r"); int r; scanf("%x", &r); // printf( "\n\rregistar %x ima vrednost %x\n\r", r, readMiWiReg(r)); 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; } ThisThread::yield(); thread_sleep_for(100); } }