[En-Nut-Discussion] node_cs definition in NUTSPINODE

Harald Kipp harald.kipp at egnite.de
Tue Feb 21 19:57:21 CET 2012


Hello Uwe,

On 21.02.2012 16:18, Uwe Bonnes wrote:
> if I understand right, node_cs in the NUTSPINODE structure is a symbolic
> number that later in xxxSpiChipSelect() gets decoded from a fixed list of
> possibilities into port/pin and an access to that port/pin combination.

That's right. The "fixed" list is configurable, of course.


> That way, users can have SPI CS on arbitrary pins without the need to change
> NUTOS.

After finishing the code, I discovered that passing the chip select
number from application code via

int NutRegisterSpiDevice(NUTDEVICE * dev, NUTSPIBUS * bus, int cs);

was not a good idea. In practice you will configure Nut/OS for a
specific board once and never change it.

Furthermore, Nut/OS doesn't currently allow to re-use a device. If you
got 4 DataFlash chips, you'll need devSpiAt45d0 to devSpiAt45d3. Each
SPI bus device has a fixed hardware chip select.


> In that light I propose
> to make node_cs a 32 bits entitie.

My proposal would be to remove the cs parameter and configure the chip
select in the device driver.

I'm open to arguments, of course.

Regards,

Harald



More information about the En-Nut-Discussion mailing list