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 12:48:08 2011 +0000
Revision:
2:99cf337cd23e
Parent:
1:42b124ed1f57
Child:
3:e72ad65868ab
Simplified Interface

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 2:99cf337cd23e 9 PinName SDO,
harryeakins 2:99cf337cd23e 10 PinName SCK,
harryeakins 2:99cf337cd23e 11 PinName NCS,
harryeakins 2:99cf337cd23e 12 PinName NIRQ);
harryeakins 2:99cf337cd23e 13
harryeakins 0:bd1232f200be 14 /* Reads a byte of data from the RF module's buffer
harryeakins 0:bd1232f200be 15 This is a blocking call */
harryeakins 0:bd1232f200be 16 unsigned char read();
harryeakins 2:99cf337cd23e 17
harryeakins 0:bd1232f200be 18 /* Sends a byte of data to the RF module for transmission */
harryeakins 1:42b124ed1f57 19 void write(unsigned char * data);
harryeakins 2:99cf337cd23e 20
harryeakins 0:bd1232f200be 21 /* Flushes all data from the RF module's buffer */
harryeakins 0:bd1232f200be 22 void flush();
harryeakins 0:bd1232f200be 23
harryeakins 0:bd1232f200be 24 private:
harryeakins 0:bd1232f200be 25 SPI spi;
harryeakins 0:bd1232f200be 26 DigitalOut NCS;
harryeakins 0:bd1232f200be 27 DigitalIn NIRQ;
harryeakins 0:bd1232f200be 28 bool trans;
harryeakins 0:bd1232f200be 29 bool initialized;
harryeakins 2:99cf337cd23e 30
harryeakins 0:bd1232f200be 31 unsigned int writeCmd(unsigned int cmd);
harryeakins 1:42b124ed1f57 32 void send(unsigned char data);
harryeakins 2:99cf337cd23e 33 /* Initialises the RF12B module */
harryeakins 2:99cf337cd23e 34 void init();
harryeakins 2:99cf337cd23e 35 /* Switch module between receive and transmit modes */
harryeakins 2:99cf337cd23e 36 void mode(bool trans);
harryeakins 0:bd1232f200be 37 };
harryeakins 0:bd1232f200be 38
harryeakins 0:bd1232f200be 39 #endif /* _RF12B_H */