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

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

?? mmc.c

?? MSP430F149讀寫SD卡以及簡單的文件系統 硬件:www.just430.com朱明老師提供的Easy430開發板以及SD卡模塊 底層驅動使用TI提供的MMC驅動程序
?? C
?? 第 1 頁 / 共 2 頁
字號:
// ***********************************************************
// File: mmc.c 
// Description: Library to access a MultiMediaCard 
//              functions: init, read, write ...
//  C. Speck / S. Schauer
//  Texas Instruments, Inc
//  June 2005
//
// Version 1.1
//   corrected comments about connection the MMC to the MSP430
//   increased timeout in mmcGetXXResponse
//
// ***********************************************************
// MMC Lib
// ***********************************************************


/* ***********************************************************
* THIS PROGRAM IS PROVIDED "AS IS". TI MAKES NO WARRANTIES OR
* REPRESENTATIONS, EITHER EXPRESS, IMPLIED OR STATUTORY, 
* INCLUDING ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS 
* FOR A PARTICULAR PURPOSE, LACK OF VIRUSES, ACCURACY OR 
* COMPLETENESS OF RESPONSES, RESULTS AND LACK OF NEGLIGENCE. 
* TI DISCLAIMS ANY WARRANTY OF TITLE, QUIET ENJOYMENT, QUIET 
* POSSESSION, AND NON-INFRINGEMENT OF ANY THIRD PARTY 
* INTELLECTUAL PROPERTY RIGHTS WITH REGARD TO THE PROGRAM OR 
* YOUR USE OF THE PROGRAM.
*
* IN NO EVENT SHALL TI BE LIABLE FOR ANY SPECIAL, INCIDENTAL, 
* CONSEQUENTIAL OR INDIRECT DAMAGES, HOWEVER CAUSED, ON ANY 
* THEORY OF LIABILITY AND WHETHER OR NOT TI HAS BEEN ADVISED 
* OF THE POSSIBILITY OF SUCH DAMAGES, ARISING IN ANY WAY OUT 
* OF THIS AGREEMENT, THE PROGRAM, OR YOUR USE OF THE PROGRAM. 
* EXCLUDED DAMAGES INCLUDE, BUT ARE NOT LIMITED TO, COST OF 
* REMOVAL OR REINSTALLATION, COMPUTER TIME, LABOR COSTS, LOSS 
* OF GOODWILL, LOSS OF PROFITS, LOSS OF SAVINGS, OR LOSS OF 
* USE OR INTERRUPTION OF BUSINESS. IN NO EVENT WILL TI'S 
* AGGREGATE LIABILITY UNDER THIS AGREEMENT OR ARISING OUT OF 
* YOUR USE OF THE PROGRAM EXCEED FIVE HUNDRED DOLLARS 
* (U.S.$500).
*
* Unless otherwise stated, the Program written and copyrighted 
* by Texas Instruments is distributed as "freeware".  You may, 
* only under TI's copyright in the Program, use and modify the 
* Program without any charge or restriction.  You may 
* distribute to third parties, provided that you transfer a 
* copy of this license to the third party and the third party 
* agrees to these terms by its first use of the Program. You 
* must reproduce the copyright notice and any other legend of 
* ownership on each copy or partial copy, of the Program.
*
* You acknowledge and agree that the Program contains 
* copyrighted material, trade secrets and other TI proprietary 
* information and is protected by copyright laws, 
* international copyright treaties, and trade secret laws, as 
* well as other intellectual property laws.  To protect TI's 
* rights in the Program, you agree not to decompile, reverse 
* engineer, disassemble or otherwise translate any object code 
* versions of the Program to a human-readable form.  You agree 
* that in no event will you alter, remove or destroy any 
* copyright notice included in the Program.  TI reserves all 
* rights not specifically granted under this license. Except 
* as specifically provided herein, nothing in this agreement 
* shall be construed as conferring by implication, estoppel, 
* or otherwise, upon you, any license or other right under any 
* TI patents, copyrights or trade secrets.
*
* You may not use the Program in non-TI devices.
* ********************************************************* */


// ********************************************************
//
//   
//
//            MSP430F169                  MMC Card 
//         -----------------          -----------------
//     /|\|              XIN|-   /|\ |                 |
//      | |                 |     |  |                 |
//      --|RST          XOUT|-    |--|Pin4/Vcc         |
//        |                 |        |                 |
//        |                 |        |                 |
//        |            P5.0 |<-------|Pin6/CD          |
//        |            P5.4 |------->|Pin1/CS          |
//        |                 |        |                 |
//        |      P5.2/SOMI1 |------->|Pin2/DIN         |
//        |      P5.1/SIMO1 |<-------|Pin7/DOUT        |
//        |      P5.3/UCLK1 |------->|Pin5/CLK         |
//        |                 |        |                 |
//        |                 |     |--|Pin3/GND         |
//                                |
//                                =
//
//  Pin configuration at MSP430F169:
//  --------------------------------
//  MSP430F169      MSP Pin        MMC             MMC Pin
//  -------------------------------------------------------------
//  P5.4              48           ChipSelect       1
//  P5.2 / SOMI       46           DataIn           2
//                                 GND              3 (0 V)
//                                 VDD              4 (3.3 V)
//  P5.3 / UCLK1      47           Clock            5
//  P5.0              44           CardDetect       6
//  P5.1 / SIMO       45           DataOut          7
//  -------------------------------------------------------------
//
//
//
//
#ifndef _MMCLIB_C
#define _MMCLIB_C
//
//---------------------------------------------------------------
#include "mmc.h"
#include  "MSP430x14x.H"

//#define withDMA


// Function Prototypes
char mmcGetResponse(void);
char mmcGetXXResponse(const char resp);
char mmcCheckBusy(void);
void initSPI (void);
unsigned char spiSendByte(const unsigned char data);
char mmc_GoIdle();

// Varialbes
char mmc_buffer[512] = { 0 };               // Buffer for mmc i/o for data and registers

//---------------------------------------------------------------------

// setup usart1 in spi mode
void initSPI (void)
{
  UCTL1 = SWRST;                            // 8-bit SPI Master **SWRST**
  UTCTL1 = CKPH | SSEL1 | SSEL0 | STC;      // SMCLK, 3-pin mode, clock idle low, data valid on rising edge, UCLK delayed
  UBR01 = 0x02;                             // 0x02: UCLK/2 (4 MHz), works also with 3 and 4
  UBR11 = 0x00;                             // -"-
  UMCTL1 = 0x00;                            // no modulation
  UCTL1 = CHAR | SYNC | MM | SWRST;         // 8-bit SPI Master **SWRST**
  UCTL1 &= ~SWRST;                          // clear SWRST
  ME2 |= USPIE1;                            // Enable USART1 SPI mode
  while (!(IFG2 & UTXIFG1));                // USART1 TX buffer ready (empty)?
}


// Initialize MMC card
char initMMC (void)
{

  //raise SS and MOSI for 80 clock cycles
  //SendByte(0xff) 10 times with SS high
  //RAISE SS
  int i;

  // Port 5 Function           Dir       On/Off
  //         5.0-mmcCD         Out       0 - card inserted
  //         5.1-Dout          Out       0 - off    1 - On -> init in SPI_Init
  //         5.2-Din           Inp       0 - off    1 - On -> init in SPI_Init
  //         5.3-Clk           Out       -                 -> init in SPI_Init
  //         5.4-mmcCS         Out       0 - Active 1 - none Active

  P5SEL |= 0x0E;
  P5SEL &= ~0x11;
  P5OUT |= 0x10;
  P5DIR |= 0x1A;

  initSPI();
  //initialization sequence on PowerUp
  CS_HIGH();
  for(i=0;i<=9;i++)
    spiSendByte(0xff);

  return (mmc_GoIdle());
}


char mmc_GoIdle()
{
  char response=0x01;
  CS_LOW();

  //Send Command 0 to put MMC in SPI mode
  mmcSendCmd(MMC_GO_IDLE_STATE,0,0x95);
  //Now wait for READY RESPONSE
  if(mmcGetResponse()!=0x01)
    return MMC_INIT_ERROR;

  while(response==0x01)
  {
    CS_HIGH();
    spiSendByte(0xff);
    CS_LOW();
    mmcSendCmd(MMC_SEND_OP_COND,0x00,0xff);
    response=mmcGetResponse();
  }
  CS_HIGH();
  spiSendByte(0xff);
  return (MMC_SUCCESS);
}

// mmc Get Responce
char mmcGetResponse(void)
{
  //Response comes 1-8bytes after command
  //the first bit will be a 0
  //followed by an error code
  //data will be 0xff until response
  int i=0;

  char response;

  while(i<=64)
  {
    response=spiSendByte(0xff);
    if(response==0x00)break;
    if(response==0x01)break;
    i++;
  }
  return response;
}

char mmcGetXXResponse(const char resp)
{
  //Response comes 1-8bytes after command
  //the first bit will be a 0
  //followed by an error code
  //data will be 0xff until response
  int i=0;

  char response;

  while(i<=1000)
  {
    response=spiSendByte(0xff);
    if(response==resp)break;
    i++;
  }
  return response;
}
char mmcCheckBusy(void)
{
  //Response comes 1-8bytes after command
  //the first bit will be a 0
  //followed by an error code
  //data will be 0xff until response
  int i=0;

  char response;
  char rvalue;
  while(i<=64)
  {
    response=spiSendByte(0xff);
    response &= 0x1f;
    switch(response)
    {
      case 0x05: rvalue=MMC_SUCCESS;break;
      case 0x0b: return(MMC_CRC_ERROR);
      case 0x0d: return(MMC_WRITE_ERROR);
      default:
        rvalue = MMC_OTHER_ERROR;
        break;
    }
    if(rvalue==MMC_SUCCESS)break;
    i++;
  }
  i=0;
  do
  {
    response=spiSendByte(0xff);
    i++;
  }while(response==0);
  return response;
}

// The card will respond with a standard response token followed by a data
// block suffixed with a 16 bit CRC.

char mmcReadBlock(const unsigned long address, const unsigned long count, unsigned char *pBuffer)
{
  unsigned long i = 0;
  char rvalue = MMC_RESPONSE_ERROR;

  // Set the block length to read
  if (mmcSetBlockLength (count) == MMC_SUCCESS)   // block length could be set
  {
    // SS = LOW (on)
    CS_LOW ();
    // send read command MMC_READ_SINGLE_BLOCK=CMD17
    mmcSendCmd (MMC_READ_SINGLE_BLOCK,address, 0xFF);
    // Send 8 Clock pulses of delay, check if the MMC acknowledged the read block command
    // it will do this by sending an affirmative response
    // in the R1 format (0x00 is no errors)
    if (mmcGetResponse() == 0x00)
    {
      // now look for the data token to signify the start of
      // the data
      if (mmcGetXXResponse(MMC_START_DATA_BLOCK_TOKEN) == MMC_START_DATA_BLOCK_TOKEN)
      {
#ifndef withDMA
        // clock the actual data transfer and receive the bytes; spi_read automatically finds the Data Block
        for (i = 0; i < count; i++)
          pBuffer[i] = spiSendByte(0xff);   // is executed with card inserted
#else
        U1IFG &= ~(URXIFG1 + URXIFG1);      /* clear flags */
        /* Get the block */
        /* DMA trigger is UART1 receive for both DMA0 and DMA1 */
        DMACTL0 &= ~(DMA0TSEL_15 | DMA1TSEL_15);
        DMACTL0 |= (DMA0TSEL_9 | DMA1TSEL_9);
        /* Source DMA address: receive register.  */
        DMA0SA = U1RXBUF_;
        /* Destination DMA address: the user data buffer. */
        DMA0DA = (unsigned short)pBuffer;
        /* The size of the block to be transferred */
        DMA0SZ = count;
        /* Configure the DMA transfer*/
        DMA0CTL =
          DMAIE   |                         /* Enable interrupt */
          DMADT_0 |                         /* Single transfer mode */
          DMASBDB |                         /* Byte mode */
          DMAEN |                           /* Enable DMA */
          DMADSTINCR1 | DMADSTINCR0;        /* Increment the destination address */

        /* We depend on the DMA priorities here.  Both triggers occur at
           the same time, since the source is identical.  DMA0 is handled
           first, and retrieves the byte.  DMA1 is triggered next, and
           sends the next byte. */
        /* Source DMA address: constant 0xFF (don't increment)*/
        DMA1SA = U1TXBUF_;
        /* Destination DMA address: the transmit buffer. */
        DMA1DA = U1TXBUF_;
        /* Increment the destination address */
        /* The size of the block to be transferred */
        DMA1SZ = count-1;
        /* Configure the DMA transfer*/
        DMA1CTL =

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
1024国产精品| 亚洲国产精品成人综合色在线婷婷| 国产黄人亚洲片| 国产一区二区三区黄视频 | 国产精品乡下勾搭老头1| 日韩激情av在线| 日韩va欧美va亚洲va久久| 亚洲国产一区二区a毛片| 亚洲一线二线三线久久久| 亚洲亚洲精品在线观看| 一区二区三区在线播放| 亚洲大片在线观看| 免费看日韩精品| 国产毛片一区二区| 成人综合激情网| 91蜜桃在线观看| 欧美久久一区二区| 日韩欧美国产精品一区| 欧美国产日韩亚洲一区| 一区二区三区日韩欧美精品| 日韩黄色在线观看| 高清不卡在线观看av| 91美女福利视频| 欧美一区二区视频在线观看2022| 欧美岛国在线观看| 欧美国产日韩亚洲一区| 亚洲天堂成人在线观看| 天堂在线亚洲视频| 国产高清在线精品| 一本色道亚洲精品aⅴ| 欧美日韩成人一区二区| 久久久不卡影院| 亚洲九九爱视频| 日产国产欧美视频一区精品| 国产69精品久久久久毛片| 在线视频欧美区| 欧美成人精品二区三区99精品| 国产精品久久久久毛片软件| 五月婷婷激情综合| 国产98色在线|日韩| 欧美三级中文字幕在线观看| 久久久久九九视频| 视频一区二区三区中文字幕| 国产成人av电影在线| 51精品久久久久久久蜜臀| 国产精品免费网站在线观看| 蜜桃视频免费观看一区| 99国产精品久久久久久久久久| 欧美成人猛片aaaaaaa| 一级精品视频在线观看宜春院| 国产综合成人久久大片91| 欧美系列一区二区| 自拍偷拍国产精品| 国产成人精品在线看| 4hu四虎永久在线影院成人| 亚洲品质自拍视频| 高清shemale亚洲人妖| 日韩欧美在线影院| 性做久久久久久免费观看欧美| 99久久综合狠狠综合久久| 精品久久国产老人久久综合| 午夜久久久久久| 91视频在线看| 中文字幕在线观看一区二区| 国产一区二区三区四区五区入口 | 在线亚洲人成电影网站色www| 国产亚洲1区2区3区| 久色婷婷小香蕉久久| 欧美日韩国产小视频| 亚洲综合免费观看高清完整版| 高清不卡在线观看av| 2021久久国产精品不只是精品| 欧美96一区二区免费视频| 欧美色网一区二区| 一区二区三区日本| 欧美在线一区二区| 一区二区三区免费在线观看| 色综合久久综合中文综合网| 亚洲三级久久久| 成人99免费视频| 亚洲欧美在线另类| 色综合天天综合狠狠| 亚洲精品国产第一综合99久久 | 婷婷开心久久网| 欧美日韩日本视频| 婷婷开心激情综合| 91精选在线观看| 久久99精品久久久久久国产越南 | 丰满亚洲少妇av| 中文在线资源观看网站视频免费不卡| 国产91丝袜在线播放| 国产亚洲成av人在线观看导航| 国产成人久久精品77777最新版本| 日本一区二区三区免费乱视频 | 日日夜夜精品视频天天综合网| 欧美日韩1区2区| 久久国产精品72免费观看| 久久蜜桃av一区二区天堂| 国产不卡在线视频| 亚洲欧洲日韩综合一区二区| 91黄色激情网站| 奇米影视在线99精品| 久久午夜国产精品| 91在线无精精品入口| 午夜精品在线看| 久久女同互慰一区二区三区| 91捆绑美女网站| 人人超碰91尤物精品国产| 久久久久久久一区| 欧美亚洲免费在线一区| 久久国产精品99久久久久久老狼 | 亚洲成人www| 久久综合五月天婷婷伊人| 99久久99久久精品免费看蜜桃| 天天射综合影视| 日本一区二区三区视频视频| 欧美伊人久久久久久久久影院 | 91免费观看视频| 日韩专区在线视频| 中文字幕在线播放不卡一区| 在线播放中文一区| av激情成人网| 久久草av在线| 午夜婷婷国产麻豆精品| 国产精品网曝门| 欧美成人精精品一区二区频| 色88888久久久久久影院按摩| 久久99精品国产.久久久久 | 欧美一级夜夜爽| 99久久er热在这里只有精品66| 久久国产精品99久久人人澡| 亚洲午夜一二三区视频| 国产精品欧美一区二区三区| 日韩欧美一区在线| 欧美三级电影网站| 99久久精品国产导航| 国产福利一区二区| 日本亚洲三级在线| 亚洲一区二区黄色| 自拍av一区二区三区| 中国av一区二区三区| 日本一区二区三区国色天香| 欧美一区二区久久| 4438x亚洲最大成人网| 在线观看av不卡| av影院午夜一区| 成人动漫视频在线| 粉嫩在线一区二区三区视频| 老司机午夜精品| 男女男精品视频网| 男女男精品视频| 美美哒免费高清在线观看视频一区二区| 亚洲永久精品国产| 亚洲无人区一区| 亚洲成a人v欧美综合天堂| 亚洲精品成人在线| 夜夜爽夜夜爽精品视频| 亚洲伦在线观看| 亚洲国产成人va在线观看天堂| 亚洲五码中文字幕| 奇米888四色在线精品| 免费成人性网站| 国产一区二区三区免费看| 国内精品视频666| 国产sm精品调教视频网站| 福利91精品一区二区三区| 成人性生交大片免费看中文| 成人av免费在线| 97精品视频在线观看自产线路二| 色婷婷久久一区二区三区麻豆| 在线观看欧美黄色| 欧美日韩一区在线| 日韩一区二区三区视频在线观看| 欧美不卡一区二区三区四区| 久久久久97国产精华液好用吗| 中文欧美字幕免费| 尤物在线观看一区| 青青草国产成人av片免费| 精品一区二区三区在线视频| 国产91丝袜在线观看| 色综合久久久久久久| 日韩一区二区在线看| 国产欧美一区二区精品婷婷| 亚洲综合色在线| 国产综合久久久久久鬼色| 成人久久18免费网站麻豆| 欧美影院一区二区| 精品国产一区二区精华| 中文字幕在线免费不卡| 日本欧美一区二区在线观看| 国产精品一区二区你懂的| 欧美一区二区三区小说| 国产日韩视频一区二区三区| 一区二区三区影院| 国产一区二区三区免费观看| 色屁屁一区二区| 久久久久88色偷偷免费| 亚洲午夜久久久久久久久电影网| 国产麻豆成人精品| 色国产综合视频|