Suga koubou / IM920

Dependents:   IM920_sample IM920_SDlog IM920_sample IM920_sample3 ... more

Files at this revision

API Documentation at this revision

Comitter:
okini3939
Date:
Thu Jan 08 13:25:46 2015 +0000
Parent:
2:0b47f6b25cc4
Child:
4:ba939555ed35
Commit message:
fix init
;

Changed in this revision

IM920.cpp Show annotated file Show diff for this revision Revisions of this file
IM920.h Show annotated file Show diff for this revision Revisions of this file
IM920_cmd.cpp Show annotated file Show diff for this revision Revisions of this file
IM920_hal.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/IM920.cpp	Mon Jan 05 03:47:08 2015 +0000
+++ b/IM920.cpp	Thu Jan 08 13:25:46 2015 +0000
@@ -28,17 +28,26 @@
     setReset(false);
 }
 
-int IM920::init (int node) {
-
-    _state.node = node;
+int IM920::init () {
 
     cmdRDID();
-    cmdSTNN(_state.node);
+    cmdRDNN();
     cmdSTPO(3);  // 10dBm
     cmdSTRT(2);  // 1.25kbps
     return 0;
 }
 
+
+int IM920::setNode (int node) {
+    _state.node = node;
+    return cmdSTNN(_state.node);
+}
+
+int IM920::getNode () {
+    cmdRDNN();
+    return _state.node;
+}
+
 void IM920::poll () {
 
     if (_state.received && _state.buf != NULL)
--- a/IM920.h	Mon Jan 05 03:47:08 2015 +0000
+++ b/IM920.h	Thu Jan 08 13:25:46 2015 +0000
@@ -59,9 +59,11 @@
         STAT_SLEEP,
     };
 
-    IM920 (PinName tx, PinName rx, PinName busy = NC, PinName reset = NC, int baud = IM920_BAUD);
+    IM920 (PinName tx, PinName rx, PinName busy, PinName reset, int baud = IM920_BAUD);
 
-    int init (int node);
+    int init ();
+    int setNode (int node);
+    int getNode ();
 
     void attach (void(*fptr)() = NULL) {
         _func.attach(fptr);
@@ -90,7 +92,7 @@
 private:
     RawSerial _im;
     DigitalIn *_busy;
-    DigitalOut *_reset;
+    DigitalInOut *_reset;
     int _baud;
     FunctionPointer _func;
 
@@ -152,3 +154,4 @@
  };
 
 #endif
+
--- a/IM920_cmd.cpp	Mon Jan 05 03:47:08 2015 +0000
+++ b/IM920_cmd.cpp	Thu Jan 08 13:25:46 2015 +0000
@@ -47,6 +47,7 @@
 
     if (lockUart(timeout)) return -1;
 
+    if (len > 64) len = 64;
     clearFlags();
     putUart('T');
     putUart('X');
--- a/IM920_hal.cpp	Mon Jan 05 03:47:08 2015 +0000
+++ b/IM920_hal.cpp	Thu Jan 08 13:25:46 2015 +0000
@@ -3,9 +3,11 @@
 void IM920::setReset (bool flg) {
     if (_reset) {
         if (flg) {
+            _reset->output();
             _reset->write(0);
         } else {
-            _reset->write(1);
+            _reset->input();
+            _reset->mode(PullNone);
         }
     }
 }
@@ -52,6 +54,6 @@
         _busy = new DigitalIn(busy);
     }
     if (reset != NC) {
-        _reset = new DigitalOut(reset);
+        _reset = new DigitalInOut(reset);
     }
 }