sd 32 update

Dependencies:   FreescaleIAP mbed-rtos mbed

Fork of COM_MNG_TMTC_SIMPLE by Shreesha S

Files at this revision

API Documentation at this revision

Comitter:
pradeepvk2208
Date:
Tue Jan 19 12:29:15 2016 +0000
Parent:
71:9193fbdaa3e1
Commit message:
sd update 32

Changed in this revision

cdms_sd.h Show annotated file Show diff for this revision Revisions of this file
mbed-rtos.lib Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 9193fbdaa3e1 -r 7460872eef79 cdms_sd.h
--- a/cdms_sd.h	Tue Jan 19 10:30:46 2016 +0000
+++ b/cdms_sd.h	Tue Jan 19 12:29:15 2016 +0000
@@ -38,7 +38,7 @@
 //void FCTN_CDMS_INIT_SD();
 //int FCTN_CDMS_WR_SD(const uint8_t *, uint64_t);
 //int FCTN_CDMS_RD_SD(uint8_t *, uint64_t);
-uint8_t FCTN_SD_MNGR(uint8_t);
+uint32_t FCTN_SD_MNGR(uint8_t);
 
 
 int cmd(int, int);
@@ -48,9 +48,9 @@
 int read(uint8_t*, uint32_t );
 int write(const uint8_t*, uint32_t );
 static uint32_t ext_bits(unsigned char *, int , int );
-int SD_WRITE(uint8_t*,uint8_t,uint8_t);
+int SD_WRITE(uint8_t*,uint32_t,uint8_t);
 void FCTN_CDMS_SD_INIT();
-int SD_READ(uint8_t*,uint8_t,uint8_t);
+int SD_READ(uint8_t*,uint32_t,uint8_t);
 #define SDCARD_FAIL 0
 #define SDCARD_V1   1
 #define SDCARD_V2   2
@@ -81,54 +81,68 @@
 
     
 
-uint8_t  FCTN_SD_MNGR(uint8_t sid)
+uint32_t  FCTN_SD_MNGR(uint8_t sid)
 
 {
-    
+   
     uint32_t SD_MNG_SECT=7000;
-    uint32_t block_number;
-    uint8_t fsc;
-    uint8_t *buffer;
-    uint32_t i=0;
-    disk_read(buffer, SD_MNG_SECT);
-   
+    
+    uint32_t fsc;
+    uint8_t buffer[512];
+    int b=disk_read(buffer, SD_MNG_SECT);
     if(sid==0x0)
     {
-        fsc=buffer[0];
-        buffer[0]++;
+        
+        fsc=(uint32_t)(buffer[0]<<24)+(uint32_t)(buffer[1]<<16)+(uint32_t)(buffer[2]<<8)+(uint32_t)buffer[3];
+        uint32_t next_fsc=fsc+1;
+        buffer[0]=(uint8_t) (next_fsc>>24 & 0xFF);
+        buffer[1]=(uint8_t) (next_fsc>>16 & 0xFF);
+        buffer[2]=(uint8_t) (next_fsc>>8 & 0xFF);
+        buffer[3]=(uint8_t) (next_fsc & 0xFF);
         buffer[511]+=2;
         disk_write(buffer,SD_MNG_SECT);
     }
     if(sid==0x1)
     {
-        fsc=buffer[1];
-        buffer[1]++;
+        fsc=(uint32_t)(buffer[4]<<24)+(uint32_t)(buffer[5]<<16)+(uint32_t)(buffer[6]<<8)+(uint32_t)buffer[7];
+        uint32_t next_fsc=fsc+1;
+        buffer[4]=(uint8_t) (next_fsc>>24 & 0xFF);
+        buffer[5]=(uint8_t) (next_fsc>>16 & 0xFF);
+        buffer[6]=(uint8_t) (next_fsc>>8 & 0xFF);
+        buffer[7]=(uint8_t) (next_fsc & 0xFF);
         buffer[511]+=2;
         disk_write(buffer,SD_MNG_SECT);
     }
     if(sid==0x2)
     {
-        fsc=buffer[2];
-        buffer[2]++;
+        fsc=(uint32_t)(buffer[8]<<24)+(uint32_t)(buffer[9]<<16)+(uint32_t)(buffer[10]<<8)+(uint32_t)buffer[11];
+        uint32_t next_fsc=fsc+1;
+        buffer[8]=(uint8_t) (next_fsc>>24 & 0xFF);
+        buffer[9]=(uint8_t) (next_fsc>>16 & 0xFF);
+        buffer[10]=(uint8_t) (next_fsc>>8 & 0xFF);
+        buffer[11]=(uint8_t) (next_fsc & 0xFF);
         buffer[511]+=2;
         disk_write(buffer,SD_MNG_SECT);
     }
      if(sid==0x3)
     {
-        fsc=buffer[30];
-        printf("Hey buffer[300] pre-increment is %d\r\n",buffer[300]);
-        buffer[300]+=1;
-        printf("Hey buffer[300] post-increment is %d\r\n",buffer[300]);
+        fsc=(uint32_t)(buffer[12]<<24)+(uint32_t)(buffer[13]<<16)+(uint32_t)(buffer[14]<<8)+(uint32_t)buffer[15];
+        uint32_t next_fsc=fsc+1;
+        buffer[12]=(uint8_t) (next_fsc>>24 & 0xFF);
+        buffer[13]=(uint8_t) (next_fsc>>16 & 0xFF);
+        buffer[14]=(uint8_t) (next_fsc>>8 & 0xFF);
+        buffer[15]=(uint8_t) (next_fsc & 0xFF);
         buffer[511]+=2;
         disk_write(buffer,SD_MNG_SECT);
-        disk_read(buffer, SD_MNG_SECT);
-        printf("Hey buffer[300] post writing is %d\r\n",buffer[300]);
-         printf("Hey buffer[511] post writing is %d\r\n",buffer[511]);
     }
      if(sid==0x4)
     {
-        fsc=buffer[4];
-        buffer[4]++;
+        fsc=(uint32_t)(buffer[16]<<24)+(uint32_t)(buffer[17]<<16)+(uint32_t)(buffer[18]<<8)+(uint32_t)buffer[19];
+        uint32_t next_fsc=fsc+1;
+        buffer[16]=(uint8_t) (next_fsc>>24 & 0xFF);
+        buffer[17]=(uint8_t) (next_fsc>>16 & 0xFF);
+        buffer[18]=(uint8_t) (next_fsc>>8 & 0xFF);
+        buffer[19]=(uint8_t) (next_fsc & 0xFF);
         buffer[511]+=2;
         disk_write(buffer,SD_MNG_SECT);
     }
@@ -136,7 +150,7 @@
 }
 
 
-int SD_WRITE(uint8_t* buffer,uint8_t fsc,uint8_t sid)
+int SD_WRITE(uint8_t* buffer,uint32_t fsc,uint8_t sid)
 {
    
     uint32_t SD_SCP_FIRST=1001;
@@ -154,7 +168,7 @@
     int result;
     if(sid==0x0)
     {
-        block_number=SD_SCP_FIRST+uint32_t(fsc);
+        block_number=SD_SCP_FIRST+fsc;
 //        printf("write_block_number=%d\r\n",block_number);
         result= disk_write(buffer,block_number);
         return result;
@@ -187,7 +201,7 @@
     return 1;
 }
 
-int SD_READ(uint8_t* buffer,uint8_t fsc,uint8_t sid)
+int SD_READ(uint8_t* buffer,uint32_t fsc,uint8_t sid)
 {
    
     uint32_t SD_SCP_FIRST=1001;
@@ -205,7 +219,7 @@
     int result;
     if(sid==0x0)
     {
-        block_number=SD_SCP_FIRST + uint32_t(fsc);
+        block_number=SD_SCP_FIRST + fsc;
 //        sd1.printf("read_block_number=%d\r\n",block_number);
         result= disk_read(buffer,block_number);
     }
diff -r 9193fbdaa3e1 -r 7460872eef79 mbed-rtos.lib
--- a/mbed-rtos.lib	Tue Jan 19 10:30:46 2016 +0000
+++ b/mbed-rtos.lib	Tue Jan 19 12:29:15 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed-rtos/#c825593ece39
+http://mbed.org/users/mbed_official/code/mbed-rtos/#3d9d2b8b8f17
diff -r 9193fbdaa3e1 -r 7460872eef79 mbed.bld
--- a/mbed.bld	Tue Jan 19 10:30:46 2016 +0000
+++ b/mbed.bld	Tue Jan 19 12:29:15 2016 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/4336505e4b1c
\ No newline at end of file
+http://mbed.org/users/mbed_official/code/mbed/builds/6f327212ef96
\ No newline at end of file