Content originally posted in LPCWare by gowtham on Wed Jun 17 03:50:25 MST 2015
I am using SDHC card... According to that code, Uart will transmit particular string in both cases ie., presence and absence of the sd card... but nothing is getting transmitted...
stat = disk_initialize(0);
if (stat & STA_NOINIT) {
UART_SendString(UART_DEV,(uint8_t*)"MMC: not initialized\r\n");
uart2_sendString((uint8_t*)"\r\n no sd initialised \r\n");
oled_putString(1,1, (uint8_t*)" HELLO ", OLED_COLOR_BLACK, OLED_COLOR_WHITE);
}
if (stat & STA_NODISK) {
UART_SendString(UART_DEV,(uint8_t*)"MMC: No Disk\r\n");
uart2_sendString((uint8_t*)"\r\n no sdcard\r\n");
oled_putString(1,1, (uint8_t*)" HELLO ", OLED_COLOR_BLACK, OLED_COLOR_WHITE);
}
if (stat != 0) {
return 1;
}
UART_SendString(UART_DEV,(uint8_t*)"MMC: Initialized\r\n");
if (disk_ioctl(0, GET_SECTOR_COUNT, &p2) == RES_OK) {
i = sprintf((char*)buf, "Drive size: %d \r\n", p2);
UART_Send(UART_DEV, buf, i, BLOCKING);
}
if (disk_ioctl(0, GET_SECTOR_SIZE, &w1) == RES_OK) {
i = sprintf((char*)buf, "Sector size: %d \r\n", w1);
UART_Send(UART_DEV, buf, i, BLOCKING);
}
if (disk_ioctl(0, GET_BLOCK_SIZE, &p2) == RES_OK) {
i = sprintf((char*)buf, "Erase block size: %d \r\n", p2);
UART_Send(UART_DEV, buf, i, BLOCKING);
}
if (disk_ioctl(0, MMC_GET_TYPE, &b1) == RES_OK) {
i = sprintf((char*)buf, "Card type: %d \r\n", b1);
UART_Send(UART_DEV, buf, i, BLOCKING);
}
res = f_mount(0, &Fatfs[0]);
if (res != FR_OK) {
i = sprintf((char*)buf, "Failed to mount 0: %d \r\n", res);
UART_Send(UART_DEV, buf, i, BLOCKING);
return 1;
}
res = f_opendir(&dir, "/");
if (res) {
i = sprintf((char*)buf, "Failed to open /: %d \r\n", res);
UART_Send(UART_DEV, buf, i, BLOCKING);
return 1;
}
for(;;) {
res = f_readdir(&dir, &Finfo);
if ((res != FR_OK) || !Finfo.fname[0]) break;
UART_SendString(UART_DEV,(uint8_t*)&(Finfo.fname[0]));
UART_SendString(UART_DEV,(uint8_t*)"\r\n");
}
None of the condition is been true...Am i do it wrong?? plz let me know what should i do??