Send IR data from SD card. I changed Chip Select signal timing.

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
halfpitch
Date:
Thu Sep 01 09:45:40 2011 +0000
Parent:
0:da2f4475a464
Commit message:
Rev.B

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
wwChipSelect.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Wed Jul 13 14:25:47 2011 +0000
+++ b/main.cpp	Thu Sep 01 09:45:40 2011 +0000
@@ -9,7 +9,7 @@
 #include "SDFileSystem.h"
 
 #define SDch        0x05
-#define MAXdatanum  500
+#define MAXdatanum  1000
 #define TimeLimit   3000
 #define pul38khz       26
 #define pul38k_ON      13
@@ -52,7 +52,8 @@
     printf("again\n");
     int pHL = 0;    
     int t = 0; 
-    FILE *fp1 = fopen("/sd/IRdata.csv", "r");
+    FILE *fp1 = fopen("/sd/IRDATA.csv", "r");
+    //FILE *fp1 = fopen("/sd/off.csv", "r");
     
     datanum = 0;
     
@@ -62,8 +63,10 @@
     
     Pulse_pin.period_us(pul38khz);
     
+    j=0;
     for(j=0;j<datanum;++j){
-         fscanf(fp1, "%d,%d,\n", &pHL, &t);
+         fscanf(fp1, "%d,%d,\n",&pHL, &t);
+         //printf("%d : %d,%d,\n",j,pHL, t);
          IRdata[j] = pHL;
          pulsetime[j] = t;
     }
--- a/wwChipSelect.cpp	Wed Jul 13 14:25:47 2011 +0000
+++ b/wwChipSelect.cpp	Thu Sep 01 09:45:40 2011 +0000
@@ -5,15 +5,25 @@
 //2010/10/03
 
 #include "wwChipSelect.h"
+//#define NORMAL    //if you want to use normal chipselect, you should enable this code.
 
 wwChipSelect :: wwChipSelect(PinName cs):
  ChipSelect(cs){
  }
  
-void wwChipSelect :: wwCSwrite(int ch){   
+void wwChipSelect :: wwCSwrite(int ch){
+
+#ifdef NORMAL
+    if(ch == 0){//reset code
+        ChipSelect.write(1);
+    }else{
+        ChipSelect.write(0);
+    }
+    
+#else
     //start
     ChipSelect.write(1);   
-    wait_us(20); 
+    wait_us(30); 
     
     ChipSelect.write(0);
         
@@ -36,6 +46,8 @@
     wait_us(20);//106
     
     ChipSelect.write(1);
-
+    
+    wait_us(30);
+#endif
 }