IO plocana FRDM K64

main.cpp

Committer:
bosko001
Date:
2020-09-06
Revision:
4:fce988d27938
Parent:
3:71278c5b7c67
Child:
6:12b2660d7dff

File content as of revision 4:fce988d27938:

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

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

#include "IOspiLed.h"
#include "IOgpiospi.h"
#include "IOprotokol.h"

// Blinking rate in milliseconds
#define BLINKING_RATE_MS                                                    200




DigitalIn b2(SW2);





void consolafun( void );
Thread th_consola;

int main()
{
    // Initialise the digital pin LED1 as an output
printf("\n\n\r ____________ POCETAK IOboard_______________\n\r");

    inic_IOspiLed( );
   // inicIOboard_spi( );
    inicIO_gpiospi( );
    inicIO_protokol( );

    DigitalOut ledB(LED3,1);

int b = b2;
 
   th_consola.start( consolafun);

    while (true) 
    {

    {

        spiLed_mainfun();

        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;
            case 's': case 'S':
               set_shiftspi_signal(  );
            break;
            
     }
     ThisThread::yield();   
      thread_sleep_for(100);
    }
}