STM32_EVAL_SPI_FLASH_Private_Functions
[STM32_EVAL_SPI_FLASH]

Functions

void sFLASH_DeInit (void)
 DeInitializes the peripherals used by the SPI FLASH driver.
void sFLASH_EraseBulk (void)
 Erases the entire FLASH.
void sFLASH_EraseSector (uint32_t SectorAddr)
 Erases the specified FLASH sector.
void sFLASH_Init (void)
 Initializes the peripherals used by the SPI FLASH driver.
void sFLASH_ReadBuffer (uint8_t *pBuffer, uint32_t ReadAddr, uint16_t NumByteToRead)
 Reads a block of data from the FLASH.
uint8_t sFLASH_ReadByte (void)
 Reads a byte from the SPI Flash.
uint32_t sFLASH_ReadID (void)
 Reads FLASH identification.
uint8_t sFLASH_SendByte (uint8_t byte)
 Sends a byte through the SPI interface and return the byte received from the SPI bus.
uint16_t sFLASH_SendHalfWord (uint16_t HalfWord)
 Sends a Half Word through the SPI interface and return the Half Word received from the SPI bus.
void sFLASH_StartReadSequence (uint32_t ReadAddr)
 Initiates a read data byte (READ) sequence from the Flash.
void sFLASH_WaitForWriteEnd (void)
 Polls the status of the Write In Progress (WIP) flag in the FLASH's status register and loop until write opertaion has completed.
void sFLASH_WriteBuffer (uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite)
 Writes block of data to the FLASH.
void sFLASH_WriteEnable (void)
 Enables the write access to the FLASH.
void sFLASH_WritePage (uint8_t *pBuffer, uint32_t WriteAddr, uint16_t NumByteToWrite)
 Writes more than one byte to the FLASH with a single WRITE cycle (Page WRITE sequence).

Function Documentation

void sFLASH_DeInit ( void   ) 

DeInitializes the peripherals used by the SPI FLASH driver.

High layer functions.

Parameters:
None 
Return values:
None 

Definition at line 114 of file stm32_eval_spi_flash.c.

References sFLASH_LowLevel_DeInit().

void sFLASH_EraseBulk ( void   ) 

Erases the entire FLASH.

Parameters:
None 
Return values:
None 

< Send write enable instruction

< Bulk Erase

< Select the FLASH: Chip Select low

< Send Bulk Erase instruction

< Deselect the FLASH: Chip Select high

< Wait the end of Flash writing

Definition at line 187 of file stm32_eval_spi_flash.c.

References sFLASH_CMD_BE, sFLASH_CS_HIGH, sFLASH_CS_LOW, sFLASH_SendByte(), sFLASH_WaitForWriteEnd(), and sFLASH_WriteEnable().

void sFLASH_EraseSector ( uint32_t  SectorAddr  ) 

Erases the specified FLASH sector.

Parameters:
SectorAddr,: address of the sector to erase.
Return values:
None 

< Send write enable instruction

< Sector Erase

< Select the FLASH: Chip Select low

< Send Sector Erase instruction

< Send SectorAddr high nibble address byte

< Send SectorAddr medium nibble address byte

< Send SectorAddr low nibble address byte

< Deselect the FLASH: Chip Select high

< Wait the end of Flash writing

Definition at line 159 of file stm32_eval_spi_flash.c.

References sFLASH_CMD_SE, sFLASH_CS_HIGH, sFLASH_CS_LOW, sFLASH_SendByte(), sFLASH_WaitForWriteEnd(), and sFLASH_WriteEnable().

Referenced by main().

void sFLASH_Init ( void   ) 
void sFLASH_ReadBuffer ( uint8_t *  pBuffer,
uint32_t  ReadAddr,
uint16_t  NumByteToRead 
)

Reads a block of data from the FLASH.

Parameters:
pBuffer,: pointer to the buffer that receives the data read from the FLASH.
ReadAddr,: FLASH's internal address to read from.
NumByteToRead,: number of bytes to read from the FLASH.
Return values:
None 

< Select the FLASH: Chip Select low

< Send "Read from Memory " instruction

