[En-Nut-Discussion] EIR: SD-Card on SPI
Harald Kipp
harald.kipp at egnite.de
Mon Jan 28 12:08:20 CET 2013
Hi Markus,
On 28.01.2013 10:59, Markus Dost wrote:
>> I developed a board and a firmware based on the EIR and Nut/OS 4.10.3.
>> For I have no audio-codec-IC I would use the SPI for the SD-Card to
>> get a faster data transfer. I read the workaround with the SSC
>> (http://www.ethernut.de/en/hardware/eir/spi.html) but an upgrade to
>> Nut/OS 5 isn't possible at the moment.
This won't help, because it uses the SSC interface. On the EIR the MMC
is attached to the SSC. If I got you right, on your board the MMC is
attached to the SPI bus.
>> Can I change the OS in the configurator that the hardware SPI is used
>> for the MMC or do I have to change the driver in code?
There is no need to re-configure Nut/OS, because Nut/OS doesn't use MMC.
It's just a matter of your application. The only thing that may need
adjustment is the SPI chip select, that is used by the MMC driver.
> maybe I found the answer for my question some days ago but I have some
> questions.
> Is it sufficient to change the follow lines
>
> #include <dev/sbi_mmc.h>
> #ifnef DEV_MMCARD0
> #define DEV_MMCARD0 devSbi0MmCard0
> #endif
Yes, this is the bit-banging driver.
> #include <dev/at91_mci.h>
> #ifnef DEV_MMCARD0
> #define DEV_MMCARD0 devAt91Mci0
> #endif
This is the driver for the MCI hardware of the AT91 family.
Unfortunately, the SAM7SE doesn't have any MCI hardware.
Note further, that all these DEV_xxx macros are for portability only, so
that the provided examples will work on all boards with minor or no code
change. If you are programming for your board, you may reference the
driver structures (devAt...) directly.
If you want SPI, the optimal way is to register the SPI bus
http://www.ethernut.de/en/documents/ntn-6_spi.html
This is an important document! Take some time to study it. You will
notice, that there are many SPI drivers included in Nut/OS. The
advantage of this new SPI "Bus" driver is, that only the bus driver is
hardware dependent. Device drivers for MMC, serial flash etc. can be
written platform-independent.
Then attach Ole's devSpiMmcGpio (in dev/spi_mmc_gpio.c) to this bus.
Unfortunately I cannot find any published example right now and I never
tested it with the EIR, because the EIR doesn't have MMC on SPI. But I
successfully used Ole's driver on other boards.
> Do I have to change the DEV_MMCARD0_NAME, too?
If you look into dev/spi_mmc_gpio.c, you will see (at the end of the
file) that the name is "MMC0".
Again, the DEV_xxx_NAME macros are for writing application, that must
run without code change on several platforms. In your application you
can directly use
_open("MMC0:1/PHAT0", _O_RDWR | _O_BINARY);
to mount the file system, see also the PHAT examples at
http://www.ethernut.de/nutwiki/Nut/OS_Examples
> Which chip select is used?
For the spi_mmc_gpio.c this is configurable in the Configurator, look
for "SPI bus based Multimedia Card Support".
Regards,
Harald
More information about the En-Nut-Discussion
mailing list