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

Committer:
harryeakins
Date:
Thu Mar 10 10:56:15 2011 +0000
Revision:
0:bd1232f200be
Child:
1:42b124ed1f57
First Commit RF12B Library

Who changed what in which revision?

UserRevisionLine numberNew contents of line
harryeakins 0:bd1232f200be 1 #ifndef _RF12B_H
harryeakins 0:bd1232f200be 2 #define _RF12B_H
harryeakins 0:bd1232f200be 3
harryeakins 0:bd1232f200be 4 #include "mbed.h"
harryeakins 0:bd1232f200be 5
harryeakins 0:bd1232f200be 6 class RF12B {
harryeakins 0:bd1232f200be 7 public:
harryeakins 0:bd1232f200be 8 RF12B(PinName SDI,
harryeakins 0:bd1232f200be 9 PinName SDO,
harryeakins 0:bd1232f200be 10 PinName SCK,
harryeakins 0:bd1232f200be 11 PinName NCS,
harryeakins 0:bd1232f200be 12 PinName NIRQ);
harryeakins 0:bd1232f200be 13
harryeakins 0:bd1232f200be 14 /* Initialises the RF12B module as transmitter
harryeakins 0:bd1232f200be 15 or receiver. This should be called after the
harryeakins 0:bd1232f200be 16 RF module has fully started up (give it a
harryeakins 0:bd1232f200be 17 few hundred ms) */
harryeakins 0:bd1232f200be 18 void init(bool _trans = true); // Default transmitter
harryeakins 0:bd1232f200be 19
harryeakins 0:bd1232f200be 20 /* Reads a byte of data from the RF module's buffer
harryeakins 0:bd1232f200be 21 This is a blocking call */
harryeakins 0:bd1232f200be 22 unsigned char read();
harryeakins 0:bd1232f200be 23
harryeakins 0:bd1232f200be 24 /* Sends a byte of data to the RF module for transmission */
harryeakins 0:bd1232f200be 25 void write(unsigned char data);
harryeakins 0:bd1232f200be 26
harryeakins 0:bd1232f200be 27 /* Flushes all data from the RF module's buffer */
harryeakins 0:bd1232f200be 28 void flush();
harryeakins 0:bd1232f200be 29
harryeakins 0:bd1232f200be 30 private:
harryeakins 0:bd1232f200be 31 SPI spi;
harryeakins 0:bd1232f200be 32 DigitalOut NCS;
harryeakins 0:bd1232f200be 33 DigitalIn NIRQ;
harryeakins 0:bd1232f200be 34 bool trans;
harryeakins 0:bd1232f200be 35 bool initialized;
harryeakins 0:bd1232f200be 36 unsigned int writeCmd(unsigned int cmd);
harryeakins 0:bd1232f200be 37 };
harryeakins 0:bd1232f200be 38
harryeakins 0:bd1232f200be 39 #endif /* _RF12B_H */