nand_if.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /******************** (C) COPYRIGHT 2009 STMicroelectronics ********************
  2. * File Name : nand_if.h
  3. * Author : MCD Application Team
  4. * Version : V3.1.0
  5. * Date : 10/30/2009
  6. * Description : All functions related to the NAND process
  7. ********************************************************************************
  8. * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  9. * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
  10. * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
  11. * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
  12. * CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
  13. * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  14. *******************************************************************************/
  15. /* Define to prevent recursive inclusion -------------------------------------*/
  16. #ifndef __NAND_IF_H
  17. #define __NAND_IF_H
  18. /* Includes ------------------------------------------------------------------*/
  19. #include "stm32f10x.h"
  20. /* Exported types ------------------------------------------------------------*/
  21. /* Exported constants --------------------------------------------------------*/
  22. #define NAND_OK 0
  23. #define NAND_FAIL 1
  24. #define FREE_BLOCK (1 << 12 )
  25. #define BAD_BLOCK (1 << 13 )
  26. #define VALID_BLOCK (1 << 14 )
  27. #define USED_BLOCK (1 << 15 )
  28. #define MAX_PHY_BLOCKS_PER_ZONE 1024
  29. #define MAX_LOG_BLOCKS_PER_ZONE 1000
  30. /* Private Structures---------------------------------------------------------*/
  31. typedef struct __SPARE_AREA {
  32. uint16_t LogicalIndex;
  33. uint16_t DataStatus;
  34. uint16_t BlockStatus;
  35. } SPARE_AREA;
  36. typedef enum {
  37. WRITE_IDLE = 0,
  38. POST_WRITE,
  39. PRE_WRITE,
  40. WRITE_CLEANUP,
  41. WRITE_ONGOING
  42. }WRITE_STATE;
  43. typedef enum {
  44. OLD_BLOCK = 0,
  45. UNUSED_BLOCK
  46. }BLOCK_STATE;
  47. /* Private macro --------------------------------------------------------------*/
  48. //#define WEAR_LEVELLING_SUPPORT
  49. #define WEAR_DEPTH 10
  50. #define PAGE_TO_WRITE (Transfer_Length/512)
  51. /* Private variables ----------------------------------------------------------*/
  52. /* Private function prototypes ------------------------------------------------*/
  53. /* exported functions ---------------------------------------------------------*/
  54. uint16_t NAND_Init (void);
  55. uint16_t NAND_Write (uint32_t Memory_Offset, uint32_t *Writebuff, uint16_t Transfer_Length);
  56. uint16_t NAND_Read (uint32_t Memory_Offset, uint32_t *Readbuff, uint16_t Transfer_Length);
  57. uint16_t NAND_Format (void);
  58. SPARE_AREA ReadSpareArea (uint32_t address);
  59. #endif
  60. /******************* (C) COPYRIGHT 2009 STMicroelectronics *****END OF FILE****/