📄 bspirda.c
字号:
//-----------------------------------------------------------------------------
//
// Copyright (C) 2004, Motorola Inc. All Rights Reserved
//
//-----------------------------------------------------------------------------
//
// 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
//
//-----------------------------------------------------------------------------
//
// File: bspirda.c
//
// Provides BSP-specific configuration routines for the Irda peripheral.
//
//-----------------------------------------------------------------------------
//------------------------------------------------------------------------------
// INCLUDE FILES
//------------------------------------------------------------------------------
#include <windows.h>
#include <bsp.h>
#include <uart.h>
//------------------------------------------------------------------------------
// 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->BCTRL2_CLEAR, (1 << PBC_BCTRL2_IRDA_EN_LSH));
}
else
{
// Disable IRDA transceiver
OUTREG16(&pPBC->BCTRL2_SET, (1 << PBC_BCTRL2_IRDA_EN_LSH));
}
MmUnmapIoSpace(pPBC,sizeof(CSP_PBC_REGS));
}
//-----------------------------------------------------------------------------
//
// Function: BSPIrdaSetMode
//
// This is a private function to set the IRDA mode.
//
// Parameters:
// mode
// [in] Mode that needs to be set, SIR .
//
// Returns:
// none.
//-----------------------------------------------------------------------------
VOID BSPIrdaSetMode(irMode_c mode)
{
PHYSICAL_ADDRESS phyAddr = {BSP_BASE_REG_PA_PBC_BASE, 0};
PCSP_PBC_REGS pPBC;
// Map PBC registers to virtual address space
pPBC = (PCSP_PBC_REGS) MmMapIoSpace(phyAddr, sizeof(CSP_PBC_REGS), FALSE);
if (pPBC == NULL)
{
return ;
}
if(mode == SIR_MODE)
{
OUTREG16(&pPBC->BCTRL2_CLEAR, (1 << PBC_BCTRL2_IRDA_MOD_LSH));
}
MmUnmapIoSpace(pPBC, sizeof(CSP_PBC_REGS));
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -