K22 processor

Files at this revision

API Documentation at this revision

Comitter:
bosko001
Date:
Sun May 16 22:01:47 2021 +0200
Parent:
17:f99cdfd01d4e
Commit message:
korigovan PeripheralPins.c u mbedOS

Changed in this revision

Pinovi.h Show annotated file Show diff for this revision Revisions of this file
SPIledovi/LedLight.cpp Show annotated file Show diff for this revision Revisions of this file
SPIledovi/LedLight.h Show annotated file Show diff for this revision Revisions of this file
SPIledovi/ledControl.h Show annotated file Show diff for this revision Revisions of this file
SPIprotokol/SlaveSpi.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed-os.lib Show annotated file Show diff for this revision Revisions of this file
--- a/Pinovi.h	Sat May 15 13:59:57 2021 +0200
+++ b/Pinovi.h	Sun May 16 22:01:47 2021 +0200
@@ -4,8 +4,8 @@
 #define BROADCASTADDRESS (unsigned char)0xc0
 
 
-//#define FRDMK22F
-#define FRDMK64F
+#define FRDMK22F
+//#define FRDMK64F
 
 
 #ifdef FRDMK64F
@@ -67,7 +67,7 @@
 
 #define Led_mosi    PTD6
 #define Led_miso    PTD7
-#define Led_sclk    PTD8
+#define Led_sclk    PTD5
 #define Led_cs      PTA1
  //  C_spiled::C_spiled():C_spi(  PTD2, PTD3, PTD1, PTC4)//, C_thread()
 //C_spi( PinName mosi, PinName miso, PinName sclk, PinName pin_csdata ); 
@@ -77,7 +77,7 @@
 #define Mosi PTD2
 #define Miso PTD3
 #define SpiClock PTD1
-#define SpiSel PTD4
+#define SpiSel PTD4   /*PTD0*/
 #define SpiSel_out   PTA5
 #define IO_TELEGRAM_TAS_PIN   PTC4 
 
