publishing to check changes in cdms code

Dependencies:   FreescaleIAP SimpleDMA mbed-rtos mbed

Fork of CDMS_CODE_samp_23SEP_DMA_flag by samp Srinivasan

Revision:
306:7c3872365d58
Parent:
304:7cc4fe191a54
Child:
310:30f20cc5c94b
diff -r beb148fe97dc -r 7c3872365d58 cdms_sd.h
--- a/cdms_sd.h	Sat Sep 10 07:06:59 2016 +0000
+++ b/cdms_sd.h	Sun Oct 09 07:08:34 2016 +0000
@@ -127,8 +127,15 @@
     uint32_t start_fsc;
     int i;
     uint8_t buffer[512];
+    
+    disk_read(buffer,SD_MNG_SECT);
     SD_MNG_SECT += SD_LIB_WRITES/(int)0xFFFF;
     SD_LIB_WRITES = SD_LIB_WRITES%(int)0xFFFF;
+    disk_write(buffer,SD_MNG_SECT);
+ //   gPC.printf("in increment_SD_LIB = %d, %d,%d\n\r", FSC_CURRENT[1],FSC_CURRENT[2],FSC_CURRENT[3]);
+  //  SD_MNG_SECT += SD_LIB_WRITES/(int)0xFFFF;
+  //  SD_LIB_WRITES = SD_LIB_WRITES%(int)0xFFFF;
+ 
     disk_read(buffer,SD_MNG_SECT);
     if(sid==0x01)
     {
@@ -262,13 +269,13 @@
 
 int SD_WRITE(uint8_t* buffer,uint32_t fsc,uint8_t sid)
 {
-    /*uint32_t block_number;
+    uint32_t block_number;
     int result = 10;
     if(SD_STATUS == DEVICE_POWERED){
     if(sid==0x01)
     {
-        //block_number=SD_SCP_FIRST+(fsc%(SD_SCP_LAST-SD_SCP_FIRST+1))-1;
-        block_number=SD_SCP_FIRST+fsc;
+        block_number=SD_SCP_FIRST+(fsc%(SD_SCP_LAST-SD_SCP_FIRST+1))-1;
+        //block_number=SD_SCP_FIRST+fsc;
         result= disk_write(buffer,block_number);
         if(result == 0)
         {
@@ -279,8 +286,8 @@
     }
    if(sid==0x02)
     {
-        //block_number= SD_SFF_AT_FIRST+(fsc%(SD_SFF_AT_LAST - SD_SFF_AT_FIRST+1))-1;
-        block_number= SD_SFF_AT_FIRST+fsc;
+        block_number= SD_SFF_AT_FIRST+(fsc%(SD_SFF_AT_LAST - SD_SFF_AT_FIRST+1))-1;
+        //block_number= SD_SFF_AT_FIRST+fsc;
         result= disk_write(buffer,block_number);
         if(result == 0)
          {
@@ -291,8 +298,8 @@
     }
      if(sid==0x03)
     {
-        //block_number= SD_SFF_BT_FIRST +(fsc%(SD_SFF_BT_LAST - SD_SFF_BT_FIRST +1))-1;
-        block_number= SD_SFF_BT_FIRST +fsc;
+        block_number= SD_SFF_BT_FIRST +(fsc%(SD_SFF_BT_LAST - SD_SFF_BT_FIRST +1))-1;
+        //block_number= SD_SFF_BT_FIRST +fsc;
         result= disk_write(buffer,block_number);
         if(result == 0)
         {
@@ -303,8 +310,8 @@
     }
      if(sid==0x04)
     {
-        //block_number=SD_HK_ARCH_FIRST +(fsc%(SD_HK_ARCH_LAST - SD_HK_ARCH_FIRST +1))-1;
-        block_number=SD_HK_ARCH_FIRST +fsc;
+        block_number=SD_HK_ARCH_FIRST +(fsc%(SD_HK_ARCH_LAST - SD_HK_ARCH_FIRST +1))-1;
+        //block_number=SD_HK_ARCH_FIRST +fsc;
         result= disk_write(buffer,block_number);
         if(result == 0)
         {
@@ -315,8 +322,8 @@
     }
      if(sid==0x05)
     {
-        //block_number= LOG_FIRST +(fsc%(LOG_FIRST - LOG_FIRST +1))-1;
-        block_number= LOG_FIRST +fsc;
+        block_number= LOG_FIRST +(fsc%(LOG_FIRST - LOG_FIRST +1))-1;
+        //block_number= LOG_FIRST +fsc;
         result= disk_write(buffer,block_number);
         if(result == 0)
         {
@@ -325,13 +332,13 @@
         }
         return result;
     }
-    }*/
-    return 1;
+    }
+   // return 1;
 }
 
 uint8_t SD_READ(uint8_t* buffer,uint32_t fsc,uint8_t sid)
 {
-    /*FCTN_SD_MNGR();
+    FCTN_SD_MNGR();
     uint32_t block_number;
     int result;
     //if(SD_SW_EN_DS == 1)
@@ -341,7 +348,7 @@
         if(!(FSC_LAST[1]<=fsc && fsc<=FSC_CURRENT[1])){
             return 0x86;
         }
-        block_number=SD_SCP_FIRST + fsc;
+        block_number=SD_SCP_FIRST+(fsc%(SD_SCP_LAST-SD_SCP_FIRST+1))-1;
         result= disk_read(buffer,block_number);
     }
    else if(sid==0x02)
@@ -349,7 +356,7 @@
         if(!(FSC_LAST[2]<=fsc && fsc<=FSC_CURRENT[2])){
             return 0x86;
         }
-        block_number=SD_SFF_AT_FIRST + fsc;
+        block_number= SD_SFF_AT_FIRST+(fsc%(SD_SFF_AT_LAST - SD_SFF_AT_FIRST+1))-1;
         result= disk_read(buffer,block_number);
     }
     else if(sid==0x03)
@@ -357,7 +364,7 @@
         if(!(FSC_LAST[3]<=fsc && fsc<=FSC_CURRENT[3])){
             return 0x86;
         }
-        block_number=SD_SFF_BT_FIRST + fsc;
+        block_number= SD_SFF_BT_FIRST +(fsc%(SD_SFF_BT_LAST - SD_SFF_BT_FIRST +1))-1;
         result= disk_read(buffer,block_number);
     }
     else if(sid==0x04)
@@ -365,7 +372,7 @@
         if(!(FSC_LAST[4]<=fsc && fsc<=FSC_CURRENT[4])){
             return 0x86;
         }
-        block_number=SD_HK_ARCH_FIRST + fsc;
+        block_number=SD_HK_ARCH_FIRST +(fsc%(SD_HK_ARCH_LAST - SD_HK_ARCH_FIRST +1))-1;
         result= disk_read(buffer,block_number);
     }
     else if(sid==0x05)
@@ -373,7 +380,7 @@
         if(!(FSC_LAST[5]<=fsc && fsc<=FSC_CURRENT[5])){
             return 0x86;
         }
-        block_number=LOG_FIRST +fsc;
+        block_number= LOG_FIRST +(fsc%(LOG_FIRST - LOG_FIRST +1))-1;
         result= disk_read(buffer,block_number);
     }
     else
@@ -383,7 +390,7 @@
     if(result == 0)
         return 0xA0;
     else
-        return 0x88;*/
+        return 0x88;
     return 0xA0;
 }