0

Building CircuitPython to make unused pins available
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

Building CircuitPython to make unused pins available

by bisaac on Sat Mar 30, 2019 2:00 pm

I have an application that needed two more pins than the trinke m0 had available. I looked up the schematic and found two corner pins that were easier to solder to
PA15 and PA27.

First I tried to use microcontroller.Pin
https://circuitpython.readthedocs.io/en ... r/Pin.html
but got this error message when I tried to create
TypeError: cannot create 'Pin' instances

Next I looked at building circuit python
I was able to get the tools to compile to run under windows 10 and build circuit python for trinket_m0 using this guide
https://learn.adafruit.com/building-cir ... -for-linux

I modified the following source to add two new digital pins D5 and D6

circuitpython-master\ports\atmel-samd\boards\trinket_m0\pins.c
Code: Select all | TOGGLE FULL SIZE
    { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_PA27) },
    { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_PA15) },

circuitpython-master\circuitpython-master\ports\atmel-samd\boards\trinket_m0\mpconfigboard.h
Code: Select all | TOGGLE FULL SIZE
//#define IGNORE_PIN_PA15     1
//#define IGNORE_PIN_PA27     1

created the firmware.uf2 and copied to the device using the bootloader

Added the following code in code.py
import time
import board
from digitalio import DigitalInOut, Direction, Pull
D5 = DigitalInOut(board.D5)
D5.direction = Direction.OUTPUT

D6 = DigitalInOut(board.D6)
D6.direction = Direction.OUTPUT

while True:
D5.value = 1
D6.value = 1
time.sleep(1)
D5.value = 0
D6.value = 0
time.sleep(1)

I am really happy this worked and just wanted to share in case anyone was looking to expand the capabilities of this perfectly sized board.
Attachments
IMG_5725.JPG
IMG_5725.JPG (337.65 KiB) Viewed 104 times

bisaac
 
Posts: 1
Joined: Sat Mar 30, 2019 1:10 pm

Re: Building CircuitPython to make unused pins available

by XRAD on Sat Mar 30, 2019 3:44 pm

and you can use pin 13 if you carefully attach to correct side of LED resistor.......

XRAD
 
Posts: 440
Joined: Sat Nov 19, 2016 3:28 pm

Please be positive and constructive with your questions and comments.