161007_BDK_EEPROM(M)

Dependencies:   mbed

Fork of 161006_BDK_SPIslave3 by CUBEBITE

Files at this revision

API Documentation at this revision

Comitter:
bcup
Date:
Fri Oct 07 08:15:21 2016 +0000
Branch:
KSS
Parent:
6:21b3128fbaef
Commit message:
161007_BDK_EEPROM(M)

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Oct 06 08:27:32 2016 +0000
+++ b/main.cpp	Fri Oct 07 08:15:21 2016 +0000
@@ -18,6 +18,7 @@
 #define EEPROM_WRSR     0x01        // Write Status Register
 #define EEPROM_READ     0x03        // Read EEPROM Memory
 #define EEPROM_WRITE    0x02        // Write EEPROM Memory
+#define EEPROM_MULTIREAD    0x07        // Read Multibyte EEPROM Memory
 
 SPISlave spi_slave(SPI_MOSI, SPI_MISO, SPI_SCLK, SPI_SSEL); // MOSI, MISO, SCLK(CLK), SSEL(CS)=NC
 Serial pc_serial(USBTX, USBRX);
@@ -27,7 +28,8 @@
     PRINTD("Set the SPI SLAVE format\n");
     spi_slave.format(8,0); // setup 8bit 0 mode
     PRINTD("Set the SPI SLAVE frequency\n");
-    spi_slave.frequency(1000000); // default 1MHz
+    //spi_slave.frequency(50000000); // default 1MHz
+    spi_slave.frequency(1000000);
 }
 
 void SPI_SlaveWrite()
@@ -118,10 +120,10 @@
 int main()
 {
 
-    
-     char eepAddr = 0;     
-     char eepData = 0;
-    
+    char spiMulti = 0;    
+    char eepAddr = 0;     
+    char eepData = 0;
+
     char serialTxReadyFlag = 0;
     int spiRxTempBuf = 0;
     char spiRxBuf[255];
@@ -137,11 +139,11 @@
     
     SPI_SlaveInit();
     
-    // test code start
+    /*
     NVIC_SetVector( SPI_IRQn , ( uint32_t ) executa_spi_slave_hw ) ;
     NVIC_SetPriority( SPI_IRQn , 2 ) ;
     NVIC_EnableIRQ( SPI_IRQn ) ;
-    // test code end
+    */
 
     
     pc_serial.printf("\n\n========== KSS SPI Slave2 [Start] ==========\n");
@@ -218,6 +220,25 @@
                 break;
                 
                 
+                case  EEPROM_MULTIREAD:
+                    // EEPROM_MULTIREAD..
+                    while(!spi_slave.receive());
+                    eepAddr = spi_slave.read();
+                    printf("[DEBUG] [M to S] eepAddr=0x%02x\n",eepAddr++);
+                    //printf("[DEBUG] [M to S] eepAddr=0x%02x\n",eepAddr);
+                    for(int i=0;i<7;i++)
+                    {
+                        //spi_slave.reply( eepBuf[eepAddr] );
+                        spi_slave.reply( i );
+                        //++eepAddr;
+                        //printf("[0x%02x] ",spiMulti);
+                        pc_serial.printf("."); 
+                        
+                    }
+                    pc_serial.printf("\n"); 
+                break;
+                
+                
                 default:
                 //spi_dummy_reply();
             }