📄 nfc.cpp
字号:
//------------------------------------------------------------------------------
// Copyright (C) 2006-2007, 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;
extern "C" PCSP_PLLCRC_REGS g_pPLLCRC;
//-----------------------------------------------------------------------------
// Defines
#define NFC_CLOCK_SET_GATE_MODE(index, mode)\
do{\
REG32* pPCCR = &g_pPLLCRC->PCCR0;\
if (mode)\
SETREG32(&pPCCR[CRM_PCCR_INDEX(index)], CRM_PCCR_VAL(index, 1));\
else \
CLRREG32(&pPCCR[CRM_PCCR_INDEX(index)], CRM_PCCR_VAL(index, 1));\
}while(0)
//-----------------------------------------------------------------------------
// 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: 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:
// bEnabled
// [in] - TRUE for enabling the clock, FALSE for disabling the clock
//
// Returns:
// Returns TRUE on success. Returns FALSE on failure.
//
//-----------------------------------------------------------------------------
BOOL NFCSetClock(BOOL bEnabled)
{
if(bEnabled)
{
NFC_CLOCK_SET_GATE_MODE(DDK_CLOCK_GATE_INDEX_NFG_BAUD, DDK_CLOCK_GATE_MODE_ENABLE);
}
else
{
NFC_CLOCK_SET_GATE_MODE(DDK_CLOCK_GATE_INDEX_NFG_BAUD, DDK_CLOCK_GATE_MODE_DISABLE);
}
return TRUE;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -