在keil單步運(yùn)行可以看到 SD卡新建了文件夾和文件,但是寫入數(shù)據(jù)的時(shí)候只是寫入了一個(gè),單步運(yùn)行都可以 S都是0x14,不使用調(diào)試模式就不能寫入新建文件夾和新建文件等操作??梢源_定初始化,取反數(shù)值是通過(guò)的。
s = CH376DirCreatePath(PathName);???? ??? ? // 創(chuàng)建文件夾
?? ?s = CH376FileCreate(" BC.TXT ");
?? ?s = CH376ByteWrite(SPI_TX_BUFFER, strlen((const char *)SPI_TX_BUFFER), NULL);
//寫入數(shù)據(jù)的使用的是官方提供的函數(shù)? SPI_TX_BUFFER數(shù)組是 0-9? 長(zhǎng)度為0x1E
????UINT8?? ?CH376ByteWrite( PUINT8 buf, UINT16 ReqCount, PUINT16 RealCount )
{
?? ?UINT8?? ?s;
?? ?xWriteCH376Cmd( CMD2H_BYTE_WRITE );
?? ?xWriteCH376Data( (UINT8)ReqCount );
?? ?xWriteCH376Data( (UINT8)(ReqCount>>8) );
?? ?xEndCH376Cmd( );
?? ?if ( RealCount )
? {
?? ??? ?*RealCount = 0;
? }
?? ?
?? ?while ( 1 )
?? ?{
?? ??? ?s = Wait376Interrupt( );
?? ???? //程序到這里只運(yùn)行了一次,然后就 讀取的數(shù)據(jù)是0x14就是成功操作,用讀卡器看只寫了一個(gè)數(shù)據(jù)
?? ??? ?if ( s == USB_INT_DISK_WRITE )
?? ??? ?{
?? ??? ??? ?s = CH376WriteReqBlock( buf );????????????????????????????????????????????? /* 向內(nèi)部指定緩沖區(qū)寫入請(qǐng)求的數(shù)據(jù)塊,返回長(zhǎng)度 */
?? ??? ??? ?xWriteCH376Cmd( CMD0H_BYTE_WR_GO );
?? ??? ??? ?xEndCH376Cmd( );
?? ??? ??? ?buf += s;
?? ??? ??? ?if ( RealCount ) *RealCount += s;
?? ??? ?}
?? ??? ?else
?? ??? ?{
?? ??? ??? ??? ?return( s );??????????????????????????????????????????????????????????????? /* 錯(cuò)誤 */
?? ??? ?}
?? ?}
}