• 大小: 7KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-19
  • 语言: 其他
  • 标签: W25N01G  

资源简介

uint8_t Program_verify(uint8_t* buff1, uint8_t* buff2, uint32_t count); void WB_Serial_NAND_Pageprogram_Pattern(uint8_t addh, uint8_t addl, uint8_t* program_buffer, uint32_t count); void WB_Serial_NAND_Program_Excute(uint8_t addh, uint8_t addl); /* status check */ uint8_t WB_Check_Embedded_ECC(); uint8_t WB_Check_Program_Erase_Fail_Flag(); uint8_t WB_Read_Serial_NAND_StatusRegister(uint8_t sr_sel); void WB_Serial_NAND_ReadyBusy_Check(); uint32_t WB_NAND_Read_JEDEC_ID(); uint8_t WB_Serial_NAND_bad_block_check(uint32_t page_address); void WB_Serial_NAND_LUT_Read(uint16_t* LBA, uint16_t* PBA); /* Stack function for W25M series */ void WB_Die_Select(uint8_t select_die); /* status set */ void WB_Enable_Embedded_ECC(); void WB_Disable_Embedded_ECC(); void WB_Enable_Buffer_mode(); void WB_Disable_Buffer_mode(); void WB_Serial_NAND_StatusRegister_Write_SR1(uint8_t SR1); void WB_Serial_NAND_StatusRegister_Write_SR2(uint8_t SR2); void WB_Serial_NAND_StatusRegister_Write_SR3(uint8_t SR3); void WB_NAND_Reset(); void WB_Protect(); void WB_Unprotect(); void WB_Serial_NAND_LUT_Set(uint16_t LBA, uint16_t PBA); /* erase function */ void WB_Serial_NAND_BlockErase(uint8_t PA_H, uint8_t PA_L); /* read function */ void WB_Serial_NAND_PageDataRead(uint8_t PA_H, uint8_t PA_L); void WB_Serial_NAND_Normal_Read(uint8_t addh, uint8_t addl, uint8_t* buff, uint32_t count); void WB_Serial_NAND_Continuous_Normal_Read(uint8_t* buff, uint32_t count);

资源截图

代码片段和文件信息

/**
  ******************************************************************************
  * @file    /WB_SerialNAND_Sample_Code_LLD.c
  * @author  Winbond FAE Steam Lin
  * @version V1.0.4
  * @date    9-March-2016
  * @brief   This code provide the basic Serial NAND Flash application cover ONFI NAND Flash working behavior based on STM32F205 
  *            
  * COPYRIGHT 2015 Winbond.
*/ 

#include 
#include “WB_SerialNAND_Sample_Code_LLD.h“

#define Page_size 0x800 // 2048 bytes per page
#define Spare_size 0x40 // 64 bytes per page spare area
#define Block_size 0x40 // 64 pages per block
#define Block_count 0x400 // 1024 blocks per 1G NAND
#define status_ok 0x00
#define ID_error 0x01
#define Read_error 0x02
#define Erase_error 0x03
#define Program_error 0x04
#define Bad_block_count_over 0x05

uint32_t Chip_size = Page_size*Block_size*Block_count;

// Address data mapping follow W25N01GV datasheet user could modify according to the controller memory mapping method

#define ADDR_Col_CA15_CA8(ADD) (uint8_t)(((ADD) & 0x0F00) >> 8)
#define ADDR_Col_CA7_CA0(ADD) (uint8_t)((ADD) & 0xFF)
#define ADDR_Row_PA15_PA8(ADD) (uint8_t)(((ADD) & 0xFF00000) >> 20)
#define ADDR_Row_PA7_PA0(ADD) (uint8_t)(((ADD) & 0xFF000) >> 12)

void main(){
Initial_Serial_NAND();
Check_JEDEC_ID();
Check_Serial_NAND_Read_Write();
}

void Die_Select_Sample(){
WB_Die_Select(0x00); // Select default die
WB_Die_Select(0x01); // Select the other 1G NAND Flash die
}

void Continuous_Read_Sample(){
uint8_t read_buf[Chip_size]; // read whole Flash data
WB_Disable_Buffer_mode(); // Enter continuous read mode
WB_Serial_NAND_PageDataRead(0x00 0x00); // Load paga data address at 0x00
WB_Serial_NAND_Continuous_Normal_Read(read_buf Chip_size);
}

void Initial_Serial_NAND(){
PCB_SPI_Bus_Init();  // Initial MOSI MISO and CLK 
PCB_SPI_IO_Init(); // Initial CS WP CLK
PCB_Power_on(); // Flash power on function prototype
WB_NAND_Reset(); // Reset instruction Serial NAND enter in buffer mode
//WB_Disable_embedded_ECC(); // After power on Winbond Serial NAND ECC-E default = 1. Set ECC-E = 0 to disable embedded ECC
}

uint8_t Check_JEDEC_ID(){
uint32_t JEDEC_ID;
JEDEC_ID = WB_NAND_Read_JEDEC_ID(); // Read JEDEC_ID
if(JEDEC_ID != 0xEFAA21){
return ID_error;
}
else{
return status_ok;
}
}

uint8_t Check_Serial_NAND_Read_Write(){
uint32_t memory_offset = 0;  // Flash Address to access
uint8_t read_buffer[Page_size];
uint8_t program_buffer[Page_size];
uint8_t EPR_status; // Check Erase program read status
uint32_t i;

/*Do un-protect */
WB_Unprotect();

/*Winbond Serial NAND Flash default ECC-enable
//WB_Enable_embedded_ECC();
//WB_Disable_embedded_ECC();

/*Do block erase*/
//WB_Serial_NAND_BlockErase( ADDR_Row_PA15_PA8(memory_offset) ADDR_Row_PA7_PA0(memory_offset) ); // Do Erase
WB_Serial_NAND_BlockErase(0 0); // 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        2117  2016-03-09 10:39  Read_me.txt
     文件        5979  2016-03-09 10:38  WB_SerialNAND_Sample_Code_APP.c
     文件       15195  2016-03-09 09:42  WB_SerialNAND_Sample_Code_LLD.c
     文件        2089  2016-03-09 09:43  WB_SerialNAND_Sample_Code_LLD.h

评论

共有 条评论