[En-Nut-Discussion] Using UFLASH and MMC at same time....

Ulrich Prinz uprinz2 at netscape.net
Wed Nov 17 21:35:51 CET 2010


Hi!

Afaik it is part of the NutRegisterSpiDevice() to select the correct 
chip select in one of it's parameters. So registering different nodes at 
a single SPI bus should not be a problem. What can be a problem is if 
these different devices use different SPI modes. With some chips there 
are problems if the bus is switched from one mode to the other. Look 
into the errata carefully.

What is a problem too, is that different CPU don't support hardware 
chipselects. So it is not done with giving the chipselect ( you called 
it index) with the driver but one has to give a complete combination of 
GPIO port an pin. I never used Nut/OS with those small devices like AVR.

AT91SAM7xx do support up to 4 hardware driven chip selects per SPI port 
but they do require a certain handling of the bus transfers. You can 
either use a single chipselect mode where a transfer sets up the CS it 
uses and keeps it until the transfer has finished. The second option is 
to transform any sort of SPI data into uint32_t words. The lower 8..16 
bit contain the data, the upper 16 bit have control information about 
the cs, the SPI mode and the transfer end marker. If you set up this for 
all of the devices at your bus, the AT91 chains the transfers together 
and uses time delays for one device to transfer other waiting data to 
another device on the bus. And again this can be combined with DMA/PDC...

So to say, it is not easy to write an 'I can all' driver for these 
totally different architectures.

But the idea to call the driver with a CS Index instead of a real CS 
line might offer a good thing. You first can assign CS lines to the SPI 
driver and then refer to them by the index. Writing a small setup for 
these CS line index system offers to separate architecture specific 
things from the system.
NutSpiCsConfig( port, pin, mode, tmin, tdelay)
where mode is
GPIO_HIGH GPIO driven pin, active high
GPIO_LOW  GPIO driven pin, active low
AT91_HIGH AT91 Hardware specific active high
AT91_LOW  ...
tmin and tdelay are some specific things that are needed for AT91 
intermitted transfers and can be left 0 in other systems.

Ok, that might not directly solve your problem but is a neat idea for a 
driver update :)

Best regards
Ulrich

Am 17.11.2010 20:56, schrieb Remi Bilodeau:
> Hello,
>
> I using UFLASH file system with succes, I have written  SPI bus driver to
> read AD7843 with this struct, using the new SPI bus.
>
> NUTSPINODE nodeAds7843 = {
>      &spiBus0At91, /* Pointer to the bus controller driver. */
>      NULL, /* Optional pointer to device specific settings. */
>      2000000, /* SPI clock rate. */
>      3, /* SPI mode. */
>      8, /* SPI data bits. */
>      1   /* Chip select index. */
> }
>
> So, how to add third device, a SD card reader, with PHAT file system?? I
> don't see any SD card driver using the new SPIBUS ?
>
> I want to use at same time dataflash with UFLASH, SD card and my touch
> screen driver. Something I can do your that ??
>
> thank !
>
> Rémi
> _______________________________________________
> http://lists.egnite.de/mailman/listinfo/en-nut-discussion



More information about the En-Nut-Discussion mailing list