Skip to main content

chunks

Function chunks 

Source
pub fn chunks(address: u16, len: usize) -> impl Iterator<Item = (u16, usize)>
Expand description

Walks a long transfer as the chunks it actually goes out in.

A burst longer than BURST_CHUNK is sent as several, each with a header of its own and an address advanced by everything already written.

§Arguments

  • address - where the first byte lands.
  • len - how many bytes there are in all.

§Returns

The address and length of each chunk, in the order they go out.

§Examples

use pamoja_radios::sx1302::spi::chunks;

// The microcontroller firmware is eight kilobytes, which is eight full chunks.
let plan: Vec<_> = chunks(0x0000, 8192).collect();
assert_eq!(plan.len(), 8);
assert_eq!(plan[0], (0x0000, 1024));
assert_eq!(plan[7], (0x1c00, 1024));