📄 main.c
字号:
#include "./SD_Driver/SD_INC.h"
xdata unsigned char ReadBuf[512];
xdata unsigned char WriteBuf[512];
int main(void)
{
unsigned int i,ret;
while(SD_Initialize() != SD_NO_ERR); // Wait for Initialize
for(i = 0; i < 512; i++)
{
WriteBuf[i] = i; // Initialize the buffer
}
ret = SD_WriteBlock(10, WriteBuf); // Write the content of WriteBuf to Block 10
ret = SD_WriteBlock(11, WriteBuf); // Write the content of WriteBuf to Block 11
if(ret!= SD_NO_ERR)
{
while(1); // Write Err
}
ret = SD_ReadBlock(10, ReadBuf); // Read the content of Block 10 to the ReadBuf
if(ret != SD_NO_ERR)
{
while(1); // Read Err
}
for(i = 0; i < 512; i++) // Compare
{
if(i != ReadBuf[i])
{
while(1); // Content Err
}
}
SD_EraseBlock(10,2); // Erase tow blocks start with Block 10
ret = SD_ReadBlock(11, ReadBuf); // Read the content of Block 11 to the ReadBuf
if(ret != SD_NO_ERR)
{
while(1); // Read Err
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -