Test function for CThunk class

Dependencies:   CThunk mbed

Revision:
4:97c886c2d89b
Parent:
3:c929fd5a4d3d
Child:
5:64411d876ad4
--- a/main.cpp	Fri Aug 15 16:05:12 2014 +0000
+++ b/main.cpp	Wed Aug 20 07:50:37 2014 +0000
@@ -1,5 +1,4 @@
 #include <mbed.h>
-#include <CThunk.h>
 
 DigitalOut g_led1(LED1);
 DigitalOut g_led2(LED2);
@@ -7,6 +6,8 @@
 DigitalOut g_led4(LED4);
 Serial pc(USBTX, USBRX);
 
+#include <CThunk.h>
+
 class CTest
 {
 public:
@@ -57,7 +58,7 @@
 {
     int i;
 
-    pc.printf("Dump %u bytes from 0x%08Xn", length, data);
+    pc.printf("Dump %u bytes from 0x%08X\n", length, data);
 
     for(i=0; i<length; i++)
     {
@@ -81,8 +82,7 @@
     /* TEST1: */
 
     /* assign callback1 to thunk - no context needed */
-    test.thunk = (void*)0xDEADBEEF;
-    test.thunk = &CTest::callback1;
+    //test.thunk.callback(&CTest::callback1);
     hexdump((const void*)entry, 16);
     /* call entry point */
 
@@ -94,9 +94,10 @@
     /* TEST2: */
 
     /* assign a context ... */
-    test.thunk = 0xDEADBEEF;
+    test.thunk.context(0xDEADBEEF);
     /* and switch callback to callback2 */
-    test.thunk = &CTest::callback2;
+    test.thunk.callback(&CTest::callback2);
+
     /* call entry point */
     pc.printf("before entry 2\n");
     g_led3 = 1;
@@ -106,14 +107,16 @@
 
 int main(void)
 {
-    g_led1 = 1;
+    pc.baud(115200);    
 
+    printf("Test 1\n");
     /* run tests */
+    g_led1 = 1;
     test();
 
     /* turn both LED's on */
     g_led4 = 1;
     while(1)
         __WFI();
-    return 0;
+//    return 0;
 }