GSwifiInterface library (interface for GainSpan Wi-Fi GS1011 modules) Please see https://mbed.org/users/gsfan/notebook/GSwifiInterface/

Dependents:   GSwifiInterface_HelloWorld GSwifiInterface_HelloServo GSwifiInterface_UDPEchoServer GSwifiInterface_UDPEchoClient ... more

Fork of WiflyInterface by mbed official

GainSpan Wi-Fi library

The GS1011/GS2100 is an ultra low power 802.11b wireless module from GainSpan.

mbed RTOS supported.

/media/uploads/gsfan/gs_im_002.jpg /media/uploads/gsfan/gs1011m_2.jpg

ゲインスパン Wi-Fi モジュール ライブラリ

ゲインスパン社の低電力 Wi-Fiモジュール(無線LAN) GS1011/GS2100 シリーズ用のライブラリです。

mbed RTOS に対応しています。(mbed2.0)

Revision:
22:d25a5a0d2497
Parent:
19:d035412a7803
--- a/GSwifi/GSwifi_hal.cpp	Thu Jun 05 06:12:59 2014 +0000
+++ b/GSwifi/GSwifi_hal.cpp	Tue Sep 24 06:24:37 2019 +0000
@@ -223,3 +223,75 @@
         _alarm = NULL;
     }
 }
+
+#ifdef CFG_SPI_DATAINTERFACE
+void GSwifi::putSpi (char c) {
+    _spi.write(c);
+}
+
+void GSwifi::isrSpi () {
+    char c;
+
+    while (_wake == 1) {
+        c = _spi.write(0xf5);
+        recvData(c);
+    }
+}
+
+int GSwifi::lockSpi (int ms) {
+    Timer t;
+
+    if (_state.mode != MODE_COMMAND) {
+        t.start();
+        while (_state.mode != MODE_COMMAND) {
+            if (t.read_ms() >= ms) {
+                WARN("lock timeout (%d)\r\n", _state.mode);
+                return -1;
+            }
+        }
+    }
+
+#ifdef CFG_ENABLE_RTOS
+    if (_mutexSpi.lock(ms) != osOK) return -1;
+#endif
+
+    if (_wake.read()) {
+        t.start();
+        while (_wake.read()) {
+            if (t.read_ms() >= ms) {
+                DBG("hostwake timeout\r\n");
+                return -1;
+            }
+        }
+    }
+    return 0;
+}
+
+void GSwifi::unlockSpi () {
+#ifdef CFG_ENABLE_RTOS
+    _mutexSpi.unlock();
+#endif
+}
+
+void GSwifi::initSpi (PinName cs, int freq) {
+    _spi.format(8, 0);
+    _spi.frequency(freq);
+    _wake.mode(PullDown);
+    _wake.rise(this, &GSwifi::isrSpi);
+
+#if defined(TARGET_LPC1768) || defined(TARGET_LPC2368) || defined(TARGET_LPC176X)
+    if (cs == p8) { // SPI_1 (P0_6)
+        LPC_PINCON->PINSEL0 &= ~(3 << 12);
+        LPC_PINCON->PINSEL0 |= (2 << 12); // SSEL1
+    } else
+    if (cs == p14) { // (SPI_0) P0_16
+        LPC_PINCON->PINSEL1 &= ~(3 << 0);
+        LPC_PINCON->PINSEL1 |= (2 << 0); // SSEL0
+    } else
+    if (cs == P1_21) { // (SPI_0) P1_21
+        LPC_PINCON->PINSEL3 &= ~(3 << 10);
+        LPC_PINCON->PINSEL3 |= (3 << 10); // SSEL0
+    }
+#endif
+}
+#endif