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

📄 bspirda.c

📁 Microsoft WinCE 6.0 BSP FINAL release source code for use with the i.MX27ADS TO2 WCE600_FINAL_MX27_S
💻 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 + -