Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of RF12B by
Revision 8:7d282360721a, committed 2013-05-31
- Comitter:
- hajesusrodrigues
- Date:
- Fri May 31 16:34:12 2013 +0000
- Parent:
- 7:19d9da22271a
- Commit message:
- Implementation of Sleep/WakeUp/LowBattery methods.
Changed in this revision
RFM12B.cpp | Show annotated file Show diff for this revision Revisions of this file |
RFM12B.h | Show annotated file Show diff for this revision Revisions of this file |
--- 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
--- a/RFM12B.h Thu May 30 22:11:42 2013 +0000 +++ b/RFM12B.h 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 @@ -102,6 +103,11 @@ void SendACK(const void* sendBuf = "", uint8_t sendLen = 0); void Send(uint8_t toNodeId, const void* sendBuf, uint8_t sendLen, bool requestACK = false); + void Sleep(int n); + void Sleep(); + void Wakeup(); + bool LowBattery(); + volatile uint8_t * GetData(); uint8_t GetDataLen(void); // how many bytes were received uint8_t GetSender(void);