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:
2:0b47f6b25cc4
Parent:
1:81b2fd407327
Child:
3:db269462ad1c
--- a/IM920.h	Fri Dec 26 15:51:37 2014 +0000
+++ b/IM920.h	Mon Jan 05 03:47:08 2015 +0000
@@ -21,6 +21,7 @@
 #include "IM920_conf.h"
 
 #include "mbed.h"
+#include "FunctionPointer.h"
 #include "CBuffer.h"
 #include <ctype.h>
 #include <stdlib.h>
@@ -60,7 +61,17 @@
 
     IM920 (PinName tx, PinName rx, PinName busy = NC, PinName reset = NC, int baud = IM920_BAUD);
 
-    int init (int node, void(*func)() = NULL);
+    int init (int node);
+
+    void attach (void(*fptr)() = NULL) {
+        _func.attach(fptr);
+    }
+    template<typename T>
+    void attach (T* tptr, void (T::*mptr)()) {
+        if ((mptr != NULL) && (tptr != NULL)) {
+            _func.attach(tptr, mptr);
+        }
+    }
 
     void poll ();
 
@@ -81,6 +92,7 @@
     DigitalIn *_busy;
     DigitalOut *_reset;
     int _baud;
+    FunctionPointer _func;
 
     struct STATE {
         int id, node, rssi;
@@ -96,7 +108,6 @@
 
         CircBuffer<char> *data;
         volatile bool received;
-        void(*func)();
     } _state;
 
     // ----- IM920_util.cpp -----