Interplan IM920 library, 920MHz module

Dependents:   IM920_sample IM920_SDlog IM920_sample IM920_sample3 ... more

IM920 ライブラリ

データモード、低速、長距離 の設定で通信するライブラリです。

920MHz無線モジュール

http://www.interplan.co.jp/images/contents/solution/im920.png IM920 (インタープラン製)

  • mbedとモジュールとは、シリアル(TX,RX)、BUSY、RESET端子を接続します。
  • モジュールはあらかじめ、コマンドでノード番号などを設定しておきます。

NECの920MHz近距離無線モジュールもおすすめ

Revision:
0:d3ab05ed8142
Child:
3:db269462ad1c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/IM920_hal.cpp	Fri Dec 26 15:35:20 2014 +0000
@@ -0,0 +1,57 @@
+#include "IM920.h"
+
+void IM920::setReset (bool flg) {
+    if (_reset) {
+        if (flg) {
+            _reset->write(0);
+        } else {
+            _reset->write(1);
+        }
+    }
+}
+
+void IM920::isrUart () {
+    recvData(getUart());
+}
+
+int IM920::getUart () {
+    return _im.getc();
+}
+
+void IM920::putUart (char c) {
+    _im.putc(c);
+}
+
+int IM920::lockUart (int ms) {
+    Timer t;
+
+    if (_busy && _busy->read()) {
+        // CTS check
+        t.start();
+        while (_busy->read()) {
+            if (t.read_ms() >= ms) {
+                DBG("cts timeout\r\n");
+                return -1;
+            }
+        }
+    }
+    return 0;
+}
+
+void IM920::unlockUart () {
+}
+
+void IM920::initUart (PinName busy, PinName reset, int baud) {
+    _baud = baud;
+    if (_baud) _im.baud(_baud);
+    _im.attach(this, &IM920::isrUart, Serial::RxIrq);
+
+    _busy = NULL;
+    _reset = NULL;
+    if (busy != NC) {
+        _busy = new DigitalIn(busy);
+    }
+    if (reset != NC) {
+        _reset = new DigitalOut(reset);
+    }
+}