Breadcrumbs

SPI

The spi connector in the node can be added in the device tree of the KCH Control ARM VFP Linux.

image2021-2-16_10-30-21.png

Parameters

Parameter

Description 

SPI Port

Linux Device File Path of spidev port (see HW chapter)

diMode

Set optional SPI Mode (if <> 0, 0: Linux Device Tree File Values):

SPI_MODE_CPHA : DINT := 16#01; // clock phase
SPI_MODE_CPOL : DINT := 16#02; // clock polarity
SPI_MODE_MODE_0 : DINT := (16#0); // (original MicroWire)
SPI_MODE_MODE_1 : DINT := TO_DINT(16#0 OR TO_UDINT(SPI_MODE_CPHA));
SPI_MODE_MODE_2 : DINT := TO_DINT(TO_UDINT(SPI_MODE_CPOL) OR 16#0);
SPI_MODE_MODE_3 : DINT := TO_DINT(TO_UDINT(SPI_MODE_CPOL) OR TO_UDINT(SPI_MODE_CPHA));
SPI_MODE_CS_HIGH : DINT := 16#04; // chipselect active high?
SPI_MODE_LSB_FIRST : DINT := 16#08; // per-word bits-on-wire
SPI_MODE_3WIRE : DINT := 16#10; // SI/SO signals shared
SPI_MODE_LOOP : DINT := 16#20; // loopback mode
SPI_MODE_NO_CS : DINT := 16#40; // 1 dev/bus, no chipselect
SPI_MODE_READY : DINT := 16#80; // slave pulls low TO pause

diBitsPerWord

Set optional bits per word (if <> 0, 0: Linux Device Tree File Values)

diMaxSpeed

Set optional max clock speed (if <> 0, 0: Linux Device Tree File Values)

With the new spi master node there are read/write commands available.

spiMaster.transferExt (METH)

METHOD transferExt : BOOL

This method is used to transfer data via SPI

Parameters

Parameter

Description 

pabyTxBuffer [in]

pointer to send buffer

pabyRxBuffer [in] 

pointer to receive buffer

udiLen [in]

length to transfer

uiDelayus [in]

delay in µs

udiSpeedHz [in]

send clock in Hz; if 0, _diMaxSpeed is used


Return Values

Return Values 

Description 

transferExt

TRUE if successful

Hardware

The SPI functions can only used on own SOM Hardware with a specific Linux Device Tree File, where a spidev node is defined.