📄 wmxscaleinterrupts.c
字号:
/*-----------------------------------------------------------------------------
* Copyright (c) Wolfson Microelectronics plc. All rights reserved.
*
* This software as well as any related documentation is furnished under
* license and may only be used or copied in accordance with the terms of the
* license. The information in this file is furnished for informational use
* only, is subject to change without notice, and should not be construed as
* a commitment by Wolfson Microelectronics plc. Wolfson Microelectronics plc
* assumes no responsibility or liability for any errors or inaccuracies that
* may appear in this document or any software that may be provided in
* association with this document.
*
* Except as permitted by such license, no part of this document may be
* reproduced, stored in a retrieval system, or transmitted in any form or by
* any means without the express written consent of Wolfson Microelectronics plc.
*
* $Id: WMXScaleInterrupts.c 2924 2006-04-12 12:50:25Z fb $
*
* This file contains XScale Interrupt-handling functionality for the drivers
* for the Wolfson chips.
*
* Warning:
* This driver is specifically written for Wolfson Codecs. It is not a
* general CODEC device driver.
*
* This platform file is specifically designed to work with the Lubbock and
* Mainstone XScale platforms from Intel. There is no guarantee of correct
* operation with other platforms/controllers.
*
* -----------------------------------------------------------------------------*/
/*
* IMPORTANT
*
* The functions in this file must obey two rules:
*
* 1. They do not use any memory other than stack space and parameters passed in.
* 2. They do not make system calls, unless WMSystemCallsAllowed returns TRUE.
*
* All functions take a context parameter, which passes in pointers to the virtual
* addresses of memory-mapped registers, and stores what type of device is being
* accessed.
*
* Some client functions provide shared memory via the v_pWMData member of the
* context structure. This cannot be relied on.
*
* Note:
* The functions in this file are just wrappers around the macros in
* WMInterrupts_Raw.h.
*/
/*
* Include files
*/
#include "WMCommon.h"
#include "WMInterrupts.h"
#include "WMInterrupts_Raw.h"
#include "WMGPIO.h"
#include "WMRegisterDefs.h"
#include "WMControlLink.h"
/*
* Private data
*/
/*
* Function prototypes
*/
#if WM_TOUCH
/*-----------------------------------------------------------------------------
* Function: WMEnablePenInterrupt
*
* Requests an interrupt when the pen detect GPIO triggers.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
*
* Returns: void
*---------------------------------------------------------------------------*/
void WMEnablePenInterrupt( WM_DEVICE_HANDLE hDevice )
{
#if WM_USE_VIRTUAL_PENDOWN
if ( IS_WM9705_FAMILY( hDevice ) )
{
/*
* The WM9705 does not have support for AC'97 GPIO.
* Make sure that WM_USE_CODEC_IRQ_PIN & WM_USE_VIRTUAL_PENDOWN
* are defined as FALSE in WMConfig.h.
*/
WM_ASSERT( hDevice, FALSE );
}
/*
* Configure GPIO 2 to be used as IRQ.
*/
# if WM_USE_CODEC_IRQ_PIN
/* Set GPIO 2 to be an output */
WMGPIOConfig( hDevice,
WM_GPIO_2,
WM_GPIO_OUTPUT
);
/* Set GPIO2 to use its alternate function which is IRQ */
WMGPIOEnableAlternateFunction( hDevice,
WM_GPIO_2,
TRUE
);
WM_TRACE( hDevice, ("Touch Interrupt configured to use GPIO2/IRQ pin") );
# else /* WM_USE_CODEC_IRQ_PIN */
WM_TRACE( hDevice, ("Touch Interrupt configured to use AC'97 slot 12 IRQ") );
# endif /* WM_USE_CODEC_IRQ_PIN */
/*
* Configure virtual pendown (GPIO 13).
*/
/* Set the polarity to active high - Pen Down. */
WMGPIOSetInputPolarity( hDevice,
WM_GPIO_VIRTUAL_PENDOWN,
WM_GPIO_ACTIVE_HIGH
);
/* Enable the sticky bit. */
WMGPIOEnableSticky( hDevice,
WM_GPIO_VIRTUAL_PENDOWN,
TRUE
);
/* The pen detect wake bit is configured in WMMaskPenInterrupt */
/* Enable the global wake up bit. */
WMGPIOEnableGlobalWake( hDevice, TRUE );
#else /* WM_USE_VIRTUAL_PENDOWN */
if ( IS_WM9705_FAMILY( hDevice ) )
{
WM_TRACE( hDevice, ("Touch Interrupt configured to use PENDET pin") );
}
else
{
WM_TRACE( hDevice, ("Touch Interrupt configured to use GPIO3/PENDOWN pin") );
}
#endif /* WM_USE_VIRTUAL_PENDOWN */
WMMaskPenInterrupt( hDevice, FALSE );
}
/*-----------------------------------------------------------------------------
* Function: WMDisablePenInterrupt
*
* Cancels the interrupt when the pen detect GPIO triggers.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
*
* Returns: void
*---------------------------------------------------------------------------*/
void WMDisablePenInterrupt( WM_DEVICE_HANDLE hDevice )
{
WMMaskPenInterrupt( hDevice, TRUE );
}
/*-----------------------------------------------------------------------------
* Function: WMMaskPenInterrupt
*
* Masks (disables) or unmasks (enables) the pendetect interrupt.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
* mask whether to mask or unmask
*
* Returns: void
*---------------------------------------------------------------------------*/
void WMMaskPenInterrupt( WM_DEVICE_HANDLE hDevice, WM_BOOL mask )
{
#if WM_USE_VIRTUAL_PENDOWN
WM_BOOL wakeup = !mask;
if ( !mask )
{
/* Clear the status of the bit if we're enabling. */
WMGPIOClearInput( hDevice,
WM_GPIO_VIRTUAL_PENDOWN
);
}
/* Enable or disable the wake up bit. */
WMGPIOEnableWakeUp( hDevice,
WM_GPIO_VIRTUAL_PENDOWN,
wakeup
);
#endif /* WM_USE_VIRTUAL_PENDOWN */
#if !WM_USE_VIRTUAL_IRQ
if ( mask )
WMInlineDisablePenInterrupt( hDevice );
else
WMInlineEnablePenInterrupt( hDevice );
#endif
}
/*-----------------------------------------------------------------------------
* Function: WMIsPenInterruptTriggered
*
* Returns whether the pen detect GPIO interrupt is currently triggered.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
*
* Returns: int
* Non-zero = interrupt triggered.
*---------------------------------------------------------------------------*/
int WMIsPenInterruptTriggered( WM_DEVICE_HANDLE hDevice )
{
WM_XSCALE_DEVICE_CONTEXT *pDeviceContext =
(WM_XSCALE_DEVICE_CONTEXT*) hDevice;
WM_BOOL retval = FALSE;
#if WM_USE_VIRTUAL_PENDOWN
WM_REGVAL value;
WMSTATUS status;
status = WMRead( hDevice, WM97_DIGITIZER_DATA, &value );
if ( WM_SUCCESS( status ) && ( value & WM_DATA_PENDOWN ) )
{
retval = TRUE;
}
else
{
retval = FALSE;
}
#else /* WM_USE_VIRTUAL_PENDOWN */
#if WM_BOARD_LUBBOCK
if ( pDeviceContext->v_pGPIORegs->PEN_DETECT_GPIO_REG(GPLR) &
PEN_DETECT_GPIO_MASK
)
{
retval = TRUE;
}
else
{
retval = FALSE;
}
#elif WM_BOARD_MAINSTONEII
# if PENIRQ
if ( pDeviceContext->v_pBLRegs->MISCRR1 & XLLP_BCR_MISCRR1_nPENIRQ )
{
retval = TRUE;
}
else
{
retval = FALSE;
}
# elif AC97IRQ
WM_REGVAL value;
WMSTATUS status;
status = WMRead( hDevice, WM97_DIGITIZER_DATA, &value );
if ( WM_SUCCESS( status ) && ( value & WM_DATA_PENDOWN ) )
{
retval = TRUE;
}
else
{
retval = FALSE;
}
# endif /* PENIRQ/AC97IRQ */
#endif /* WM_BOARD_MAINSTONEII */
#endif /* WM_USE_VIRTUAL_PENDOWN */
return retval;
}
/*-----------------------------------------------------------------------------
* Function: WMClearPenInterrupt
*
* Clears the pen detect GPIO interrupt.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
*
* Returns: void
*---------------------------------------------------------------------------*/
void WMClearPenInterrupt( WM_DEVICE_HANDLE hDevice )
{
WMInlineClearPenInterrupt( hDevice );
}
#if WM_USE_VIRTUAL_PENDOWN
/*-----------------------------------------------------------------------------
* Function: WMClearVirtualPendown
*
* Clears the virtual pen detect GPIO interrupt.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
* penDown TRUE to clear pen down interrupt.
* FALSE to clear pen up interrupt.
*
* Returns: void
*---------------------------------------------------------------------------*/
void WMClearVirtualPendown( WM_DEVICE_HANDLE hDevice, WM_BOOL penDown )
{
/*
* Pen down is active high.
* If the pen is down we need to change the polarity to active low
* for the next pen up event.
* If the pen is up then the polarity needs to be active high for
* the next pen down event.
*/
if( penDown )
WMGPIOSetInputPolarity( hDevice,
WM_GPIO_VIRTUAL_PENDOWN,
WM_GPIO_ACTIVE_LOW
);
else
WMGPIOSetInputPolarity( hDevice,
WM_GPIO_VIRTUAL_PENDOWN,
WM_GPIO_ACTIVE_HIGH
);
/* Clear the Virtual Pendown status bit. */
WMGPIOClearInput( hDevice,
WM_GPIO_VIRTUAL_PENDOWN
);
}
#endif /* WM_USE_VIRTUAL_PENDOWN */
#endif /* WM_TOUCH */
/*-----------------------------------------------------------------------------
* Function: WMRequestTimerInterrupt
*
* Requests a timer interrupt after the specified interval. This is given as
* a fraction of a second (i.e. timer frequency).
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
*
* Returns: WMSTATUS
* See WMStatus.h
*---------------------------------------------------------------------------*/
void WMRequestTimerInterrupt( WM_DEVICE_HANDLE hDevice )
{
WMInlineRequestTimerInterrupt( hDevice );
}
/*-----------------------------------------------------------------------------
* Function: WMCancelTimerInterrupt
*
* Ensures previously requested timer interrupts are cancelled.
*
* Parameters:
* hDevice handle to the device (from WMOpenDevice)
*
* Returns: void
*---------------------------------------------------------------------------*/
void WMCancelTimerInterrupt( WM_DEVICE_HANDLE hDevice )
{
WMInlineCancelTimerInterrupt( hDevice );
}
/*------------------------------ END OF FILE ---------------------------------*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -