pub struct W25<Series, SPI, HOLD, WP> { /* private fields */ }Expand description
Low level driver for the w25 flash memory chip.
Implementations§
Source§impl<Series: NorSeries, SPI, S, P, HOLD, WP> W25<Series, SPI, HOLD, WP>
impl<Series: NorSeries, SPI, S, P, HOLD, WP> W25<Series, SPI, HOLD, WP>
Sourcepub async fn device_id(&mut self) -> Result<[u8; 8], Error<S, P>>
pub async fn device_id(&mut self) -> Result<[u8; 8], Error<S, P>>
Request the 64 bit id that is unique to this chip.
Sourcepub async fn read(
&mut self,
address: u32,
buf: &mut [u8],
) -> Result<(), Error<S, P>>
pub async fn read( &mut self, address: u32, buf: &mut [u8], ) -> Result<(), Error<S, P>>
Reads a chunk of bytes from the flash chip. The number of bytes read is equal to the length of the buf slice. The first byte is read from the provided address. This address is then incremented for each following byte.
§Arguments
address- Address where the first byte of the buf will be read.buf- Slice that is going to be filled with the read bytes.
Sourcepub async fn write(
&mut self,
address: u32,
buf: &[u8],
) -> Result<(), Error<S, P>>
pub async fn write( &mut self, address: u32, buf: &[u8], ) -> Result<(), Error<S, P>>
Writes a chunk of bytes to the flash chip. The first byte is written to the provided address. This address is then incremented for each following byte.
§Arguments
address- Address where the first byte of the buf will be written.buf- Slice of bytes that will be written.
Sourcepub async fn erase_range(
&mut self,
start_address: u32,
end_address: u32,
) -> Result<(), Error<S, P>>
pub async fn erase_range( &mut self, start_address: u32, end_address: u32, ) -> Result<(), Error<S, P>>
Erases a range of sectors. The range is expressed in bytes. These bytes need to be a multiple of SECTOR_SIZE. If the range starts at SECTOR_SIZE * 3 then the erase starts at the fourth sector. All sectors are erased in the range [start_sector..end_sector]. The start address may not be a higher value than the end address.
§Arguments
start_address- Address of the first byte of the start of the range of sectors that need to be erased.end_address- Address of the first byte of the end of the range of sectors that need to be erased.
Sourcepub async fn erase_sector(&mut self, index: u32) -> Result<(), Error<S, P>>
pub async fn erase_sector(&mut self, index: u32) -> Result<(), Error<S, P>>
Erases a single sector of flash memory with the size of SECTOR_SIZE.
§Arguments
index- the index of the sector that needs to be erased. The address of the first byte of the sector is the provided index * SECTOR_SIZE.
Sourcepub async fn erase_block_32k(&mut self, index: u32) -> Result<(), Error<S, P>>
pub async fn erase_block_32k(&mut self, index: u32) -> Result<(), Error<S, P>>
Erases a single block of flash memory with the size of BLOCK_32K_SIZE.
§Arguments
index- the index of the block that needs to be erased. The address of the first byte of the block is the provided index * BLOCK_32K_SIZE.
Sourcepub async fn erase_block_64k(&mut self, index: u32) -> Result<(), Error<S, P>>
pub async fn erase_block_64k(&mut self, index: u32) -> Result<(), Error<S, P>>
Erases a single block of flash memory with the size of BLOCK_64K_SIZE.
§Arguments
index- the index of the block that needs to be erased. The address of the first byte of the block is the provided index * BLOCK_64K_SIZE.
Sourcepub async fn erase_chip(&mut self) -> Result<(), Error<S, P>>
pub async fn erase_chip(&mut self) -> Result<(), Error<S, P>>
Erases all sectors on the flash chip. This is a very expensive operation.
Sourcepub async fn enable_power_down_mode(&mut self) -> Result<(), Error<S, P>>
pub async fn enable_power_down_mode(&mut self) -> Result<(), Error<S, P>>
Puts the chip into power down mode. While in the power-down state, only the Release Power-down/Device ID (0xAB) instruction will be recognized. This instruction restores the device to normal operation. All other instructions are ignored.
Sourcepub async fn disable_power_down_mode(&mut self) -> Result<(), Error<S, P>>
pub async fn disable_power_down_mode(&mut self) -> Result<(), Error<S, P>>
Releases the chip from power down mode. Restores operation from power down mode by reading the deviceID from the device.
Source§impl<Series: NorSeries, SPI, S: Debug, P: Debug, HOLD, WP> W25<Series, SPI, HOLD, WP>
impl<Series: NorSeries, SPI, S: Debug, P: Debug, HOLD, WP> W25<Series, SPI, HOLD, WP>
Sourcepub fn new(
spi: SPI,
hold: HOLD,
wp: WP,
capacity: u32,
) -> Result<Self, Error<S, P>>
pub fn new( spi: SPI, hold: HOLD, wp: WP, capacity: u32, ) -> Result<Self, Error<S, P>>
Create a new instance of the flash.
The capacity must be the total chip capacity. Weird things can happen if you provide the wrong value. No checks are done, you’re believed at your word.
Sourcepub fn set_hold(&mut self, value: PinState) -> Result<(), Error<S, P>>
pub fn set_hold(&mut self, value: PinState) -> Result<(), Error<S, P>>
Set the hold pin state.
The driver doesn’t do anything with this pin. When using the chip, make sure the hold pin is not asserted. By default this means the pin needs to be high (true).
This function sets the pin directly and can cause the chip to not work.
Sourcepub fn set_wp(&mut self, value: PinState) -> Result<(), Error<S, P>>
pub fn set_wp(&mut self, value: PinState) -> Result<(), Error<S, P>>
Set the write protect pin state.
The driver doesn’t do anything with this pin. When using the chip, make sure the hold pin is not asserted. By default this means the pin needs to be high (true).
This function sets the pin directly and can cause the chip to not work.