Reference for older versions
This document describes features that have been updated in the current version of uLisp.
with-spi special form
Syntax: (with-spi (stream pin [divider] [lsbfirst] [mode]) form*)
The following description applies to version 2.7 of uLisp and earlier.
Evaluates the forms with stream bound to an spi-stream using pin as the enable pin.
The SPI interface works with the following pins on different processors:
Platform | MOSI pin | MISO pin | SCK pin |
Arduino Uno, Arduino Nano | 11 | 12 | 13 |
Arduino Mega 2560 | 51 | 50 | 52 |
Tiny Lisp Computer, Lisp Badge | 5 | 6 | 7 |
Arduino Due | 75 | 74 | 76 |
Arduino Zero | 23 | 22 | 24 |
Arduino MKRZero | 8 | 10 | 9 |
Adafruit Metro M4 | 26 | 24 | 25 |
Adafruit ItsyBitsy M4 | 25 | 23 | 24 |
Adafruit Feather M4 | 24 | 23 | 25 |
BBC Micro Bit | 15 | 14 | 13 |
MSP430 F5529 LaunchPad | 15 | 14 | 7 |
MSP430 FR5969 LaunchPad | 15 | 14 | 7 |
MSP430 FR5994 LaunchPad | 15 | 14 | 7 |
MSP430 FR6989 LaunchPad | 15 | 14 | 7 |
By default the system clock is divided by 4, giving a speed of 4 MHz with a 16 MHz clock. Alternatively you can specify a divider parameter as follows:
Parameter | Divider |
1 | 2 |
2 | 4 |
3 | 8 |
4 | 16 |
5 | 32 |
6 | 64 |
7 | 128 |
By default the bit order is MSB first. Alternatively set the lsbfirst parameter to t for LSB first.
By default the mode is SPI Mode 0. Alternatively set the mode parameter to a number from 0 to 3 to specify the mode.