lpcware

Read SDCard from USB

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by gdigiulio on Tue Sep 16 02:42:24 MST 2014
Hi,

I would to connect my board LPC4088 to the PC via USB cable, in order to read the SD Card.

I tested the USB_MSC_RAM example and it works fine, I tested the SDMMC example and it works, but is there a project that merge both the example?

I tried to do it myself, but I don't know the function to be wrapped here in order to read/write the SD Card:

static void translate_rd(uint32_t offset, uint8_t * *buff_adr, uint32_t length, uint32_t hi_offset)
{
*buff_adr = &g_memDiskArea[(((uint64_t) offset) | (((uint64_t) hi_offset) << 32))];
}

/* USB device mass storage class write callback routine */
static void translate_wr(uint32_t offset, uint8_t * *buff_adr, uint32_t length, uint32_t hi_offset)
{
*buff_adr = &g_memDiskArea[(((uint64_t) offset) | (((uint64_t) hi_offset) << 32)) + length];
}

/* USB device mass storage class get write buffer callback routine */
static void translate_GetWrBuf(uint32_t offset, uint8_t * *buff_adr, uint32_t length, uint32_t hi_offset)
{
*buff_adr = &g_memDiskArea[(((uint64_t) offset) | (((uint64_t) hi_offset) << 32))];
}

/* USB device mass storage class verify callback routine */
static ErrorCode_t translate_verify(uint32_t offset, uint8_t *src, uint32_t length, uint32_t hi_offset)
{
if (memcmp((void *) &g_memDiskArea[(((uint64_t) offset) | (((uint64_t) hi_offset) << 32))], src, length)) {
return ERR_FAILED;
}

return LPC_OK;
}

How I should replace the function?

thanks

Giulio

Outcomes