Test for LinkSprite Y201 JPEG camera

Dependencies:   mbed MODSERIAL Y201 mbed-rtos

Files at this revision

API Documentation at this revision

Comitter:
donatien
Date:
Wed Jul 18 14:38:58 2012 +0000
Parent:
4:156e6339e263
Commit message:
Prevent main thread from eating up all CPU time...

Changed in this revision

main.cpp 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
rtos.lib Show diff for this revision Revisions of this file
diff -r 156e6339e263 -r 98d57f3ef81f main.cpp
--- a/main.cpp	Wed Jul 18 11:07:35 2012 +0000
+++ b/main.cpp	Wed Jul 18 14:38:58 2012 +0000
@@ -26,8 +26,8 @@
 
 
 void test(void const*) {
-  //LocalFileSystem fs("fs");
-  //FILE *fp = fopen("/fs/picture.jpg","w");
+  LocalFileSystem fs("fs");
+  FILE *fp = fopen("/fs/picture.jpg","w");
   pc.baud(115200);
   pc.printf("RESET V^V^V^V^V^V^V^V^V^V^V RESET\r\n");
   
@@ -63,6 +63,7 @@
     printf("Error getting file size\r\n");
   }
   
+  NVIC_SetPriority(UART2_IRQn, 0);
 
   // IMAGE UPLOAD
    
@@ -77,13 +78,23 @@
         
     } else {
         printf("Error in file read\r\n");
+        //Dump packet
+        for(int i = 0; i < chunkSize; i++)
+        {
+          if(!(i % 16))
+          {
+            printf("\n");
+          }
+          printf("%02x ", readBuffer[i]);
+        }
     }
     bytesRead += chunkSize;
-    printf("%d..\n",bytesRead,w);
+    //Thread::wait(1000);
+    printf("%d..\n",bytesRead);
     if(bytesRead<fileSize) {
-       // size_t w = fwrite(readBuffer,chunkSize,1,fp);
+        size_t w = fwrite(readBuffer,chunkSize,1,fp);
     } else {
-        // size_t w = fwrite(readBuffer,(chunkSize-(bytesRead-fileSize)),1,fp);
+        size_t w = fwrite(readBuffer,(chunkSize-(bytesRead-fileSize)),1,fp);
     }
     
     camera.trash();
@@ -91,7 +102,7 @@
   }
   
   printf("\r\n");
-  //fclose(fp);
+  fclose(fp);
   printf("loop exit\r\n");
   printf("filesize: %d\r\n",fileSize);  
 }
@@ -101,12 +112,12 @@
 }
 
 int main() {
-  Ticker t;
-  t.attach(tick, 1);
+ // Ticker t;
+ // t.attach(tick, 1);
 
   Thread testTask(test, NULL, osPriorityNormal, 1024 * 4);
   //Thread testTask(test);
-  while(1);
+  while(1){ Thread::wait(1000); }
 
   return 0;
 }
diff -r 156e6339e263 -r 98d57f3ef81f mbed-rtos.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Wed Jul 18 14:38:58 2012 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-rtos/#01158bb7600c
diff -r 156e6339e263 -r 98d57f3ef81f rtos.lib
--- a/rtos.lib	Wed Jul 18 11:07:35 2012 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/donatien/code/rtos/#bee70210126a