Gainspan module evaluation with WIZwiki-W7500 using SerialPassthrough.

Dependencies:   mbed

Fork of SerialPassthrough_GainspanModule_W7500 by Steve Kim

This is a serial-passthrough example using WIZwiki-W7500 and gainspan-WiFi-module.

With this example, I can issue at-command-sets to the WiFi module with WIZwiki-W7500's serial. UART data flow is shown as below.

[PC Serial Terminal] <=> [WIZwiki-W7500's UIART1/DAP] <=> [WIZwiki-W7500's UIART0] <=> [Gainspan WiFi module]

Connected pins between WIZwiki-W7500 and WiFi-module are only 4 pins. (3.3V, GND, UART-Tx, UART-Rx) And, here is a picture. /media/uploads/SteveKim/gainspan-w7500.jpg

And here is a captures of test logs. Red box is what I issued.

/media/uploads/SteveKim/gainspan-w7500-2.jpg

[PS] ASYNC_DEBUG is for internal-debugging like ISR. You can ignore it.

Revision:
0:98000a7ccec5
Child:
1:95a26b8d2887
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Aug 21 05:53:34 2015 +0000
@@ -0,0 +1,87 @@
+#include "mbed.h"
+#include "CBuffer.h"
+
+DigitalOut led1(LED1);
+DigitalOut led4(LED4);
+
+RawSerial pc(USBTX, USBRX); // tx, rx
+RawSerial dev(D1, D0); // tx, rx for WIZwiki-W75000
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+// mbed Async Debug
+Timeout timer_buffer_debug;
+CircBuffer<char> async_debugbufer(1024);
+
+void print_debugbuffer()
+{
+    char c=0;
+    while ( async_debugbufer.available() ) {
+        async_debugbufer.dequeue(&c);
+        pc.putc(c);
+    }
+    timer_buffer_debug.attach(&print_debugbuffer, 0.1);
+}
+
+#include <stdarg.h>
+static char debug_line[64];
+void mbed_async_debug(const char *format, ...)
+{
+    va_list args;
+    
+    va_start(args, format);
+    
+    vsnprintf(debug_line, sizeof(debug_line), format, args);
+    int length = strlen(debug_line);
+    
+    for (int i=0; i<length; i++)
+        async_debugbufer.queue(debug_line[i]);
+    
+    va_end(args);
+}
+
+// mbed Async Debug Print, You can move below line to mbed-src.
+void (*dbg_f)(const char *format, ...);
+extern void (*dbg_f)(const char *format, ...);
+
+////////////////////////////////////////////////////////////////////////////////////////////////
+
+void dev_recv()
+{
+    led1 = !led1;
+    while(dev.readable()) {
+        pc.putc(dev.getc());
+    }
+}
+
+void pc_recv()
+{
+    led4 = !led4;
+    while(pc.readable()) {
+        dev.putc(pc.getc());
+    }
+}
+
+int main()
+{
+    for (int i=0; i<10; i++)
+    {        
+        led1 = !led1;
+        led4 = !led4;
+        wait(0.1);
+    }
+    
+    pc.baud(115200);
+    dev.baud(9600);
+    
+    pc.printf("Serial Passthrough Started. \r\n");
+    
+    dbg_f = &mbed_async_debug;
+    timer_buffer_debug.attach(&print_debugbuffer, 0.1);
+    
+    pc.attach(&pc_recv, Serial::RxIrq);
+    dev.attach(&dev_recv, Serial::RxIrq);
+    
+    while(1) {
+        wait(1);
+    }
+}