RKTK API Docs RKTK Home Repo

rktk_drivers_rp/
flash.rs

1use embassy_rp::{Peri, dma::AnyChannel, flash::Flash, peripherals::FLASH};
2use rktk::drivers::interface::storage::StorageDriver;
3use rktk_drivers_common::storage::flash_sequential_map::FlashSequentialMapStorage;
4
5/// Utility to initialize flash and initialize it as storage driver.
6///
7/// This function uses fixed flash area for storage: from 1MB to 3MB.
8/// If you need different area, you can create [`Flash`] and [`FlashSequentialMapStorage`] directly.
9pub fn init_storage<const SIZE: usize>(
10    flash: Peri<'static, FLASH>,
11    dma: Peri<'static, AnyChannel>,
12) -> impl StorageDriver {
13    let flash = Flash::<_, _, SIZE>::new(flash, dma);
14
15    const FLASH_START: u32 = 1024 * 1024;
16    const FLASH_SIZE: u32 = 2 * 1024 * 1024;
17
18    FlashSequentialMapStorage::new(flash, FLASH_START, FLASH_SIZE)
19}