< Send ReadAddr high nibble address byte to read from

< Send ReadAddr medium nibble address byte to read from

< Send ReadAddr low nibble address byte to read from

< while there is data to be read

< Read a byte from the FLASH

< Point to the next location where the byte read will be saved

Definition at line 334 of file stm32_eval_spi_flash.c.

References sFLASH_CMD_READ, sFLASH_CS_HIGH, sFLASH_CS_LOW, sFLASH_DUMMY_BYTE, and sFLASH_SendByte().

Referenced by main().

uint8_t sFLASH_ReadByte ( void   ) 

Reads a byte from the SPI Flash.

Low layer functions.

Note:
This function must be used only if the Start_Read_Sequence function has been previously called.
Parameters:
None 
Return values:
Byte Read from the SPI Flash.

Definition at line 426 of file stm32_eval_spi_flash.c.

References sFLASH_DUMMY_BYTE, and sFLASH_SendByte().

uint32_t sFLASH_ReadID ( void   ) 

Reads FLASH identification.

Parameters:
None 
Return values:
FLASH identification

< Select the FLASH: Chip Select low

< Send "RDID " instruction

< Read a byte from the FLASH

< Read a byte from the FLASH

< Read a byte from the FLASH

< Deselect the FLASH: Chip Select high

Definition at line 366 of file stm32_eval_spi_flash.c.

References sFLASH_CS_HIGH, sFLASH_CS_LOW, sFLASH_DUMMY_BYTE, and sFLASH_SendByte().

Referenced by main().

uint8_t sFLASH_SendByte ( uint8_t  byte  ) 

Sends a byte through the SPI interface and return the byte received from the SPI bus.

Parameters:
byte,: byte to send.
Return values:
The value of the received byte.

< Loop while DR register in not emplty

< Send byte through the SPI1 peripheral

< Wait to receive a byte

< Return the byte read from the SPI bus

Definition at line 437 of file stm32_eval_spi_flash.c.

References RESET, sFLASH_SPI, SPI_I2S_FLAG_RXNE, SPI_I2S_FLAG_TXE, SPI_I2S_GetFlagStatus(), SPI_I2S_ReceiveData(), and SPI_I2S_SendData().

Referenced by sFLASH_EraseBulk(), sFLASH_EraseSector(), sFLASH_ReadBuffer(), sFLASH_ReadByte(), sFLASH_ReadID(), sFLASH_StartReadSequence(), sFLASH_WaitForWriteEnd(), sFLASH_WriteEnable(), and sFLASH_WritePage().

uint16_t sFLASH_SendHalfWord ( uint16_t  HalfWord  ) 

Sends a Half Word through the SPI interface and return the Half Word received from the SPI bus.

Parameters:
HalfWord,: Half Word to send.
Return values:
The value of the received Half Word.

< Loop while DR register in not emplty

< Send Half Word through the sFLASH peripheral

< Wait to receive a Half Word

< Return the Half Word read from the SPI bus

Definition at line 458 of file stm32_eval_spi_flash.c.

References RESET, sFLASH_SPI, SPI_I2S_FLAG_RXNE, SPI_I2S_FLAG_TXE, SPI_I2S_GetFlagStatus(), SPI_I2S_ReceiveData(), and SPI_I2S_SendData().

void sFLASH_StartReadSequence ( uint32_t  ReadAddr  ) 

Initiates a read data byte (READ) sequence from the Flash.

This is done by driving the /CS line low to select the device, then the READ instruction is transmitted followed by 3 bytes address. This function exit and keep the /CS line low, so the Flash still being selected. With this technique the whole content of the Flash is read with a single READ instruction.

Parameters:
ReadAddr,: FLASH's internal address to read from.
Return values:
None 

< Select the FLASH: Chip Select low

< Send "Read from Memory " instruction

< Send the 24-bit address of the address to read from -------------------

< Send ReadAddr high nibble address byte

< Send ReadAddr medium nibble address byte

< Send ReadAddr low nibble address byte

Definition at line 402 of file stm32_eval_spi_flash.c.

References sFLASH_CMD_READ, sFLASH_CS_LOW, and sFLASH_SendByte().

