internal function
| 388 | |
| 389 | // internal function |
| 390 | void RFM69::sendFrame(uint16_t toAddress, const void* buffer, uint8_t bufferSize, bool requestACK, bool sendACK) { |
| 391 | //NOTE: overridden in RFM69_ATC! |
| 392 | setMode(RF69_MODE_STANDBY); // turn off receiver to prevent reception while filling fifo |
| 393 | while ((readReg(REG_IRQFLAGS1) & RF_IRQFLAGS1_MODEREADY) == 0x00); // wait for ModeReady |
| 394 | //writeReg(REG_DIOMAPPING1, RF_DIOMAPPING1_DIO0_00); // DIO0 is "Packet Sent" |
| 395 | if (bufferSize > RF69_MAX_DATA_LEN) bufferSize = RF69_MAX_DATA_LEN; |
| 396 | |
| 397 | // control byte |
| 398 | uint8_t CTLbyte = 0x00; |
| 399 | if (sendACK) |
| 400 | CTLbyte = RFM69_CTL_SENDACK; |
| 401 | else if (requestACK) |
| 402 | CTLbyte = RFM69_CTL_REQACK; |
| 403 | |
| 404 | if (toAddress > 0xFF) CTLbyte |= (toAddress & 0x300) >> 6; // assign last 2 bits of address if > 255 |
| 405 | if (_address > 0xFF) CTLbyte |= (_address & 0x300) >> 8; // assign last 2 bits of address if > 255 |
| 406 | |
| 407 | // write to FIFO |
| 408 | select(); |
| 409 | _spi->transfer(REG_FIFO | 0x80); |
| 410 | _spi->transfer(bufferSize + 3); |
| 411 | _spi->transfer((uint8_t)toAddress); |
| 412 | _spi->transfer((uint8_t)_address); |
| 413 | _spi->transfer(CTLbyte); |
| 414 | |
| 415 | for (uint8_t i = 0; i < bufferSize; i++) |
| 416 | _spi->transfer(((uint8_t*) buffer)[i]); |
| 417 | unselect(); |
| 418 | |
| 419 | // no need to wait for transmit mode to be ready since its handled by the radio |
| 420 | setMode(RF69_MODE_TX); |
| 421 | //uint32_t txStart = millis(); |
| 422 | //while (digitalRead(_interruptPin) == 0 && millis() - txStart < RF69_TX_LIMIT_MS); // wait for DIO0 to turn HIGH signalling transmission finish |
| 423 | while ((readReg(REG_IRQFLAGS2) & RF_IRQFLAGS2_PACKETSENT) == 0x00); // wait for PacketSent |
| 424 | setMode(RF69_MODE_STANDBY); |
| 425 | } |
| 426 | |
| 427 | // internal function - interrupt gets called when a packet is received |
| 428 | void RFM69::interruptHandler() { |
nothing calls this directly
no outgoing calls
no test coverage detected