Skip to main content

field

Function field 

Source
pub const fn field(byte: u8, offset: u8, width: u8) -> u8
Expand description

Reads the bits a register holds out of the byte it lives in.

§Arguments

  • byte - the byte the register was read from.
  • offset - which bit the field starts at.
  • width - how many bits it spans.

§Returns

The field, shifted down to where it can be read as a number.

§Examples

use pamoja_radios::sx1302::spi::field;

// The checksum status sits in the top four bits of the OTP status byte.
assert_eq!(field(0xa0, 4, 4), 0x0a);