IO plocana FRDM K64

Committer:
bosko001
Date:
Sun Aug 23 16:20:21 2020 +0200
Revision:
3:71278c5b7c67
Parent:
2:b188a511819f
Child:
4:fce988d27938
sa tickerom

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bosko001 0:c06c791ca345 1 /* mbed Microcontroller Library
bosko001 0:c06c791ca345 2 * Copyright (c) 2019 ARM Limited
bosko001 0:c06c791ca345 3 * SPDX-License-Identifier: Apache-2.0
bosko001 0:c06c791ca345 4 */
bosko001 0:c06c791ca345 5
bosko001 0:c06c791ca345 6 #include "mbed.h"
bosko001 0:c06c791ca345 7 #include "platform/mbed_thread.h"
bosko001 0:c06c791ca345 8
bosko001 3:71278c5b7c67 9 #include "IOtest.h"
bosko001 3:71278c5b7c67 10 #include "IOboard.h"
bosko001 0:c06c791ca345 11
bosko001 0:c06c791ca345 12 // Blinking rate in milliseconds
bosko001 0:c06c791ca345 13 #define BLINKING_RATE_MS 200
bosko001 0:c06c791ca345 14
bosko001 0:c06c791ca345 15
bosko001 0:c06c791ca345 16
bosko001 0:c06c791ca345 17
bosko001 0:c06c791ca345 18 DigitalIn b2(SW2);
bosko001 0:c06c791ca345 19
bosko001 0:c06c791ca345 20
bosko001 0:c06c791ca345 21
bosko001 3:71278c5b7c67 22
bosko001 0:c06c791ca345 23
bosko001 0:c06c791ca345 24 void consolafun( void );
bosko001 0:c06c791ca345 25 Thread th_consola( consolafun );
bosko001 0:c06c791ca345 26
bosko001 0:c06c791ca345 27 int main()
bosko001 0:c06c791ca345 28 {
bosko001 0:c06c791ca345 29 // Initialise the digital pin LED1 as an output
bosko001 1:1052d6227111 30 printf("\n\n\r ____________ POCETAK IOspi_______________\n\r");
bosko001 0:c06c791ca345 31
bosko001 1:1052d6227111 32 inic_IOspi( );
bosko001 3:71278c5b7c67 33 // inicIOboard_spi( );
bosko001 3:71278c5b7c67 34 inicIOboard_spi( );
bosko001 0:c06c791ca345 35 DigitalOut ledB(LED3,1);
bosko001 0:c06c791ca345 36
bosko001 0:c06c791ca345 37 int b = b2;
bosko001 0:c06c791ca345 38
bosko001 0:c06c791ca345 39
bosko001 0:c06c791ca345 40 while (true)
bosko001 0:c06c791ca345 41 {
bosko001 0:c06c791ca345 42
bosko001 0:c06c791ca345 43 {
bosko001 0:c06c791ca345 44
bosko001 0:c06c791ca345 45 if( b!= b2)
bosko001 0:c06c791ca345 46 {
bosko001 0:c06c791ca345 47 b = b2;
bosko001 3:71278c5b7c67 48 if( b ) { /*ledB = 1;*/}
bosko001 3:71278c5b7c67 49 else { /*ledB = 0;*/ static char c = 0; /*writeIOspiData( 0xa0, c++ );*/
bosko001 3:71278c5b7c67 50 transIOspiData( 1, 0xa, c++ ); }
bosko001 0:c06c791ca345 51 }
bosko001 3:71278c5b7c67 52 ThisThread::yield();
bosko001 0:c06c791ca345 53
bosko001 0:c06c791ca345 54 }
bosko001 0:c06c791ca345 55
bosko001 0:c06c791ca345 56
bosko001 0:c06c791ca345 57
bosko001 0:c06c791ca345 58 thread_sleep_for(BLINKING_RATE_MS);
bosko001 0:c06c791ca345 59 }
bosko001 0:c06c791ca345 60 }
bosko001 0:c06c791ca345 61
bosko001 0:c06c791ca345 62
bosko001 0:c06c791ca345 63
bosko001 0:c06c791ca345 64
bosko001 0:c06c791ca345 65 void consolafun( void )
bosko001 0:c06c791ca345 66 {
bosko001 0:c06c791ca345 67 while( true )
bosko001 0:c06c791ca345 68 {
bosko001 0:c06c791ca345 69
bosko001 0:c06c791ca345 70 char uc = getchar( );
bosko001 0:c06c791ca345 71 switch( (unsigned char) uc )
bosko001 0:c06c791ca345 72 {
bosko001 0:c06c791ca345 73 case 'r': case 'R':
bosko001 0:c06c791ca345 74
bosko001 0:c06c791ca345 75 printf("\n\rcitanje registra, unesi broj:\n\r");
bosko001 0:c06c791ca345 76 int r;
bosko001 0:c06c791ca345 77 scanf("%x", &r);
bosko001 1:1052d6227111 78 // printf( "\n\rregistar %x ima vrednost %x\n\r", r, readMiWiReg(r));
bosko001 0:c06c791ca345 79
bosko001 0:c06c791ca345 80 break;
bosko001 0:c06c791ca345 81 case 'w': case 'W':
bosko001 0:c06c791ca345 82 {
bosko001 0:c06c791ca345 83 printf("\n\rupis registra, unesi broj registra:");
bosko001 0:c06c791ca345 84 int r;
bosko001 0:c06c791ca345 85 scanf("%x", &r);
bosko001 0:c06c791ca345 86 printf( " %x", r );
bosko001 0:c06c791ca345 87 printf("\n\runesi vrednost registra:");
bosko001 0:c06c791ca345 88 int v;
bosko001 0:c06c791ca345 89 scanf("%x", &v);
bosko001 0:c06c791ca345 90 printf( " %x", v );
bosko001 1:1052d6227111 91 // printf( "\n\rregistar %x ima vrednost %x\n\r", r, readMiWiReg(r));
bosko001 0:c06c791ca345 92 }
bosko001 0:c06c791ca345 93 break;
bosko001 0:c06c791ca345 94 }
bosko001 3:71278c5b7c67 95 ThisThread::yield();
bosko001 3:71278c5b7c67 96 thread_sleep_for(100);
bosko001 0:c06c791ca345 97 }
bosko001 0:c06c791ca345 98 }