Tsungta Wu / Mbed OS mbed_SPIS_multiByte_example_SOG

Dependencies:   NNN50_WIFI_API

Fork of mbed_SPIS_multiByte_example_SOG by Sog Yang

Files at this revision

API Documentation at this revision

Comitter:
tsungta
Date:
Wed May 31 07:39:37 2017 +0000
Parent:
0:b7415ae44dac
Child:
2:c520d7c7739d
Commit message:
Able to receive multiple bytes in single CS cycle;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
spi_api_multibyte.c Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed May 24 10:17:56 2017 +0000
+++ b/main.cpp	Wed May 31 07:39:37 2017 +0000
@@ -6,22 +6,13 @@
 
 int main() {
     uart.printf("START!");
-    device.format(8,1);
-    
-   device.reply(0xAA);              // Prime SPI with first reply
+    device.format(8,1);    
+
    while(1) {
        if(device.receive()) {
            int v = device.read();   // Read byte from master
-           v = (v + 1) % 0x100;     // Add one to it, modulo 256
-           device.reply(v);         // Make this the next reply
-
-           v = device.read();   // Read byte from master
-           v = (v + 1) % 0x100;     // Add one to it, modulo 256
-           device.reply(v);         // Make this the next reply
-           
-           v = device.read();   // Read byte from master
-           v = (v + 1) % 0x100;     // Add one to it, modulo 256
-           device.reply(v);         // Make this the next reply                      
+           uart.printf("v = %s ", v);
+                        
        }
    }
 }
\ No newline at end of file
--- a/spi_api_multibyte.c	Wed May 24 10:17:56 2017 +0000
+++ b/spi_api_multibyte.c	Wed May 31 07:39:37 2017 +0000
@@ -80,7 +80,8 @@
 #endif
 } spi_info_t;
 
-    #define TEST_STRING "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"  //Tsungta, handle 32 bytes per SPI CS cycle
+//    #define TEST_STRING "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"  //Tsungta, handle 32 bytes per SPI CS cycle
+    #define TEST_STRING "012"  //Tsungta, handle 32 bytes per SPI CS cycle    
     uint8_t       m_tx_buf[] = TEST_STRING;           /**< TX buffer. */
     uint8_t       m_rx_buf[sizeof(TEST_STRING)+1];    /**< RX buffer. */
     const uint8_t m_length = sizeof(m_tx_buf);        /**< Transfer length. */
@@ -187,7 +188,8 @@
 
     if (event.evt_type == NRF_DRV_SPIS_XFER_DONE) {
         // Signal that there is some data received that could be read.
-        p_spi_info->flag.readable = true;
+        if(event.rx_amount == 3)//Tsungta
+            p_spi_info->flag.readable = true;
 
         // And prepare for the next transfer.
         // Previous data set in 'spi_slave_write' (if any) has been transmitted,