CDMS_CODE_samp_23SEP_DMA_flag

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA by iitm sat

Revision:
167:9e1775d19ac3
Parent:
165:60a4a23131a3
diff -r 60a4a23131a3 -r 9e1775d19ac3 adf.h
--- a/adf.h	Tue Apr 19 17:03:29 2016 +0000
+++ b/adf.h	Tue Apr 19 18:16:56 2016 +0000
@@ -232,7 +232,8 @@
     gCS_ADF=1;\
     SPI_mutex.unlock();\
 }
- 
+bool data_err=false;
+int data_err_count=0;
 #define write_data {\
     SPI_mutex.lock();\
     gCS_ADF=0;\
@@ -240,6 +241,8 @@
     spi.write(0x36);\
     spi.write(0xFF);\
     gCS_ADF=1;\
+    data_err_count=0;\
+    while(data_err && data_err_count<20){\
     gCS_ADF=0;\
     if(buffer_state){\
         spi.write(0x18);\
@@ -264,6 +267,37 @@
         }\
     }\
     gCS_ADF=1;\
+    wait_us(1);\
+    data_err=false;\
+    gCS_ADF=0;\
+    if(buffer_state){\
+        spi.write(0x38);\
+        spi.write(0x20);\
+        spi.write(0xFF);\
+        for(unsigned char i=0; i<112;i++){\
+                if(buffer_112[i]!=spi.write(0xFF)){\
+                    data_err=true;\
+                    }\
+            /*gPC.printf("0x%X,",spi.write(buffer_112[i]));*/\
+        }\
+    }\
+    else{\
+        spi.write(0x38);\
+        spi.write(0x90);\
+        spi.write(0xFF);\
+        for(unsigned char i=0; i<112;i++){\
+                   if(buffer_112[i]!=spi.write(0xFF)){\
+                    data_err=true;\
+                    }\
+            /*gPC.printf("0x%X,",spi.write(buffer_112[i]));*/\
+        }\
+    }\
+    gCS_ADF=1;\
+    data_err_count++;\
+    }\
+    if(data_err_count==20){\
+       gPC.printf("e%d\n",data_err_count);\
+        }\
     SPI_mutex.unlock();\
     buffer_state = !buffer_state;\
     if(last_buffer){\