[En-Nut-Discussion] node_cs definition in NUTSPINODE

Uwe Bonnes bon at elektron.ikp.physik.tu-darmstadt.de
Tue Feb 21 16:18:09 CET 2012


Hello,

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.

Why don't we use both a node_port and node_pin entry in the NUTSPINODE
structure and xxxSpiChipSelect() does the access direct on the resulting
port/pin combination, at the cost of a NUTSPINODE structure 4 to 7 bytes
larger. 4 Bytes larger if the compiler aligns the NUTSPINODE structure at 4
byte, 7 bytes with no alignment in the NUTSPINODE structure.

If structure size is an issue, we could also encode port and pin via
((symbolic port number)& 0x0f) << 4 | (pin & 0x0f), in a microsoft like
attitude : Nobody will ever use more then 16 ports with 16 pins each :-) or
as uint16_t with ((symbolic port number) & 0xff) << 8 | (pin & 0xff)

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

On cm3 node_cs could also be the 32 bit bit-band adress to the GPIOx_BSRR of
that port/bit. To set CS high, we would write 1 to that address, to set CS
low we would write 1 to the address 64 bytes above. In that light I propose
to make node_cs a 32 bits entitie.

Bye
-- 
Uwe Bonnes                bon at elektron.ikp.physik.tu-darmstadt.de

Institut fuer Kernphysik  Schlossgartenstrasse 9  64289 Darmstadt
--------- Tel. 06151 162516 -------- Fax. 06151 164321 ----------



More information about the En-Nut-Discussion mailing list