STM3210E_EVAL_FSMC_NAND_Exported_Functions
[STM3210E_EVAL_FSMC_NAND]

Functions

uint32_t NAND_AddressIncrement (NAND_ADDRESS *Address)
 Increment the NAND memory address.
uint32_t NAND_EraseBlock (NAND_ADDRESS Address)
 This routine erase complete block from NAND FLASH.
uint32_t NAND_GetStatus (void)
 Get the NAND operation status.
void NAND_Init (void)
 Configures the FSMC and GPIOs to interface with the NAND memory.
void NAND_ReadID (NAND_IDTypeDef *NAND_ID)
 Reads NAND memory's ID.
uint32_t NAND_ReadSmallPage (uint8_t *pBuffer, NAND_ADDRESS Address, uint32_t NumPageToRead)
 This routine is for sequential read from one or several 512 Bytes Page size.
uint32_t NAND_ReadSpareArea (uint8_t *pBuffer, NAND_ADDRESS Address, uint32_t NumSpareAreaToRead)
 This routine read the spare area information from the specified pages addresses.
uint32_t NAND_ReadStatus (void)
 Reads the NAND memory status using the Read status command.
uint32_t NAND_Reset (void)
 This routine reset the NAND FLASH.
uint32_t NAND_WriteSmallPage (uint8_t *pBuffer, NAND_ADDRESS Address, uint32_t NumPageToWrite)
 This routine is for writing one or several 512 Bytes Page size.
uint32_t NAND_WriteSpareArea (uint8_t *pBuffer, NAND_ADDRESS Address, uint32_t NumSpareAreaTowrite)
 This routine write the spare area information for the specified pages addresses.

Function Documentation

uint32_t NAND_AddressIncrement ( NAND_ADDRESS Address  ) 

Increment the NAND memory address.

Parameters:
Address,: address to be incremented.
Return values:
The new status of the increment address operation. It can be:

  • NAND_VALID_ADDRESS: When the new address is valid address
  • NAND_INVALID_ADDRESS: When the new address is invalid address

Definition at line 499 of file stm3210e_eval_fsmc_nand.c.

References NAND_ADDRESS::Block, NAND_BLOCK_SIZE, NAND_INVALID_ADDRESS, NAND_MAX_ZONE, NAND_VALID_ADDRESS, NAND_ZONE_SIZE, NAND_ADDRESS::Page, status, and NAND_ADDRESS::Zone.

Referenced by NAND_ReadSmallPage(), NAND_ReadSpareArea(), NAND_WriteSmallPage(), and NAND_WriteSpareArea().

uint32_t NAND_EraseBlock ( NAND_ADDRESS  Address  ) 

This routine erase complete block from NAND FLASH.

Parameters:
Address,: Any address into block to be erased
Return values:
New status of the NAND operation. This parameter can be:

  • NAND_TIMEOUT_ERROR: when the previous operation generate a Timeout error
  • NAND_READY: when memory is ready for the next operation

Definition at line 405 of file stm3210e_eval_fsmc_nand.c.

References ADDR_1st_CYCLE, ADDR_2nd_CYCLE, ADDR_3rd_CYCLE, ADDR_AREA, Bank_NAND_ADDR, CMD_AREA, NAND_CMD_ERASE0, NAND_CMD_ERASE1, NAND_GetStatus(), and ROW_ADDRESS.

Referenced by main().

uint32_t NAND_GetStatus ( void   ) 

Get the NAND operation status.

Parameters:
None 
Return values:
New status of the NAND operation. This parameter can be:

  • NAND_TIMEOUT_ERROR: when the previous operation generate a Timeout error
  • NAND_READY: when memory is ready for the next operation

< Wait for a NAND operation to complete or a TIMEOUT to occur

Definition at line 438 of file stm3210e_eval_fsmc_nand.c.

References NAND_ReadStatus(), NAND_READY, NAND_TIMEOUT_ERROR, and status.

Referenced by NAND_EraseBlock(), NAND_ReadSmallPage(), NAND_ReadSpareArea(), NAND_WriteSmallPage(), and NAND_WriteSpareArea().

void NAND_Init ( void   ) 

Configures the FSMC and GPIOs to interface with the NAND memory.

This function must be called before any write/read operation on the NAND.

Parameters:
None 
Return values:
None 

< CLE, ALE, D0->D3, NOE, NWE and NCE2 NAND pin configuration

< D4->D7 NAND pin configuration

< NWAIT NAND pin configuration

< INT2 NAND pin configuration

< FSMC NAND Bank Cmd Test

Definition at line 100 of file stm3210e_eval_fsmc_nand.c.

References ENABLE, FSMC_NANDInitTypeDef::FSMC_AttributeSpaceTimingStruct, FSMC_NANDInitTypeDef::FSMC_Bank, FSMC_Bank2_NAND, FSMC_NANDInitTypeDef::FSMC_CommonSpaceTimingStruct, FSMC_NANDInitTypeDef::FSMC_ECC, FSMC_ECC_Enable, FSMC_NANDInitTypeDef::FSMC_ECCPageSize, FSMC_ECCPageSize_512Bytes, FSMC_NAND_PCCARDTimingInitTypeDef::FSMC_HiZSetupTime, FSMC_NAND_PCCARDTimingInitTypeDef::FSMC_HoldSetupTime, FSMC_NANDInitTypeDef::FSMC_MemoryDataWidth, FSMC_MemoryDataWidth_8b, FSMC_NANDCmd(), FSMC_NANDInit(), FSMC_NAND_PCCARDTimingInitTypeDef::FSMC_SetupTime, FSMC_NANDInitTypeDef::FSMC_TARSetupTime, FSMC_NANDInitTypeDef::FSMC_TCLRSetupTime, FSMC_NANDInitTypeDef::FSMC_Waitfeature, FSMC_Waitfeature_Enable, FSMC_NAND_PCCARDTimingInitTypeDef::FSMC_WaitSetupTime, GPIO_Init(), GPIO_InitStructure, GPIO_InitTypeDef::GPIO_Mode, GPIO_Mode_AF_PP, GPIO_Mode_IPU, GPIO_InitTypeDef::GPIO_Pin, GPIO_Pin_0, GPIO_Pin_1, GPIO_Pin_10, GPIO_Pin_11, GPIO_Pin_12, GPIO_Pin_14, GPIO_Pin_15, GPIO_Pin_4, GPIO_Pin_5, GPIO_Pin_6, GPIO_Pin_7, GPIO_Pin_8, GPIO_Pin_9, GPIO_InitTypeDef::GPIO_Speed, GPIO_Speed_50MHz, GPIOD, GPIOE, GPIOG, RCC_APB2Periph_GPIOD, RCC_APB2Periph_GPIOE, RCC_APB2Periph_GPIOF, RCC_APB2Periph_GPIOG, and RCC_APB2PeriphClockCmd().

Referenced by main().

void NAND_ReadID ( NAND_IDTypeDef NAND_ID  ) 

Reads NAND memory's ID.

Parameters:
NAND_ID,: pointer to a NAND_IDTypeDef structure which will hold the Manufacturer and Device ID.
Return values:
None 

< Send Command to the command area

< Sequence to read ID from NAND flash

Definition at line 164 of file stm3210e_eval_fsmc_nand.c.

References ADDR_1st_CYCLE, ADDR_2nd_CYCLE, ADDR_3rd_CYCLE, ADDR_4th_CYCLE, ADDR_AREA, Bank_NAND_ADDR, CMD_AREA, DATA_AREA, NAND_IDTypeDef::Device_ID, NAND_IDTypeDef::Fourth_ID, NAND_IDTypeDef::Maker_ID, and NAND_IDTypeDef::Third_ID.

Referenced by main().

uint32_t NAND_ReadSmallPage ( uint8_t *  pBuffer,
NAND_ADDRESS  Address,
uint32_t  NumPageToRead 
)

This routine is for sequential read from one or several 512 Bytes Page size.

Parameters:
pBuffer,: pointer on the Buffer to fill
Address,: First page address
NumPageToRead,: Number of page to read
Return values:
New status of the NAND operation. This parameter can be:

  • NAND_TIMEOUT_ERROR: when the previous operation generate a Timeout error
  • NAND_READY: when memory is ready for the next operation And the new status of the increment address operation. It can be:
  • NAND_VALID_ADDRESS: When the new address is valid address
  • NAND_INVALID_ADDRESS: When the new address is invalid address

< Page Read command and page address

< Calculate the size

< Get Data into Buffer

< Calculate page address

Definition at line 251 of file stm3210e_eval_fsmc_nand.c.

References ADDR_1st_CYCLE, ADDR_2nd_CYCLE, ADDR_3rd_CYCLE, ADDR_AREA, Bank_NAND_ADDR, CMD_AREA, DATA_AREA, index, NAND_AddressIncrement(), NAND_CMD_AREA_A, NAND_GetStatus(), NAND_PAGE_SIZE, NAND_READY, NAND_VALID_ADDRESS, ROW_ADDRESS, and status.

Referenced by main().

uint32_t NAND_ReadSpareArea ( uint8_t *  pBuffer,
NAND_ADDRESS  Address,
uint32_t  NumSpareAreaToRead 
)

This routine read the spare area information from the specified pages addresses.

Parameters:
pBuffer,: pointer on the Buffer to fill
Address,: First page address
NumSpareAreaToRead,: Number of Spare Area to read
Return values:
New status of the NAND operation. This parameter can be:

  • NAND_TIMEOUT_ERROR: when the previous operation generate a Timeout error
  • NAND_READY: when memory is ready for the next operation And the new status of the increment address operation. It can be:
  • NAND_VALID_ADDRESS: When the new address is valid address
  • NAND_INVALID_ADDRESS: When the new address is invalid address

< Page Read command and page address

< Data Read

< Get Data into Buffer

< Calculate page address

Definition at line 360 of file stm3210e_eval_fsmc_nand.c.

References ADDR_1st_CYCLE, ADDR_2nd_CYCLE, ADDR_3rd_CYCLE, ADDR_AREA, Bank_NAND_ADDR, CMD_AREA, DATA_AREA, index, NAND_AddressIncrement(), NAND_CMD_AREA_C, NAND_GetStatus(), NAND_READY, NAND_SPARE_AREA_SIZE, NAND_VALID_ADDRESS, ROW_ADDRESS, and status.

uint32_t NAND_ReadStatus ( void   ) 

Reads the NAND memory status using the Read status command.

Parameters:
None 
Return values:
The status of the NAND memory. This parameter can be:

  • NAND_BUSY: when memory is busy
  • NAND_READY: when memory is ready for the next operation
  • NAND_ERROR: when the previous operation gererates error

< Read status operation ------------------------------------

Definition at line 468 of file stm3210e_eval_fsmc_nand.c.

References Bank_NAND_ADDR, CMD_AREA, NAND_BUSY, NAND_CMD_STATUS, NAND_ERROR, NAND_READY, and status.

Referenced by NAND_GetStatus().

uint32_t NAND_Reset ( void   ) 

This routine reset the NAND FLASH.

Parameters:
None 
Return values:
NAND_READY 

Definition at line 423 of file stm3210e_eval_fsmc_nand.c.

References Bank_NAND_ADDR, CMD_AREA, NAND_CMD_RESET, and NAND_READY.

uint32_t NAND_WriteSmallPage ( uint8_t *  pBuffer,
NAND_ADDRESS  Address,
uint32_t  NumPageToWrite 
)

This routine is for writing one or several 512 Bytes Page size.

Parameters:
pBuffer,: pointer on the Buffer containing data to be written
Address,: First page address
NumPageToWrite,: Number of page to write
Return values:
New status of the NAND operation. This parameter can be:

  • NAND_TIMEOUT_ERROR: when the previous operation generate a Timeout error
  • NAND_READY: when memory is ready for the next operation And the new status of the increment address operation. It can be:
  • NAND_VALID_ADDRESS: When the new address is valid address
  • NAND_INVALID_ADDRESS: When the new address is invalid address

< Page write command and address

< Calculate the size

< Write data

< Check status for successful operation

< Calculate Next small page Address

Definition at line 194 of file stm3210e_eval_fsmc_nand.c.

References ADDR_1st_CYCLE, ADDR_2nd_CYCLE, ADDR_3rd_CYCLE, ADDR_AREA, Bank_NAND_ADDR, CMD_AREA, DATA_AREA, index, NAND_AddressIncrement(), NAND_CMD_AREA_A, NAND_CMD_WRITE0, NAND_CMD_WRITE_TRUE1, NAND_GetStatus(), NAND_PAGE_SIZE, NAND_READY, NAND_VALID_ADDRESS, ROW_ADDRESS, and status.

Referenced by main().

uint32_t NAND_WriteSpareArea ( uint8_t *  pBuffer,
NAND_ADDRESS  Address,
uint32_t  NumSpareAreaTowrite 
)

This routine write the spare area information for the specified pages addresses.

Parameters:
pBuffer,: pointer on the Buffer containing data to be written
Address,: First page address
NumSpareAreaTowrite,: Number of Spare Area to write
Return values:
New status of the NAND operation. This parameter can be:

  • NAND_TIMEOUT_ERROR: when the previous operation generate a Timeout error
  • NAND_READY: when memory is ready for the next operation And the new status of the increment address operation. It can be:
  • NAND_VALID_ADDRESS: When the new address is valid address
  • NAND_INVALID_ADDRESS: When the new address is invalid address

< Page write Spare area command and address

< Calculate the size

< Write the data

< Check status for successful operation

< Calculate Next page Address

Definition at line 302 of file stm3210e_eval_fsmc_nand.c.

References ADDR_1st_CYCLE, ADDR_2nd_CYCLE, ADDR_3rd_CYCLE, ADDR_AREA, Bank_NAND_ADDR, CMD_AREA, DATA_AREA, index, NAND_AddressIncrement(), NAND_CMD_AREA_C, NAND_CMD_WRITE0, NAND_CMD_WRITE_TRUE1, NAND_GetStatus(), NAND_READY, NAND_SPARE_AREA_SIZE, NAND_VALID_ADDRESS, ROW_ADDRESS, and status.

STM32F10x Standard Peripherals Library: Footer

 

 

 

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