Skip to content

Instantly share code, notes, and snippets.

@kasparsd
Created January 1, 2019 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kasparsd/04c6b2b91d8fd338abfd7dd92d9f19c6 to your computer and use it in GitHub Desktop.
Save kasparsd/04c6b2b91d8fd338abfd7dd92d9f19c6 to your computer and use it in GitHub Desktop.

RFM69_initialise

  • Set MY_RFM69_POWER_PIN mode to OUTPUT, if defined.

  • Power up the radio RFM69_powerUp().

  • Reset radio module, if MY_RFM69_RST_PIN is defined.

  • Configure radio:

    • Set radio address to RFM69_BROADCAST_ADDRESS.
    • Set radio dataReceived to false.
    • Set radio ackReceived to false.
    • Set radio txSequenceNumber to 0.
    • Set radio radioMode to RFM69_RADIO_MODE_SLEEP.
    • Disable ATC by setting ATCenabled to false.
    • Set radio ATCtargetRSSI to RFM69_RSSItoInternal(MY_RFM69_ATC_TARGET_RSSI_DBM).
  • Init SPI:

    • Set MY_RFM69_CS_PIN to HIGH.
    • Set MY_RFM69_CS_PIN to OUTPUT (why that order?).
  • Call SPI.begin()

  • Set radio mode RFM69_setRadioMode(RFM69_RADIO_MODE_STDBY).

  • Set radio configuration RFM69_setConfiguration()

    Register Value Comments
    RFM69_REG_OPMODE RFM69_OPMODE_SEQUENCER_ON RFM69_OPMODE_LISTEN_OFF
    RFM69_REG_DATAMODUL RFM69_CONFIG_FSK
    RFM69_REG_BITRATEMSB RFM69_BITRATEMSB_55555
    RFM69_REG_BITRATELSB RFM69_BITRATELSB_55555
    RFM69_REG_FDEVMSB RFM69_FDEVMSB_50000
    RFM69_REG_FDEVLSB RFM69_FDEVLSB_50000
    RFM69_REG_LNA RFM69_LNA_ZIN_200 RFM69_LNA_CURRENTGAIN
    RFM69_REG_RXBW RFM69_RXBW_111_16_2
    RFM69_REG_AFCBW RFM69_RXBW_111_16_2
    RFM69_REG_DIOMAPPING2 RFM69_DIOMAPPING2_CLKOUT_OFF
    RFM69_REG_IRQFLAGS2 RFM69_IRQFLAGS2_FIFOOVERRUN clear FIFO and flags
    RFM69_REG_RSSITHRESH RFM69_RSSITHRESH_VALUE
    RFM69_REG_PREAMBLEMSB RFM69_PREAMBLESIZE_MSB_VALUE
    RFM69_REG_PREAMBLELSB RFM69_PREAMBLESIZE_LSB_VALUE
    RFM69_REG_SYNCCONFIG RFM69_SYNC_ON RFM69_SYNC_FIFOFILL_AUTO
    RFM69_REG_SYNCVALUE1 RFM69_SYNCVALUE1
    RFM69_REG_SYNCVALUE2 MY_RFM69_NETWORKID
    RFM69_REG_PACKETCONFIG1 RFM69_CONFIG_WHITE
    RFM69_REG_PAYLOADLENGTH RFM69_MAX_PACKET_LEN in variable length mode: the max frame size, not used in TX
    RFM69_REG_NODEADRS RFM69_BROADCAST_ADDRESS
    RFM69_REG_BROADCASTADRS RFM69_BROADCAST_ADDRESS
    RFM69_REG_FIFOTHRESH RFM69_FIFOTHRESH_TXSTART_FIFOTHRESH (RFM69_HEADER_LEN - 1)
    RFM69_REG_PACKETCONFIG2 RFM69_PACKET2_RXRESTARTDELAY_2BITS RFM69_PACKET2_AUTORXRESTART_OFF
    RFM69_REG_TESTDAGC RFM69_DAGC_IMPROVED_LOWBETA0 continuous DAGC mode, use 0x30 if afc offset == 0
  • Set radio frequency to the first argument frequencyHz value of RFM69_initialise.

  • Set radio power level to RFM69_setTxPowerLevel(MY_RFM69_TX_POWER_DBM).

  • Read all radio registers.

  • Call RFM69_sanityCheck() and return false if failed.

    • Ensure that register RFM69_REG_RSSITHRESH is equal to RFM69_RSSITHRESH_VALUE.
    • Ensure that register RFM69_REG_SYNCVALUE1 is equal to RFM69_SYNCVALUE1.
    • Ensure that register RFM69_REG_SYNCVALUE2 is equal to MY_RFM69_NETWORKID.
  • Set RFM69_irq to false.

  • Set MY_RFM69_IRQ_PIN mode to INPUT.

  • Return true.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment