fn sector_erase_program(
        &self,
        flash: &mut Flasher,
        sectors: &[FlashSector],
    ) -> Result<(), FlashBuilderError> {
        let number_of_sectors_to_be_programmed = sectors
            .iter()
            .filter(|s| s.is_pages_to_be_programmed())
            .count();
        log::debug!("Flashing {} sectors.", number_of_sectors_to_be_programmed);
        let mut i = 0;
        for sector in sectors {
            if sector.is_pages_to_be_programmed() {
                log::debug!("Erasing sector {}", i);
                flash.run_erase(|active| active.erase_sector(sector.address))?;

                log::debug!("Programming sector {}", i);
                for page in &sector.pages {
                    flash.run_program(|active| {
                        active.program_page(page.address, page.data.as_slice())
                    })?;
                }
            }
            i += 1;
        }
        Ok(())
    }
/// Program by performing sector erases.
Program by performing sector erases.
Program by performing sector erases .
fn sector_erase_program(
        &self,
        flash: &mut Flasher,
        sectors: &[FlashSector],
    ) -> Result<(), FlashBuilderError> {
        let number_of_sectors_to_be_programmed = sectors
            .iter()
            .filter(|s| s.is_pages_to_be_programmed())
            .count();
        log::debug!("Flashing {} sectors.", number_of_sectors_to_be_programmed);
        let mut i = 0;
        for sector in sectors {
            if sector.is_pages_to_be_programmed() {
                log::debug!("Erasing sector {}", i);
                flash.run_erase(|active| active.erase_sector(sector.address))?;
                log::debug!("Programming sector {}", i);
                for page in &sector.pages {
                    flash.run_program(|active| {
                        active.program_page(page.address, page.data.as_slice())
                    })?;
                }
            }
            i += 1;
        }
        Ok(())
    }
fn sector_erase_program ( & self , flash : & mut Flasher , sectors : & [ FlashSector ] , ) -> Result < ( ) , FlashBuilderError > { let number_of_sectors_to_be_programmed = sectors . iter ( ) . filter ( | s | s . is_pages_to_be_programmed ( ) ) . count ( ) ; log :: debug ! ( " " number_of_sectors_to_be_programmed ) ; let mut i = 0 ; for sector in sectors { if sector . is_pages_to_be_programmed ( ) { log :: debug ! ( " " i ) ; flash . run_erase ( | active | active . erase_sector ( sector . address ) ) ? ; log :: debug ! ( " " i ) ; for page in & sector . pages { flash . run_program ( | active | { active . program_page ( page . address , page . data . as_slice ( ) ) } ) ? ; } } i += 1 ; } Ok ( ( ) ) }
Program by performing sector erases.
Program by performing sector erases .
&self
flash
&mut Flasher
sectors
&[FlashSector]