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:
- 2:99cf337cd23e
- Parent:
- 1:42b124ed1f57
- Child:
- 3:e72ad65868ab
--- a/RF12B.h Thu Mar 10 11:26:20 2011 +0000 +++ b/RF12B.h Thu Mar 10 12:48:08 2011 +0000 @@ -6,24 +6,18 @@ 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 - + PinName SDO, + PinName SCK, + PinName NCS, + PinName NIRQ); + /* 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(); @@ -33,8 +27,13 @@ DigitalIn NIRQ; bool trans; bool initialized; + unsigned int writeCmd(unsigned int cmd); void send(unsigned char data); + /* Initialises the RF12B module */ + void init(); + /* Switch module between receive and transmit modes */ + void mode(bool trans); }; #endif /* _RF12B_H */ \ No newline at end of file