Well, I have this code I'm working on, made with Keil's (ARM) uVision. It was ported from STM's USB-FS library examples and
Domen Puncer's SD/SDHC
SPI fat implementation.
So far I managed to make a 1GB SD card, then a 16GB SDHC appear as a USB Mass Storage Devices through a STM32F103RBT6.
I'm still working on it, so it's far from optimized. But it works well on Windows 7 x64.
The code will want to address an ILI9325 lcd controller too. You may want to remove all references to "ili9325.h" and stripe the project off its "ili9325.c" file.
I also modified RealView's "stdint.h" file so it includes more kinds of integers typedefs, mostly Finnish integers notations (u8, u16, s32, an such unambiguous ones STM's engineers & I like to use). Although it implies to modify STM's demo headers from spurious definitions sometimes.
So
here's a copy of my project, including my <sdtint.h> file you'll wanna paste into your
%KeilDirectory%\ARM\ARMCC\include directory to
overwrite the existing one, or simply add it to the project's tree, your choice. It wasn't stripped of any typedefs, 'au contraire' some where added, along with preprocessor conditionals.
Anyway, about the project : don't try to use the FatFS methods implemented there once the device is plugged to a USB port, cuz I didn't work on interleaving theses operations yet.
Also, right now, the card shouldn't be plugged/removed on-the-fly... You need to reset the MCU for the card's CSD copy to be refreshed... I had a precomputed version of the
card specific data (CSD) cached upon initialization, since I discovered the STM's media acces layer ask for it quite often. And since my project is supposed to deal with the same SD card for extended periods of time, I had this critical data cached in the MCU's SRAM.
Ah, yes...almost forgot: neither DMA transfers between SPI and USB, nor harware CRC usage for the card's comms... those are things to come, but just not yet.