nandflash.h
Go to the documentation of this file.00001
00017 #ifndef __NANDFLASH_H
00018 #define __NANDFLASH_H
00019
00020
00025
00030 #ifdef __cplusplus
00031 extern "C" {
00032 #endif
00033
00034 #define NAND256W3A_SPARESIZE 16
00036
00037 #define NAND_SPARE_BADBLOCK_POS 5
00038 #define NAND_SPARE_ECC0_POS 6
00039 #define NAND_SPARE_ECC1_POS 7
00040 #define NAND_SPARE_ECC2_POS 8
00043 typedef enum
00044 {
00045 NANDFLASH_STATUS_OK = 0,
00046 NANDFLASH_INVALID_DEVICE = -1,
00047 NANDFLASH_INVALID_ADDRESS = -2,
00048 NANDFLASH_WRITE_ERROR = -3,
00049 NANDFLASH_ECC_ERROR = -4,
00050 NANDFLASH_ECC_UNCORRECTABLE = -5,
00051 NANDFLASH_INVALID_SETUP = -6,
00052 NANDFLASH_NOT_INITIALIZED = -7,
00053 } NANDFLASH_Status_TypeDef;
00054
00056 typedef struct
00057 {
00058 uint32_t baseAddress;
00059 uint8_t manufacturerCode;
00060 uint8_t deviceCode;
00061 uint32_t deviceSize;
00062 uint32_t pageSize;
00063 uint32_t spareSize;
00064 uint32_t blockSize;
00065 uint32_t ecc;
00066 uint8_t spare[ NAND256W3A_SPARESIZE ];
00067 int dmaCh;
00068 } NANDFLASH_Info_TypeDef;
00069
00070 bool NANDFLASH_AddressValid(uint32_t addr);
00071 int NANDFLASH_CopyPage(uint32_t dstAddr, uint32_t srcAddr);
00072 NANDFLASH_Info_TypeDef *
00073 NANDFLASH_DeviceInfo(void);
00074 int NANDFLASH_EccCorrect(uint32_t generatedEcc, uint32_t readEcc, uint8_t *data);
00075 int NANDFLASH_EraseBlock(uint32_t address);
00076 int NANDFLASH_Init(int dmaCh);
00077 int NANDFLASH_MarkBadBlock(uint32_t address);
00078 int NANDFLASH_ReadPage(uint32_t address, uint8_t *buffer);
00079 int NANDFLASH_ReadSpare(uint32_t address, uint8_t *buffer);
00080 int NANDFLASH_WritePage(uint32_t address, uint8_t *buffer);
00081
00082 #ifdef __cplusplus
00083 }
00084 #endif
00085
00089 #endif