Karl Zweimüller
/
eth_comfort_test
Programm for decoding radio-signals sent by a ETH-Window-Shutter-Contact, received with a RFM12B-module
Diff: rfm12b.h
- Revision:
- 1:fc72e0bdb693
- Parent:
- 0:96794c9fc5a3
--- a/rfm12b.h Wed Mar 02 20:46:57 2011 +0000 +++ b/rfm12b.h Thu Apr 07 19:54:09 2011 +0000 @@ -3,14 +3,19 @@ #include <mbed.h> +/*! + * \file rfm12b.h + * \brief class for rfm2b in rawmode - only receive part implemented + * \author Karl Zweimüller based on code from WED 6.9.2009 + */ + typedef unsigned char Byte; // used to be uint8_t : something a byte wide, whatever .... /** This Class handles a rfm12b transceiver * see http://www.hoperf.com/rf_fsk/rfm12b.htm - * + * */ -class rfm12b -{ +class rfm12b { public: /** Create a rfm12b object * @@ -21,15 +26,15 @@ * @param rxdata Data-Pin for received data. A DigitalIn of mbed */ rfm12b(PinName mosi, PinName miso, PinName sclk, PinName nsel, PinName rxdata); - + /** init the spi-interface */ void init_spi(); - + /** initialize the device */ void RFM_init(void); - + /** write and read 16 bit */ uint16_t rfm_spi16(uint16_t outval); @@ -45,14 +50,29 @@ m_pinRXData->rise(fptr); } + template<typename T> + /** attach an object member function to be called when the data-pin changes from 0->1 and from 1->0 + * + * @param tptr pointer to object + * @param mprt pointer ro member function + * + */ + void attachISR(T* tptr, void (T::*mptr)(void)) { + if ((mptr != NULL) && (tptr != NULL)) { + m_pinRXData->fall(tptr, mptr); + m_pinRXData->rise(tptr, mptr); + } + } + + private: - + DigitalOut *cs; //chipselect InterruptIn *m_pinRXData; //rx data pin SPI *rfm12b_spi; //spi-interface - + };