[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Getting started with FAT Filesystem on SD/MMC cards over SPI
- Date: Mon, 15 Sep 2008 13:50:38 +0200
- From: sebastian.huber at embedded-brains.de (Sebastian Huber)
- Subject: Getting started with FAT Filesystem on SD/MMC cards over SPI
Robert S. Grimes wrote:
> Thanks Sebastian, I'll give it a try. Likely I won't have anything to
> report on until next week.
> One question in clarification: you said "it must be possible to drive
> the clock with inactive chip select". Do you mean the clock must always
> be running, or that there needs to be a way to drive the clock sometimes
> while the socket is _not_ selected? Maybe it'll become obvious when I
Some cards require in the initialization procedure that they see some
clock cycles without an active chip select. So the LibI2C functions
have to satisfy this (in this sequence):
start: The driver occupies the bus.
set transfer mode: The driver sets the transfer mode.
write/read: Write/read to/from the device with INACTIVE chip select
(drives the clock).
send address: Activates the appropriate chip select.
write/read: Write/read to/from the device ACTIVE chip select.
stop: Deactivates the corresponding chip select and releases the bus.
> delve into the code, but I was just a bit curious...
> Thanks again, and say "Hello" to Thomas for me,
> Sebastian Huber wrote:
>> I wrote a SD Card driver that uses the LibI2C interface. It is already
>> included in the RTEMS CVS under the LibChip:
>> It works with the SPI drivers for the MPC5566EVB and MPC8313ERDB boards.
>> I had problems to initialize some SD Cards (1 out of 10), but this is
>> maybe a problem of the SPI interface in these cards. The initialization
>> sequence is not perfect and may need improvement. One problem is that
>> not all documents are publicly available.
>> The SD Card driver registers itself to LibBlock so you can use easily
>> imfs and dosfs.
>> Example code:
>> The crucial point for the SPI driver is that it must be possible to
>> drive the clock with inactive chip select:
>> /* Stop */
>> sc = sd_card_stop( e);
>> CHECK_SC( sc, "Stop");
>> /* Start with inactive chip select */
>> sc = rtems_libi2c_send_start( e->minor);
>> CHECK_SC( sc, "Send start");
>> /* Set transfer mode */
>> rv = rtems_libi2c_ioctl( e->minor, RTEMS_LIBI2C_IOCTL_SET_TFRMODE,
>> CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Set transfer mode");
>> /* Send idle tokens with inactive chip select */
>> rv = sd_card_query( e, e->response, SD_CARD_COMMAND_SIZE);
>> CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Inactive chip select
>> /* Activate chip select */
>> sc = rtems_libi2c_send_addr( e->minor, 1);
>> CLEANUP_SC( sc, sd_card_driver_init_cleanup, "Send address");
>> So you have to activate the chip select in rtems_libi2c_send_addr() and
>> not before.
Sebastian Huber, Embedded Brains GmbH
Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone : +49 89 18 90 80 79-6
Fax : +49 89 18 90 80 79-9
E-Mail : sebastian.huber at embedded-brains.de
PGP : Public key available on request
Diese Nachricht ist keine gesch?ftliche Mitteilung im Sinne des EHUG.