xspccardsocket.c

来自「优龙YLP270开发板 光盘自带的BIOS和实验例程源码 强烈推荐」· C语言 代码 · 共 756 行 · 第 1/3 页

C
756
字号
                }
                else
                {
                    // Card detect being cleared indicates card inserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0CDState = XLLP_TRUE;
                }

                //Check the BVD1 status bit[8] of the Socket 0 Status Register. Set
                //the corresponding member's value in the XLLP Socket State structure.
                if((pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR) & 
                                                         (XLLP_BCR_PCMCIA_SCR_S0_nSTSCHG_BVD1))
                {
                    // VDD voltage sense signal/card status changed not asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0BVD1State = XLLP_FALSE;
                }
                else
                {
                    // VDD voltage sense signal/card status changed asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0BVD1State = XLLP_TRUE;
                }

                //Check the BVD2 status bit[9] of the Socket 0 Status Register. Set
                //the corresponding member's value in the XLLP Socket State structure.
                if((pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR) & 
                                                         (XLLP_BCR_PCMCIA_SCR_S0_nSPKR_BVD2))
                {
                    // VDD voltage sense signal/audio digital speaker not asserted.
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0BVD2State = XLLP_FALSE;
                }
                else
                {
                    // VDD voltage sense signal/audio digital speaker asserted.
                    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;

} //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)
{
    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,

⌨️ 快捷键说明

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