A WiFiDipCortex based robot. Control is via sockets over WiFi. See also: https://github.com/mfurseman/robo-android

Dependencies:   Motordriver USBDevice cc3000_hostdriver_mbedsocket_hacked mbed

Revision:
0:993d6b65e255
Child:
1:b66a2d756c8a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sat Oct 18 02:28:52 2014 +0000
@@ -0,0 +1,73 @@
+#include "mbed.h"
+#include "cc3000.h"
+#include "USBSerial.h"
+
+/* Quickly change debug flag to remove blocking serial code */
+#define DEBUG
+#ifdef DEBUG
+USBSerial serial;
+#define debug(x, ...) serial.printf(x, ##__VA_ARGS__);
+#else
+#define debug(x, ...)
+#endif
+
+using namespace mbed_cc3000;
+
+/* On board LED */
+DigitalOut led(P0_1);
+
+/* Serial library for WiFi module */
+cc3000 wifi(p28, p27, p30, SPI(p21, p14, p37));
+
+/* Struct to hold connection data */
+tNetappIpconfigRetArgs ipinfo;
+
+
+void printConnectionInfo() {
+    if (( wifi.is_enabled() ) && ( wifi.is_dhcp_configured() )) {
+        wifi.get_ip_config(&ipinfo);
+    }    
+    debug("\r\n");
+    if (! wifi.is_enabled() ) {
+        debug("CC3000 Disabled\r\n"); 
+    }
+    else if ( wifi.is_dhcp_configured() ) {
+        debug("SSID : %-33s|\r\n", ipinfo.uaSSID);
+        debug("IP : %-35s|\r\n", wifi.getIPAddress());   
+    }
+    else if ( wifi.is_connected() ) {
+        debug("Connecting, waiting for DHCP\r\n"); 
+    }
+    else {
+        debug("Not Connected\r\n");   
+    }
+}
+
+int main(void) {
+    NVIC_SetPriority(SSP1_IRQn, 0x0); 
+    NVIC_SetPriority(PIN_INT0_IRQn, 0x1);
+    
+    // SysTick set to lower priority than Wi-Fi SPI bus interrupt
+    NVIC_SetPriority(SysTick_IRQn, 0x2); 
+    
+    // Enable RAM1
+    LPC_SYSCON->SYSAHBCLKCTRL |= (0x1 << 26);
+        
+    wait(1);
+    printConnectionInfo();
+
+    wifi.start(0);
+    printConnectionInfo();
+    
+    wait_ms(750);
+
+    wifi._wlan.ioctl_set_connection_policy(0, 0, 1);
+    printConnectionInfo();
+
+    while(1) {
+        printConnectionInfo();
+        debug("test message\r\n");
+        led = !led;
+        wait(1);
+   }
+}