Skip to main content

Module sx1261

Module sx1261 

Source
Expand description

Bringing up the SX1261 that listens beside the concentrator.

lbt builds the frames that ask this radio whether a channel is busy, but two of the opcodes it sends are not in the SX1261’s own command set. They exist only once the radio’s patch memory holds Semtech’s patch, so a gateway that sends them to a radio straight out of reset is talking to a chip that has never heard of them, and gets silence rather than an answer. This module is the half that comes first: park the radio, load the patch and prove it took, calibrate the image for the band, and set up the receiver the check listens with.

The radio takes commands rather than register writes. Every one of them is a single opcode byte followed by its payload, which is what a Frame carries, and the few registers that are written go inside the payload of a write command rather than on a bus of their own.

Three things here are not what they look like:

  • The patch is 386 words rather than bytes, written four bytes at a time from PRAM_BASE, and it does not take effect until commit is sent.
  • Whether it took is read as text. PRAM_VERSION is compared against the last four characters of the version string, not the whole of it.
  • The last level a spectral scan reports repeats the level before it, because it counts what was heard below the lowest threshold rather than at a new one.

Nothing in this module opens a bus.

Structs§

Frame
One command: the opcode, and the payload that follows it.
Level
One level a spectral scan counted at.
Status
What the radio answered when asked how it was.

Enums§

Bandwidth
How wide the receiver listens.
CommandStatus
How the last command went, from the low bits of a status byte.
Mode
What the radio is doing, from the middle bits of a status byte.
PatchError
What went wrong reading a patch.
ScanStatus
How far along a spectral scan is.
Standby
Which clock the radio is parked on.

Constants§

CALIBRATION_WAIT_MS
How long an image calibration takes before the radio can be asked whether it worked.
MAX_PAYLOAD
The longest payload any command here carries, which is the packet settings.
OP_CALIBRATE_IMAGE
Calibrates the image rejection for one band.
OP_GET_DEVICE_ERRORS
Reports what the radio failed at, which is how a refused calibration is noticed.
OP_GET_STATUS
Asks the radio what mode it is in and how the last command went.
OP_READ_REGISTER
Reads the radio’s registers from an address given in the payload.
OP_SET_BUFFER_BASE_ADDRESS
Points the transmit and receive buffers at somewhere in the radio’s memory.
OP_SET_FS
Puts the radio on frequency without receiving, which is where it waits between checks.
OP_SET_MODULATION_PARAMS
Sets the bitrate, the shaping, the bandwidth, and the deviation.
OP_SET_PACKET_PARAMS
Sets the preamble, the sync word length, and how a packet’s length is carried.
OP_SET_PACKET_TYPE
Chooses the modulation the receiver expects.
OP_SET_RF_FREQUENCY
Tunes the radio.
OP_SET_RX
Puts the radio into continuous receive.
OP_SET_STANDBY
Parks the radio, on either of the two clocks.
OP_UPDATE_PRAM
Takes the patch just written into use.
OP_WRITE_REGISTER
Writes one of the radio’s registers, with the address and value inside the payload.
PATCH_UPDATE_CLOSED
Closes REG_PATCH_UPDATE once the patch is written.
PATCH_UPDATE_OPEN
Opens REG_PATCH_UPDATE so the patch can be written.
PRAM_BASE
Where the patch is written, one word every four addresses.
PRAM_VERSION
The last four characters of the version string a loaded patch answers with.
PRAM_WORDS
How many words the patch holds.
REG_PATCH_UPDATE
The register that has to be opened before the patch is written, and closed after.
REG_PRAM_VERSION
Where the version string the radio is running sits.
REG_RSSI_WINDOW
The register holding how long the radio averages a signal level over.
REG_SCAN_RESULTS
Where a spectral scan leaves its counts.
REG_SCAN_STATUS
Where a spectral scan reports whether it is finished.
REG_SENSITIVITY
The register that trades a little current for a lower noise floor.
RSSI_WINDOW_ARMED
The averaging window a carrier check listens with.
SCAN_LEVELS
How many levels a spectral scan reports.
SCAN_TRANSFER
How many bytes a spectral scan’s counts take: the address, one the radio answers over, then two bytes for each level.
SENSITIVITY_VALUE
What REG_SENSITIVITY is set to, which the reference applies to every board.
STANDBY_READY
The whole byte the radio answers with once it is parked and ready.
STATUS_MASK
The bits of a status byte that carry anything. The top and bottom bits are not answered.
VERSION_LEN
How many characters the version string holds.
VERSION_TRANSFER
How many bytes a version read moves: the address, one the radio answers over, then the string itself.

Functions§

calibrate
Calibrates the image rejection for the band a carrier falls in.
calibration_failed
Whether the radio reports that an image calibration did not work.
close_patch
Closes the radio once the patch is written.
commit
Takes the patch into use.
device_errors
Asks the radio what it has failed at.
free_running
Puts the radio on frequency without receiving, which is where it waits between checks.
frequency_value
Turns a frequency into the number the radio is tuned with.
open_patch
Opens the radio so the patch can be written.
patch_word
Writes one word of the patch.
patched
Whether the radio is running the patch this crate writes.
read_patch
Reads a patch from the form Semtech ships it in.
receive
The commands that point the receiver at a channel and start it listening.
scan_counts
Reads what a spectral scan counted.
setup
The commands that bring a parked radio up for carrier checks.
standby
Parks the radio.
status
Asks the radio how it is.
version
Reads the version string out of what the radio answered.
version_read
Asks the radio which patch it is running.
write_register
Writes one of the radio’s registers.