IO spi

main.cpp

Committer:
bosko001
Date:
2020-08-13
Revision:
1:1052d6227111
Parent:
0:c06c791ca345
Child:
2:b188a511819f

File content as of revision 1:1052d6227111:

/* mbed Microcontroller Library
 * Copyright (c) 2019 ARM Limited
 * SPDX-License-Identifier: Apache-2.0
 */

#include "mbed.h"
#include "platform/mbed_thread.h"

#include "IOspi.h"

// Blinking rate in milliseconds
#define BLINKING_RATE_MS                                                    200




DigitalIn b2(SW2);



char tx_niz[] = { 7,0,1,2,3, 4, 5 , 6, 7, 8};

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( );
    
    DigitalOut led(LED1,1);
    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++ );*/ char *rx =  transIOspiData( 1, 0xa, c++ ); for(int i= 0; i<8; i++) printf(" %x", rx[i]);printf(" \n\r"); }
        }
   
    }



        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;
     }
        
    }
}