]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
Add Raspberry Pi Pico support for MicroPython
authorMelissa LeBlanc-Williams <melissa@adafruit.com>
Fri, 7 May 2021 01:56:21 +0000 (18:56 -0700)
committerMelissa LeBlanc-Williams <melissa@adafruit.com>
Fri, 7 May 2021 01:56:21 +0000 (18:56 -0700)
src/adafruit_blinka/board/raspberry_pi_pico.py [new file with mode: 0755]
src/adafruit_blinka/microcontroller/rp2040/__init__.py [new file with mode: 0644]
src/adafruit_blinka/microcontroller/rp2040/pin.py [new file with mode: 0755]
src/board.py
src/digitalio.py
src/microcontroller/__init__.py
src/microcontroller/pin.py

diff --git a/src/adafruit_blinka/board/raspberry_pi_pico.py b/src/adafruit_blinka/board/raspberry_pi_pico.py
new file mode 100755 (executable)
index 0000000..37b0794
--- /dev/null
@@ -0,0 +1,32 @@
+"""PyBoard pin names"""
+
+from adafruit_blinka.microcontroller.rp2040 import pin
+
+GP0 = pin.GP0
+GP1 = pin.GP1
+GP2 = pin.GP2
+GP3 = pin.GP3
+GP4 = pin.GP4
+GP5 = pin.GP5
+GP6 = pin.GP6
+GP7 = pin.GP7
+GP8 = pin.GP8
+GP9 = pin.GP9
+GP10 = pin.GP10
+GP11 = pin.GP11
+GP12 = pin.GP12
+GP13 = pin.GP13
+GP14 = pin.GP14
+GP15 = pin.GP15
+GP16 = pin.GP16
+GP17 = pin.GP17
+GP18 = pin.GP18
+GP19 = pin.GP19
+GP20 = pin.GP20
+GP21 = pin.GP21
+GP22 = pin.GP22
+GP25 = pin.GP25
+GP26 = pin.GP26
+GP27 = pin.GP27
+GP28 = pin.GP28
+LED = GP25
diff --git a/src/adafruit_blinka/microcontroller/rp2040/__init__.py b/src/adafruit_blinka/microcontroller/rp2040/__init__.py
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/src/adafruit_blinka/microcontroller/rp2040/pin.py b/src/adafruit_blinka/microcontroller/rp2040/pin.py
new file mode 100755 (executable)
index 0000000..aaa9ac3
--- /dev/null
@@ -0,0 +1,99 @@
+"""RP2040 pins"""
+
+from microcontroller import Pin
+
+GP0 = Pin(0)
+GP1 = Pin(1)
+GP2 = Pin(2)
+GP3 = Pin(3)
+GP4 = Pin(4)
+GP5 = Pin(5)
+GP6 = Pin(6)
+GP7 = Pin(7)
+GP8 = Pin(8)
+GP9 = Pin(9)
+GP10 = Pin(10)
+GP11 = Pin(11)
+GP12 = Pin(12)
+GP13 = Pin(13)
+GP14 = Pin(14)
+GP15 = Pin(15)
+GP16 = Pin(16)
+GP17 = Pin(17)
+GP18 = Pin(18)
+GP19 = Pin(19)
+GP20 = Pin(20)
+GP21 = Pin(21)
+GP22 = Pin(22)
+GP25 = Pin(25)
+GP26 = Pin(26)
+GP27 = Pin(27)
+GP28 = Pin(28)
+
+# ordered as spiId, sckId, mosiId (tx), misoId (rx)
+SPI_PORTS = (
+    (0, GP2, GP3, GP0),
+    (0, GP2, GP3, GP4),
+    (0, GP2, GP7, GP0),
+    (0, GP2, GP7, GP4),
+    (0, GP6, GP3, GP0),
+    (0, GP6, GP3, GP4),
+    (0, GP6, GP7, GP0),
+    (0, GP6, GP7, GP4),
+    (1, GP10, GP11, GP8),
+    (1, GP10, GP11, GP12),
+    (1, GP10, GP15, GP8),
+    (1, GP10, GP15, GP12),
+    (1, GP14, GP11, GP8),
+    (1, GP14, GP11, GP12),
+    (1, GP14, GP15, GP8),
+    (1, GP14, GP15, GP12),
+)
+
+# ordered as uartId, txId, rxId
+UART_PORTS = (
+    (0, GP0, GP1),
+    (0, GP0, GP13),
+    (0, GP12, GP1),
+    (0, GP12, GP13),
+    (1, GP4, GP5),
+    (1, GP4, GP9),
+    (1, GP8, GP5),
+    (1, GP8, GP9),
+)
+
+# ordered as scl, sda
+I2C_PORTS = (
+    (0, GP1, GP0),
+    (0, GP1, GP4),
+    (0, GP1, GP8),
+    (0, GP1, GP12),
+    (0, GP5, GP0),
+    (0, GP5, GP4),
+    (0, GP5, GP8),
+    (0, GP5, GP12),
+    (0, GP9, GP0),
+    (0, GP9, GP4),
+    (0, GP9, GP8),
+    (0, GP9, GP12),
+    (0, GP13, GP0),
+    (0, GP13, GP4),
+    (0, GP13, GP8),
+    (0, GP13, GP12),
+    (1, GP3, GP2),
+    (1, GP3, GP6),
+    (1, GP3, GP10),
+    (1, GP3, GP14),
+    (1, GP7, GP2),
+    (1, GP7, GP6),
+    (1, GP7, GP10),
+    (1, GP7, GP14),
+    (1, GP11, GP2),
+    (1, GP11, GP6),
+    (1, GP11, GP10),
+    (1, GP11, GP14),
+    (1, GP15, GP2),
+    (1, GP15, GP6),
+    (1, GP15, GP10),
+    (1, GP15, GP14),
+)
index 9cdd379bd1e886e97a13593e81757654c74994cd..a589e0a7195083de21587914beed56742090b347 100755 (executable)
@@ -44,6 +44,9 @@ elif board_id == ap_board.NODEMCU:
 elif board_id == ap_board.PYBOARD:
     from adafruit_blinka.board.pyboard import *
 
+elif board_id == ap_board.RASPBERRY_PI_PICO:
+    from adafruit_blinka.board.raspberry_pi_pico import *
+
 elif detector.board.any_raspberry_pi_40_pin:
     from adafruit_blinka.board.raspberrypi.raspi_40pin import *
 
index 0f5f321f5bfca97a1c529c4bb59a13bb3b8dd144..7b4ea8f48dca90abdb73be0ab5f3b3db7a8ee8bd 100755 (executable)
@@ -61,6 +61,8 @@ elif detector.board.greatfet_one:
     from adafruit_blinka.microcontroller.nxp_lpc4330.pin import Pin
 elif detector.chip.STM32F405:
     from machine import Pin
+elif detector.chip.RP2040:
+    from machine import Pin
 elif detector.board.microchip_mcp2221:
     from adafruit_blinka.microcontroller.mcp2221.pin import Pin
 elif detector.chip.PENTIUM_N3710:
index eed47576345a9530148654681a4994a94d602bab..a213869cceffc5fe03739691eb424006deaaf148 100755 (executable)
@@ -43,6 +43,8 @@ if chip_id == ap_chip.ESP8266:
     from adafruit_blinka.microcontroller.esp8266 import *
 elif chip_id == ap_chip.STM32F405:
     from adafruit_blinka.microcontroller.stm32.stm32f405 import *
+elif chip_id == ap_chip.RP2040:
+    from adafruit_blinka.microcontroller.rp2040 import *
 elif chip_id == ap_chip.BCM2XXX:
     from adafruit_blinka.microcontroller.bcm283x import *
 elif chip_id == ap_chip.DRA74X:
index f69d30e7aef0ddb76c33df7d9cab0b1aff3b6876..4916c197b53a470312808b0d470f7b648f7024ef 100755 (executable)
@@ -10,6 +10,8 @@ if chip_id == ap_chip.ESP8266:
     from adafruit_blinka.microcontroller.esp8266.pin import *
 elif chip_id == ap_chip.STM32F405:
     from adafruit_blinka.microcontroller.stm32.stm32f405.pin import *
+elif chip_id == ap_chip.RP2040:
+    from adafruit_blinka.microcontroller.rp2040.pin import *
 elif chip_id == ap_chip.BCM2XXX:
     from adafruit_blinka.microcontroller.bcm283x.pin import *
 elif chip_id == ap_chip.DRA74X: