Programm for decoding radio-signals sent by a ETH-Window-Shutter-Contact, received with a RFM12B-module

Dependencies:   TextLCD mbed

Committer:
charly
Date:
Wed Mar 02 20:46:57 2011 +0000
Revision:
0:96794c9fc5a3
Child:
1:fc72e0bdb693
Initial pre-beta version

Who changed what in which revision?

UserRevisionLine numberNew contents of line
charly 0:96794c9fc5a3 1 #ifndef rfm12B_H
charly 0:96794c9fc5a3 2 #define rfm12B_H
charly 0:96794c9fc5a3 3
charly 0:96794c9fc5a3 4 #include <mbed.h>
charly 0:96794c9fc5a3 5
charly 0:96794c9fc5a3 6 typedef unsigned char Byte; // used to be uint8_t : something a byte wide, whatever ....
charly 0:96794c9fc5a3 7
charly 0:96794c9fc5a3 8 /** This Class handles a rfm12b transceiver
charly 0:96794c9fc5a3 9 * see http://www.hoperf.com/rf_fsk/rfm12b.htm
charly 0:96794c9fc5a3 10 *
charly 0:96794c9fc5a3 11 */
charly 0:96794c9fc5a3 12 class rfm12b
charly 0:96794c9fc5a3 13 {
charly 0:96794c9fc5a3 14 public:
charly 0:96794c9fc5a3 15 /** Create a rfm12b object
charly 0:96794c9fc5a3 16 *
charly 0:96794c9fc5a3 17 * @param mosi SPI-Interface. One of the 2 PSI-Interfaces of mbed. Pin p5 or p11
charly 0:96794c9fc5a3 18 * @param miso SPI-Interface. One of the 2 PSI-Interfaces of mbed. Pin p6 or p12
charly 0:96794c9fc5a3 19 * @param sclk SPI-Interface. One of the 2 PSI-Interfaces of mbed. Pin p7 or p13
charly 0:96794c9fc5a3 20 * @param nsel Chip-Select. A Digial Output of mbed
charly 0:96794c9fc5a3 21 * @param rxdata Data-Pin for received data. A DigitalIn of mbed
charly 0:96794c9fc5a3 22 */
charly 0:96794c9fc5a3 23 rfm12b(PinName mosi, PinName miso, PinName sclk, PinName nsel, PinName rxdata);
charly 0:96794c9fc5a3 24
charly 0:96794c9fc5a3 25 /** init the spi-interface
charly 0:96794c9fc5a3 26 */
charly 0:96794c9fc5a3 27 void init_spi();
charly 0:96794c9fc5a3 28
charly 0:96794c9fc5a3 29 /** initialize the device
charly 0:96794c9fc5a3 30 */
charly 0:96794c9fc5a3 31 void RFM_init(void);
charly 0:96794c9fc5a3 32
charly 0:96794c9fc5a3 33 /** write and read 16 bit
charly 0:96794c9fc5a3 34 */
charly 0:96794c9fc5a3 35 uint16_t rfm_spi16(uint16_t outval);
charly 0:96794c9fc5a3 36
charly 0:96794c9fc5a3 37 /** attach a function to be called when the data-pin changes from 0->1 and from 1->0
charly 0:96794c9fc5a3 38 * this function has to do all the decoding
charly 0:96794c9fc5a3 39 * keep this function short, as no interrrupts can occour within
charly 0:96794c9fc5a3 40 *
charly 0:96794c9fc5a3 41 * @param fptr Pointer to callback-function
charly 0:96794c9fc5a3 42 */
charly 0:96794c9fc5a3 43 void attachISR(void (*fptr)(void)) {
charly 0:96794c9fc5a3 44 m_pinRXData->fall(fptr);
charly 0:96794c9fc5a3 45 m_pinRXData->rise(fptr);
charly 0:96794c9fc5a3 46 }
charly 0:96794c9fc5a3 47
charly 0:96794c9fc5a3 48
charly 0:96794c9fc5a3 49 private:
charly 0:96794c9fc5a3 50
charly 0:96794c9fc5a3 51
charly 0:96794c9fc5a3 52 DigitalOut *cs; //chipselect
charly 0:96794c9fc5a3 53 InterruptIn *m_pinRXData; //rx data pin
charly 0:96794c9fc5a3 54 SPI *rfm12b_spi; //spi-interface
charly 0:96794c9fc5a3 55
charly 0:96794c9fc5a3 56
charly 0:96794c9fc5a3 57 };
charly 0:96794c9fc5a3 58
charly 0:96794c9fc5a3 59 #endif