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

📄 xllp_pccardsocket.c

📁 Windows CE 6.0 BSP for VOIP sample phone. Intel PXA270 platform.
💻 C
📖 第 1 页 / 共 3 页
字号:
                if((pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR) & (XLLP_BCR_PCMCIA_SCR_S0_nSTSCHG_BVD1))
                {
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0BVD1State = XLLP_FALSE;
                }
                else
                {
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0BVD1State = XLLP_TRUE;
                }

                //
                //Check the BVD2 status bit[9] of the Socket 0 Status Register. If set, then it
                //indicates that the card status has not changed. If clear, then it indicates that
                //a card status change event has occurred.
                //
                if((pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR) & (XLLP_BCR_PCMCIA_SCR_S0_nSPKR_BVD2))
                {
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0BVD2State = XLLP_FALSE;
                }
                else
                {
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0BVD2State = XLLP_TRUE;
                }

                //
                //Check the IREQ status bit[10] of the Socket 0 Status Register. If set, then it
                //indicates that the card is READY (i.e. no interrupt request is pending). If clear,
                //it indicates that the card is BUSY, pending an interrupt request.
                //
                if((pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR) & (XLLP_BCR_PCMCIA_SCR_S0_nIRQ))
                {
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0IREQState = XLLP_TRUE;
                }
                else
                {
                    pstrSocketHandle->pstrPCCardSocketState->blSocket0IREQState = XLLP_FALSE;
                }

                break;

            case XLLP_PCCARD_SOCKET1:

                //
                //Check the CD status bit[5] of the Socket 1 Status Register. If set, it indicates
                //that a card is either not present or is not properly inserted in the socket. If clear,
                //it indicates that a card is present in the socket.
                //
                if((pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) & (XLLP_BCR_PCMCIA_SCR_S1_nCD))
                {
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1CDState = XLLP_FALSE;
                }
                else
                {
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1CDState = XLLP_TRUE;
                }

                //
                //Check the BVD1 status bit[8] of the Socket 1 Status Register. If set, then it
                //indicates that the card status has not changed. If clear, then it indicates that
                //a card status change event has occurred.
                //
                if((pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) & (XLLP_BCR_PCMCIA_SCR_S1_nSTSCHG_BVD1))
                {
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1BVD1State = XLLP_FALSE;
                }
                else
                {
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1BVD1State = XLLP_TRUE;
                }

                //
                //Check the BVD2 status bit[9] of the Socket 1 Status Register. If set, then it
                //indicates that the card status has not changed. If clear, then it indicates that
                //a card status change event has occurred.
                //
                if((pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) & (XLLP_BCR_PCMCIA_SCR_S1_nSPKR_BVD2))
                {
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1BVD2State = XLLP_FALSE;
                }
                else
                {
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1BVD2State = XLLP_TRUE;
                }

                //
                //Check the IREQ status bit[10] of the Socket 1 Status Register. If set, then it
                //indicates that the card is READY (i.e. no interrupt request is pending). If clear,
                //it indicates that the card is BUSY, pending an interrupt request.
                //
                if((pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) & (XLLP_BCR_PCMCIA_SCR_S1_nIRQ))
                {
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1IREQState = XLLP_TRUE;
                }
                else
                {
                    pstrSocketHandle->pstrPCCardSocketState->blSocket1IREQState = XLLP_FALSE;
                }

                break;

            default:
                break;

        } //end switch(uSocket)

    } //end if

    return ReturnValue;

} //end XllpPCCardGetSocketState()


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

  Function Name: XllpPCCardResetSocket

  Description:

  Global Registers Modified:

  Input Arguments:

  Output Arguments:

  Return Value:


*******************************************************************************/
XLLP_STATUS_T XllpPCCardResetSocket(XLLP_PCCARDSOCKET_T *pstrSocketHandle,
                                    XLLP_VUINT16_T       ushSocketNumber)
{
    XLLP_STATUS_T ReturnValue = XLLP_STATUS_SUCCESS;
    XLLP_BOOL_T blCDStatus = XLLP_FALSE;
    XLLP_BOOL_T blRDYStatus = XLLP_FALSE;
    XLLP_UINT16_T t; //loop counter

    //Check the validity of the input arguments to the function
    if((ushSocketNumber > XLLP_MAINSTONE_MAX_PCCARD_SOCKETS) ||
       (pstrSocketHandle == XLLP_NULL_PTR))
    {
        ReturnValue = XLLP_STATUS_PCCARD_FAILURE;   
    }

    if(ReturnValue != XLLP_STATUS_PCCARD_FAILURE)
    {
        switch(ushSocketNumber)
        {
            case XLLP_PCCARD_SOCKET0:

                //
                //Check if a card is inserted in the socket
                //
                blCDStatus = ((pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR) & (XLLP_BCR_PCMCIA_SCR_S0_nCD));

                //
                //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(!blCDStatus)
                {
                    //Assert reset
                    (pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR) |= (XLLP_BCR_PCMCIA_SCR_S0_RESET);

					// Wait long enough for the device to notice.
                    XllpOstDelayMilliSeconds(pstrSocketHandle->pstrOstRegsHandle,200);

                    //Clear reset
                    (pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR) &= ~(XLLP_BCR_PCMCIA_SCR_S0_RESET);

                    //Wait for the READY signal to be set.This will indicate that the socket
                    XllpOstDelayMilliSeconds(pstrSocketHandle->pstrOstRegsHandle,20);
                    //is interrupt-ready and can function normally now.
                    for(t = 0; t < XLLP_PCCARD_MAX_READY_WAIT_TIME;  t += XLLP_PCCARD_READY_POLL_INTERVAL)
                    {
                        blRDYStatus = ((pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR) &
                                                             (XLLP_BCR_PCMCIA_SCR_S0_nIRQ));

                        if(!blRDYStatus)
                        {
                            XllpOstDelayMilliSeconds(pstrSocketHandle->pstrOstRegsHandle,
                                                     XLLP_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
                {
                    //Tri-state the socket here.
                    ReturnValue = XLLP_STATUS_PCCARD_FAILURE;
                }

            break;

            case XLLP_PCCARD_SOCKET1:
                //Check if a card is inserted in the socket
                blCDStatus = ((pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) &
                                                     (XLLP_BCR_PCMCIA_SCR_S1_nCD));

                //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(!blCDStatus)
                {
                    //Assert reset
                    (pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) |=
                                          (XLLP_BCR_PCMCIA_SCR_S1_RESET);

					// Wait long enough for the device to notice.
                    XllpOstDelayMilliSeconds(pstrSocketHandle->pstrOstRegsHandle,200);

                    //Clear reset
                    (pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) &=
                                         ~(XLLP_BCR_PCMCIA_SCR_S1_RESET);
                    XllpOstDelayMilliSeconds(pstrSocketHandle->pstrOstRegsHandle,20);


                    //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 < XLLP_PCCARD_MAX_READY_WAIT_TIME;  t += XLLP_PCCARD_READY_POLL_INTERVAL)
                    {
                        blRDYStatus = ((pstrSocketHandle->pstrBcrHandle->PCMCIAS1SCR) &
                                                             (XLLP_BCR_PCMCIA_SCR_S1_nIRQ));

                        if(!blRDYStatus)
                        {
                            XllpOstDelayMilliSeconds(pstrSocketHandle->pstrOstRegsHandle,
                                                     XLLP_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
                {
                    //Tri-state the socket here
                    ReturnValue = XLLP_STATUS_PCCARD_FAILURE;
                }

            break;

            default:
                //TBD. Should not be here at all!!
                ReturnValue = XLLP_STATUS_PCCARD_FAILURE;

            break;
        } //end switch

    } //end if

    return ReturnValue;

} //end XllpPCCardResetSocket()



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

  Function Name: XllpPCCardPowerOn

  Description:

  Global Registers Modified:

  Input Arguments:

  Output Arguments:

  Return Value:


*******************************************************************************/
XLLP_STATUS_T XllpPCCardPowerOn(XLLP_PCCARDSOCKET_T *pstrSocketHandle,
                                XLLP_VUINT16_T      ushSocketNumber,
                                XLLP_UINT32_T       uiCardVoltage)
{
    XLLP_STATUS_T ReturnValue = XLLP_STATUS_SUCCESS;



    //
    //Check the validity of the input arguments to the function
    //
    if((ushSocketNumber > XLLP_MAINSTONE_MAX_PCCARD_SOCKETS) ||
       (pstrSocketHandle == XLLP_NULL_PTR))
    {
        ReturnValue = XLLP_STATUS_PCCARD_FAILURE;
    }

    if(ReturnValue != XLLP_STATUS_PCCARD_FAILURE)
    {
        switch(ushSocketNumber)
        {
            case XLLP_PCCARD_SOCKET0:

                if(uiCardVoltage == XLLP_PCCARD_5_00VOLTS)
                {
                    //
                    //5V card detected; set bit[2] of the status register
                    //
                    pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR |= (XLLP_BIT_2);
                    pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR &= ~(XLLP_BIT_3);
                }
                else if(uiCardVoltage == XLLP_PCCARD_3_30VOLTS)
                {
                    //
                    //3.3V card detected; set bit[3] of the status register
                    //
                    pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR |= (XLLP_BIT_3);
                    pstrSocketHandle->pstrBcrHandle->PCMCIAS0SCR &= ~(XLLP_BIT_2);
                }
                else
                {
                    //
                    //Unsupported PC Card voltage
                    //
                    ReturnValue = XLLP_STATUS_PCCARD_FAILURE;
                }

⌨️ 快捷键说明

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