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 untilcommitis sent. - Whether it took is read as text.
PRAM_VERSIONis 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.
- Command
Status - 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.
- Patch
Error - What went wrong reading a patch.
- Scan
Status - 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_UPDATEonce the patch is written. - PATCH_
UPDATE_ OPEN - Opens
REG_PATCH_UPDATEso 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_SENSITIVITYis 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.