mBed RFM12B module library

Dependents:   _EXAMPLE_RFM12B

Fork of RF12B by Sukkin Pang

RFM12B Library

The main purpose of this library was to implement the RFM12B module in order to be able to establish communication with the Moteino (arduino clone that uses the RFM12B).

In order to achieve my goal I was highly inspired by RF12B library from pangsk https://mbed.org/users/pangsk/ and by RFM12B arduino library made by Felix Rusu (http://lowpowerlab.com/blog/2012/12/28/rfm12b-arduino-library/)

Who/What is Moteino? (http://lowpowerlab.com/moteino/)

Revision:
8:7d282360721a
Parent:
7:19d9da22271a
--- a/RFM12B.cpp	Thu May 30 22:11:42 2013 +0000
+++ b/RFM12B.cpp	Fri May 31 16:34:12 2013 +0000
@@ -1,13 +1,14 @@
 /*
  RFM12B Library. Based on work done by JeeLabs.org ported to mBed by SK Pang.
  http://jeelabs.net/projects/cafe/wiki/RF12
+ Jan 2012 skpang.co.uk
+
+ RFM12B Library (Moteino Comunication Protocol). Based on work done by Felix Rusu ported to mBed by Hugo Rodrigues
+ http://lowpowerlab.com/blog/2012/12/28/rfm12b-arduino-library/
+ May 2013 Hugo Rodrigues
 
  http://opensource.org/licenses/mit-license.php
 
- Jan 2012 skpang.co.uk
-
- Modified by Hugo Rodrigues (May 2013)
-
  Permission is hereby granted, free of charge, to any person obtaining a copy
  of this software and associated documentation files (the "Software"), to deal
  in the Software without restriction, including without limitation the rights
@@ -392,3 +393,29 @@
     } else
         useEncryption = false;
 }
+
+void RFM12B::Sleep(int n)
+{
+    if (n < 0)
+        xfer(RF_IDLE_MODE);
+    else {
+        xfer(RF_WAKEUP_TIMER | 0x0500 | n);
+        xfer(RF_SLEEP_MODE);
+        if (n > 0)
+            xfer(RF_WAKEUP_MODE);
+    }
+    rxstate = TXIDLE;
+}
+void RFM12B::Sleep()
+{
+    Sleep(0);
+}
+void RFM12B::Wakeup()
+{
+    Sleep(-1);
+}
+
+bool RFM12B::LowBattery()
+{
+    return (xfer(0x0000) & RF_LBD_BIT) != 0;
+}
\ No newline at end of file