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
RFSerial.cpp@9:cd34784da6da, 2011-03-11 (annotated)
- Committer:
- harryeakins
- Date:
- Fri Mar 11 21:38:26 2011 +0000
- Revision:
- 9:cd34784da6da
- Parent:
- 6:98da0571ec31
Fixed bug in initialization routine where the mode of the RF module was not set.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
harryeakins | 6:98da0571ec31 | 1 | |
harryeakins | 6:98da0571ec31 | 2 | /* Constructor */ |
harryeakins | 6:98da0571ec31 | 3 | #include "RFSerial.h" |
harryeakins | 6:98da0571ec31 | 4 | |
harryeakins | 6:98da0571ec31 | 5 | RFSerial::RFSerial(PinName _SDI, |
harryeakins | 6:98da0571ec31 | 6 | PinName _SDO, |
harryeakins | 6:98da0571ec31 | 7 | PinName _SCK, |
harryeakins | 6:98da0571ec31 | 8 | PinName _NCS, |
harryeakins | 6:98da0571ec31 | 9 | PinName _NIRQ) |
harryeakins | 6:98da0571ec31 | 10 | :RF12B(_SDI, _SDO, _SCK, _NCS, _NIRQ) { |
harryeakins | 6:98da0571ec31 | 11 | |
harryeakins | 6:98da0571ec31 | 12 | } |
harryeakins | 6:98da0571ec31 | 13 | |
harryeakins | 6:98da0571ec31 | 14 | // Stream implementation functions |
harryeakins | 6:98da0571ec31 | 15 | int RFSerial::_putc(int value) { |
harryeakins | 6:98da0571ec31 | 16 | RF12B::write((unsigned char) value); |
harryeakins | 6:98da0571ec31 | 17 | return value; |
harryeakins | 6:98da0571ec31 | 18 | } |
harryeakins | 6:98da0571ec31 | 19 | int RFSerial::_getc() { |
harryeakins | 6:98da0571ec31 | 20 | if(available()) { |
harryeakins | 6:98da0571ec31 | 21 | return RF12B::read(); |
harryeakins | 6:98da0571ec31 | 22 | } else { |
harryeakins | 6:98da0571ec31 | 23 | return EOF; |
harryeakins | 6:98da0571ec31 | 24 | } |
harryeakins | 6:98da0571ec31 | 25 | } |