Library to send and receive data using RF12B transceiver modules Big thanks to the tutorial at https://loee.jottit.com/rfm12b_and_avr_-_quick_start and madcowswe
Dependents: Measure_system Quadcopter_copy
Diff: RF12B.h
- Revision:
- 0:bd1232f200be
- Child:
- 1:42b124ed1f57
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/RF12B.h Thu Mar 10 10:56:15 2011 +0000 @@ -0,0 +1,39 @@ +#ifndef _RF12B_H +#define _RF12B_H + +#include "mbed.h" + +class RF12B { +public: + RF12B(PinName SDI, + PinName SDO, + PinName SCK, + PinName NCS, + PinName NIRQ); + + /* Initialises the RF12B module as transmitter + or receiver. This should be called after the + RF module has fully started up (give it a + few hundred ms) */ + void init(bool _trans = true); // Default transmitter + + /* Reads a byte of data from the RF module's buffer + This is a blocking call */ + unsigned char read(); + + /* Sends a byte of data to the RF module for transmission */ + void write(unsigned char data); + + /* Flushes all data from the RF module's buffer */ + void flush(); + +private: + SPI spi; + DigitalOut NCS; + DigitalIn NIRQ; + bool trans; + bool initialized; + unsigned int writeCmd(unsigned int cmd); +}; + +#endif /* _RF12B_H */ \ No newline at end of file