Adafruit M4 boards

The Adafruit Metro M4 Grand Central, Adafruit Metro M4, Adafruit ItsyBitsy M4, and Adafruit Feather M4 are each based on the ATSAMD51 or ATSAMD51P20 ARM Cortex M4 microcontroller running at 120 MHz.

Each board provides 512 KB flash and 192 KB RAM, apart from the Adafruit Metro Grand Central which has 1 MB flash and 256 KB RAM. The boards also include a separate SPI DataFlash chip which is used by uLisp to allow you to save the Lisp image using (save-image).

These are excellent platforms for running uLisp. For example, the Arduino Zero runs the Tak benchmark in 10 secs, but the Adafruit ItsyBitsy M4 takes 4.2 secs; see Performance.

Install the ARM version of uLisp for use with these boards.

Boards

Adafruit Metro M4 Grand Central

Adafruit Metro M4

Adafruit ItsyBitsy M4

Adafruit Feather M4

Adafruit Metro M4 Grand Central

The Adafruit Metro M4 Grand Central [1] is a new board in the form factor of the Arduino Mega 2560. It's based on the 128-pin Atmel ATSAMD51P20 Cortex M4 core running at 120 MHz, and it has 1 Mbytes of flash and 256 Kbytes of RAM:

GrandCentral.jpg

It provides a massive selection of digital and analogue inputs and outputs, and an SD Card socket, which you can use to read from and write to SD cards from uLisp.

LEDs

The Adafruit Metro M4 Grand Central has a red LED connected to :led-builtin (digital pin 13) which you can flash with the following program:

(defun blink (&optional x)
  (pinmode :led-builtin t)
  (digitalwrite :led-builtin x)
(delay 1000) (blink (not x)))

Run it by typing:

(blink t)

This pin can also be used as an analogue pin, so you can pulsate the red LED slowly on and off with the program:

(defun pulse ()
  (let (down)
    (loop
     (dotimes (x 256) 
       (delay 5) 
       (analogwrite :led-builtin (if down (- 255 x) x)))
(setq down (not down)))))

Run it by typing:

(pulse)

Exit from either program by entering ~.

Analogue inputs

Adafruit Metro M4 Grand Central has 16 analogue inputs on pins 67 (A0) to 74 (A7) and 54 (A8) to 61 (A15).

Analogue reference

The following options are available for analogreference:

Keyword Description
:ar-default Default internal reference of 3.3 V
:ar-internal1v0 Internal reference of 1.0 V
:ar-internal1v1 Internal reference of 1.1 V
:ar-internal1v2 Internal reference of 1.2 V
:ar-internal1v25 Internal reference of 1.25 V
:ar-internal1v65 Internal reference of 1.65 V
:ar-internal2v0 Internal reference of 2.0 V
:ar-internal2v2 Internal reference of 2.2 V
:ar-internal2v23 Internal reference of 2.23 V
:ar-internal2v4 Internal reference of 2.4 V
:ar-internal2v5 Internal reference of 2.5 V
:ar-external Voltage applied to the AREF pin

Analogue outputs

Adafruit Metro M4 Grand Central has PWM analogue output on pins 2 to 9, 11, 13 to 45, 48, 50 to 53, 58, 61, 68, and 69. It also has two digital-to-analogue converters on pins 67 (DAC0) and 68 (DAC1).

Serial

The Adafruit Metro M4 Grand Central Arduino core only supports one serial port, Serial1, on pin numbers 1 (TX) and 0 (RX). To add support for Serial2 and Serial3 see this forum post: Adding support for Serial2 and Serial3 on Grand Central M4.

SPI

The Adafruit Metro M4 Grand Central has two SPI ports; port 0 on pin numbers 64 (MISO), 66 (MOSI), and 65 (SCK), and port 1 on pin numbers 80 (MISO), 82 (MOSI), and 81 (SCK).

I2C

The Adafruit Metro M4 Grand Central has two I2C ports: port 0 on pin numbers 62 (SDA) and 63 (SCL), port 1 on pin numbers 25 (SDA) and 24 (SCL). 

Adafruit Metro M4

The Adafruit Metro M4 is the same size as the original Arduino Uno, and so can take a range of Arduino shields.

MetroM4.jpg

LEDs

The Adafruit Metro M4 has a red LED connected to the digital pin 13 which you can flash with the following program:

(defun blink (x)
  (pinmode 13 t)
  (digitalwrite 13 x)
  (delay 1000)
  (blink (not x)))

Run it by typing:

(blink t)

Pin 13 can also be used as an analogue pin, so you can pulsate the red LED slowly on and off with the program:

(defun pulse ()
  (let (down)
    (loop
     (dotimes (x 256) 
       (delay 5) 
       (analogwrite 13 (if down (- 255 x) x)))
     (setq down (not down)))))

Run it by typing:

(pulse)

Exit from either program by entering ~.

Analogue inputs

14 (A0) to 21 (A7)

Analogue reference

The following options are available for analogreference:

Keyword Description
:ar-default Default internal reference of 3.3 V
:ar-internal1v0 Internal reference of 1.0 V
:ar-internal1v1 Internal reference of 1.1 V
:ar-internal1v2 Internal reference of 1.2 V
:ar-internal1v25 Internal reference of 1.25 V
:ar-internal1v65 Internal reference of 1.65 V
:ar-internal2v0 Internal reference of 2.0 V
:ar-internal2v2 Internal reference of 2.2 V
:ar-internal2v23 Internal reference of 2.23 V
:ar-internal2v4 Internal reference of 2.4 V
:ar-internal2v5 Internal reference of 2.5 V
:ar-external Voltage applied to the AREF pin

Analogue outputs

0 to 13, 14 (DAC0), 15 (DAC1)

Serial

The Adafruit Metro M4 has a serial port, Serial1, on pin numbers 1 (TX) and 0 (RX).

SPI

The Adafruit Metro M4 has an SPI port on pin numbers 24 (MISO), 26 (MOSI), and 25 (SCK).

I2C

The Adafruit Metro M4 has an I2C port on pin numbers 22 (SDA) and 23 (SCL). 

Adafruit ItsyBitsy M4

The Adafruit ItsyBitsy M4 is the smallest of the three boards, the same size as Adafruit's other ItsyBitsy boards.

ItsyBitsy.jpg

LEDs

The Adafruit ItsyBitsy M4 also has a red LED connected to the digital pin 13 which you can flash with the following program:

(defun blink (x)
  (pinmode 13 t)
  (digitalwrite 13 x)
  (delay 1000)
  (blink (not x)))

Run it by typing:

(blink t)

Pin 13 can also be used as an analogue pin, so you can pulsate the red LED slowly on and off with the program:

(defun pulse ()
  (let (down)
    (loop
     (dotimes (x 256) 
       (delay 5) 
       (analogwrite 13 (if down (- 255 x) x)))
     (setq down (not down)))))

Run it by typing:

(pulse)

Exit from either program by entering ~.

DotStar RGB LED

The Adafruit ItsyBitsy M4 has a DotStar (APA102) RGB LED mounted on the board. For more information about DotStar LEDs see Driving DotStar RGB LEDs.

Here's a program to set the LED to an arbitrary colour and brightness:

First we define variables for the clock and data pins; these are connected to Arduino pins 8 (data) and 6 (clock):

(defvar clk 6)
(defvar data 8)

Here's a routine to send a byte to the display, MSB first, toggling the clock pin after each bit:

(defun send (byte)
  (dotimes (i 8)
    (digitalwrite clk 0)
    (digitalwrite data (logand (ash byte (- i 7)) 1))
    (digitalwrite clk 1)))

Finally here's the function to send the appropriate stream of bits to the LED to define its colour and brightness:

(defun dotstar (bri blue green red)
(pinmode clk t) (pinmode data t) (mapc send (list 0 0 0 0 (logior bri #xe0) blue green red #xff)))

To set the LED evaluate:

(dotstar bri blue green red)

where bri is the brightness (from 0 to 31), and blue, green, and red are the colour components, from 0 to 255. For example, this sets the LED to magenta (blue+red) at low brightness:

(dotstar 1 255 0 255)

Analogue inputs

14 (A0) to 19 (A5)

Analogue reference

The following options are available for analogreference:

Keyword Description
:ar-default Default internal reference of 3.3 V
:ar-internal1v0 Internal reference of 1.0 V
:ar-internal1v1 Internal reference of 1.1 V
:ar-internal1v2 Internal reference of 1.2 V
:ar-internal1v25 Internal reference of 1.25 V
:ar-internal1v65 Internal reference of 1.65 V
:ar-internal2v0 Internal reference of 2.0 V
:ar-internal2v2 Internal reference of 2.2 V
:ar-internal2v23 Internal reference of 2.23 V
:ar-internal2v4 Internal reference of 2.4 V
:ar-internal2v5 Internal reference of 2.5 V
:ar-external Voltage applied to the AREF pin

Analogue outputs

0, 1, 4, 5, 7, 9 to 13, 14 (DAC0), 15 (DAC1), 21, 22

Serial

The Adafruit ItsyBitsy M4 has a serial port, Serial1, on pin numbers 1 (TX) and 0 (RX).

SPI

The Adafruit ItsyBitsy M4 has an SPI port on pin numbers 23 (MISO), 25 (MOSI), and 24 (SCK).

I2C

The Adafruit ItsyBitsy M4 has an I2C port on pin numbers 21 (SDA) and 22 (SCL). 

Adafruit Feather M4

The Adafruit Feather M4 is the same size as Adafruit's Feather range of boards, with its own family of matching shields:

FeatherM4.jpg

It's identical in behaviour to the Arduino Metro M4.

Analogue inputs

14 (A0) to 19 (A5)

Analogue reference

The following options are available for analogreference:

Keyword Description
:ar-default Default internal reference of 3.3 V
:ar-internal1v0 Internal reference of 1.0 V
:ar-internal1v1 Internal reference of 1.1 V
:ar-internal1v2 Internal reference of 1.2 V
:ar-internal1v25 Internal reference of 1.25 V
:ar-internal1v65 Internal reference of 1.65 V
:ar-internal2v0 Internal reference of 2.0 V
:ar-internal2v2 Internal reference of 2.2 V
:ar-internal2v23 Internal reference of 2.23 V
:ar-internal2v4 Internal reference of 2.4 V
:ar-internal2v5 Internal reference of 2.5 V
:ar-external Voltage applied to the AREF pin

Analogue outputs

0, 1, 4 to 6, 9 to 13, 14 (DAC0), 15 (DAC1), 17, 21, 22

Serial

The Adafruit Feather M4 Express has a serial port, Serial1, on pin numbers 1 (TX) and 0 (RX).

SPI

The Adafruit Feather M4 Express has an SPI port on pin numbers 23 (MISO), 24 (MOSI), and 25 (SCK).

I2C

The Adafruit Feather M4 Express has an I2C port on pin numbers 21 (SDA) and 22 (SCL). 


  1. ^ Adafruit Grand Central M4 Express on Adafruit.