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

📄 boardcontrol.c

📁 pxa270触摸屏驱动程序
💻 C
📖 第 1 页 / 共 3 页
字号:
/******************************************************************************
**
**  COPYRIGHT (C) 2000, 2001 Intel Corporation.
**
**  This software as well as the software described in it 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 Intel Corporation. Intel Corporation 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 Intel Corporation.
**
**  FILENAME:       lubbockControl.c
**
**  PURPOSE:        This module contain the Lubbock access routines.
**
**  LAST MODIFIED:  $Modtime: 3/25/04 2:39p $
******************************************************************************/

/*
*******************************************************************************
*   HEADER FILES
*******************************************************************************
*/

#include <stdio.h>
#include <stdarg.h>
#include "systypes.h"
#include "cotulla.h"
#include "boardControl.h"
#include "dm_errors.h"
#include "xllp_gpio.h"
#include "XsGpioApi.h"
#include "XsGpio.h"
#include "timedelays.h"
/*
*******************************************************************************
*   LOCAL DEFINITIONS
*******************************************************************************
*/
static volatile BoardRegistersT * boardCtrlRegsP = (BoardRegistersT *)BOARD_REG_BASE;
static int lastMajorId, lastMinorId;

void GetMultipleParamFromString (PCHAR paramStringP, UINT32 paramNumber, PUINT32 paramArrayP)
{
    UINT32 i, j;
    PCHAR stringP, valueP;

    stringP = paramStringP;
    for (j = 0; j < paramNumber; ++j)
    {
        i = 0;
        while ((*stringP != ',') && (*stringP != '\0'))
        {
            ++i;
            ++stringP;
        }
        *stringP = '\0';
        valueP = stringP - i;
        sscanf(valueP, "%d", &paramArrayP[j]);
        ++stringP;
    }
}

/*
*******************************************************************************
*
* FUNCTION:
*    WriteHexLeds
*
* DESCRIPTION:
*    This routine display the specified value on the Hex Leds.
*
* INPUT PARAMETERS:
*    UINT ledBits - the 32-bit value to display
*
* RETURNS:
*    None.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    None.
*
* CALLS:
*    None.
*
* CALLED BY:
*    Test code or DM infrastructure.
*
* PROTOTYPE:
*    VOID WriteHexLeds(UINT ledBits);
*
*******************************************************************************
*/
VOID WriteHexLeds(UINT ledBits)
{
    // Update the Hex LEDs.
    boardCtrlRegsP->hex_led = ledBits;
}

/*
*******************************************************************************
*
* FUNCTION:
*    BoardSetHexLeds
*
* DESCRIPTION:
*    This routine display the specified value on the Hex Leds.
*
* INPUT PARAMETERS:
*    UINT16 HighLEDs - the high order 16-bit value to display
*    UINT16 LowLEDs - the low order 16-bit value to display
*
* RETURNS:
*    None.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    None.
*
* CALLS:
*    None.
*
* CALLED BY:
*    Test code or DM infrastructure.
*
* PROTOTYPE:
*    VOID BoardSetHexLeds(UINT16 HighLEDs, UINT16 LowLEDs);
*
*******************************************************************************
*/
VOID WriteHexLedsHalfs(UINT16 HighLEDs, UINT16 LowLEDs)
{
    // Update the Hex LEDs.
    boardCtrlRegsP->hex_led = (HighLEDs << 16) | LowLEDs;
}

/*
*******************************************************************************
*
* FUNCTION:
*    BlankHexLeds
*
* DESCRIPTION:
*    This routine blanks the specified hex LED.
*
* INPUT PARAMETERS:
*    HexLedsT ledBit - The LED bit to modify.
*
* RETURNS:
*    None.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    None.
*
* CALLS:
*    None.
*
* CALLED BY:
*    Test code or DM infrastructure.
*
* PROTOTYPE:
*    VOID BlankHexLeds(HexLedsT ledBit);
*
* NOTE:
*    The bit specify will blank out the corresponding number. For example,
*    if the hex LEDS are display the value 0x12345678 and bit 3 is specified,
*    the 5 will be turned off.
*
*******************************************************************************
*/
VOID BlankHexLeds(HexLedsT ledBit)
{
    UINT16 blank_disc;

    // Get the current LED bits and OR in the blank bits.
    blank_disc = (boardCtrlRegsP->disc_blank_led & 0xFF) | (ledBit << 8);

    // Blank the specified hex led bits keeping the discrete LEDs unchanged.
    boardCtrlRegsP->disc_blank_led = blank_disc;
}

/*
*******************************************************************************
*
* FUNCTION:
*    SetDiscreteLed
*
* DESCRIPTION:
*    This routine turns on/off the specified discrete led.
*
* INPUT PARAMETERS:
*    DiscrLedStateT operation - LED will be off if one, and on if zero.
*    DiscrLedsT led - the discrete LED that need to be turn on/off
*
* RETURNS:
*    None.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    None.
*
* CALLS:
*    None.
*
* CALLED BY:
*    Test code or DM infrastructure.
*
* PROTOTYPE:
*    VOID SetDiscreteLed(DiscrLedStateT operation, DiscrLedsT led);
*
*
* NOTE:
*    The discrete LEDs on Lubbock are turned on by writing a zero. This
*    routine will invert the value specified to display the intented pattern.
*
*******************************************************************************
*/
VOID SetDiscreteLed(DiscrLedStateT operation, DiscrLedsT led)
{
    if (operation == LED_OFF)
    {
        // Turn the specified LED OFF
        boardCtrlRegsP->disc_blank_led |= led;
    }
    else
    {
        // Turn the specified LED ON
        boardCtrlRegsP->disc_blank_led &= (~led);
    }
}

/*
*******************************************************************************
*
* FUNCTION:
*    WriteValueDiscreteLeds
*
* DESCRIPTION:
*    This routine display the specified value on the discrete Leds.
*
* INPUT PARAMETERS:
*    UINT8 value - the value to display
*
* RETURNS:
*    None.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    None.
*
* CALLS:
*    None.
*
* CALLED BY:
*    Test code or DM infrastructure.
*
* PROTOTYPE:
*    VOID WriteValueDiscreteLeds(UINT8 value);
*
*
* NOTE:
*    The discrete LEDs are turned on by writing a zero. This
*    routine will invert the value specified to display the intented pattern.
*
*******************************************************************************
*/
VOID WriteValueDiscreteLeds(UINT8 value)
{
#if 0	//hzh
    // Get the current blank bits and OR in the discrete LED.
    boardCtrlRegsP->disc_blank_led = (boardCtrlRegsP->disc_blank_led & 0xFF00) |
                                     (~value & 0xFF);
#else
	P_XLLP_GPIO_T gpioReg = (P_XLLP_GPIO_T ) XS_GPIO_REGISTER_BASE;
	
	if(value & 1)
		gpioReg->GPCR2 = 1<<25;
	else
		gpioReg->GPSR2 = 1<<25;
	
	if(value & 2)
		gpioReg->GPCR3 = 1<<0;
	else
		gpioReg->GPSR3 = 1<<0;
	
	if(value & 4)
		gpioReg->GPCR3 = 1<<11;
	else
		gpioReg->GPSR3 = 1<<11;
	
	if(value & 8)
		gpioReg->GPCR3 = 1<<12;
	else
		gpioReg->GPSR3 = 1<<12;
#endif
}

/*
*******************************************************************************
*
* FUNCTION:
*    ReadUserSwitches
*
* DESCRIPTION:
*    This routine reads the User Switches.
*
* INPUT PARAMETERS:
*    None.
*
* RETURNS:
*    The configuration switches. See boardControl.h for bit definitions.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    None.
*
* CALLS:
*    None.
*
* CALLED BY:
*    Test code or DM infrastructure.
*
* PROTOTYPE:
*    UINT ReadUserSwitches(VOID);
*
*******************************************************************************
*/
UINT ReadUserSwitches(VOID)
{
    VUINT32 value, userSwitch;
    
    if (IsMainBoardPresent()) return 0;
    
    userSwitch = (boardCtrlRegsP->user_switches);
    value = userSwitch >> 8;

    // Light discrete LED
    WriteValueDiscreteLeds ((UINT8)value);

    // Return the user switches.
    return userSwitch;
}

/*
*******************************************************************************
*
* FUNCTION:
*    ModifyMiscWr1Register
*
* DESCRIPTION:
*    This routine sets/clears the specified bits in the Lubbock Write Register.
*
* INPUT PARAMETERS:
*    MiscWrEnableT operation - 0 = clear the bit, 1 = set the bit.
*    MiscWr1T bit - The bit to clear or set.
*
* RETURNS:
*    The contents of the Lubbock Misc. Write Register after the bit is changed.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    None.
*
* CALLS:
*    None.
*
* CALLED BY:
*    Test code or DM infrastructure.
*
* PROTOTYPE:
*    UINT ModifyMiscWr1Register(UINT operation, MiscWr1T bit);
*
*******************************************************************************
*/
UINT ModifyMiscWr1Register(MiscWrEnableT operation, MiscWr1T bit)
{
    // Set or Clear the specified bit?
    if (operation)
    {
        // Set the bit.
        boardCtrlRegsP->miscWr1 = (boardCtrlRegsP->miscWr1 & MASK_WR1) | bit;
    }
    else
    {
        // Clear the bit.
        boardCtrlRegsP->miscWr1 = (boardCtrlRegsP->miscWr1 & MASK_WR1) & ~bit;
    }

    // Return the misc. Write Register.
    return (boardCtrlRegsP->miscWr1);
}


/*
*******************************************************************************
*
* FUNCTION:
*    ModifyMiscWr2Register
*
* DESCRIPTION:
*    This routine sets/clears the specified bits in the Lubbock Write Register.
*
* INPUT PARAMETERS:
*    UINT operation - 0 = clear the bit, 1 = set the bit.
*    Misc_Wr2T bit - The bit to clear or set.
*
* RETURNS:
*    The contents of the Lubbock Misc. Write Register after the bit is changed.
*
* GLOBAL EFFECTS:
*    None.
*
* ASSUMPTIONS:
*    None.
*
* CALLS:
*    None.
*
* CALLED BY:
*    Test code or DM infrastructure.
*
* PROTOTYPE:
*    UINT ModifyMiscWr2Register(UINT operation, MiscWr2T bit);
*
*******************************************************************************
*/
UINT ModifyMiscWr2Register(MiscWrEnableT operation, MiscWr2T bit)
{
    // Set or Clear the specified bit?
    if (operation)
    {
        // Set the bit.
        boardCtrlRegsP->miscWr2 |= bit;
    }
    else
    {
        // Clear the bit.
        boardCtrlRegsP->miscWr2 &= ~bit;
    }

    // Return the misc. Write Register.
    return (boardCtrlRegsP->miscWr2);
}

VOID ModifyPcmciaRegister(BCR_PcmciaT set, BCR_PcmciaT clear, INT socket)
{
    if (!socket)
        boardCtrlRegsP->pcmcia0 = (boardCtrlRegsP->pcmcia0 & (~clear)) | set;
    else
        boardCtrlRegsP->pcmcia1 = (boardCtrlRegsP->pcmcia1 & (~clear)) | set;
}

UINT16 GetPcmciaRegister(INT socket)
{
#if 0	//hzh
    return socket ? boardCtrlRegsP->pcmcia1 : boardCtrlRegsP->pcmcia0;
#else
	UINT16 val = 0;
	P_XLLP_GPIO_T gpioReg = (P_XLLP_GPIO_T ) XS_GPIO_REGISTER_BASE;
	
	if(socket)
		return BCR_PCMCIA_nCD;
	
	if(gpioReg->GPLR2 & (1<<17))
		val |= BCR_PCMCIA_nIRQ;
	if(gpioReg->GPLR2 & (1<<18))
		val |= BCR_PCMCIA_nVS1 | BCR_PCMCIA_nVS2;
	if(gpioReg->GPLR2 & (1<<19))
		val |= BCR_PCMCIA_nCD;
	if(gpioReg->GPLR2 & (1<<20))
		val |= BCR_PCMCIA_nBVD1;
	if(gpioReg->GPLR1 & (1<<21))
		val |= BCR_PCMCIA_nBVD2;
	
	return val;
#endif
}

/*
*******************************************************************************
*
* FUNCTION:
*    ReadMiscRdRegister
*
* DESCRIPTION:
*    This routine returns the contents of the Read Register.
*

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -