Skip to main content

open_sx1302

Function open_sx1302 

Source
pub fn open_sx1302(
    wiring: &Wiring,
) -> Result<(LinuxConcentrator, Option<Line>), OpenError>
Expand description

Opens an SX1302 or SX1303 concentrator and pulses its reset line.

Unlike a transceiver, a concentrator is not ready when this returns. It answers on the bus, which is what the reset buys, but it hears nothing until its two microcontrollers are given firmware, and those images belong to the caller. So this hands back a handle to check with Sx1302::check and load with Sx1302::load_firmware, rather than pretending to an initialization it cannot finish.

§Arguments

  • wiring - the SPI device and the reset line. The concentrator has no BUSY pin, so busy_line is ignored.

§Returns

The concentrator, reset and answering, and the supply line for a board that gates one.

That second value has to be kept for as long as the concentrator is used. A GPIO line is released when the handle holding it is dropped, so letting it go switches the card off again, and the card then answers nothing while every other part of the configuration looks right. Bind it to a name rather than to _.

§Errors

Returns OpenError::Unsupported on any platform but Linux, and OpenError::Bus if the SPI device, the reset line, or the supply line cannot be opened.