freepeople性欧美熟妇, 色戒完整版无删减158分钟hd, 无码精品国产vα在线观看DVD, 丰满少妇伦精品无码专区在线观看,艾栗栗与纹身男宾馆3p50分钟,国产AV片在线观看,黑人与美女高潮,18岁女RAPPERDISSSUBS,国产手机在机看影片

正文內(nèi)容

mcs51mcu讀寫sd卡版(單片機(jī)論文)畢業(yè)論文-資料下載頁(yè)

2025-06-20 12:56本頁(yè)面
  

【正文】 = SBUF。//注意串口調(diào)試助手的發(fā)送方式, //十六進(jìn)制發(fā)送要注意 RI = 0。 } ES = 1。}/*********************************************** 函數(shù): UART_Send_Enter.* 描述: 此函數(shù)就是發(fā)送0d 0a這兩個(gè)字節(jié)。在串口調(diào)試助手上有回車換行* 輸入: 無(wú).* 輸出: 無(wú).* 返回: 無(wú).*************************************************/void Uart_Send_Enter(void){ Uart_Send_Char(0x0d)。 Uart_Send_Char(0x0a)。}/************************************************** *File name : Mold *Author : peng *MCLK : *Version : *Last modified : 20091123***************************************************/include include //延時(shí)微妙void Delay_us(INT32U us){ while(us)。}//延時(shí)毫秒.void Delay_ms(INT32U ms){ INT32U i = 0。 INT32U j = 0。 for(i = 0。 i ms。 i++) { for(j = 0。 j 1000。 j++)。 }}/**********************************************************功能描述:將一個(gè)32位的變量轉(zhuǎn)為字符串,比如把1234轉(zhuǎn)為 1234參數(shù)說明:dat:帶轉(zhuǎn)的long型的變量 str:指向字符數(shù)組的指針,轉(zhuǎn)換后的字節(jié)串放在其中 ***************************************************/void Itoa(unsigned char vaule, char *string) { char temp[20] = {0}。 unsigned char i=0。 unsigned char j=0。 while(vaule) { temp[i] = vaule%10 + 39。039。 i++。 vaule/=10。 } j = i。 for(i=0。ij。i++) { string[i] = temp[ji1]。 } if(!i) { string[i++] = 39。039。 } string[i] = 0。}/**********************************************************功能描述:將一個(gè)字符串轉(zhuǎn)為32位的變量,比如1234轉(zhuǎn)為1234參數(shù)說明:str:指向待轉(zhuǎn)換的字符串 返回說明:轉(zhuǎn)換后的數(shù)值 *************************************************/unsigned long Atoi(char *string) { unsigned long temp = 0。 unsigned long fact = 1。 unsigned char len = strlen(string)。 unsigned char i = 0。 for(i=len。 i0。 i) {temp += ((string[i1]0x30)*fact)。 fact *= 10。 } return temp。} /******************************************* *File name : *Author : peng *MCLK : *Version : *Last modified : 2010429********************************************/include include include include sbit SD_CLK = P1^1。 //時(shí)鐘信號(hào)sbit SD_SDI = P1^2。 //數(shù)據(jù)輸入sbit SD_SDO = P1^0。 //數(shù)據(jù)輸出 sbit SD_CS = P1^3。 //片選/**************************** 函數(shù): SD_WriteByte.* 描述: 往SD卡定一字節(jié).* 輸入: byte 寫的字節(jié)* 輸出: 無(wú).* 返回: 無(wú).*****************************/void SD_WriteByte(unsigned char byte){ unsigned char BitCounter = 0。 SD_Enable()。 //使能片 for(BitCounter = 0。 BitCounter 8。 BitCounter++) { SD_SDI = byte amp。 0x80。//SPI先傳送最高位 byte = 1。 SD_CLK = 0。 Delay_us(100)。 SD_CLK = 1。 Delay_us(100)。 }SD_SDI = 1。 SD_Disable()。 //不使能片選 }/***************************** 函數(shù): SD_ReadByte.* 描述: 讀取一字節(jié).* 輸入: 無(wú)* 輸出: 無(wú).* 返回: 讀取的數(shù)據(jù).********************************/unsigned char SD_ReadByte(void){ unsigned char BitCounter = 0。unsigned char ret = 0。 //使能片選 SD_Enable()。 SD_SDO = 1。 for(BitCounter = 0。 BitCounter 8。 BitCounter++) { ret = 1。 SD_CLK = 0。 Delay_us(100)。 if(SD_SDO) { ret |= 0x01。 } SD_CLK = 1。 Delay_us(100)。 } return ret。}/***************************** 函數(shù): SD_ReadResponse.* 描述: 讀SD卡響應(yīng).* 輸入: 無(wú)* 輸出: 無(wú).* 返回: 讀取的數(shù)據(jù).********************************/unsigned char SD_ReadResponse(void){ unsigned char count = 0。 unsigned char response = 0。 while(count = 64) { response = SD_ReadByte()。 if(0x00 == response || 0x01 == response) { break。 } count++。 } return response。} /****************************** 函數(shù): SD_WriteCommand.* 描述: 向SD卡寫命令.* 輸入: 無(wú)* 輸出: 無(wú).* 返回: 寫命令的回應(yīng).********************************/unsigned char SD_WriteCommand(const unsigned char Command, unsigned long date, const char CRC){ unsigned char cmdBuf[6] = {0}。 unsigned char temp = 0。 unsigned char timeout = 0。 int i = 0。 //封裝命令數(shù)據(jù) 01xxxxxx cmdBuf[0]=(Command | 0x40)。 for(i = 3。 i = 0。 i) { temp = (char)(date (8 * i))。 cmdBuf[4i] = (temp)。 } //CRC數(shù)據(jù) cmdBuf[5] = (CRC)。 SD_Disable()。 SD_WriteByte(0xff)。//提高兼容性 SD_Enable()。 //發(fā)送命令數(shù)據(jù) for(i = 0。 i SD_CMD_LENGTH。 i++) { SD_WriteByte(cmdBuf[i])。 } do { temp = SD_ReadByte()。//一直讀,直到讀到的不是0xff或超時(shí) timeout++。 }while((temp==0xff)amp。amp。(timeout TRY_TIME))。 return temp。}/****************************** 函數(shù): SD_Reset.* 描述: 復(fù)位SD卡進(jìn)入SPI模式.* 輸入: 無(wú)* 輸出: 無(wú).* 返回: 如果操作成功返回SD_SUCCESS.********************************/unsigned char SD_Reset(void){ unsigned char response = 0xff。 unsigned char i = 0。 unsigned char timeout = 0。 //寫命令超時(shí) SD_Disable()。 for(i = 0。 i 0xf。 i++) { SD_WriteByte(0xff)。 //初始化時(shí)至少發(fā)送74個(gè)脈沖 } SD_Enable()。 do { //發(fā)送復(fù)位命令CMD0,將SD卡設(shè)置為SPI模式 response = SD_WriteCommand(SD_RESET,0,0x95)。 timeout++。 }while((0x1 != response) amp。amp。 (timeout TRY_TIME))。 if(0x1 != response) { Uart_Send_String(復(fù)位失敗\r\n)。 Uart_Send_String(Reset Failed\r\n)。 return SD_RESET_ERROR。 } SD_Disable()。 SD_WriteByte(0xff)。 //滿足時(shí)序要求 return SD_SUCCESS。 //復(fù)位操作成功}/****************************** 函數(shù): SD_Init.* 描述: 初始化SD卡.* 輸入: 無(wú)* 輸出: 無(wú).* 返回: 如果操作成功返回SD_SUCCESS.********************************/unsigned char SD_Init(void){ unsigned char response = 0。 unsigned char i = 0。 unsigned int timeout = 0。 //寫命令超時(shí) SD_Enable()。 do { response = SD_WriteCommand(0x41, 0x0, 0xff)。//發(fā)送復(fù)位命 //令,將SD卡設(shè)置為SPI模式 timeout++。 }while((0x0 != response) amp。amp。 (timeout TRY_TIME))。if(0x0 != response) { Uart_Send_String(初始化失敗\r\n)。 Uart_Send_String(Init Failed\r\n)。 return SD_INIT_ERROR。 } SD_Disable()。 SD_WriteByte(0xff)。//滿足時(shí)序要求 return SD_SUCCESS。}/****************************** 函數(shù): SD_WriteSector.* 描述: 寫扇區(qū).* 輸入: buffer:寫入的數(shù)據(jù)* 輸出: address:要寫入數(shù)據(jù)的地址.* 返回: ********************************/unsigned char
點(diǎn)擊復(fù)制文檔內(nèi)容
環(huán)評(píng)公示相關(guān)推薦
文庫(kù)吧 www.dybbs8.com
備案圖鄂ICP備17016276號(hào)-1