亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sdmmc.c

?? WINDOWSCE4.2 ARM PXA255 SDMMC驅動程序源代碼
?? C
?? 第 1 頁 / 共 5 頁
字號:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
/********************************************************************************
* Filename: sdmmc.c - SD/MMC protocol
*
* SanDisk Host Developer's Toolkit
*
* Copyright (c) 1997 - 2000 SanDisk Corporation
* All rights reserved.
* This code may not be redistributed in source or linkable object form
* without the consent of its author.
*
* Description:
*       This module can be used to interface to the MMC card in MMC or
*       SPI modes. It supports a multiple card environment. The reset and
*       identification processes assume multiple cards on the bus.
*       In MMC mode, the card number is used as the RCA operand in the
*       commands.
*       In SPI mode, the card number is passed to the low level hardware drivers
*       where the appropriate CS signal should be asserted.
*
********************************************************************************/

#include "sdconfig.h"
#include "sdmmc.h"

extern void test_mmc(void);
#if (USE_SPI || USE_MMC || USE_SPI_EMULATION || USE_MMC_EMULATION || USE_SD)

#include "sdmmc.h"

#if (USE_SD)
/*******************************************************************************
* Name: mmcSDApplCmd - Handle all application commands
*
* Description:
*       Send CMD55 to switch the card into application mode. Then,
*       the application command is sent.
*
* NOTE: buff is a pointer to data buffer. This buffer is ONLY for the
*       command associated with data to/from the card.  For the command
*       without data requirement, this buff should be set to NULL before
*       calling this routine.
*
* Input:
*       PDEVICE_CONTROLLER pc
*       UCHAR *buff
*       ULONG multipp
*       UINT16 RCA
*       RESP_TYPE resp
*       UINT16 Cmd
*
* Output:
*       Depending on the type of the command.
*
* Returns:
*       Completion code
* 
********************************************************************************/
MMC_CC mmcSDApplCmd(PDEVICE_CONTROLLER pc, UCHAR *buff, ULONG multipp, UINT16 noBlocks, UINT16 RCA, RESP_TYPE resp, UINT16 Cmd)
{
    MMC_CC  respErr;
        UINT16  tLength;

        tLength = 0;
        if (Cmd & SECURITY_CMD_BIT)
                tLength = noBlocks;

#if (USE_SPI || USE_SPI_EMULATION)
        /* SD ACMD6 command is not supported in SPI mode. Only 1-bit bus is supported. */
    
    /* Turn Chip select signal on */
    selectChip( RCA );

    /* Send CMD55 to the card to start Application Specific Command */
    respErr = mmcCommandAndResponse ( pc,
            (((ULONG)RCA) << 16),
                        APPL_CMD,
            0,
            R1 );
    
    /* Turn Chip select signal off */
     deSelectChip( RCA );
#else
        /* ONLY FOR data transfer when buff is set */ 
    if (buff)
    {
        /* Put the card in transfer state. */
                respErr = mmcSetXferState (pc, RCA);
    }

    /* Send CMD55 to the card to start Application Specific Command */
    respErr = mmcCommandAndResponse ( pc,
                        (((ULONG)RCA) << 16),
                        APPL_CMD, 
            0,
            R1 );

#endif

        /* The CMD55 is not supported by MMC card.  The MMC card may
           not responded or responded with an error to this command.
           Check for error here to tell if it is MMC or SD card. 
    */
        /***********************************************************
           An SD card should behave well to this command (NO ERROR).
           MMC card in SPI mode should reject or not respond to it.
           MMC card in MMC mode should reject or not respond to it.
        ***********************************************************/
        if ( ( respErr != MMC_NO_ERROR) && (respErr == MMC_COMUNC_ILLEG_COM) )
    {
        pc->error_code = (UINT16)respErr;
        return respErr;
    }

    /* Application Specific command follows CMD55. */
#if (USE_SPI || USE_SPI_EMULATION)
        /* Turn Chip select signal on. */
    selectChip( RCA );
#endif

    respErr = mmcCommandAndResponse ( pc,
                                multipp,
                                Cmd,
                                tLength,
                                resp );

        /* The buff is ONLY for data transfer. Check it here for that purpose. */
        if (buff)
        {
                /* Security data will be handled different module */
                if (Cmd & SECURITY_CMD_BIT)
                        return respErr;

                /* Set up the buffer */
                pc->user_address = (USERADDRESS)buff;

                /* Get information */
                if (respErr == MMC_NO_ERROR)
                {
                        if (Cmd == SD_SEND_SCR)
                        {
                                tLength = SD_SCR_LENGTH;
                        }
                        else if (Cmd == SD_STATUS)
                        {
                                tLength = SD_STATUS_LENGTH;
                        }

                        /* Get data */
                        respErr = receive_data( pc, tLength, 1, NO );
                }
        }

#if (USE_SPI || USE_SPI_EMULATION)
        /* Turn Chip select signal off. */
        deSelectChip( RCA );
#endif

    return respErr;
}
#endif /* (USE_SD) */

/*******************************************************************************
* Name: mmcReset - Initialize the card
*
* Description:
*       Resets the cards and the MMC or SPI HW port.
*       It must be called after power on before any other commands.
*
*       This function sends reset command (CMD0) to the card and waits for the
*       card to complete the initialization process by polling its status using
*       send_op_condition command (CMD1) to complete its reset process.
*
*       In MMC mode, this function can be used to query a card stack for the
*       the common voltage range or to set a voltage range and initialize
*       the cards to be ready.
*
*       In SPI mode, the reset is card specific. The card number is used for the
*       device to be intialized for the card to be ready.
*
* Input:
*       setupInfo       In MMC mode, Host operating voltage range.
*                       In SPI mode, Card Address.
*
* Output:
*       Initialization process is finished.
*
* Returns:
*       Completion code
* 
********************************************************************************/
MMC_CC mmcReset( PDEVICE_CONTROLLER pc, ULONG setupInfo )
{
        UINT32  cardType;
    MMC_CC  resErr;
        UINT16  sdFlag;
        UINT16  readyFlag;
	
#if (USE_SPI || USE_SPI_EMULATION)
    INT16   ChipNum;

    ChipNum = (INT16)setupInfo;
    pc->timer = (RESET_DELAY << 2);
        cardType = NO;
        readyFlag = NO;
        resErr = MMC_NO_ERROR;
        pc->drive_active = ChipNum;

    /* Turn Chip select signal on */
    selectChip( ChipNum );

        /* Reset the card */
    resErr = mmcCommandAndResponse ( pc,
                0L,
                GO_IDLE_STATE,
                0,
                R1 );

        /* Turn Chip select signal off */
    deSelectChip ( ChipNum );

        /* Make sure the card is presented. The card should not be ready. */
        if ( (resErr != MMC_CARD_IS_NOT_READY) )
        {
                /* At this time if resErr == 0, it's really an error. */
        pc->error_code = MMC_INTERFACE_ERROR;
        return MMC_INTERFACE_ERROR;
    }

        /* It is very much to tell at this point, the card is in the slot
           because CMD0 has been executed correctly. Now, it is the focus
           of figuring out what type of the card is in the slot.
        */
#if (USE_SD)
        sdFlag = YES;           /* For SD card first */
#else
        sdFlag = NO;
#endif
    while ( pc->timer )
    {
                /* There is no way to tell what the card type is at this
                   point. The application command ACMD41 is sent first to
                   test.  If there is no response,  or error with ACMD41,
                   the card is not an SD card.  Then, the MMC card will
                   be tested next by sending CMD1.
        */   

#if (USE_SD)
                /* Check for SD card first. */
                if (sdFlag)
        {
                        /* Make sure the card is ready */
                        resErr = mmcSDApplCmd(pc, SDNULL, 0L, 0, 0, R1, SD_SEND_OP_COND);

                        /* The returned error indicates the card type. */
                        if (resErr == MMC_COMUNC_ILLEG_COM)
            {
                                /* An error shows that the card could be SPI
                                   or no card in the slot. We will retest this
                                   again in SPI mode to verify the card is an
                                   MMC card in SPI mode.
                                */
                                sdFlag = NO;
                        }
                        else if (resErr == MMC_NO_ERROR)
                        {
                                /* Hee Ha, Got an SD card. */
                                cardType = SD_TYPE;     /* Set card type */
                                readyFlag = CARD_READY_FLAG;

/* Comment out for the FPGA is not working at this time */
#if 0
                                /* Get OCR. Checking for card ready. The OCR
                                   information is returned in pc->LastResponse[1..3].
                                */
                                selectChip( ChipNum );
                                resErr = mmcCommandAndResponse ( pc,
                                                        0L,
                                                        SD_READ_OCR,
                                                        0,
                                                        R3 );
                                deSelectChip ( ChipNum );

                                if (resErr == MMC_NO_ERROR)
                                {
                                        /* Get the card BUSY/READY bit */
                                        readyFlag = to_WORD((UCHAR *)&pc->LastResponse[1]);
                                        if (!(readyFlag & CARD_READY_FLAG))
                                        {
                                                /* If the card is not ready, do it again */
                                                resErr = MMC_CARD_IS_NOT_READY;
                                        }
                                }
#endif
            }
        }
#endif /* (USE_SD) */

                /* Now, check for MMC card in SPI mode. */
                if (!sdFlag)    /* The current card may be an MMC card */
        {
                        /* Check the card to make sure the device is ready */
			RETAILMSG(1, (TEXT(" Before sending SEND_OP_COND command"\r\n")));
      //      selectChip( ChipNum );        
            resErr = mmcCommandAndResponse ( pc,
                    0L,
                    SEND_OP_COND,
                                        0,
                                        R1 );
    //        deSelectChip ( ChipNum );

                        /* MMC card will respond to CMD1. Verify it here. */
                        if ( (resErr == MMC_CARD_IS_NOT_READY) || (resErr == MMC_NO_ERROR) )
                        {
                                /* Set the card type */
                                cardType = SPI_TYPE;

                                sdFlag = NO;
								RETAILMSG(1, (TEXT(" After sending SEND_OP_COND command, MMC_CARD_NOT_READY\r\n")));
                        }
        }                

                /* Now, make sure the card behaves well. */
        if ( (resErr != MMC_CARD_IS_NOT_READY) && resErr )
        {
            pc->error_code = (UINT16)resErr;
            return resErr;
        }

                /* Make sure the card is in the slot. */
        if ( resErr == MMC_CARD_IS_NOT_READY )
        {
            pc->timer--;
            OS_WAIT(1);     /* Delay to 1 ms */
            if ( !pc->timer )
            {
                pc->error_code = MMC_CARD_IS_NOT_READY;
                return MMC_CARD_IS_NOT_READY;
            }
        }
                else if (resErr == MMC_NO_ERROR)
                {
                        /* Set the card type. */
                        pc->drive[ChipNum].drv_type = cardType;

                        /* The RCA is the Chip number. */
                        pc->drive[ChipNum].RCA = (UINT16)ChipNum;
                        break;
                }
    }
    
#else /* This is for MMC */
        UINT16  i, bInterface;
        UINT16  devCount;
//	RETAILMSG(1, (TEXT("mmcReset() entered \r\n")));
    pc->timer = (RESET_DELAY << 2);
        cardType = NO;
        readyFlag = NO;
        resErr = MMC_NO_ERROR;

        /* Reset all devices on the bus. */
 /*   mmcCommandAndResponse ( pc,
            0L,
            GO_IDLE_STATE, 
            0,
            R0 );
*/
        bInterface = 0;
        devCount = 0;

        sdFlag = NO;

#if (USE_SD)
DO_ALL_BUS_INTERFACE:
#endif
    for (i = 0; i < (CID_BYTE_LENGTH/2); pc->LastResponse[i++] = 0); /* Clear buffer */

        /* Delay it for a while */
        OS_WAIT(25);

        /* Wait for all cards to be ready */
    while (pc->timer)
    {
                /* There is no way to tell what type of the card is at this
                   point. The command CMD1 is sent first to test the card.
                   Because the MMC card is always responded to CMD1, if there
                   is no response, or an error, on the return, we could assume
                   that the card is not MMC card, the application command ACMD41
                   will be sent next to test for SD card.
        */   
                /* Now, check for MMC card. SD do not support CMD1 in MMC mode. */
                if (!sdFlag)    /* The current card may be an MMC card */
        {
                        /* Check for MMC card. */
            resErr = mmcCommandAndResponse ( pc,
                    setupInfo,
                                        SEND_OP_COND,
                    0,
                    R3 );

                        /* Check if the card is an MMC card. */
                        if (resErr == MMC_NO_ERROR)
                        {
                                /* Got the response from the card. */
                                /* The card is indeed an MMC card. */
                                cardType = MMC_TYPE;
                                readyFlag = to_WORD((UCHAR *)&pc->LastResponse[0]);
								// RETAILMSG(1, (TEXT("is the card ready? %x\r\n"), readyFlag));
                        }
                        /* CMD1 failed.  There are two ways to explain this:
                           1. SD card seems not to respond to CMD1 at all (MMC mode).
                              Therefore, based on the error, this could be an SD card.
                              Try ACMD41 command to verify this claim.
                           2. There is no card in the slot.
                        */
                        /* Try SD application command. This application command should
                           return an error. It is unclear why the card returns an error
                           after CMD1. Is it a firmware bug? or...
                           Whatever that error is, just ignore it.
                           You can tell very much the card is an SD card because of this
                           error.

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日本视频一区二区| 欧日韩精品视频| 在线观看91视频| 久久婷婷成人综合色| 亚洲一区二区在线免费看| 国产乱码精品一区二区三区av| 欧美色综合影院| 国产精品国产成人国产三级| 毛片不卡一区二区| 欧美日韩激情一区| 亚洲精品欧美激情| 成人精品免费视频| 久久伊99综合婷婷久久伊| 天堂资源在线中文精品| 色一区在线观看| 亚洲欧美日韩一区二区三区在线观看| 狠狠色丁香婷婷综合| 日韩欧美高清一区| 免费看日韩精品| 777xxx欧美| 蜜桃视频一区二区三区在线观看| 在线观看国产一区二区| 亚洲美女视频一区| 99久久国产综合色|国产精品| 久久久国产午夜精品| 韩国中文字幕2020精品| 日韩女同互慰一区二区| 日本欧美在线观看| 欧美一区二区观看视频| 日韩国产高清在线| 欧美一区二区免费视频| 免费在线观看一区| 精品久久五月天| 国产精品一二一区| 日本一区二区三区电影| 不卡的av电影| 亚洲精品自拍动漫在线| 99久久精品国产精品久久| 亚洲同性gay激情无套| av亚洲精华国产精华精| 一区二区中文字幕在线| 在线观看亚洲一区| 秋霞成人午夜伦在线观看| 69精品人人人人| 激情六月婷婷久久| 中文字幕+乱码+中文字幕一区| 成人免费黄色大片| 一区二区在线观看视频| 欧美精三区欧美精三区| 久久99久久99小草精品免视看| 久久五月婷婷丁香社区| 成人av动漫在线| 亚洲18女电影在线观看| 日韩三级电影网址| 99久久精品免费精品国产| 亚洲一区在线视频观看| 精品国产一区二区三区不卡| 成人精品视频.| 五月婷婷久久综合| 久久精品一区蜜桃臀影院| 色婷婷精品大视频在线蜜桃视频| 偷拍日韩校园综合在线| 久久久久88色偷偷免费| 91香蕉国产在线观看软件| 石原莉奈在线亚洲二区| 国产调教视频一区| 欧美三级中文字幕在线观看| 精品一区二区在线看| 中文字幕一区在线观看| 91精品欧美久久久久久动漫| 国产91富婆露脸刺激对白| 亚洲va欧美va人人爽午夜| 久久综合色之久久综合| 91国产福利在线| 国产激情精品久久久第一区二区| 亚洲一区二区三区在线播放| 久久综合色播五月| 精品污污网站免费看| 大白屁股一区二区视频| 日韩国产欧美三级| 一区二区三区中文字幕| 精品久久久久香蕉网| 欧美性猛片xxxx免费看久爱| 高清不卡在线观看| 九九精品一区二区| 亚洲大片免费看| 自拍偷在线精品自拍偷无码专区| 久久在线免费观看| 欧美精品丝袜中出| 欧美在线免费观看视频| 国产99精品在线观看| 久久成人久久爱| 亚洲mv在线观看| 亚洲欧美偷拍卡通变态| 欧美韩国日本一区| 久久在线观看免费| 欧美一区二区三区日韩| 欧美三区在线视频| 欧美午夜精品一区二区蜜桃 | 国产日韩欧美制服另类| 欧美精品乱码久久久久久| 色综合久久久久| 91视频www| 色综合久久久久综合体桃花网| 国产麻豆视频一区二区| 韩国女主播成人在线观看| 美日韩一区二区| 日本成人在线看| 男女性色大片免费观看一区二区 | 欧美高清hd18日本| 欧美日本免费一区二区三区| 欧美午夜影院一区| 欧洲精品一区二区| 欧美久久久久久久久久 | 91视视频在线直接观看在线看网页在线看 | 国产精品二区一区二区aⅴ污介绍| 久久综合九色综合欧美98| 日韩精品一区二区在线| 日韩久久免费av| 亚洲精品一区二区三区四区高清| 欧美一区二区在线免费观看| 欧美一区二区三区喷汁尤物| 精品日韩欧美在线| 久久免费的精品国产v∧| 日本一区二区成人在线| 国产精品国产三级国产a| 亚洲精品菠萝久久久久久久| 亚洲一区二区三区四区五区中文| 夜夜揉揉日日人人青青一国产精品| 亚洲一区免费在线观看| 日韩中文字幕一区二区三区| 美女高潮久久久| 成人黄页毛片网站| 日本精品视频一区二区| 欧美精品123区| 久久综合色天天久久综合图片| 国产精品污www在线观看| 亚洲蜜臀av乱码久久精品蜜桃| 午夜激情久久久| 国内精品第一页| 色一区在线观看| 日韩欧美激情四射| 国产精品传媒在线| 五月婷婷欧美视频| 高清免费成人av| 欧美日韩免费视频| 国产欧美精品一区二区色综合| 一区二区三区精品在线观看| 免费一级片91| 91色在线porny| 久久综合网色—综合色88| 亚洲你懂的在线视频| 伦理电影国产精品| 99久久精品一区二区| 欧美成人乱码一区二区三区| 国产精品乱码一区二区三区软件 | 国产精品久久综合| 婷婷丁香久久五月婷婷| 成人性生交大片免费看视频在线 | 欧美中文字幕亚洲一区二区va在线| 欧美一区二区日韩| 一区二区在线观看av| 久久66热偷产精品| 欧日韩精品视频| 国产欧美日韩亚州综合| 日韩精品亚洲一区二区三区免费| 国产福利91精品一区| 欧美剧在线免费观看网站| 欧美国产一区在线| 久久99精品久久久久久国产越南| 色综合色狠狠综合色| 国产日韩一级二级三级| 日韩精品高清不卡| 91福利国产精品| 国产精品久久久爽爽爽麻豆色哟哟| 美腿丝袜在线亚洲一区| 欧美日韩在线直播| 日韩一区有码在线| 国产xxx精品视频大全| 精品欧美黑人一区二区三区| 亚洲成av人在线观看| 91视频观看视频| 中文字幕亚洲成人| 高清av一区二区| 国产亚洲成aⅴ人片在线观看| 男女性色大片免费观看一区二区 | 国产精品自拍网站| 日韩欧美美女一区二区三区| 亚洲午夜电影在线| 91精品91久久久中77777| 国产精品久久精品日日| 国产福利精品导航| www国产成人免费观看视频 深夜成人网| 亚洲午夜国产一区99re久久| 在线视频中文字幕一区二区| 亚洲三级免费观看| 91久久精品一区二区二区| 亚洲图片你懂的| 欧美亚洲国产一区二区三区| 一区二区在线观看av|