circuitpython/atmel-samd
Scott Shawcroft 34cc304fda atmel-samd: Update README and add pinout tables that map MCU names
to names in the board module and explain pin capabilities.

Fixes #149
2017-07-13 16:07:02 -07:00
..
asf Fix USB Busy error for kbd hid. Made kbd USB report descriptor be 2017-06-29 21:47:30 -07:00
asf_conf atmel-samd: Use DMA for SPI flash block transfers. 2017-05-02 15:25:06 -07:00
bindings/samd atmel-samd: Fixup autoreset after switching boot to running once. 2017-05-15 20:21:26 -07:00
boards atmel-samd: Update README and add pinout tables that map MCU names 2017-07-13 16:07:02 -07:00
common-hal atmel-samd: Fix AudioOut buffer playback by supporting bytes_per_sample. 2017-06-20 11:18:46 -07:00
freetouch@1f21fde3fe atmel-samd: Swap out pulseio for touchio based on FreeTouch. 2017-04-18 09:44:04 -07:00
modules atmel-samd: Move neopixel out of internal flash. 2016-11-18 16:17:56 -08:00
tools atmel-samd: Update README and add pinout tables that map MCU names 2017-07-13 16:07:02 -07:00
.gitattributes Include the precompiled math library from ASF. 2016-09-07 14:35:40 -07:00
.gitignore Blinking the LED works. Clocks should be set up correctly. 2016-08-22 23:53:11 -07:00
access_vfs.c atmel-samd: Rename auto-reset to auto-reload to reduce confusion with physical reset buttons. 2017-05-12 16:45:38 -07:00
access_vfs.h atmel-samd: Rework mass storage interaction with underlying block 2016-10-21 15:36:59 -07:00
autoreload.c atmel-samd: Fixup autoreset after switching boot to running once. 2017-05-15 20:21:26 -07:00
autoreload.h atmel-samd: Rename auto-reset to auto-reload to reduce confusion with physical reset buttons. 2017-05-12 16:45:38 -07:00
background.c atmel-samd: Support wav file playback. Tested up to 16bit 22.1khz. Must be mono file! 2017-05-15 19:52:38 -07:00
background.h atmel-samd: Support wav file playback. Tested up to 16bit 22.1khz. Must be mono file! 2017-05-15 19:52:38 -07:00
builtin_open.c atmel/samd: Add filesystem support. 64k is stored in flash. 2016-09-02 17:00:30 -07:00
fatfs_port.c atmel-samd: Correct fake date for FAT. Hopefully it'll be in 2016 now. 2016-12-05 11:15:46 -08:00
flash_api.c atmel-samd: Rework boot, main and REPL order. 2017-05-12 18:26:14 -07:00
flash_api.h atmel-samd: Rework boot, main and REPL order. 2017-05-12 18:26:14 -07:00
internal_flash.c atmel-samd: Rework boot, main and REPL order. 2017-05-12 18:26:14 -07:00
internal_flash.h atmel-samd: Rework SPI flash defines for clarity. 2017-05-12 14:47:39 -07:00
main.c atmel-samd: Give the on board flash filesystem a unique volume ID. This is useful for identifying filesystem mounts and matching them up to hardware. 2017-07-06 10:45:42 -07:00
Makefile atmel-samd: Reboot to bootloader when a 1200 baud serial connection is 2017-07-06 13:41:13 -07:00
moduos.c Switch exception throwing to mp_raise helpers. It saves a little code space each time to share the call. 2017-02-24 15:13:07 +01:00
mpconfigport.h atmel-samd: Switch streams to non-blocking mode. Fixes #159. 2017-07-03 12:02:03 -07:00
mphalport.c atmel-samd: Reboot to bootloader when a 1200 baud serial connection is 2017-07-06 13:41:13 -07:00
mphalport.h atmel-samd: Rework boot, main and REPL order. 2017-05-12 18:26:14 -07:00
qstrdefsport.h Compiled and linked SAMD21x18 version successfully. 2016-08-22 23:53:10 -07:00
README.rst atmel-samd: Update README and add pinout tables that map MCU names 2017-07-13 16:07:02 -07:00
reset.c atmel-samd: Reboot to bootloader when a 1200 baud serial connection is 2017-07-06 13:41:13 -07:00
reset.h atmel-samd: Reboot to bootloader when a 1200 baud serial connection is 2017-07-06 13:41:13 -07:00
rgb_led_colors.h atmel-samd: Add a safe mode which detects hard faults and reboots without running user code again. 2017-05-15 15:29:04 -07:00
rgb_led_status.c atmel-samd: Rework status LED implementation 2017-04-12 15:24:50 -07:00
rgb_led_status.h atmel-samd: Rework status LED implementation 2017-04-12 15:24:50 -07:00
samd21_pins.c atmel-samd: Fix TCC1, its two channels and four wave outputs. 2017-06-12 15:36:09 -07:00
samd21_pins.h atmel-samd: Rework status LED implementation 2017-04-12 15:24:50 -07:00
shared_dma.c atmel-samd: Support wav file playback. Tested up to 16bit 22.1khz. Must be mono file! 2017-05-15 19:52:38 -07:00
shared_dma.h atmel-samd: Use DMA for SPI flash block transfers. 2017-05-02 15:25:06 -07:00
spi_flash.c atmel-samd: Rework boot, main and REPL order. 2017-05-12 18:26:14 -07:00
spi_flash.h atmel-samd: Switch to MICROPY_PORT_ROOT_POINTERS for the flash cache. 2016-11-29 14:29:33 -08:00
tick.c atmel-samd: Rename auto-reset to auto-reload to reduce confusion with physical reset buttons. 2017-05-12 16:45:38 -07:00
tick.h atmel-samd: Rename auto-reset to auto-reload to reduce confusion with physical reset buttons. 2017-05-12 16:45:38 -07:00

SAMD21x18
=========

This port brings MicroPython to SAMD21x18 based development boards under the name
CircuitPython. Supported boards include the Adafruit CircuitPlayground Express,
Adafruit Feather M0 Express, Adafruit Metro M0 Express, Arduino Zero, Adafruit
Feather M0 Basic and Adafruit M0 Bluefruit LE.

Pinout
------

All of the boards share the same core pin functionality but call pins by
different names. The table below matches the pin order in
`the datasheet <http://ww1.microchip.com/downloads/en/DeviceDoc/40001882A.pdf>`_
and omits the pins only available on the largest package because all supported
boards use smaller version.

=====================  ===============  ===========================  ====================  ================  ==================  =========================  ================  ================
`microcontroller.pin`  `board`
---------------------  -----------------------------------------------------------------------------------------------------------------------------------------------------------------------
Datasheet              arduino_zero     circuitplayground_express    feather_m0_adalogger  feather_m0_basic  feather_m0_express  gemma_m0                   metro_m0_express  trinket_m0
=====================  ===============  ===========================  ====================  ================  ==================  =========================  ================  ================
PA00                                    ``ACCELEROMETER_SDA``                                                                    ``APA102_MOSI``                              ``APA102_MOSI``
PA01                                    ``ACCELEROMETER_SCL``                                                                    ``APA102_SCK``                               ``APA102_SCK``
PA02                   ``A0``           ``A0`` / ``SPEAKER``         ``A0``                ``A0``            ``A0``              ``A0`` / ``D1``            ``A0``            ``D1`` / ``A0``
PA03
PB08                   ``A1``           ``A7`` / ``TX``              ``A1``                ``A1``            ``A1``                                         ``A1``
PB09                   ``A2``           ``A6`` / ``RX``              ``A2``                ``A2``            ``A2``                                         ``A2``
PA04                   ``A3``           ``IR_PROXIMITY``             ``A3``                ``A3``            ``A3``              ``D0`` / ``TX`` / ``SDA``  ``A3``
PA05                   ``A4``           ``A1``                       ``A4``                ``A4``            ``A4``              ``D2`` / ``RX`` / ``SCL``  ``A4``
PA06                   ``D8``           ``A2``                                                               ``NEOPIXEL``                                   ``D8``            ``D4`` / ``TX``
PA07                   ``D9``           ``A3``                       ``D9``                ``D9``            ``D9``                                         ``D9``            ``D3`` / ``RX``
PA08                   ``D4``           ``MICROPHONE_DO``            ``SD_CS``                                                                              ``D4``            ``D0`` / ``SDA``
PA09                   ``D3``           ``TEMPERATURE`` / ``A9``                                                                                            ``D3``            ``D2`` / ``SCL``
PA10                   ``D1`` / ``TX``  ``MICROPHONE_SCK``           ``D1`` / ``TX``       ``D1`` / ``TX``   ``D1`` / ``TX``                                ``D1`` / ``TX``   ``D13``
PA11                   ``D0`` / ``RX``  ``LIGHT`` / ``A8``           ``D0`` / ``RX``       ``D0`` / ``RX``   ``D0`` / ``RX``                                ``D0`` / ``RX``
PB10                   ``MOSI``                                      ``MOSI``              ``MOSI``          ``MOSI``                                       ``MOSI``
PB11                   ``SCK``                                       ``SCK``               ``SCK``           ``SCK``                                        ``SCK``
PA12                   ``MISO``         ``REMOTEIN`` / ``IR_RX``     ``MISO``              ``MISO``          ``MISO``                                       ``MISO``
PA13                                    ``ACCELEROMETER_INTERRUPT``                                                                                         ``FLASH_CS``
PA14                   ``D2``           ``BUTTON_B`` / ``D5``                                                                                               ``D2``
PA15                   ``D5``           ``SLIDE_SWITCH`` / ``D7``    ``D5``                ``D5``            ``D5``                                         ``D5``
PA16                   ``D11``          ``MISO``                     ``D11``               ``D11``           ``D11``                                        ``D11``
PA17                   ``D13``          ``D13``                      ``D13``               ``D13``           ``D13``                                        ``D13``
PA18                   ``D10``                                       ``D10``               ``D10``           ``D10``                                        ``D10``
PA19                   ``D12``                                       ``D12``               ``D12``           ``D12``                                        ``D12``
PA20                   ``D6``           ``MOSI``                     ``D6``                ``D6``            ``D6``                                         ``D6``
PA21                   ``D7``           ``SCK``                                                                                                             ``D7``
PA22                   ``SDA``                                       ``SDA``               ``SDA``           ``SDA``                                        ``SDA``
PA23                   ``SCL``          ``REMOTEOUT`` / ``IR_TX``    ``SCL``               ``SCL``           ``SCL``             ``L`` / ``D13``            ``SCL``
PA24
PA25
PB22                                    ``FLASH_CS``
PB23                                    ``NEOPIXEL`` / ``D8``
PA27
PA28                                    ``BUTTON_A`` / ``D4``
PA29
PA30                                    ``SPEAKER_ENABLE``                                                                                                  ``NEOPIXEL``
PA31
PB02                   ``A5``           ``A5`` / ``SDA``             ``A5``                ``A5``            ``A5``                                         ``A5``
PB03                                    ``A4`` / ``SCL``
=====================  ===============  ===========================  ====================  ================  ==================  =========================  ================  ================

Here is a table about which pins can do what in CircuitPython terms. However,
just because something is listed, doesn't mean it will always work. Existing use
of other pins and functionality will impact your ability to use a pin for your
desired purpose. For example, only certain combinations of SPI pins will work
because they use shared hardware internally.

=====================  ========  =========  =========  =======  =======  =======  =========  =========  =======  ==========  ==========  =========  =========  =========  ============  =======  =======  =========
`microcontroller.pin`  `analogio`           `audioio`  `bitbangio`                `busio`                                                                                 `digitalio`   `pulseio`         `touchio`
---------------------  -------------------  ---------  -------------------------  --------------------------------------------------------------------------------------  ------------  ----------------  ---------
Datasheet              AnalogIn  AnalogOut  AudioOut   I2C      OneWire  SPI      I2C - SDA  I2C - SCL  OneWire  SPI - MISO  SPI - MOSI  SPI - SCK  UART - RX  UART - TX  DigitalInOut  PulseIn  PWMOut   TouchIn
=====================  ========  =========  =========  =======  =======  =======  =========  =========  =======  ==========  ==========  =========  =========  =========  ============  =======  =======  =========
PA00                                                   **Yes**  **Yes**  **Yes**  **Yes**               **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**
PA01                                                   **Yes**  **Yes**  **Yes**             **Yes**    **Yes**  **Yes**                 **Yes**    **Yes**               **Yes**       **Yes**  **Yes**
PA02                   **Yes**   **Yes**    **Yes**    **Yes**  **Yes**  **Yes**                        **Yes**                                                           **Yes**       **Yes**           **Yes**
PA03                   **Yes**                         **Yes**  **Yes**  **Yes**                        **Yes**                                                           **Yes**       **Yes**           **Yes**
PB08                   **Yes**                         **Yes**  **Yes**  **Yes**  **Yes**               **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**           **Yes**
PB09                   **Yes**                         **Yes**  **Yes**  **Yes**             **Yes**    **Yes**  **Yes**                 **Yes**    **Yes**               **Yes**       **Yes**  **Yes**  **Yes**
PA04                   **Yes**                         **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**  **Yes**  **Yes**
PA05                   **Yes**                         **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**                 **Yes**    **Yes**               **Yes**       **Yes**  **Yes**  **Yes**
PA06                   **Yes**                         **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**  **Yes**  **Yes**
PA07                   **Yes**                         **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**                 **Yes**    **Yes**               **Yes**       **Yes**  **Yes**  **Yes**
PA08                   **Yes**                         **Yes**  **Yes**  **Yes**  **Yes**               **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**  **Yes**
PA09                   **Yes**                         **Yes**  **Yes**  **Yes**             **Yes**    **Yes**  **Yes**                 **Yes**    **Yes**               **Yes**       **Yes**  **Yes**
PA10                   **Yes**                         **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**  **Yes**
PA11                   **Yes**                         **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**     **Yes**    **Yes**               **Yes**       **Yes**  **Yes**
PB10                                                   **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**  **Yes**
PB11                                                   **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**     **Yes**    **Yes**               **Yes**       **Yes**  **Yes**
PA12                                                   **Yes**  **Yes**  **Yes**  **Yes**               **Yes**  **Yes**                            **Yes**    **Yes**    **Yes**       **Yes**  **Yes**
PA13                                                   **Yes**  **Yes**  **Yes**             **Yes**    **Yes**  **Yes**                 **Yes**    **Yes**               **Yes**       **Yes**  **Yes**
PA14                                                   **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**  **Yes**
PA15                                                   **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**     **Yes**    **Yes**               **Yes**       **Yes**  **Yes**
PA16                                                   **Yes**  **Yes**  **Yes**  **Yes**               **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**  **Yes**
PA17                                                   **Yes**  **Yes**  **Yes**             **Yes**    **Yes**  **Yes**                 **Yes**    **Yes**               **Yes**       **Yes**  **Yes**
PA18                                                   **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**  **Yes**
PA19                                                   **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**     **Yes**    **Yes**               **Yes**       **Yes**  **Yes**
PA20                                                   **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**  **Yes**
PA21                                                   **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**     **Yes**    **Yes**               **Yes**       **Yes**  **Yes**
PA22                                                   **Yes**  **Yes**  **Yes**  **Yes**               **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**  **Yes**
PA23                                                   **Yes**  **Yes**  **Yes**             **Yes**    **Yes**  **Yes**                 **Yes**    **Yes**               **Yes**       **Yes**  **Yes**
PA24
PA25
PB22                                                   **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**
PB23                                                   **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**     **Yes**    **Yes**               **Yes**       **Yes**
PA27                                                   **Yes**  **Yes**  **Yes**                        **Yes**                                                           **Yes**       **Yes**
PA28                                                   **Yes**  **Yes**  **Yes**                        **Yes**                                                           **Yes**       **Yes**
PA29                                                   **Yes**  **Yes**  **Yes**                        **Yes**                                                           **Yes**       **Yes**
PA30                                                   **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**  **Yes**
PA31                                                   **Yes**  **Yes**  **Yes**                        **Yes**  **Yes**     **Yes**     **Yes**    **Yes**               **Yes**       **Yes**  **Yes**
PB02                   **Yes**                         **Yes**  **Yes**  **Yes**  **Yes**               **Yes**  **Yes**     **Yes**                **Yes**    **Yes**    **Yes**       **Yes**           **Yes**
PB03                   **Yes**                         **Yes**  **Yes**  **Yes**             **Yes**    **Yes**  **Yes**                 **Yes**    **Yes**               **Yes**       **Yes**           **Yes**
=====================  ========  =========  =========  =======  =======  =======  =========  =========  =======  ==========  ==========  =========  =========  =========  ============  =======  =======  =========

Building
--------

To build for the Arduino Zero:

.. code-block:: shell

    make

To build for other boards you must change it by setting ``BOARD``. For example:

.. code-block:: shell

    make BOARD=feather_m0_basic

Board names are the directory names in the `boards <https://github.com/adafruit/circuitpython/tree/master/atmel-samd/boards>`_ folder.

Deploying
---------

Arduino Bootloader
^^^^^^^^^^^^^^^^^^

If your board has an existing Arduino bootloader on it then you can use bossac
to flash MicroPython. First, activate the bootloader. On Adafruit Feathers you
can double click the reset button and the #13 will fade in and out. Finally,
run bossac:

    tools/bossac_osx -e -w -v -b -R build-feather_m0_basic/firmware.bin

No Bootloader via GDB
^^^^^^^^^^^^^^^^^^^^^

This method works for loading MicroPython onto the Arduino Zero via the
programming port rather than the native USB port.

Note: These instructions are tested on Mac OSX and will vary for different
platforms.

    openocd -f ~/Library/Arduino15/packages/arduino/hardware/samd/1.6.6/variants/arduino_zero/openocd_scripts/arduino_zero.cfg

In another terminal from ``micropython/atmel-samd``:

    arm-none-eabi-gdb build-arduino_zero/firmware.elf
    (gdb) tar ext :3333
    ...
    (gdb) load
    ...
    (gdb) monitor reset init
    ...
    (gdb) continue

Connecting
----------

Serial
^^^^^^

All boards are currently configured to work over USB rather than UART. To
connect to it from OSX do something like this:

    screen /dev/tty.usbmodem142422 115200

You may not see a prompt immediately because it doesn't know you connected. To
get one either hit enter to get `>>>` or do CTRL-B to get the full header.

Mass storage
^^^^^^^^^^^^

All boards will also show up as a mass storage device. Make sure to eject it
before resetting or disconnecting the board.

Port Specific modules
---------------------

.. toctree::
    bindings/samd/__init__