SAM3S8/SD8 Software Package: libraries/memories/include/NandFlashModel.h Source File

SAM3S8/SD8 Software Package 1.2

# NandFlashModel.h

Go to the documentation of this file.

    00001 /* ----------------------------------------------------------------------------
    00002  *         ATMEL Microcontroller Software Support
    00003  * ----------------------------------------------------------------------------
    00004  * Copyright (c) 2009, Atmel Corporation
    00005  *
    00006  * All rights reserved.
    00007  *
    00008  * Redistribution and use in source and binary forms, with or without
    00009  * modification, are permitted provided that the following conditions are met:
    00010  *
    00011  * - Redistributions of source code must retain the above copyright notice,
    00012  * this list of conditions and the disclaimer below.
    00013  *
    00014  * Atmel's name may not be used to endorse or promote products derived from
    00015  * this software without specific prior written permission.
    00016  *
    00017  * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
    00018  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
    00019  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
    00020  * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
    00021  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    00022  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
    00023  * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
    00024  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
    00025  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
    00026  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    00027  * ----------------------------------------------------------------------------
    00028  */
    00029
    00030 /**
    00031  * \file
    00032  *
    00033  * Type and methods for manipulating NandFlash models.
    00034  *
    00035  * -# Find the model of a NandFlash using its device ID with the NandFlashModel_Find function.
    00036  *
    00037  * -# Retrieve parameters of a NandFlash model using the following functions:
    00038  *      - NandFlashModel_GetDeviceId
    00039  *      - NandFlashModel_GetDeviceSizeInBlocks
    00040  *      - NandFlashModel_GetDeviceSizeInPages
    00041  *      - NandFlashModel_GetDeviceSizeInBytes
    00042  *      - NandFlashModel_GetBlockSizeInPages
    00043  *      - NandFlashModel_GetBlockSizeInBytes
    00044  *      - NandFlashModel_GetPageDataSize
    00045  *      - NandFlashModel_GetPageSpareSize
    00046  *      - NandFlashModel_GetDataBusWidth
    00047  *      - NandFlashModel_UsesSmallBlocksRead
    00048  *      - NandFlashModel_UsesSmallBlocksWrite
    00049  */
    00050
    00051 #ifndef NANDFLASHMODEL_H
    00052 #define NANDFLASHMODEL_H
    00053
    00054 /*----------------------------------------------------------------------------
    00055  *        Forward declarations
    00056  *----------------------------------------------------------------------------*/
    00057 struct NandSpareScheme;
    00058
    00059 /*----------------------------------------------------------------------------
    00060  *        Definitions
    00061  *----------------------------------------------------------------------------*/
    00062
    00063 /**
    00064   * NandFlashModel_opts NandFlashModel options
    00065   * - NandFlashModel_DATABUS8
    00066   * - NandFlashModel_DATABUS16
    00067   * - NandFlashModel_COPYBACK
    00068 */
    00069
    00070 /** Indicates the Nand uses an 8-bit databus. */
    00071 #define NandFlashModel_DATABUS8     (0 << 0)
    00072
    00073 /** Indicates the Nand uses a 16-bit databus.*/
    00074 #define NandFlashModel_DATABUS16    (1 << 0)
    00075
    00076 /** The Nand supports the copy-back function (internal page-to-page copy).*/
    00077 #define NandFlashModel_COPYBACK     (1 << 1)
    00078
    00079
    00080 /*----------------------------------------------------------------------------
    00081  *        Types
    00082  *----------------------------------------------------------------------------*/
    00083
    00084 /** \brief Describes a particular model of NandFlash device.*/
    00085 struct NandFlashModel {
    00086
    00087     /** Identifier for the device.*/
    00088     unsigned char deviceId;
    00089     /** Special options for the NandFlash.*/
    00090     unsigned char options;
    00091     /** Size of the data area of a page, in bytes.*/
    00092     unsigned short pageSizeInBytes;
    00093     /** Size of the device in MB.*/
    00094     unsigned short deviceSizeInMegaBytes;
    00095     /** Size of one block in kilobytes.*/
    00096     unsigned short blockSizeInKBytes;
    00097     /** Spare area placement scheme*/
    00098     const struct NandSpareScheme *scheme;
    00099 };
    00100
    00101 /*----------------------------------------------------------------------------
    00102  *        Exported functions
    00103  *----------------------------------------------------------------------------*/
    00104 extern unsigned char NandFlashModel_Find(
    00105     const struct NandFlashModel *modelList,
    00106     unsigned int size,
    00107     unsigned int id,
    00108     struct NandFlashModel *model);
    00109
    00110 extern unsigned char NandFlashModel_TranslateAccess(
    00111     const struct NandFlashModel *model,
    00112     unsigned int address,
    00113     unsigned int size,
    00114     unsigned short *block,
    00115     unsigned short *page,
    00116     unsigned short *offset);
    00117
    00118 extern const struct NandSpareScheme * NandFlashModel_GetScheme(
    00119     const struct NandFlashModel *model);
    00120
    00121 extern unsigned char NandFlashModel_GetDeviceId(
    00122     const struct NandFlashModel *model);
    00123
    00124 extern unsigned short NandFlashModel_GetDeviceSizeInBlocks(
    00125     const struct NandFlashModel *model);
    00126
    00127 extern unsigned int NandFlashModel_GetDeviceSizeInPages(
    00128     const struct NandFlashModel *model);
    00129
    00130 extern unsigned long long NandFlashModel_GetDeviceSizeInBytes(
    00131     const struct NandFlashModel *model);
    00132
    00133 extern unsigned int NandFlashModel_GetDeviceSizeInMBytes(
    00134     const struct NandFlashModel *model);
    00135
    00136 extern unsigned short NandFlashModel_GetBlockSizeInPages(
    00137     const struct NandFlashModel *model);
    00138
    00139 extern unsigned int NandFlashModel_GetBlockSizeInBytes(
    00140     const struct NandFlashModel *model);
    00141
    00142 extern unsigned short NandFlashModel_GetPageDataSize(
    00143     const struct NandFlashModel *model);
    00144
    00145 extern unsigned char NandFlashModel_GetPageSpareSize(
    00146     const struct NandFlashModel *model);
    00147
    00148 extern unsigned char NandFlashModel_GetDataBusWidth(
    00149     const struct NandFlashModel *model);
    00150
    00151 extern unsigned char NandFlashModel_HasSmallBlocks(
    00152     const struct NandFlashModel *model);
    00153
    00154 extern unsigned char NandFlashModel_SupportsCopyBack(
    00155     const struct NandFlashModel *model);
    00156
    00157 #endif /*#ifndef NANDFLASHMODEL_H*/
    00158

All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines