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

📄 xspccardsocket.c

📁 优龙pxa270平台试验程序
💻 C
📖 第 1 页 / 共 3 页
字号:
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0BVD2State = XLLP_TRUE;
                }

                //Check the IREQ status bit[10] of the Socket 0 Status Register. If set, then set
                //the corresponding member's value in the XLLP Socket State structure.
                if((pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR) & 
                                                         (XLLP_BCR_PCMCIA_SCR_S0_nIRQ))
                {
                    // Interrupt request/ready singal is asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0IREQState = XLLP_TRUE;
                }
                else
                {
                    // Interrupt request/ready singal is not asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0IREQState = XLLP_FALSE;
                }

                //Check the CD Interrupt status for Socket 0. If the interrupt is set,
                //then set the corresponding member's value in the XLLP Socket State structure.
                if((pstrSocketHandle->pstrBcrHandle->PSCR1 ) & (XLLP_BCR_INTSET_CLEAR_R1_S0_CD))
                {
                    // Interupt request is asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0CDIntState = XLLP_TRUE;
                }               
                else
                {
                    // Interupt request is not asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0CDIntState = XLLP_FALSE;
                }
                break;

            case XS_PCCARD_SOCKET1:
                //Check the CD status bit[5] of the Socket 1 Status Register. Set
                //the corresponding member's value in the XLLP Socket State structure.
                if((pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) & (XLLP_BCR_PCMCIA_SCR_S1_nCD))
                {
                    // Card detect being set indicates no card inserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1CDState = XLLP_FALSE;
                }
                else
                {
                    // Card detect being cleared indicates card inserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1CDState = XLLP_TRUE;
                }

                //Check the BVD1 status bit[8] of the Socket 1 Status Register. Set
                //the corresponding member's value in the XLLP Socket State structure.
                if((pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) & 
                                                         (XLLP_BCR_PCMCIA_SCR_S1_nSTSCHG_BVD1))
                {
                    // VDD voltage sense signal/card status changed not asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1BVD1State = XLLP_FALSE;
                }
                else
                {
                    // VDD voltage sense signal/card status changed asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1BVD1State = XLLP_TRUE;
                }
                //Check the BVD2 status bit[9] of the Socket 1 Status Register. Set
                //the corresponding member's value in the XLLP Socket State structure.
                if((pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) & 
                                                         (XLLP_BCR_PCMCIA_SCR_S1_nSPKR_BVD2))
                {
                    // VDD voltage sense signal/audio digital speaker not asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1BVD2State = XLLP_FALSE;
                }
                else
                {
                    // VDD voltage sense signal/audio digital speaker asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1BVD2State = XLLP_TRUE;
                }

                //Check the IREQ status bit[10] of the Socket 1 Status Register. Set
                //the corresponding member's value in the XLLP Socket State structure.
                if((pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) & 
                                                         (XLLP_BCR_PCMCIA_SCR_S1_nIRQ))
                {
                    // Interrupt request/ready singal is asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1IREQState = XLLP_TRUE;
                }
                else
                {
                    // Interrupt request/ready singal is not asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1IREQState = XLLP_FALSE;
                }

                //Check the CD Interrupt status for Socket 1. If the interrupt is set,
                //then set the corresponding member's value in the XLLP Socket State structure.
                if((pstrSocketHandle->pstrBcrHandle->PSCR1) & (XLLP_BCR_INTSET_CLEAR_R1_S1_CD))
                {
                    // Interupt request is asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1CDIntState = XLLP_TRUE;
                }
                else
                {
                    // Interupt request is not asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1CDIntState = XLLP_FALSE;
                }

                break;

            default:
                break;

        } //end switch(uSocket)

    } //end if

    return ReturnValue;
#else
	XS_STATUS_T ReturnValue = XS_PCCARD_SUCCESS;
	volatile XLLP_GPIO_T *vpstrBvdGPIORegs = (volatile XLLP_GPIO_T *)pstrSocketHandle->pstrGpioRegsHandle;
	
	if(ushSocketNumber || (pstrSocketHandle == XS_NULL_PTR))
    {
        ReturnValue = XS_PCCARD_FAILURE;  
    }
    else
    {
		if(vpstrBvdGPIORegs->GPLR2 & (1<<19))
		{
			pstrSocketHandle->pstrPCCardSocketState->blSocket0CDState = XLLP_FALSE;
		}
		else
		{
			pstrSocketHandle->pstrPCCardSocketState->blSocket0CDState = XLLP_TRUE;
		}

		if(vpstrBvdGPIORegs->GPLR2 & (1<<20))
		{
			pstrSocketHandle->pstrPCCardSocketState->blSocket0BVD1State = XLLP_FALSE;
		}
		else
		{
			pstrSocketHandle->pstrPCCardSocketState->blSocket0BVD1State = XLLP_TRUE;
		}

		if(vpstrBvdGPIORegs->GPLR1 & (1<<21))
		{
			pstrSocketHandle->pstrPCCardSocketState->blSocket0BVD2State = XLLP_FALSE;
		}
		else
		{
			pstrSocketHandle->pstrPCCardSocketState->blSocket0BVD2State = XLLP_TRUE;
		}

		if(vpstrBvdGPIORegs->GPLR2 & (1<<17))
		{
			pstrSocketHandle->pstrPCCardSocketState->blSocket0IREQState = XLLP_TRUE;
		}
		else
		{
			pstrSocketHandle->pstrPCCardSocketState->blSocket0IREQState = XLLP_FALSE;
		}
    }
    return ReturnValue;
#endif
} //end XsPcCardGetSocketState()


/******************************************************************************

  Function Name: XsPcCardResetSocket

  Description: 

  Global Registers Modified: 

  Input Arguments:

  Output Arguments:

  Return Value: 


*******************************************************************************/
XS_STATUS_T XsPcCardResetSocket(XS_PCCARD_SOCKET_T *pstrSocketHandle,
                                XLLP_VUINT16_T ushSocketNumber)
{
#if 0	//hzh
    XS_STATUS_T ReturnValue = XS_PCCARD_SUCCESS;
    XLLP_UINT16_T t; //loop counter

    //Check the validity of the input arguments to the function
    if((ushSocketNumber > XS_MAINSTONE_MAX_PCCARD_SOCKETS) ||
       (pstrSocketHandle == XS_NULL_PTR))
    {
        ReturnValue = XS_PCCARD_FAILURE;  
    } 
    else
    {
        switch(ushSocketNumber)
        {
            case XS_PCCARD_SOCKET0:
                //Check if a card is inserted in the socket.
                //If the CD status bit is *not* set in the PC Card Status register,
                //it implies that a card is properly inserted. Reset the socket 
                //in that case.
                if (!((pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR) & 
                       XLLP_BCR_PCMCIA_SCR_S0_nCD))
                {
                    //Assert reset
                    (pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR) |= 
                                          (XLLP_BCR_PCMCIA_SCR_S0_RESET);
                    XllpOstDelayMilliSeconds(pstrSocketHandle->pstrOstRegsHandle,
                                             50);
                    //Clear reset
                    (pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR) &= 
                                         ~(XLLP_BCR_PCMCIA_SCR_S0_RESET);
                    XllpOstDelayMilliSeconds(pstrSocketHandle->pstrOstRegsHandle,
                                             50);

                    //Wait for the READY signal to be set.This will indicate that the socket 
                    //is interrupt-ready and can function normally now.
                    for(t = 0; t < XS_PCCARD_MAX_READY_WAIT_TIME;  t += XS_PCCARD_READY_POLL_INTERVAL)
                    {
                        if (!((pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR) &
                               XLLP_BCR_PCMCIA_SCR_S0_nIRQ))
                        {
                            XllpOstDelayMilliSeconds(pstrSocketHandle->pstrOstRegsHandle,
                                                     XS_PCCARD_READY_POLL_INTERVAL);
                        }
                        else
                        {
                            break;
                        }
                    } //end for loop

                }
                //If no card is inserted or if a card is not properly inserted, then tri-
                //state the socket.
                else
                {
                    // Power down the socket.
                    XsPcCardDisableSocket(pstrSocketHandle, ushSocketNumber);
                    // Return the error.
                    ReturnValue = XS_PCCARD_FAILURE;
                }

            break;

            case XS_PCCARD_SOCKET1:
                //Check if a card is inserted in the socket.
                //If the CD status bit is *not* set in the PC Card Status register,
                //it implies that a card is properly inserted. Reset the socket 
                //in that case.
                if (!((pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) & 
                       XLLP_BCR_PCMCIA_SCR_S1_nCD))
                {
                    //Assert reset
                    (pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) |= 
                                          (XLLP_BCR_PCMCIA_SCR_S1_RESET);
                    XllpOstDelayMilliSeconds(pstrSocketHandle->pstrOstRegsHandle,
                                             50);
                    //Clear reset
                    (pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) &= 
                                         ~(XLLP_BCR_PCMCIA_SCR_S1_RESET);
                    XllpOstDelayMilliSeconds(pstrSocketHandle->pstrOstRegsHandle,
                                             50);

                    //Wait for the READY signal to be set.This will indicate that the socket 
                    //is interrupt-ready and can function normally now.
                    for(t = 0; t < XS_PCCARD_MAX_READY_WAIT_TIME;  t += XS_PCCARD_READY_POLL_INTERVAL)
                    {
                        if (!((pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) &
                               XLLP_BCR_PCMCIA_SCR_S1_nIRQ))
                        {
                            XllpOstDelayMilliSeconds(pstrSocketHandle->pstrOstRegsHandle,
                                                     XS_PCCARD_READY_POLL_INTERVAL);
                        }
                        else
                        {
                            break;
                        }
                    } //end for loop

                }
                //If no card is inserted or if a card is not properly inserted, then tri-
                //state the socket.
                else
                {
                    // Power down the socket.
                    XsPcCardDisableSocket(pstrSocketHandle, ushSocketNumber);
                    // Return the error.

⌨️ 快捷键说明

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