bosko lekovic
/
IO_board
IO plocana FRDM K64
main.cpp@4:fce988d27938, 2020-09-06 (annotated)
- Committer:
- bosko001
- Date:
- Sun Sep 06 00:18:11 2020 +0200
- Revision:
- 4:fce988d27938
- Parent:
- 3:71278c5b7c67
- Child:
- 6:12b2660d7dff
faza 1
Who changed what in which revision?
User | Revision | Line number | New 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 | 4:fce988d27938 | 9 | #include "IOspiLed.h" |
bosko001 | 4:fce988d27938 | 10 | #include "IOgpiospi.h" |
bosko001 | 4:fce988d27938 | 11 | #include "IOprotokol.h" |
bosko001 | 0:c06c791ca345 | 12 | |
bosko001 | 0:c06c791ca345 | 13 | // Blinking rate in milliseconds |
bosko001 | 0:c06c791ca345 | 14 | #define BLINKING_RATE_MS 200 |
bosko001 | 0:c06c791ca345 | 15 | |
bosko001 | 0:c06c791ca345 | 16 | |
bosko001 | 0:c06c791ca345 | 17 | |
bosko001 | 0:c06c791ca345 | 18 | |
bosko001 | 0:c06c791ca345 | 19 | DigitalIn b2(SW2); |
bosko001 | 0:c06c791ca345 | 20 | |
bosko001 | 0:c06c791ca345 | 21 | |
bosko001 | 0:c06c791ca345 | 22 | |
bosko001 | 3:71278c5b7c67 | 23 | |
bosko001 | 0:c06c791ca345 | 24 | |
bosko001 | 0:c06c791ca345 | 25 | void consolafun( void ); |
bosko001 | 4:fce988d27938 | 26 | Thread th_consola; |
bosko001 | 0:c06c791ca345 | 27 | |
bosko001 | 0:c06c791ca345 | 28 | int main() |
bosko001 | 0:c06c791ca345 | 29 | { |
bosko001 | 0:c06c791ca345 | 30 | // Initialise the digital pin LED1 as an output |
bosko001 | 4:fce988d27938 | 31 | printf("\n\n\r ____________ POCETAK IOboard_______________\n\r"); |
bosko001 | 0:c06c791ca345 | 32 | |
bosko001 | 4:fce988d27938 | 33 | inic_IOspiLed( ); |
bosko001 | 3:71278c5b7c67 | 34 | // inicIOboard_spi( ); |
bosko001 | 4:fce988d27938 | 35 | inicIO_gpiospi( ); |
bosko001 | 4:fce988d27938 | 36 | inicIO_protokol( ); |
bosko001 | 4:fce988d27938 | 37 | |
bosko001 | 0:c06c791ca345 | 38 | DigitalOut ledB(LED3,1); |
bosko001 | 0:c06c791ca345 | 39 | |
bosko001 | 0:c06c791ca345 | 40 | int b = b2; |
bosko001 | 0:c06c791ca345 | 41 | |
bosko001 | 4:fce988d27938 | 42 | th_consola.start( consolafun); |
bosko001 | 4:fce988d27938 | 43 | |
bosko001 | 0:c06c791ca345 | 44 | while (true) |
bosko001 | 0:c06c791ca345 | 45 | { |
bosko001 | 0:c06c791ca345 | 46 | |
bosko001 | 0:c06c791ca345 | 47 | { |
bosko001 | 4:fce988d27938 | 48 | |
bosko001 | 4:fce988d27938 | 49 | spiLed_mainfun(); |
bosko001 | 4:fce988d27938 | 50 | |
bosko001 | 0:c06c791ca345 | 51 | if( b!= b2) |
bosko001 | 0:c06c791ca345 | 52 | { |
bosko001 | 0:c06c791ca345 | 53 | b = b2; |
bosko001 | 3:71278c5b7c67 | 54 | if( b ) { /*ledB = 1;*/} |
bosko001 | 3:71278c5b7c67 | 55 | else { /*ledB = 0;*/ static char c = 0; /*writeIOspiData( 0xa0, c++ );*/ |
bosko001 | 4:fce988d27938 | 56 | // transIOspiData( 1, 0xa, c++ ); |
bosko001 | 4:fce988d27938 | 57 | } |
bosko001 | 0:c06c791ca345 | 58 | } |
bosko001 | 3:71278c5b7c67 | 59 | ThisThread::yield(); |
bosko001 | 0:c06c791ca345 | 60 | |
bosko001 | 0:c06c791ca345 | 61 | } |
bosko001 | 0:c06c791ca345 | 62 | |
bosko001 | 0:c06c791ca345 | 63 | |
bosko001 | 0:c06c791ca345 | 64 | |
bosko001 | 0:c06c791ca345 | 65 | thread_sleep_for(BLINKING_RATE_MS); |
bosko001 | 0:c06c791ca345 | 66 | } |
bosko001 | 0:c06c791ca345 | 67 | } |
bosko001 | 0:c06c791ca345 | 68 | |
bosko001 | 0:c06c791ca345 | 69 | |
bosko001 | 0:c06c791ca345 | 70 | |
bosko001 | 0:c06c791ca345 | 71 | |
bosko001 | 0:c06c791ca345 | 72 | void consolafun( void ) |
bosko001 | 0:c06c791ca345 | 73 | { |
bosko001 | 0:c06c791ca345 | 74 | while( true ) |
bosko001 | 0:c06c791ca345 | 75 | { |
bosko001 | 0:c06c791ca345 | 76 | |
bosko001 | 0:c06c791ca345 | 77 | char uc = getchar( ); |
bosko001 | 0:c06c791ca345 | 78 | switch( (unsigned char) uc ) |
bosko001 | 0:c06c791ca345 | 79 | { |
bosko001 | 0:c06c791ca345 | 80 | case 'r': case 'R': |
bosko001 | 0:c06c791ca345 | 81 | |
bosko001 | 0:c06c791ca345 | 82 | printf("\n\rcitanje registra, unesi broj:\n\r"); |
bosko001 | 0:c06c791ca345 | 83 | int r; |
bosko001 | 0:c06c791ca345 | 84 | scanf("%x", &r); |
bosko001 | 1:1052d6227111 | 85 | // printf( "\n\rregistar %x ima vrednost %x\n\r", r, readMiWiReg(r)); |
bosko001 | 0:c06c791ca345 | 86 | |
bosko001 | 0:c06c791ca345 | 87 | break; |
bosko001 | 0:c06c791ca345 | 88 | case 'w': case 'W': |
bosko001 | 0:c06c791ca345 | 89 | { |
bosko001 | 0:c06c791ca345 | 90 | printf("\n\rupis registra, unesi broj registra:"); |
bosko001 | 0:c06c791ca345 | 91 | int r; |
bosko001 | 0:c06c791ca345 | 92 | scanf("%x", &r); |
bosko001 | 0:c06c791ca345 | 93 | printf( " %x", r ); |
bosko001 | 0:c06c791ca345 | 94 | printf("\n\runesi vrednost registra:"); |
bosko001 | 0:c06c791ca345 | 95 | int v; |
bosko001 | 0:c06c791ca345 | 96 | scanf("%x", &v); |
bosko001 | 0:c06c791ca345 | 97 | printf( " %x", v ); |
bosko001 | 1:1052d6227111 | 98 | // printf( "\n\rregistar %x ima vrednost %x\n\r", r, readMiWiReg(r)); |
bosko001 | 0:c06c791ca345 | 99 | } |
bosko001 | 0:c06c791ca345 | 100 | break; |
bosko001 | 4:fce988d27938 | 101 | case 's': case 'S': |
bosko001 | 4:fce988d27938 | 102 | set_shiftspi_signal( ); |
bosko001 | 4:fce988d27938 | 103 | break; |
bosko001 | 4:fce988d27938 | 104 | |
bosko001 | 0:c06c791ca345 | 105 | } |
bosko001 | 3:71278c5b7c67 | 106 | ThisThread::yield(); |
bosko001 | 3:71278c5b7c67 | 107 | thread_sleep_for(100); |
bosko001 | 0:c06c791ca345 | 108 | } |
bosko001 | 0:c06c791ca345 | 109 | } |