MRF24J40 based drivers¶
This module contains drivers for radio devices in Microchip MRF24J40 series.
The driver is aimed to work with all devices of this series.
Default TX power is 0dBm.
TX power mapping:
- 0 -> -36dB
- 1 -> -35dB
- 2 -> -34dB
- 3 -> -33dB
- 4 -> -32dB
- 5 -> -31dB
- 6 -> -30dB
- 7 -> -30dB
- 8 -> -26dB
- 9 -> -25dB
- 10 -> -24dB
- 11 -> -23dB
- 12 -> -22dB
- 13 -> -21dB
- 14 -> -20dB
- 15 -> -20dB
- 16 -> -16dB
- 17 -> -15dB
- 18 -> -14dB
- 19 -> -13dB
- 20 -> -12dB
- 21 -> -11dB
- 22 -> -10dB
- 23 -> -10dB
- 24 -> -6dB
- 25 -> -5dB
- 26 -> -4dB
- 27 -> -3dB
- 28 -> -2dB
- 29 -> -1dB
- 30 -> -0dB
- 31 -> -0dB
-
MRF24J40_PSEUDO_STATE_IDLE
¶ Idle, ready to transmit or receive.
1
(0x01)
-
MRF24J40_PSEUDO_STATE_SLEEP
¶ sleep mode, registers functional, but no RF
1
(0x02)
-
MRF24J40_PSEUDO_STATE_RESET
¶ Reset device, next state is idle.
1
(0x04)
-
MRF24J40_OPT_CSMA
¶ CSMA active.
1
(0x0100)
-
MRF24J40_OPT_PROMISCUOUS
¶ promiscuous mode active
1
(0x0200)
-
MRF24J40_OPT_PRELOADING
¶ preloading enabled
1
(0x0400)
-
MRF24J40_OPT_TELL_TX_START
¶ notify MAC layer on TX start
1
(0x0800)
-
MRF24J40_OPT_TELL_TX_END
¶ notify MAC layer on TX finished
1
(0x1000)
-
MRF24J40_OPT_TELL_RX_START
¶ notify MAC layer on RX start
1
(0x2000)
-
MRF24J40_OPT_TELL_RX_END
¶ notify MAC layer on RX finished
1
(0x4000)
-
MRF24J40_OPT_REQ_AUTO_ACK
¶ notify MAC layer on RX finished
1
(0x8000)
-
struct mrf24j40_params
mrf24j40_params_t
¶ struct holding all params needed for device initialization
-
void
mrf24j40_setup
(mrf24j40_t * dev, constmrf24j40.h::mrf24j40_params_t
* params)¶ Setup an MRF24J40 based device state.
Parameters
dev: device descriptor params: parameters for device initialization
-
void
mrf24j40_reset
(mrf24j40_t * dev)¶ Trigger a hardware reset and configure radio with default values.
Parameters
dev: device to reset
-
bool
mrf24j40_cca
(mrf24j40_t * dev)¶ Trigger a clear channel assessment.
Parameters
dev: device to use Return values
- true if channel is clear
- false if channel is busy
-
uint16_t
mrf24j40_get_addr_short
(mrf24j40_t * dev)¶ Get the short address of the given device.
Parameters
dev: device to read from Return values
- the currently set (2-byte) short address
-
void
mrf24j40_set_addr_short
(mrf24j40_t * dev, uint16_t addr)¶ Set the short address of the given device.
Parameters
dev: device to write to addr: (2-byte) short address to set
-
uint64_t
mrf24j40_get_addr_long
(mrf24j40_t * dev)¶ Get the configured long address of the given device.
Parameters
dev: device to read from Return values
- the currently set (8-byte) long address
-
void
mrf24j40_set_addr_long
(mrf24j40_t * dev, uint64_t addr)¶ Set the long address of the given device.
Parameters
dev: device to write to addr: (8-byte) long address to set
-
uint8_t
mrf24j40_get_chan
(mrf24j40_t * dev)¶ Get the configured channel number of the given device.
Parameters
dev: device to read from Return values
- the currently set channel number
-
void
mrf24j40_set_chan
(mrf24j40_t * dev, uint8_t chan)¶ Set the channel number of the given device.
Parameters
dev: device to write to chan: channel number to set
-
uint16_t
mrf24j40_get_pan
(mrf24j40_t * dev)¶ Get the configured PAN ID of the given device.
Parameters
dev: device to read from Return values
- the currently set PAN ID
-
void
mrf24j40_set_pan
(mrf24j40_t * dev, uint16_t pan)¶ Set the PAN ID of the given device.
Parameters
dev: device to write to pan: PAN ID to set
-
int16_t
mrf24j40_get_txpower
(mrf24j40_t * dev)¶ Get the configured transmission power of the given device [in dBm].
Parameters
dev: device to read from Return values
- configured transmission power in dBm
-
void
mrf24j40_set_txpower
(mrf24j40_t * dev, int16_t txpower)¶ Set the transmission power of the given device [in dBm].
If the device does not support the exact dBm value given, it will set a value as close as possible to the given value. If the given value is larger or lower then the maximal or minimal possible value, the min or max value is set, respectively.
Parameters
dev: device to write to txpower: transmission power in dBm
-
uint8_t
mrf24j40_get_csma_max_retries
(mrf24j40_t * dev)¶ Get the maximum number of channel access attempts per frame (CSMA)
Parameters
dev: device to read from Return values
- configured number of retries
-
void
mrf24j40_set_csma_max_retries
(mrf24j40_t * dev, int8_t retries)¶ Set the maximum number of channel access attempts per frame (CSMA)
This setting specifies the number of attempts to access the channel to transmit a frame. If the channel is busy
retries
times, then frame transmission fails. Valid values: 0 to 5, -1 means CSMA disabledParameters
dev: device to write to retries: the maximum number of retries
-
void
mrf24j40_set_csma_backoff_exp
(mrf24j40_t * dev, uint8_t min, uint8_t max)¶ Set the min and max backoff exponent for CSMA/CA.
- Maximum BE: 0 - 8
- Minimum BE: 0 - [max]
Parameters
dev: device to write to min: the minimum BE max: the maximum BE
-
int8_t
mrf24j40_get_cca_threshold
(mrf24j40_t * dev)¶ Get the CCA threshold value.
Parameters
dev: device to read value from Return values
- the current CCA threshold value
-
void
mrf24j40_set_cca_threshold
(mrf24j40_t * dev, int8_t value)¶ Set the CCA threshold value.
Parameters
dev: device to write to value: the new CCA threshold value
-
void
mrf24j40_set_option
(mrf24j40_t * dev, uint16_t option, bool state)¶ Enable or disable driver specific options.
Parameters
dev: device to set/clear option flag for option: option to enable/disable state: true for enable, false for disable
-
void
mrf24j40_set_state
(mrf24j40_t * dev, uint8_t state)¶ Set the state of the given device (trigger a state change)
Parameters
dev: device to change state of state: the targeted new state
-
void
mrf24j40_sleep
(mrf24j40_t * dev)¶ Put in sleep mode.
Parameters
dev: device to put to sleep
-
void
mrf24j40_assert_sleep
(mrf24j40_t * dev)¶ Put in sleep mode if idle_state is sleep.
Parameters
dev: device to put to sleep
-
void
mrf24j40_assert_awake
(mrf24j40_t * dev)¶ Wake up from sleep mode.
Parameters
dev: device to eventually wake up
-
void
mrf24j40_reset_state_machine
(mrf24j40_t * dev)¶ Reset the internal state machine to TRX_OFF mode.
This will force a transition to TRX_OFF regardless of whether the transceiver is currently busy sending or receiving. This function is used to get back to a known state during driver initialization.
Parameters
dev: device to operate on
-
void
mrf24j40_software_reset
(mrf24j40_t * dev)¶ Software Reset.
This will force the power management circuitry, the baseband circuitry and the MAC circuitry to be reset
Parameters
dev: device to operate on
-
int8_t
mrf24j40_dbm_from_reg
(uint8_t value)¶ Convert scalar from mrf24j40 RSSI to dBm.
Parameters
value: value to convert to dBm Return values
- converted value in dBm
-
void
mrf24j40_tx_prepare
(mrf24j40_t * dev)¶ Prepare for sending of data.
This function puts the given device into the TX state, so no receiving of data is possible after it was called.
Parameters
dev: device to prepare for sending
-
msp430_types.h::size_t
mrf24j40_tx_load
(mrf24j40_t * dev, uint8_t * data,msp430_types.h::size_t
len,msp430_types.h::size_t
offset)¶ Load chunks of data into the transmit buffer of the given device.
Parameters
dev: device to write data to data: buffer containing the data to load len: number of bytes in buffer
offset: offset used when writing data to internal buffer Return values
- offset + number of bytes written
-
void
mrf24j40_tx_exec
(mrf24j40_t * dev)¶ Trigger sending of data previously loaded into transmit buffer.
Parameters
dev: device to trigger
-
MRF24J40_TASK_TX_DONE
¶ TX operation is done.
1
(0x01)
-
MRF24J40_TASK_TX_READY
¶ TX operation results ready for processing.
1
(0x02)
-
MRF24J40_TASK_RX_READY
¶ RX processing needed.
1
(0x04)
-
MRF24J40_MAX_FRAME_RETRIES
¶ Number of frame retries (fixed)
1
(3U)
-
struct
mrf24j40_params
¶ struct holding all params needed for device initialization
-
spi.h::spi_t
spi
¶ SPI bus the device is connected to.
-
atmega_common/include/periph_cpu_common.h::spi_clk_t
spi_clk
¶ SPI speed to use.
-
spi.h::spi_cs_t
cs_pin
¶ GPIO pin connected to chip select.
-
gpio.h::gpio_t
int_pin
¶ GPIO pin connected to the interrupt pin.
-
gpio.h::gpio_t
reset_pin
¶ GPIO pin connected to the reset pin.
-
-
struct
mrf24j40_t
¶ Device descriptor for MRF24J40 radio devices.
-
netdev_ieee802154_t
netdev
¶ netdev parent struct
-
mrf24j40.h::mrf24j40_params_t
params
¶ parameters for initialization
-
uint8_t
state
¶ current state of the radio
-
uint8_t
idle_state
¶ state to return to after sending
-
uint8_t
tx_frame_len
¶ length of the current TX frame
-
uint8_t
header_len
¶ length of the header
-
uint8_t
fcf_low
¶ Low 8 FCF bits of the current TX frame.
-
uint8_t
pending
¶ Flags for pending tasks.
-
uint8_t
irq_flag
¶ Flags for IRQs.
-
uint8_t
tx_retries
¶ Number of retries needed for last transmission.
-
netdev_ieee802154_t