Library for HopeRF RFM22 / RFM22B transceiver module ported to mbed. Original Software from Mike McCauley (mikem@open.com.au) . See http://www.open.com.au/mikem/arduino/RF22/
Dependents: RF22_MAX_test_Send Geofence_receiver Geofence_sender Geofence_sender ... more
More Info about RFM22-modules like connecting and a demo-program see RF22-Notebook
Diff: RF22.cpp
- Revision:
- 7:b86825b9d74b
- Parent:
- 5:0386600f3408
- Child:
- 8:d9e2ca137f2e
--- a/RF22.cpp Sat Mar 02 22:01:22 2013 +0000 +++ b/RF22.cpp Wed Mar 13 20:37:19 2013 +0000 @@ -191,7 +191,7 @@ { uint8_t _lastInterruptFlags[2]; -led1 = !led1; +led1 = 1; // Read the interrupt flags which clears the interrupt spiBurstRead(RF22_REG_03_INTERRUPT_STATUS1, _lastInterruptFlags, 2); @@ -282,10 +282,12 @@ } spiBurstRead(RF22_REG_7F_FIFO_ACCESS, _buf + _bufLen, len - _bufLen); + __disable_irq(); // Disable Interrupts _rxGood++; _bufLen = len; _mode = RF22_MODE_IDLE; _rxBufValid = true; + __enable_irq(); // Enable Interrupts led3 = !led3; @@ -306,6 +308,7 @@ _lastRssi = spiRead(RF22_REG_26_RSSI); clearRxBuf(); } + led1 = 0; } // These are low level functions that call the interrupt handler for the correct @@ -334,6 +337,7 @@ uint8_t RF22::spiRead(uint8_t reg) { + __disable_irq(); // Disable Interrupts //digitalWrite(_slaveSelectPin, LOW); _slaveSelectPin=0; //_spi.write(reg & ~RF22_SPI_WRITE_MASK); // Send the address with the write mask off @@ -341,17 +345,20 @@ uint8_t val = _spi.write(0); // The written value is ignored, reg value is read //digitalWrite(_slaveSelectPin, HIGH); _slaveSelectPin = 1; + __enable_irq(); // Enable Interrupts return val; } void RF22::spiWrite(uint8_t reg, uint8_t val) { + __disable_irq(); // Disable Interrupts //digitalWrite(_slaveSelectPin, LOW); _slaveSelectPin = 0; _spi.write(reg | RF22_SPI_WRITE_MASK); // Send the address with the write mask on _spi.write(val); // New value follows //digitalWrite(_slaveSelectPin, HIGH); _slaveSelectPin = 1; + __enable_irq(); // Enable Interrupts } void RF22::spiBurstRead(uint8_t reg, uint8_t* dest, uint8_t len) @@ -575,8 +582,10 @@ void RF22::clearRxBuf() { + __disable_irq(); // Disable Interrupts _bufLen = 0; _rxBufValid = false; + __enable_irq(); // Enable Interrupts } boolean RF22::available() @@ -648,9 +657,11 @@ void RF22::clearTxBuf() { + __disable_irq(); // Disable Interrupts _bufLen = 0; _txBufSentIndex = 0; _txPacketSent = false; + __enable_irq(); // Enable Interrupts } void RF22::startTransmit()