Skip to main content

Module spi

Module spi 

Source
Expand description

The SPI transactions the SX1302 answers.

Every transfer starts with a target byte, because the concentrator sits in front of the radios and passes a transfer through to whichever the first byte names. After that comes a command byte carrying the access bit and the top seven bits of the address, then the low eight bits, then the data.

A read costs two bytes more than a write: the chip needs a byte to turn the bus around, so the host clocks out a dummy and reads the answer in the last byte it receives.

These functions build the bytes and read them back. They touch no bus, so a caller can check a frame against the datasheet, or replay one captured from a working gateway, without any hardware present.

Constants§

BURST_CHUNK
The most bytes one burst carries before the host starts another.
BURST_READ_HEADER_LEN
How many bytes the header of a burst read takes, before the data.
BURST_WRITE_HEADER_LEN
How many bytes the header of a burst write takes, before the data.
CLOCK_HZ
The clock the concentrator is driven at, in hertz.
READ_ACCESS
The access bit for a read, which is the absence of the write bit.
READ_LEN
How many bytes a single-byte read transfer takes.
TARGET_CONCENTRATOR
The concentrator itself, rather than a radio behind it.
TARGET_RADIO_A
The radio on the first chain, reached through the concentrator.
TARGET_RADIO_B
The radio on the second chain.
WRITE_ACCESS
The access bit for a write, the top bit of the command byte.
WRITE_LEN
How many bytes a single-byte write transfer takes.

Functions§

burst_read_header
Builds the header that precedes the data of a burst read.
burst_write_header
Builds the header that precedes the data of a burst write.
chunks
Walks a long transfer as the chunks it actually goes out in.
field
Reads the bits a register holds out of the byte it lives in.
read
Builds the transfer that reads one byte from a register.
read_value
Takes the byte a read transfer brought back.
with_field
Puts a value into the bits a register holds, leaving the rest of the byte alone.
write
Builds the transfer that writes one byte to a register.