uchar MMC_SPI(data uchar cmd) { data uchar i,j=0; //ACC=0; for (i = 8; i > 0; i --) { j<<=1; MMC_SCK=0; j |= MMC_DO; MMC_DI = (cmd & 0x80)==0x80; //MMC_DI = cmd >> 7; MMC_SCK=1; cmd<<=1; } //MMC_SCK=1; return(j); }
uchar MMC_SPI(data uchar cmd) ; 15. { MMC_SPI: ; 16. data uchar i,j=0; ; 17. //ACC=0; ; 18. for (i = 8; i > 0; i --) MOV $LOCBD MMC_SPI+1,#0 MOV $LOCBD MMC_SPI,#8 MOV $LOCBD MMC_SPI+2,R4 ?0001: MOV A,$LOCBD MMC_SPI JZ ?0000 ?0002: ; 19. { ; 20. j<<=1; MOV A,$LOCBD MMC_SPI+1 ADD A,ACC MOV $LOCBD MMC_SPI+1,A ; 21. MMC_SCK=0; CLR 232.1 ; 22. j |= MMC_DO; CLR A MOV C,232.0 MOV ACC.0,C ORL $LOCBD MMC_SPI+1,A ; 23. MMC_DI = (cmd & 0x80)==0x80; MOV A,$LOCBD MMC_SPI+2 ANL A,#128 XRL A,#128 JZ ?0031 MOV A,#255 ?0031: INC A MOV C,ACC.0 MOV 232.2,C ; 24. //MMC_DI = cmd >> 7; ; 25. MMC_SCK=1; SETB 232.1 ; 26. cmd<<=1; MOV A,$LOCBD MMC_SPI+2 ADD A,ACC MOV $LOCBD MMC_SPI+2,A DEC $LOCBD MMC_SPI SJMP ?0001 ?0000: ; 27. } ; 28. //MMC_SCK=1; ; 29. return(j); MOV R4,$LOCBD MMC_SPI+1 ; 30. } |