--- a/SPIledovi/LedLight.cpp	Sat May 15 13:59:57 2021 +0200
+++ b/SPIledovi/LedLight.cpp	Sun May 16 22:01:47 2021 +0200
@@ -11,8 +11,8 @@
     C_spi::C_spi( PinName mosi, PinName miso, PinName sclk, PinName pin_csdata ): SPI( mosi,  miso,  sclk)  //SPI( PTD2, PTD3, PTD1 )
     {
         p_csdata = new DigitalOut( pin_csdata,1);
-        format( 16, 0);
-        frequency(10000000);
+         format( 16, 0);
+         frequency(10000000);
     }
     unsigned short C_spi::transfer( unsigned short tx )
     {
@@ -107,14 +107,14 @@
     {    
                static char j=1;
             
-            set_led( 1,  (E_ledColor)( (get_ledLightTickPatern(1) & j) ? ((get_ledLightColor(1))) : 0 ) );
-            set_led( 2,  (E_ledColor)( (get_ledLightTickPatern(2) & j) ? ((get_ledLightColor(2))) : 0 ) );
-            set_led( 3,  (E_ledColor)( (get_ledLightTickPatern(3) & j) ? ((get_ledLightColor(3))) : 0 ) );
-            set_led( 4,  (E_ledColor)( (get_ledLightTickPatern(4) & j) ? ((get_ledLightColor(4))) : 0 ) );
-            set_led( 5,  (E_ledColor)( (get_ledLightTickPatern(5) & j) ? ((get_ledLightColor(5))) : 0 ) );
-            set_led( 6,  (E_ledColor)( (get_ledLightTickPatern(6) & j) ? ((get_ledLightColor(6))) : 0 ) );
+             set_led( 1,  (E_ledColor)( (get_ledLightTickPatern(1) & j) ? ((get_ledLightColor(1))) : 0 ) );
+             set_led( 2,  (E_ledColor)( (get_ledLightTickPatern(2) & j) ? ((get_ledLightColor(2))) : 0 ) );
+             set_led( 3,  (E_ledColor)( (get_ledLightTickPatern(3) & j) ? ((get_ledLightColor(3))) : 0 ) );
+             set_led( 4,  (E_ledColor)( (get_ledLightTickPatern(4) & j) ? ((get_ledLightColor(4))) : 0 ) );
+             set_led( 5,  (E_ledColor)( (get_ledLightTickPatern(5) & j) ? ((get_ledLightColor(5))) : 0 ) );
+             set_led( 6,  (E_ledColor)( (get_ledLightTickPatern(6) & j) ? ((get_ledLightColor(6))) : 0 ) );
 
-            do_Sifter();
+             do_Sifter();
 
             if( !(j<<=1) ) j = 1;
             
--- a/SPIledovi/LedLight.h	Sat May 15 13:59:57 2021 +0200
+++ b/SPIledovi/LedLight.h	Sun May 16 22:01:47 2021 +0200
@@ -80,7 +80,7 @@
 
 // klasa osvezavanja prikaza funkcija. Aktivira sopstveni C_thread i periodicno salje novo stanje ledova 
 
-class C_ledLight: public C_spiled, C_thread
+class C_ledLight : public  C_thread, public C_spiled
 {
     char tickCounter =1;
     S_ledLight s_ledLight[NO_LED] = {{ledOff,0},{ledOff,0},{ledOff,0},{ledOff,0},{ledOff,0},{ledOff,0}};
@@ -89,7 +89,7 @@
 
 virtual void _refresh( void);
    
-    void thread_fun(void) override { _refresh(); }
+     void thread_fun(void) override { _refresh(); }
  
     C_ledLight(  );// { }
     C_ledLight( int stack );//:C_thread( stack) { }
--- a/SPIledovi/ledControl.h	Sat May 15 13:59:57 2021 +0200
+++ b/SPIledovi/ledControl.h	Sun May 16 22:01:47 2021 +0200
@@ -85,7 +85,7 @@
 
         while( true )
         { 
-            pc_data->set_address( (C_spiled::get_received()>>8) & 0x0f);
+             pc_data->set_address( (/*C_spiled::*/get_received()>>8) & 0x0f);
            // ledG = 0;
  //          if(pf != nullptr)   { pf(); ledG = ! ledG; }
             if( e_ledView == komanda )  { set_ledPort(pc_data->get_command_uncut());  }
--- a/SPIprotokol/SlaveSpi.h	Sat May 15 13:59:57 2021 +0200
+++ b/SPIprotokol/SlaveSpi.h	Sun May 16 22:01:47 2021 +0200
@@ -32,46 +32,46 @@
 public: 
 
 
-static int spiReadRegister( int ar ){    return *(int*)( _SPI_BASE +  ar);}
-static void spiWriteRegister( int ar, int d ){    *(int*)( _SPI_BASE + ar) = d;}
+    static int spiReadRegister( int ar ){    return *(int*)( _SPI_BASE +  ar);}
+    static void spiWriteRegister( int ar, int d ){    *(int*)( _SPI_BASE + ar) = d;}
 
-static void inic_slaveSpi( void )
-{
-    NVIC_DisableIRQ( _SPI_IRQn );  
-    _CS = 1;
-    wait_us(10);
-    _CS = 0;
-        spiWriteRegister(0, spiReadRegister(0) | 0x3c00);   /* 0x00000C00 = ciscenje rx i tx buffer-a*/
-        spiWriteRegister(0x2c, spiReadRegister(0x2c) | 0x80000000);  /* TCF clear */
-        spiWriteRegister(0x30, spiReadRegister(0x30) | 0x80000000);  /* transfer interrupt enable */
+    static void inic_slaveSpi( void )
+    {
+        NVIC_DisableIRQ( _SPI_IRQn );  
+        _CS = 1;
+        wait_us(10);
+        _CS = 0;
+            spiWriteRegister(0, spiReadRegister(0) | 0x3c00);   /* 0x00000C00 = ciscenje rx i tx buffer-a*/
+        //!    spiWriteRegister(0x2c, spiReadRegister(0x2c) | 0x80000000);  /* TCF clear */
+        //!    spiWriteRegister(0x30, spiReadRegister(0x30) | 0x80000000);  /* transfer interrupt enable */
+
+         spiWriteRegister(0x34, writeData);  /* data for transmit */  
+     }
 
-    spiWriteRegister(0x34, writeData);  /* data for transmit */  
-}
-
-static void ff(void )
-{
-    if( ( spiReadRegister(0x2c)) & 0x80000000 )
+    static void ff(void )
     {
-        spiWriteRegister(0x2c, spiReadRegister(0x2c) | 0x80000000);
-        readData = spiReadRegister(0x38);   /* data register read */
-    spiWriteRegister(0x34, writeData);  /* data for transmit */    
- 
+        if( ( spiReadRegister(0x2c)) & 0x80000000 )
+        {
+            spiWriteRegister(0x2c, spiReadRegister(0x2c) | 0x80000000);
+            readData = spiReadRegister(0x38);   /* data register read */
+        spiWriteRegister(0x34, writeData);  /* data for transmit */    
     
-    _transferFlag = 1;
-    ef.set(1);
+        
+        _transferFlag = 1;
+        ef.set(1);
+        }
+
+    //   else { ledG =! ledG; inic_slaveSpi(  );  set_slaveSpiInterrupt(ff);}
+    // ledC =! ledC;
+    //    spiByteTransfer( &writeData, readData );
     }
 
- //   else { ledG =! ledG; inic_slaveSpi(  );  set_slaveSpiInterrupt(ff);}
- // ledC =! ledC;
-//    spiByteTransfer( &writeData, readData );
-}
+    static void set_slaveSpiInterrupt( pfv p_fun )
+    {
+        NVIC_SetVector( _SPI_IRQn, (int)p_fun );   // varijanta sa static ff()
+        NVIC_EnableIRQ( _SPI_IRQn );  
 
-static void set_slaveSpiInterrupt( pfv p_fun )
-{
-    NVIC_SetVector( _SPI_IRQn, (int)p_fun );   // varijanta sa static ff()
-    NVIC_EnableIRQ( _SPI_IRQn );  
-
-}
+    }
 
 // class C_slaveSpi: SPISlave, C_thread
 // {
@@ -123,7 +123,11 @@
 
 
     char get_bitCount( void ) { return bitCount;}
-    void clear_bitCount( void ) { /*ledG =! ledG;*/ bitCount = 0; inic_slaveSpi(  );  set_slaveSpiInterrupt(ff);}
+    void clear_bitCount( void ) { /*ledG =! ledG;*/ 
+    bitCount = 0; 
+    inic_slaveSpi(  );  
+    set_slaveSpiInterrupt(ff);
+    }
 
     void spi_monitor( void ){};
 
--- a/main.cpp	Sat May 15 13:59:57 2021 +0200
+++ b/main.cpp	Sun May 16 22:01:47 2021 +0200
@@ -44,22 +44,22 @@
 
 class C_data c_data;
 
-C_ledControl c_ledControl(&c_data);//( &c_ledLight);
+ C_ledControl c_ledControl(&c_data);//( &c_ledLight);
 
-C_spiProtokol c_spiProtokol( &c_data, &c_ledControl );
+ C_spiProtokol c_spiProtokol( &c_data, &c_ledControl );
 
 
 
 
-C_zeroCrossing c_zeroCrossing( &c_data);
+ C_zeroCrossing c_zeroCrossing( &c_data);
 
 
 
-C_zeroCrossing& rc_zc = c_zeroCrossing;
+// C_zeroCrossing& rc_zc = c_zeroCrossing;
 
-C_zcControl c_zcControl( &c_zeroCrossing, &c_spiProtokol);
+// C_zcControl c_zcControl( &c_zeroCrossing, &c_spiProtokol);
 
-C_ZC_CommandIndication c_zc_ci( &c_data, &c_zeroCrossing);
+ C_ZC_CommandIndication c_zc_ci( &c_data, &c_zeroCrossing);
 
 
 //Ticker test_RasaLed;
@@ -75,61 +75,63 @@
 
 printf("\n\n\r ____________ POCETAK IOboard_______________\n\r");
 
-s_log.resize(1000);
-s_log.clear();
+// s_log.resize(1000);
+// s_log.clear();
 
-printf( " capacity %d max_size %d size %d\n\r", s_log.capacity(), s_log.max_size(), s_log.size());
+// printf( " capacity %d max_size %d size %d\n\r", s_log.capacity(), s_log.max_size(), s_log.size());
 
 
-//test_RasaLed.attach_us([=]{ RasaLed = !RasaLed;}, 500000   );
+// //test_RasaLed.attach_us([=]{ RasaLed = !RasaLed;}, 500000   );
 
 
 
-int b = b2;
+// int b = b2;
  
-    /* konzolu napraciti kao klasu koja nasledjuje C_thread klasu */
-    extern void consolafun( void );
+//     /* konzolu napraciti kao klasu koja nasledjuje C_thread klasu */
+//     extern void consolafun( void );
 
-    Thread th_consola;
-    th_consola.start( consolafun);
+//     Thread th_consola;
+//     th_consola.start( consolafun);
 
 
 
-    /* cekanje da se procita prva ispravna adresa  sa dip switch-a  */
+//     /* cekanje da se procita prva ispravna adresa  sa dip switch-a  */
  
 
-    do       { ThisThread::sleep_for(10ms);;c_spiProtokol.inic_address( ); }
-    while   ( c_data.get_address() == 0 );
-                    printf(" adresa je = %d\n\r", c_data.get_address());
+//     do       { ThisThread::sleep_for(10ms);;c_spiProtokol.inic_address( ); }
+//     while   ( c_data.get_address() == 0 );
+//                     printf(" adresa je = %d\n\r", c_data.get_address());
 
-    //   postavljanje sopstvene adrese i prikaz na ledovima
-    c_spiProtokol.set_myAddress(c_data.get_address());
-    c_ledControl.set_colorTemplate_Green(); 
-    c_ledControl.set_ledView(adresa);
+//     //   postavljanje sopstvene adrese i prikaz na ledovima
+//     c_spiProtokol.set_myAddress(c_data.get_address());
+//     c_ledControl.set_colorTemplate_Green(); 
+//     c_ledControl.set_ledView(adresa);
 
 
-    while (true) 
-    {
+//     while (true) 
+//     {
 
 
-        if( b!= b2)
-        {
-            b = b2;
-        if( b ) { ledB = 1;}
-        else    { ledB = 0; //printf( " bitCount = %d, byteCount = %d\n\r", c_spiProtokol.get_bitCount(), c_spiProtokol.get_byteCount());  
+//         if( b!= b2)
+//         {
+//             b = b2;
+//         if( b ) { ledB = 1;}
+//         else    { ledB = 0; //printf( " bitCount = %d, byteCount = %d\n\r", c_spiProtokol.get_bitCount(), c_spiProtokol.get_byteCount());  
                 
-                printf( " zerocrossing timer on = %d   off = %d \n\r", c_zeroCrossing.get_zcTimeON(), c_zeroCrossing.get_zcTimeOFF());
-               // printf(" port in %x\n\r", rc_zc.s_portinMin.get_port() );
-                printf(" adresa je = %d\n\r", c_data.get_address());
-                }
-        }
+//                 printf( " zerocrossing timer on = %d   off = %d \n\r", c_zeroCrossing.get_zcTimeON(), c_zeroCrossing.get_zcTimeOFF());
+//                // printf(" port in %x\n\r", rc_zc.s_portinMin.get_port() );
+//                 printf(" adresa je = %d\n\r", c_data.get_address());
+//                 }
+//         }
     
-        c_spiProtokol.spi_monitor();
+//         c_spiProtokol.spi_monitor();
 
 
-        thread_sleep_for(BLINKING_RATE_MS);
-    }
-}
+//         thread_sleep_for(BLINKING_RATE_MS);
+//     }
+
+while(1);
+ }
 
 
 
@@ -182,4 +184,5 @@
      ThisThread::yield();   
       thread_sleep_for(100);
     }
+
 }
--- a/mbed-os.lib	Sat May 15 13:59:57 2021 +0200
+++ b/mbed-os.lib	Sun May 16 22:01:47 2021 +0200
@@ -1,1 +1,1 @@
-https://github.com/ARMmbed/mbed-os/#890f0562dc2efb7cf76a5f010b535c2b94bce849
\ No newline at end of file
+https://github.com/ARMmbed/mbed-os/#9738b27c7df897c29e9769911d6794ba3e5b3f19
\ No newline at end of file