<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          SD卡讀CID寄存器

          作者: 時間:2016-11-10 來源:網(wǎng)絡(luò) 收藏
          /**

          * @brief Card Identification Data: CID Register
          */
          typedef struct
          {
          uint8 ManufacturerID; // 生產(chǎn)標(biāo)識ID
          uint16 OEM_AppliID; // OEM/應(yīng)用 ID
          uint32 ProdName1; // 產(chǎn)品名稱1
          uint8 ProdName2; // 產(chǎn)品名稱2
          uint8 ProdRev; // 產(chǎn)品版本
          uint32 ProdSN; // 產(chǎn)品序號
          uint8 Reserved1; // 保留
          uint16 ManufactDate; // 生產(chǎn)日期
          uint8 CID_CRC; // CID CRC
          uint8 Reserved2; // always 1
          } SD_CID;

          本文引用地址:http://www.ex-cimer.com/article/201611/317388.htm

          /**************************************************************************************
          * FunctionName : SD_GetCIDRegister()
          * Description : 讀CID寄存器,寄存器長度為128,16字節(jié)
          * EntryParameter : cid - 寄存器
          * ReturnValue : 返回操作狀態(tài):成功-0
          **************************************************************************************/
          uint8 SD_GetCIDRegister(SD_CID *cid)
          {
          uint8 i;
          uint8 cidTable[16];
          uint8 count = 0xFF;
          uint8 rvalue = SD_RESPONSE_FAILURE; // 返回值

          SD_Enable(0); // SD卡使能

          if (SD_SendCmd(CMD10,0x00,0xFF) == SD_RESPONSE_NO_ERROR)
          {
          while ((SD_ReadByte() != SD_START_SINGLE_BLOCK_READ) && count) // 等待數(shù)據(jù)接收開始,收到0xFE表示開始
          {
          count--; // 等待超時
          }

          if (count != 0x00)
          {
          for (i=0; i<16; i++)
          {
          cidTable[i] = SD_ReadByte();
          }
          }

          SD_ReadByte(); // 讀CRC
          SD_ReadByte();

          rvalue = SD_RESPONSE_NO_ERROR; // 設(shè)置成功標(biāo)志
          }

          SD_Enable(1); // 清除SD卡片選
          SD_WriteByte(0xFF); // 8個時鐘脈沖的延遲

          // 把獲取值放入CID結(jié)構(gòu)體中
          cid->ManufacturerID = cidTable[0]; // Byte 0
          cid->OEM_AppliID = cidTable[1] << 8; // Byte 1
          cid->OEM_AppliID |= cidTable[2]; // Byte 2
          cid->ProdName1 = cidTable[3] << 24; // Byte 3
          cid->ProdName1 |= cidTable[4] << 16; // Byte 4
          cid->ProdName1 |= cidTable[5] << 8; // Byte 5
          cid->ProdName1 |= cidTable[6]; // Byte 6
          cid->ProdName2 = cidTable[7]; // Byte 7
          cid->ProdRev = cidTable[8]; // Byte 8
          cid->ProdSN = cidTable[9] << 24; // Byte 9
          cid->ProdSN |= cidTable[10] << 16; // Byte 10
          cid->ProdSN |= cidTable[11] << 8; // Byte 11
          cid->ProdSN |= cidTable[12]; // Byte 12
          cid->Reserved1 |= (cidTable[13] & 0xF0) >> 4; // Byte 13
          cid->ManufactDate = (cidTable[13] & 0x0F) << 8; // Byte 14
          cid->ManufactDate |= cidTable[14]; // Byte 15
          cid->CID_CRC = (cidTable[15] & 0xFE) >> 1;
          cid->Reserved2 = 1;

          return rvalue;
          }



          關(guān)鍵詞: SD卡讀CID寄存

          評論


          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();