SAMV71 Xplained Ultra Software Package 1.3

smc.h

Go to the documentation of this file.
00001 /* ----------------------------------------------------------------------------
00002  *         SAM Software Package License 
00003  * ----------------------------------------------------------------------------
00004  * Copyright (c) 2011, 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 *  Definitions and function prototype for SMC module
00034 */
00035 
00036 #ifndef _SMC_
00037 #define _SMC_
00038 
00039 /*----------------------------------------------------------------------------
00040  *        Headers
00041  *----------------------------------------------------------------------------*/
00042 #include "chip.h"
00043 
00044 /*----------------------------------------------------------------------------
00045  *        Types
00046  *----------------------------------------------------------------------------*/
00047 typedef union _SmcStatus {
00048     uint8_t BStatus;
00049     struct _SmcStatusBits {
00050         uint8_t smcSts:1,    /**< NAND Flash Controller Status */
00051                 xfrDone:1,   /**< NFC Data Transfer Terminated */
00052                 cmdDone:1,   /**< Command Done */
00053                 rbEdge: 1,   /**< Ready/Busy Line 3 Edge Detected*/
00054            hammingReady:1;   /**< Hamming ecc ready */
00055     } bStatus;
00056 } SmcStatus;
00057 
00058 /*----------------------------------------------------------------------------
00059  *        Definitions
00060  *----------------------------------------------------------------------------*/
00061 /*
00062  * NFC definitions
00063  */
00064 
00065 /** Base address of NFC SRAM */
00066 #define NFC_SRAM_BASE_ADDRESS 0x200000
00067 /** Base address for NFC Address Command */
00068 #define NFC_CMD_BASE_ADDR     0x70000000
00069 
00070 
00071 /* -------- NFCADDR_CMD : NFC Address Command -------- */
00072 #define NFCADDR_CMD_CMD1      (0xFFu <<  2) 
00073 /* Command Register Value for Cycle 1 */
00074 #define NFCADDR_CMD_CMD2      (0xFFu << 10) 
00075 /* Command Register Value for Cycle 2 */
00076 #define NFCADDR_CMD_VCMD2     (0x1u << 18)  
00077 /* Valid Cycle 2 Command */
00078 #define NFCADDR_CMD_ACYCLE    (0x7u << 19)  
00079 /* Number of Address required for the current command */
00080 #define   NFCADDR_CMD_ACYCLE_NONE    (0x0u << 19) 
00081 /* No address cycle */
00082 #define   NFCADDR_CMD_ACYCLE_ONE     (0x1u << 19) 
00083 /* One address cycle */
00084 #define   NFCADDR_CMD_ACYCLE_TWO     (0x2u << 19) 
00085 /* Two address cycles */
00086 #define   NFCADDR_CMD_ACYCLE_THREE   (0x3u << 19) 
00087 /* Three address cycles */
00088 #define   NFCADDR_CMD_ACYCLE_FOUR    (0x4u << 19) 
00089 /* Four address cycles */
00090 #define   NFCADDR_CMD_ACYCLE_FIVE    (0x5u << 19) 
00091 /* Five address cycles */
00092 #define NFCADDR_CMD_CSID      (0x7u << 22)  
00093 /* Chip Select Identifier */
00094 #define   NFCADDR_CMD_CSID_0                    (0x0u << 22) 
00095 /* CS0 */
00096 #define   NFCADDR_CMD_CSID_1                    (0x1u << 22) 
00097 /* CS1 */
00098 #define   NFCADDR_CMD_CSID_2                    (0x2u << 22) 
00099 /* CS2 */
00100 #define   NFCADDR_CMD_CSID_3                    (0x3u << 22) 
00101 /* CS3 */
00102 #define   NFCADDR_CMD_CSID_4                    (0x4u << 22) 
00103 /* CS4 */
00104 #define   NFCADDR_CMD_CSID_5                    (0x5u << 22) 
00105 /* CS5 */
00106 #define   NFCADDR_CMD_CSID_6                    (0x6u << 22) 
00107 /* CS6 */
00108 #define   NFCADDR_CMD_CSID_7                    (0x7u << 22) 
00109 /* CS7 */
00110 #define NFCADDR_CMD_DATAEN   (0x1u << 25)  
00111 /* NFC Data Enable */
00112 #define NFCADDR_CMD_DATADIS  (0x0u << 25)  
00113 /* NFC Data disable */
00114 #define NFCADDR_CMD_NFCRD    (0x0u << 26)  
00115 /* NFC Read Enable */
00116 #define NFCADDR_CMD_NFCWR    (0x1u << 26)  
00117 /* NFC Write Enable */
00118 #define NFCADDR_CMD_NFCCMD   (0x1u << 27)  
00119 /* NFC Command Enable */
00120 
00121 /*
00122  * ECC definitions (Hsiao Code Errors)
00123  */
00124 
00125 /** A single bit was incorrect but has been recovered. */
00126 #define Hsiao_ERROR_SINGLEBIT         1
00127 
00128 /** The original code has been corrupted. */
00129 #define Hsiao_ERROR_ECC               2
00130 
00131 /** Multiple bits are incorrect in the data and they cannot be corrected. */
00132 #define Hsiao_ERROR_MULTIPLEBITS      3
00133 
00134 /*----------------------------------------------------------------------------
00135  *        Exported functions
00136  *----------------------------------------------------------------------------*/
00137 
00138 /*
00139  * NFC functions
00140  */
00141 
00142 extern void SMC_NFC_Configure(uint32_t mode);
00143 extern void SMC_NFC_Reset(void);
00144 extern void SMC_NFC_EnableNfc(void);
00145 extern void SMC_NFC_EnableSpareRead(void);
00146 extern void SMC_NFC_DisableSpareRead(void);
00147 extern void SMC_NFC_EnableSpareWrite(void);
00148 extern void SMC_NFC_DisableSpareWrite(void);
00149 extern uint8_t SMC_NFC_isSpareRead(void);
00150 extern uint8_t SMC_NFC_isSpareWrite(void);
00151 extern uint8_t SMC_NFC_isTransferComplete(void);
00152 extern uint8_t SMC_NFC_isReadyBusy(void);
00153 extern uint8_t SMC_NFC_isNfcBusy(void);
00154 extern uint32_t SMC_NFC_GetStatus(void);
00155 
00156 extern void SMC_NFC_SendCommand(uint32_t cmd, uint32_t addressCycle, 
00157         uint32_t cycle0);
00158 extern void SMC_NFC_Wait_CommandDone(void);
00159 extern void SMC_NFC_Wait_XfrDone(void);
00160 extern void SMC_NFC_Wait_RBbusy(void);
00161 extern void SMC_NFC_Wait_HammingReady(void);
00162 
00163 extern void SMC_ECC_Configure(uint32_t type, uint32_t pageSize);
00164 extern uint32_t SMC_ECC_GetCorrectoinType(void);
00165 extern uint8_t SMC_ECC_GetStatus(uint8_t eccNumber);
00166 
00167 extern void SMC_ECC_GetValue(uint32_t *ecc);
00168 extern void SMC_ECC_GetEccParity(uint32_t pageDataSize, uint8_t *code, 
00169         uint8_t busWidth);
00170 extern uint8_t SMC_ECC_VerifyHsiao(uint8_t *data, uint32_t size, 
00171         const uint8_t *originalCode, const uint8_t *verifyCode, uint8_t busWidth);
00172     
00173 #endif /* #ifndef _SMC_ */
00174 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines