pub const fn read(target: u8, address: u16) -> [u8; 5]Expand description
Builds the transfer that reads one byte from a register.
§Arguments
target- which chip the transfer is for.address- the register address.
§Returns
The bytes to clock out. The chip answers in the last byte of what comes back, which
read_value takes.
§Examples
use pamoja_radios::sx1302::register::COMMON_VERSION;
use pamoja_radios::sx1302::spi::{read, read_value, TARGET_CONCENTRATOR};
// The target, the address most significant byte first, a dummy, and the answer's slot.
let [high, low] = COMMON_VERSION.address.to_be_bytes();
let out = read(TARGET_CONCENTRATOR, COMMON_VERSION.address);
assert_eq!(out, [TARGET_CONCENTRATOR, high, low, 0, 0]);
// What the bus returned while those bytes went out: a version of 0x10, in the last one.
assert_eq!(read_value(&[0, 0, 0, 0, 0x10]), Some(0x10));