void sFLASH_WaitForWriteEnd ( void   ) 

Polls the status of the Write In Progress (WIP) flag in the FLASH's status register and loop until write opertaion has completed.

Parameters:
None 
Return values:
None 

< Select the FLASH: Chip Select low

< Send "Read Status Register" instruction

< Loop as long as the memory is busy with a write cycle

< Send a dummy byte to generate the clock needed by the FLASH and put the value of the status register in FLASH_Status variable

< Deselect the FLASH: Chip Select high

Definition at line 496 of file stm32_eval_spi_flash.c.

References SET, sFLASH_CMD_RDSR, sFLASH_CS_HIGH, sFLASH_CS_LOW, sFLASH_DUMMY_BYTE, sFLASH_SendByte(), and sFLASH_WIP_FLAG.

Referenced by sFLASH_EraseBulk(), sFLASH_EraseSector(), and sFLASH_WritePage().

void sFLASH_WriteBuffer ( uint8_t *  pBuffer,
uint32_t  WriteAddr,
uint16_t  NumByteToWrite 
)

Writes block of data to the FLASH.

In this function, the number of WRITE cycles are reduced, using Page WRITE sequence.

Parameters:
pBuffer,: pointer to the buffer containing the data to be written to the FLASH.
WriteAddr,: FLASH's internal address to write to.
NumByteToWrite,: number of bytes to write to the FLASH.
Return values:
None 

< WriteAddr is sFLASH_PAGESIZE aligned

< NumByteToWrite < sFLASH_PAGESIZE

< NumByteToWrite > sFLASH_PAGESIZE

< WriteAddr is not sFLASH_PAGESIZE aligned

< NumByteToWrite < sFLASH_PAGESIZE

< (NumByteToWrite + WriteAddr) > sFLASH_PAGESIZE

< NumByteToWrite > sFLASH_PAGESIZE

Definition at line 256 of file stm32_eval_spi_flash.c.

References sFLASH_SPI_PAGESIZE, and sFLASH_WritePage().

Referenced by main().

void sFLASH_WriteEnable ( void   ) 

Enables the write access to the FLASH.

Parameters:
None 
Return values:
None 

< Select the FLASH: Chip Select low

< Send "Write Enable" instruction

< Deselect the FLASH: Chip Select high

Definition at line 478 of file stm32_eval_spi_flash.c.

References sFLASH_CMD_WREN, sFLASH_CS_HIGH, sFLASH_CS_LOW, and sFLASH_SendByte().

Referenced by sFLASH_EraseBulk(), sFLASH_EraseSector(), and sFLASH_WritePage().

void sFLASH_WritePage ( uint8_t *  pBuffer,
uint32_t  WriteAddr,
uint16_t  NumByteToWrite 
)

Writes more than one byte to the FLASH with a single WRITE cycle (Page WRITE sequence).

Note:
The number of byte can't exceed the FLASH page size.
Parameters:
pBuffer,: pointer to the buffer containing the data to be written to the FLASH.
WriteAddr,: FLASH's internal address to write to.
NumByteToWrite,: number of bytes to write to the FLASH, must be equal or less than "sFLASH_PAGESIZE" value.
Return values:
None 

< Enable the write access to the FLASH

< Select the FLASH: Chip Select low

< Send "Write to Memory " instruction

< Send WriteAddr high nibble address byte to write to

< Send WriteAddr medium nibble address byte to write to

< Send WriteAddr low nibble address byte to write to

< while there is data to be written on the FLASH

< Send the current byte

< Point on the next byte to be written

< Wait the end of Flash writing

Definition at line 215 of file stm32_eval_spi_flash.c.

References sFLASH_CMD_WRITE, sFLASH_CS_HIGH, sFLASH_CS_LOW, sFLASH_SendByte(), sFLASH_WaitForWriteEnd(), and sFLASH_WriteEnable().

Referenced by sFLASH_WriteBuffer().

STM32F10x Standard Peripherals Library: Footer

 

 

 

      For complete documentation on STM32(CORTEX M3) 32-bit Microcontrollers platform visit  www.st.com/STM32