#include "sys.h"
#include "delay.h"
#include "usart.h"
#include "led.h"
#include "lcd.h"
#include "key.h"
#include "malloc.h"
#include "sdio_sdcard.h"
void show_sdcard_info(void)
{
switch(SDCardInfo.CardType)
{
case SDIO_STD_CAPACITY_SD_CARD_V1_1:printf("Card Type:SDSC V1.1
");break;
case SDIO_STD_CAPACITY_SD_CARD_V2_0:printf("Card Type:SDSC V2.0
");break;
case SDIO_HIGH_CAPACITY_SD_CARD:printf("Card Type:SDHC V2.0
");break;
case SDIO_MULTIMEDIA_CARD:printf("Card Type:MMC Card
");break;
}
printf("Card ManufacturerID:%d
",SDCardInfo.SD_cid.ManufacturerID);
printf("Card RCA:%d
",SDCardInfo.RCA);
printf("Card Capacity:%d MB
",(u32)(SDCardInfo.CardCapacity>>20));
printf("Card BlockSize:%d
",SDCardInfo.CardBlockSize);
}
int main(void)
{
u8 key;
u32 sd_size;
u8 *buf;
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
delay_init(168);
uart_init(115200);
LED_Init();
LCD_Init();
KEY_Init();
//my_mem_init(SRAMIN); //我把内部内存池的内存的初始化注释掉了
//my_mem_init(SRAMCCM); //我把内部内存池的内存的初始化注释掉了
POINT_COLOR=RED;
LCD_ShowString(30,50,200,16,16,"Explorer STM32F4");
LCD_ShowString(30,70,200,16,16,"SD CARD TEST");
LCD_ShowString(30,90,200,16,16,"ATOM@ALIENTEK");
LCD_ShowString(30,110,200,16,16,"2014/5/15");
LCD_ShowString(30,130,200,16,16,"KEY0:Read Sector 0");
while(SD_Init())
{
LCD_ShowString(30,150,200,16,16,"SD Card Error!");
delay_ms(500);
LCD_ShowString(30,150,200,16,16,"Please Check! ");
delay_ms(500);
LED0=!LED0;
}
show_sdcard_info();
POINT_COLOR=BLUE;
LCD_ShowString(30,150,200,16,16,"SD Card OK ");
LCD_ShowString(30,170,200,16,16,"SD Card Size: MB");
LCD_ShowNum(30+13*8,170,SDCardInfo.CardCapacity>>20,5,16);
while(1)
{
key=KEY_Scan(0);
if(key==KEY0_PRES)
{
buf=mymalloc(0,512); (这句话是什么意思???) 0应该是内部内存块啊 malloc里面的定义, 可是这是SD卡,malloc里面又没有定义,怎么定义的
if(SD_ReadDisk(buf,0,1)==0)
{
LCD_ShowString(30,190,200,16,16,"USART1 Sending Data...");
printf("SECTOR 0 DATA:
");
for(sd_size=0;sd_size<512;sd_size++)
printf("%x ",buf[sd_size]);
printf("
DATA ENDED
");
LCD_ShowString(30,190,200,16,16,"USART1 Send Data Over!");
}
myfree(0,buf)
}
}
}
---------------------------------
SD_ReadDisk(buf,0,1)-->这句话的意思是读取SD卡的第0扇区(512字节) 放到buf里面,理解的没错吧??
buf=mymalloc(0,512);——>这句话的意思是从内存块0分配512字节的空间。
mymalloc(0,512)括号中的0是代表内部内存 这个内部内存说的是哪个内部???如果想要从SD卡申请内存的话应该要在malloc里面定义SD卡的地址并且修改管理SD容量大小等等。。
话说过来 mymalloc(0,512)其中的0代表从内部SRAM(STM32F407ZGT6 196K的ram 内存管理只管理了100K的空间,不加内存管理表的大小)中申请512字节的内存???是这样吗?? 如果是这样的话那就是从内部内存SRAM中申请的512字节的空间,最后SD卡读取的又是怎么回事??
希望我理解的是错的
一周热门 更多>