⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 nfc.cpp

📁 Freescale ARM11系列CPU MX31的WINCE 5.0下的BSP
💻 CPP
字号:
//------------------------------------------------------------------------------
//
//  Copyright (C) 2004-2006, Freescale Semiconductor, Inc. All Rights Reserved.
//  THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
//  AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//------------------------------------------------------------------------------
#include "bsp.h"


//-----------------------------------------------------------------------------
// External Functions


//-----------------------------------------------------------------------------
// External Variables
extern "C" PCSP_NANDFC_REGS g_pNFC;


//-----------------------------------------------------------------------------
// Defines


//-----------------------------------------------------------------------------
// Types


//-----------------------------------------------------------------------------
// Global Variables


//-----------------------------------------------------------------------------
// Local Variables


//-----------------------------------------------------------------------------
// Local Functions


//-----------------------------------------------------------------------------
//
//  Function: NFCAlloc
//
//  This function maps the NFC peripheral, configures interupts, and
//  configures NFC DMA support.
//
//  Parameters:
//      None.
//
//  Returns:
//      Returns TRUE on success. Returns FALSE on failure.
//
//-----------------------------------------------------------------------------
BOOL NFCAlloc(VOID)
{
    // Map peripheral physical address to virtual address
    g_pNFC = (PCSP_NANDFC_REGS) OALPAtoUA(CSP_BASE_REG_PA_NANDFC);

    // Check if virtual mapping failed
    if (g_pNFC == NULL)
    {
        OALMSG(1, (_T("NFCAlloc:  MmMapIoSpace failed!\r\n")));
        return FALSE;
    }
 
    return TRUE;   
}

//-----------------------------------------------------------------------------
//
// Function: NFCSetPagesize
//
// This function will set the NFMS bit of register RCSR in CCM module. For large
// page size nand flash, bit NFMS should be set to 1.
// 
// Parameters:
//      bLargePage
//          [in] - Set TRUE for large page size nand flash, Set FALSE for small
//          page size nand flash.
//
// Returns:
//      None.
//
//-----------------------------------------------------------------------------
BOOL NFCSetPagesize(BOOL bLargePage)
{
   PCSP_CCM_REGS pCCM;
   bool rc = FALSE; 
   
   // Map peripheral physical address to virtual address
   pCCM = (PCSP_CCM_REGS)OALPAtoUA(CSP_BASE_REG_PA_CCM);

    // Check if virtual mapping failed
    if (pCCM == NULL)
    {
        OALMSG(1, (_T("NFCSetPagesize: MmMapIoSpace failed!\r\n")));
        return FALSE;
    }
 
    if(bLargePage)
        INSREG32BF(&pCCM->RCSR, CCM_RCSR_NFMS, 1);
    else
        INSREG32BF(&pCCM->RCSR, CCM_RCSR_NFMS, 0);
        
    return TRUE;
}


//-----------------------------------------------------------------------------
//
//  Function:  NFCWait
//
//  This functions waits for the pending NANDFC opeation to complete.  
//
//  Parameters:
//      bPoll
//          [in] - Ignored.  Bootloader always polls for completion.
//
//  Returns:
//      None.
//
//-----------------------------------------------------------------------------
VOID NFCWait(BOOL bPoll)
{
    while (!(INREG16(&g_pNFC->NAND_FLASH_CONFIG2) & CSP_BITFMASK(NANDFC_NAND_FLASH_CONFIG2_INT)));
    
    // Clear the NANDFC interrupt
    CLRREG16(&g_pNFC->NAND_FLASH_CONFIG2, 
             CSP_BITFMASK(NANDFC_NAND_FLASH_CONFIG2_INT));

}


//-----------------------------------------------------------------------------
//
//  Function:  NFCSetClock
//
//  This enables/disable clocks for the NANDFC.
//
//  Parameters:
//      None.
//
//  Returns:
//      Returns TRUE on success. Returns FALSE on failure.
//
//-----------------------------------------------------------------------------
BOOL NFCSetClock(BOOL bEnabled)
{
    // Bootloader does not use clock gating, just return success
    return TRUE;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -