这是我修改之后的main函数,增加了SD擦除和SD写和SD读
但是很多次都是读不出来,为什么呢?
[mw_shl_code=c,true]int main(void)
{
extern u16 OLED_GRAM[132][8];
//u8 i;
MY_NVIC_PriorityGroup_Config(NVIC_PriorityGroup_2); //?è??????·?×é
//????Systick?¨?±?÷??1us????????
SZ_STM32_SysTickInit(1000000);
//??????OLED
OLED_Init();
OLED_ShowString(3,02," System Initializing ");
OLED_ShowString(3,12," ");
OLED_ShowString(3,22," ");
OLED_ShowString(3,32," ");
OLED_ShowString(3,42," ");
OLED_ShowString(3,52," ");
OLED_Refresh_Gram();
Delay_ms(200);
/******************************************************
SD?¨??????
******************************************************/
if(SD_Init() != SD_OK) //???????§°?
{
SDtatus = SD_Init();
OLED_ShowString(3,12,"SD Init Faild! ");
OLED_Refresh_Gram();
//LCD_Display_String_BK(30, 112, "SD Init Faild!", 16, RED, WHITH);
//printf("The Faild is:%d\r\n", SDtatus);
}
else //????????????
{
OLED_ShowString(3,12,"SD Init Done! ");
OLED_Refresh_Gram();
SD_Card_Printf_Info(); //?ò???¨???????®??
}
////////////////////////
//SD ERASE TEST
////////////////////////
if (SDtatus == 0)
{
/* Erase NumberOfBlocks Blocks of WRITE_BL_LEN(512 Bytes) */
SDtatus = SD_Erase(0x00, (BLOCK_SIZE * NUMBER_OF_BLOCKS));
if (SDtatus == 0)
{
OLED_ShowChar(63,32,'R',12,0);
}
}
// if (SDtatus == 0)
// {
// SDtatus = SD_ReadMultiBlocks(Buffer_MultiBlock_Rx, 0x00, BLOCK_SIZE, NUMBER_OF_BLOCKS);
// /* Check if the Transfer is finished */
// SDtatus = SD_WaitReadOperation();
// /* Wait until end of DMA transfer */
// while(SD_GetStatus() != SD_TRANSFER_OK);
// }
////////////////////////
//SD SINGLE WRITE TEST
////////////////////////
/* Fill the buffer to send */
Fill_Buffer(Buffer_Block_Tx, BLOCK_SIZE, 0x320F);
if (SDtatus == SD_OK)
{
/* Write block of 512 bytes on address 0 */
SDtatus = SD_WriteBlock(Buffer_Block_Tx, 0x00, BLOCK_SIZE);
/* Check if the Transfer is finished */
SDtatus = SD_WaitWriteOperation();
while(SD_GetStatus() != SD_TRANSFER_OK);
}
OLED_ShowChar(69,32,'W',12,0);
Delay_ms(10);
if (SDtatus == SD_OK)
{
/* Read block of 512 bytes from address 0 */
SDtatus = SD_ReadBlock(Buffer_Block_Rx, 0x00, BLOCK_SIZE);
/* Check if the Transfer is finished */
SDtatus = SD_WaitReadOperation();
while(SD_GetStatus() != SD_TRANSFER_OK);
}
OLED_ShowChar(75,32,'R',12,0);
while(1)
{
tmp++;
OLED_ShowNum(0,52,tmp,4,12);
OLED_Refresh_Gram();
Delay_s(1);
//OLED_Display_Off();
}
}[/mw_shl_code]
|