📄 bspirda.c
字号:
//-----------------------------------------------------------------------------
//
// Copyright (C) 2004, Motorola Inc. All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// Copyright (C) 2004, Freescale Semiconductor, Inc. All Rights Reserved
// THIS SOURCE CODE IS CONFIDENTIAL AND PROPRIETARY AND MAY NOT
// BE USED OR DISTRIBUTED WITHOUT THE WRITTEN PERMISSION OF
// FREESCALE SEMICONDUCTOR, INC.
//
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// File: bspIR.c
//
// Provides BSP-specific configuration routines for the UART peripheral.
//
//-----------------------------------------------------------------------------
#include <windows.h>
#include "bsp.h"
#include "uart.h"
//-----------------------------------------------------------------------------
// External Functions
//-----------------------------------------------------------------------------
// External Variables
//-----------------------------------------------------------------------------
// Defines
//-----------------------------------------------------------------------------
// Types
//-----------------------------------------------------------------------------
// Global Variables
//-----------------------------------------------------------------------------
// Local Variables
//------------------------------------------------------------------------------
// Local Functions
//-----------------------------------------------------------------------------
//
// Function: BSPIrdaEnable
//
// This is a private function to enable the IRDA.
//
// Parameters:
// bEnable
// [in] TRUE if enable IRDA. FALSE if disable.
//
// Returns:
// none.
//-----------------------------------------------------------------------------
VOID BSPIrdaEnable(BOOL bEnable)
{
PCSP_PBC_REGS pPBC;
PHYSICAL_ADDRESS phyAddr = {BSP_BASE_REG_PA_PBC_BASE, 0};
// Map PBC registers to virtual address space
pPBC = (PCSP_PBC_REGS) MmMapIoSpace(phyAddr, sizeof(CSP_PBC_REGS), FALSE);
if (pPBC == NULL)
{
return ;
}
if (bEnable)
{
// Enable IRDA transceiver
OUTREG16(&pPBC->BCTRL1_CLEAR, (1 << PBC_BCTRL1_CLEAR_IREN_LSH));
}
else
{
// Disable IRDA transceiver
OUTREG16(&pPBC->BCTRL1_SET, (1 << PBC_BCTRL1_SET_IREN_LSH));
}
MmUnmapIoSpace(pPBC,sizeof(CSP_PBC_REGS));
}
//-----------------------------------------------------------------------------
//
// Function: BSPIrdaSetMode
//
// This is a private function to set the IRDA mode.
//
// Parameters:
// none.
//
// Returns:
// none.
//-----------------------------------------------------------------------------
VOID BSPIrdaSetMode(irMode_c mode)
{
PHYSICAL_ADDRESS phyAddr = {BSP_BASE_REG_PA_PBC_BASE, 0};
PCSP_PBC_REGS pPBC;
PCSP_FIRI_REG pFiriReg = NULL;
// Map PBC registers to virtual address space
pPBC = (PCSP_PBC_REGS) MmMapIoSpace(phyAddr, sizeof(CSP_PBC_REGS), FALSE);
if (pPBC == NULL)
{
return ;
}
switch (mode)
{
case SIR_MODE:
OUTREG16(&pPBC->BCTRL2_CLEAR, (1 << PBC_BCTRL2_IRDA_MOD_LSH));
break;
case MIR_MODE:
case FIR_MODE:
// Map FIRI peripheral physical address to virtual address
phyAddr.QuadPart = CSP_BASE_REG_PA_FIRI;
pFiriReg = (PCSP_FIRI_REG) MmMapIoSpace(phyAddr, sizeof(CSP_FIRI_REG), FALSE);
if (pFiriReg == NULL)
{
return ;
}
// IrDA Mode clear
OUTREG16(&pPBC->BCTRL2_SET, (1 << PBC_BCTRL2_IRDA_MOD_LSH));
// Invert TPP bit
OUTREG32(&pFiriReg->FIRI_TCR,
CSP_BITFVAL(FIRI_TCR_TPP, FIRI_TCR_TPP_INVERT));
// Set the Mode according to the IRDA_TXD
OUTREG16(&pPBC->BCTRL2_CLEAR, (1 << PBC_BCTRL2_IRDA_MOD_LSH));
// Invert the polarity back to original
OUTREG32(&pFiriReg->FIRI_TCR,
CSP_BITFVAL(FIRI_TCR_TPP, FIRI_TCR_TPP_NO_INVERT));
MmUnmapIoSpace(pFiriReg,sizeof(PCSP_FIRI_REG));
break;
}
MmUnmapIoSpace(pPBC,sizeof(CSP_PBC_REGS));
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -