SAMV71 Xplained Ultra Software Package 1.5

smc.h File Reference

#include "chip.h"

Go to the source code of this file.

Data Structures

union  SmcStatus
struct  SmcStatus::_SmcStatusBits

Defines

#define NFC_SRAM_BASE_ADDRESS   0x200000
#define NFC_CMD_BASE_ADDR   0x70000000
#define NFCADDR_CMD_CMD1   (0xFFu << 2)
#define NFCADDR_CMD_CMD2   (0xFFu << 10)
#define NFCADDR_CMD_VCMD2   (0x1u << 18)
#define NFCADDR_CMD_ACYCLE   (0x7u << 19)
#define NFCADDR_CMD_ACYCLE_NONE   (0x0u << 19)
#define NFCADDR_CMD_ACYCLE_ONE   (0x1u << 19)
#define NFCADDR_CMD_ACYCLE_TWO   (0x2u << 19)
#define NFCADDR_CMD_ACYCLE_THREE   (0x3u << 19)
#define NFCADDR_CMD_ACYCLE_FOUR   (0x4u << 19)
#define NFCADDR_CMD_ACYCLE_FIVE   (0x5u << 19)
#define NFCADDR_CMD_CSID   (0x7u << 22)
#define NFCADDR_CMD_CSID_0   (0x0u << 22)
#define NFCADDR_CMD_CSID_1   (0x1u << 22)
#define NFCADDR_CMD_CSID_2   (0x2u << 22)
#define NFCADDR_CMD_CSID_3   (0x3u << 22)
#define NFCADDR_CMD_CSID_4   (0x4u << 22)
#define NFCADDR_CMD_CSID_5   (0x5u << 22)
#define NFCADDR_CMD_CSID_6   (0x6u << 22)
#define NFCADDR_CMD_CSID_7   (0x7u << 22)
#define NFCADDR_CMD_DATAEN   (0x1u << 25)
#define NFCADDR_CMD_DATADIS   (0x0u << 25)
#define NFCADDR_CMD_NFCRD   (0x0u << 26)
#define NFCADDR_CMD_NFCWR   (0x1u << 26)
#define NFCADDR_CMD_NFCCMD   (0x1u << 27)
#define Hsiao_ERROR_SINGLEBIT   1
#define Hsiao_ERROR_ECC   2
#define Hsiao_ERROR_MULTIPLEBITS   3

Functions

void SMC_NFC_Configure (uint32_t mode)
 Sets NFC configuration.
void SMC_NFC_Reset (void)
 Reset NFC controller.
void SMC_NFC_EnableNfc (void)
 Enable NFC controller.
void SMC_NFC_EnableSpareRead (void)
 Enable NFC controller reads both main and spare area in read mode.
void SMC_NFC_DisableSpareRead (void)
 The NFC controller skips spare area in read mode.
void SMC_NFC_EnableSpareWrite (void)
 Enables the NFC controller writes both main and spare area in write.
void SMC_NFC_DisableSpareWrite (void)
 The NFC controller skips spare area in write mode.
uint8_t SMC_NFC_isSpareRead (void)
 Check if spare area be read in read mode.
uint8_t SMC_NFC_isSpareWrite (void)
 Check if spare area be written in write mode.
uint8_t SMC_NFC_isTransferComplete (void)
 Check if NFC transfer complete.
uint8_t SMC_NFC_isReadyBusy (void)
 Check Ready/Busy line.
uint8_t SMC_NFC_isNfcBusy (void)
 Check if NFC Controller is busy.
uint32_t SMC_NFC_GetStatus (void)
 Get NFC Status.
void SMC_NFC_SendCommand (uint32_t cmd, uint32_t addressCycle, uint32_t cycle0)
 Uses the HOST nandflash controller to send a command to the NFC.
void SMC_NFC_Wait_CommandDone (void)
 Wait for NFC command has done.
void SMC_NFC_Wait_XfrDone (void)
 Wait for NFC Data Transfer Terminated.
void SMC_NFC_Wait_RBbusy (void)
 Wait for NFC Ready/Busy Line 3 Edge Detected.
void SMC_NFC_Wait_HammingReady (void)
 Wait for NFC Data Transfer Terminated.
void SMC_ECC_Configure (uint32_t type, uint32_t pageSize)
 Configures ECC mode.
uint32_t SMC_ECC_GetCorrectoinType (void)
 Get ECC correction type.
uint8_t SMC_ECC_GetStatus (uint8_t eccNumber)
 Get ECC status.
void SMC_ECC_GetValue (uint32_t *ecc)
 Get all ECC parity and Nparity value.
void SMC_ECC_GetEccParity (uint32_t pageDataSize, uint8_t *code, uint8_t busWidth)
uint8_t SMC_ECC_VerifyHsiao (uint8_t *data, uint32_t size, const uint8_t *originalCode, const uint8_t *verifyCode, uint8_t busWidth)

Detailed Description

Definitions and function prototype for SMC module

Definition in file smc.h.


Define Documentation

#define Hsiao_ERROR_ECC   2

The original code has been corrupted.

Definition at line 129 of file smc.h.

#define Hsiao_ERROR_MULTIPLEBITS   3

Multiple bits are incorrect in the data and they cannot be corrected.

Definition at line 132 of file smc.h.

#define Hsiao_ERROR_SINGLEBIT   1

A single bit was incorrect but has been recovered.

Definition at line 126 of file smc.h.

#define NFC_CMD_BASE_ADDR   0x70000000

Base address for NFC Address Command

Definition at line 68 of file smc.h.

#define NFC_SRAM_BASE_ADDRESS   0x200000

Base address of NFC SRAM

Definition at line 66 of file smc.h.


Function Documentation

void SMC_ECC_Configure ( uint32_t  type,
uint32_t  pageSize 
)

Configures ECC mode.

Parameters:
type Type of correction.
pageSize Page size of NAND flash device.

Definition at line 426 of file smc.c.

uint32_t SMC_ECC_GetCorrectoinType ( void   ) 

Get ECC correction type.

Returns:
Returns type of ECC correction setting.

Definition at line 438 of file smc.c.

void SMC_ECC_GetEccParity ( uint32_t  pageDataSize,
uint8_t *  code,
uint8_t  busWidth 
)

Get ECC code for 8bit/16-bit data path NAND flash by giving data path. 24-bit or 32-bit ECC is generated in order to perform one bit correction for a page in page 512/1024/2048/4096.

Parameters:
size Data size in bytes.
code Codes buffer.
busWidth 8bit/16bit data path.

Definition at line 685 of file smc.c.

Here is the call graph for this function:

uint8_t SMC_ECC_GetStatus ( uint8_t  eccNumber  ) 

Get ECC status.

Parameters:
eccNumber ecc parity number from 0 to 15.
Returns:
Returns ECC status by giving ecc number.

Definition at line 449 of file smc.c.

uint8_t SMC_ECC_VerifyHsiao ( uint8_t *  data,
uint32_t  size,
const uint8_t *  originalCode,
const uint8_t *  verifyCode,
uint8_t  busWidth 
)

Verifies hsiao codes for a data block. The block is verified between the given HSIAO code generated by hardware and original HSIAO codes store has been previously stored. Returns 0 if the data is correct, Hsiao_ERROR_SINGLEBIT if one or more block(s) have had a single bit corrected, or either Hsiao_ERROR_ECC or Hsiao_ERROR_MULTIPLEBITS.

Parameters:
data Data buffer to verify.
size Size of the data in words.
originalCode Original codes.
verifyCode codes to be verified.
dataPath 8bit/16bit data path.

Definition at line 727 of file smc.c.

Here is the call graph for this function:

void SMC_NFC_Configure ( uint32_t  cfg  ) 

Sets NFC configuration.

Parameters:
cfg NFC configuration.

Definition at line 131 of file smc.c.

uint32_t SMC_NFC_GetStatus ( void   ) 

Get NFC Status.

Returns:
Returns the current status register of SMC NFC Status Register. This resets the internal value of the status register, so further read may yield different values.

Definition at line 247 of file smc.c.

uint8_t SMC_NFC_isNfcBusy ( void   ) 

Check if NFC Controller is busy.

Returns:
Returns 1 if NFC Controller is activated and accesses the memory device, otherwise returns 0.

Definition at line 235 of file smc.c.

uint8_t SMC_NFC_isReadyBusy ( void   ) 

Check Ready/Busy line.

Returns:
Returns 1 if edge has been detected on the Ready/Busy line, otherwise returns 0.

Definition at line 224 of file smc.c.

uint8_t SMC_NFC_isSpareRead ( void   ) 

Check if spare area be read in read mode.

Returns:
Returns 1 if NFC controller reads both main and spare area in read mode, otherwise returns 0.

Definition at line 192 of file smc.c.

uint8_t SMC_NFC_isSpareWrite ( void   ) 

Check if spare area be written in write mode.

Returns:
Returns 1 if NFC controller writes both main and spare area in write mode, otherwise returns 0.

Definition at line 203 of file smc.c.

uint8_t SMC_NFC_isTransferComplete ( void   ) 

Check if NFC transfer complete.

Returns:
Returns 1 if NFC controller has terminated the data transmission, otherwise returns 0.

Definition at line 213 of file smc.c.

void SMC_NFC_SendCommand ( uint32_t  cmd,
uint32_t  addressCycle,
uint32_t  cycle0 
)

Uses the HOST nandflash controller to send a command to the NFC.

Parameters:
cmd command to send.
addressCycle address cycle when command access id decoded.
cycle0 address at first cycle.

Definition at line 308 of file smc.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines