bosko lekovic
/
IO_spi
IO spi
Diff: main.cpp
- Revision:
- 1:1052d6227111
- Parent:
- 0:c06c791ca345
- Child:
- 2:b188a511819f
--- a/main.cpp Fri Jul 10 09:28:30 2020 +0000 +++ b/main.cpp Thu Aug 13 17:30:08 2020 +0000 @@ -6,7 +6,7 @@ #include "mbed.h" #include "platform/mbed_thread.h" -#include "MiWiApp.h" +#include "IOspi.h" // Blinking rate in milliseconds #define BLINKING_RATE_MS 200 @@ -26,63 +26,26 @@ int main() { // Initialise the digital pin LED1 as an output -printf("\n\n\r ____________ POCETAK MiWI RX_______________\n\r"); +printf("\n\n\r ____________ POCETAK IOspi_______________\n\r"); - inic_MiWi( ); + inic_IOspi( ); DigitalOut led(LED1,1); DigitalOut ledB(LED3,1); - - - set_mode( 3 ); //prijem - - - //for( int i=0; i<10; i++) - { - char r = readMiWiReg( 0x14 ); // read GCONFIG - printf("rssi = %d\n\r", r ); - print_regs(); -} - int b = b2; while (true) { - // led = !led; -extern DigitalIn pin_irq0, pin_irq1; -// -// unsigned char r = readMiWiReg( 0x14 ); // read GCONFIG -// printf("rssi = %d ", r ); -// printf(" irq0=%d irq1=%d\n\r", pin_irq0.read(), pin_irq1.read() ); fflush(stdout); -////if( r> 50 ) - - if( get_mode( ) == 3 ) - { - if( pin_irq0.read() ) - { - led = 0; - print_regs(); - while( pin_irq0.read() ) - { - printf(" %x ", readMiWiData( )); - // printf("\n\r irq0=%d irq1=%d\n\r", pin_irq0.read(), pin_irq1.read() ); - } - printf("\n\r"); - print_regs(); - } - else { if(!led ) led = 1; } - } -// else { if( b!= b2) { b = b2; - if( b ) {/*set_mode( 1 );*/ ledB = 1;} - else { ledB = 0; txMiWi( tx_niz ); } + if( b ) { ledB = 1;} + else { ledB = 0; static char c = 0; /*writeIOspiData( 0xa0, c++ );*/ char *rx = transIOspiData( 1, 0xa, c++ ); for(int i= 0; i<8; i++) printf(" %x", rx[i]);printf(" \n\r"); } } } @@ -109,7 +72,7 @@ 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)); + // printf( "\n\rregistar %x ima vrednost %x\n\r", r, readMiWiReg(r)); break; case 'w': case 'W': @@ -122,7 +85,7 @@ int v; scanf("%x", &v); printf( " %x", v ); - printf( "\n\rregistar %x ima vrednost %x\n\r", r, readMiWiReg(r)); + // printf( "\n\rregistar %x ima vrednost %x\n\r", r, readMiWiReg(r)); } break; }