pub const fn offset_value(offset_hz: i32) -> u16Expand description
Turns an offset from the carrier into the value a channel register takes.
The chip counts in steps of its own, not in hertz: the register is the offset times 32 over 15625, which divides exactly. A negative offset is carried as the low thirteen bits, which is what the two registers hold between them.
§Arguments
offset_hz- how far from the carrier, which is signed.
§Returns
The value, of which the high five bits and the low eight are written separately.
§Examples
use pamoja_radios::sx1302::channel::offset_value;
// A channel 400 kHz below the carrier.
assert_eq!(offset_value(-400_000), (-819i16) as u16 & 0x1fff);
// And one on it.
assert_eq!(offset_value(0), 0);