Alcor6L/PicoLisp/spi

From Wikibooks, open books for an open world
Jump to navigation Jump to search

This module contains functions for accessing the SPI interfaces of the Alcor6L CPU.

Only master SPI mode is implemented in eLua (and Alcor6L).

Functions[edit | edit source]

spi-setup[edit | edit source]

Setup the SPI interface

(spi-setup id type clock cpol cpha databits)
  • id - the ID of the SPI interface.
  • type - SPI interface type, can be either spi.MASTER or spi.SLAVE. NOTE: currently, only master SPI mode is supported.
  • clock - the clock of the SPI interface.
  • cpol - the clock polarity (0 or 1).
  • cpha - the clock phase (0 or 1).
  • databits - the length of the SPI data word.

Returns:

  • clock - The actual clock set on the SPI interface. Depending on the hardware, this might have a different value than the clock parameter.

spi-sson[edit | edit source]

Select the SS line (Slave Select) of the SPI interface. This is only applicable for SPI interfaces with a dedicated SS pin.

(spi-sson id)
  • id - the ID of the SPI interface.

Returns: NIL.

spi-ssoff[edit | edit source]

Deselect the SS line (Slave Select) of the SPI interface. This is only applicable for SPI interfaces with a dedicated SS pin.

(spi-ssoff id)

Arguments:

  • id - the ID of the SPI interface.

Returns: NIL.

spi-write[edit | edit source]

Write one or more strings/numbers to the SPI interface.

(spi-write id any1 [any2] ... [anyn])
  • id - the ID of the SPI interface.
  • any1 - the first symbol/number/list to send.
  • any2 (optional) - the second symbol/number/list to send.
  • anyn (optional) - the n-th symbol/number/list to send.

Returns: The last value written/passed as an argument to spi-write.

spi-readwrite[edit | edit source]

Not implemented in PicoLisp yet. See Issues on github