I was looking at the USB examples from the SDK of the LPCXpresso5411. Using the example "SDK_2.2.1_LPCXpresso54114/boards/lpcxpresso54114/usb_examples/usb_rom_device_msc_ram" I successfully got a PC to recognise the LPCXpresso5411 as a USB device with a USB cable using the hard coded files in ramdisk.c. eg the code below will show basic files when a usb cable is plugged into a PC.
static const struct FAT12_img
{
const uint8_t *data;
int offset;
int size;
} FAT12_img[] = {
{FAT12_header, 0, sizeof(FAT12_header)},
{FAT12_root_dir, 0x400, sizeof(FAT12_root_dir)},
{FAT12_file_readme_txt, 0x600, sizeof(FAT12_file_readme_txt)},
{FAT12_file_index_htm, 0xC00, sizeof(FAT12_file_index_htm)},
};
void DataRam_Initialize(void)
{
int i;
extern uint8_t g_memDiskArea[];
memset(g_memDiskArea, 0, MSC_MEM_DISK_SIZE);
for (i = 0; i < sizeof(FAT12_img) / sizeof(FAT12_img[0]); i++)
memcpy(&g_memDiskArea[FAT12_img[i].offset], FAT12_img[i].data, FAT12_img[i].size);
}
However I would like to integrate this with the FatFs for an SD card. With help from this forum, I have the FatFs and SD card working. So instead of the "static struct FAT12_img" I m trying to use the FIL structure from ff.h.
typedef struct {
_FDID obj;
BYTE flag;
BYTE err;
FSIZE_t fptr;
DWORD clust;
DWORD sect;
#if !_FS_READONLY
DWORD dir_sect;
BYTE* dir_ptr;
#endif
#if _USE_FASTSEEK
DWORD* cltbl;
#endif
#if !_FS_TINY
BYTE buf[_MAX_SS];
#endif
} FIL;
Would I do something like
FIL fil;
memcpy(&g_memDiskArea[fil.obj], fil.buff, fil[i].size);
I m not too sure how to do this, but any point in the right direction would be great.
Thanks,
Ronan