]> Repositories - Adafruit_Blinka-hackapet.git/commitdiff
adding support for RFM and CAN feathers
authorLiz <liz@adafruit.com>
Tue, 11 Apr 2023 15:41:59 +0000 (11:41 -0400)
committerLiz <liz@adafruit.com>
Tue, 11 Apr 2023 15:41:59 +0000 (11:41 -0400)
src/adafruit_blinka/board/feather_can_u2if.py [new file with mode: 0644]
src/adafruit_blinka/board/feather_epd_u2if.py
src/adafruit_blinka/board/feather_rfm_u2if.py [new file with mode: 0644]
src/adafruit_blinka/microcontroller/rp2040_u2if/i2c.py
src/adafruit_blinka/microcontroller/rp2040_u2if/spi.py
src/board.py
src/busio.py
src/neopixel_write.py
src/pwmio.py

diff --git a/src/adafruit_blinka/board/feather_can_u2if.py b/src/adafruit_blinka/board/feather_can_u2if.py
new file mode 100644 (file)
index 0000000..1593dbd
--- /dev/null
@@ -0,0 +1,64 @@
+# SPDX-FileCopyrightText: 2023 Liz Clark for Adafruit Industries
+#
+# SPDX-License-Identifier: MIT
+"""
+Pin definitions for the Feather RP2040 CAN with u2if firmware.
+
+Adafruit CircuitPython 6.2.0 on 2021-04-05; Adafruit Feather RP2040 CAN with rp2040
+>>> import board
+>>> board.
+A0              A1              A2              A3
+D0              D1              D10             D11
+D12             D13             D24             D25
+D4              D5              D6              D9
+I2C             SDA             SCL             LED   
+NEOPIXEL        SPI             SCK             MISO
+MOSI            RX              TX              UART
+CAN_STANDBY     CAN_TX0_RTS     CAN_RESET       CAN_CS
+CAN_INTERRUPT   CAN_RX0_BF      NEOPIXEL_POWER
+"""
+
+from adafruit_blinka.microcontroller.rp2040_u2if import pin
+
+D0 = RX = pin.GP1
+D1 = TX = pin.GP0
+D4 = pin.GP4
+D5 = pin.GP5
+D6 = pin.GP6
+D9 = pin.GP9
+D10 = pin.GP10
+D11 = pin.GP11
+D12 = pin.GP12
+D13 = pin.GP13
+D24 = pin.GP24
+D25 = pin.GP25
+
+A0 = pin.GP26
+A1 = pin.GP27
+A2 = pin.GP28
+A3 = pin.GP29
+
+LED = pin.GP13
+
+BUTTON = BOOT = pin.GP7
+
+NEOPIXEL = pin.GP21
+NEOPIXEL_POWER = pin.GP20
+
+SDA = pin.GP2
+SCL = pin.GP3
+
+SCLK = SCK = pin.GP14
+MOSI = pin.GP15
+MISO = pin.GP8
+
+CAN_STANDBY = pin.GP16
+CAN_TX0_RTS = pin.GP17
+CAN_RESET = pin.GP18
+CAN_CS = pin.GP19
+CAN_INTERRUPT = pin.GP22
+CAN_RX0_BF = pin.GP23
+
+# access u2if via pin instance to open for specifc VID/PID
+# pylint:disable = protected-access
+pin.GP0._u2if_open_hid(0x239A, 0x8130)
index 4ac0b29e931b00edae80fd771dfef14f98e44f29..f31096fa319e8708178f07c46cfaf71ee8a06b40 100644 (file)
@@ -40,7 +40,10 @@ A3 = pin.GP29
 
 LED = pin.GP13
 
+BUTTON = BOOT = pin.GP7
+
 NEOPIXEL = pin.GP21
+NEOPIXEL_POWER = pin.GP20
 
 SDA = pin.GP2
 SCL = pin.GP3
diff --git a/src/adafruit_blinka/board/feather_rfm_u2if.py b/src/adafruit_blinka/board/feather_rfm_u2if.py
new file mode 100644 (file)
index 0000000..eacad83
--- /dev/null
@@ -0,0 +1,65 @@
+# SPDX-FileCopyrightText: 2023 Liz Clark for Adafruit Industries
+#
+# SPDX-License-Identifier: MIT
+"""
+Pin definitions for the Feather RP2040 RFM with u2if firmware.
+
+Adafruit CircuitPython 6.2.0 on 2021-04-05; Adafruit Feather RP2040 RFM with rp2040
+>>> import board
+>>> board.
+A0              A1              A2              A3
+D0              D1              D10             D11
+D12             D13             D24             D25
+D4              D5              D6              D9
+I2C             SDA             SCL             LED   
+NEOPIXEL        SPI             SCK             MISO
+MOSI            RX              TX              UART
+RFM_CS          RFM_RST         RFM_IO5         RFM_IO3
+RFM_IO4         RFM_IO0         RFM_IO1         RFM_IO2
+"""
+
+from adafruit_blinka.microcontroller.rp2040_u2if import pin
+
+D0 = RX = pin.GP1
+D1 = TX = pin.GP0
+D4 = pin.GP4
+D5 = pin.GP5
+D6 = pin.GP6
+D9 = pin.GP9
+D10 = pin.GP10
+D11 = pin.GP11
+D12 = pin.GP12
+D13 = pin.GP13
+D24 = pin.GP24
+D25 = pin.GP25
+
+A0 = pin.GP26
+A1 = pin.GP27
+A2 = pin.GP28
+A3 = pin.GP29
+
+LED = pin.GP13
+
+BUTTON = BOOT = pin.GP7
+
+NEOPIXEL = pin.GP4
+
+SDA = pin.GP2
+SCL = pin.GP3
+
+SCLK = SCK = pin.GP14
+MOSI = pin.GP15
+MISO = pin.GP8
+
+RFM_CS = pin.GP16
+RFM_RST = pin.GP17
+RFM_IO5 = pin.GP18
+RFM_IO3 = pin.GP19
+RFM_IO4 = pin.GP20
+RFM_IO0 = pin.GP21
+RFM_IO1 = pin.GP22
+RFM_IO2 = pin.GP23
+
+# access u2if via pin instance to open for specifc VID/PID
+# pylint:disable = protected-access
+pin.GP0._u2if_open_hid(0x239A, 0x812E)
index 179af826f95544cd8e6bd20ae5c8ca9cac794b2b..2573b2c5ef683e756365c53f9a3f9ab57828a654 100644 (file)
@@ -87,6 +87,18 @@ class I2C_Feather(I2C):
 
         super().__init__(index, frequency=frequency)
 
+class I2C_Feather_CAN(I2C):
+    """I2C Class for Feather EPD u2if"""
+
+    def __init__(self, scl, sda, *, frequency=100000):
+        index = None
+        if scl.id == 3 and sda.id == 2:
+            index = 1
+        if index is None:
+            raise ValueError("I2C not found on specified pins.")
+        self._index = index
+
+        super().__init__(index, frequency=frequency)
 
 class I2C_Feather_EPD(I2C):
     """I2C Class for Feather EPD u2if"""
@@ -101,6 +113,18 @@ class I2C_Feather_EPD(I2C):
 
         super().__init__(index, frequency=frequency)
 
+class I2C_Feather_RFM(I2C):
+    """I2C Class for Feather EPD u2if"""
+
+    def __init__(self, scl, sda, *, frequency=100000):
+        index = None
+        if scl.id == 3 and sda.id == 2:
+            index = 1
+        if index is None:
+            raise ValueError("I2C not found on specified pins.")
+        self._index = index
+
+        super().__init__(index, frequency=frequency)
 
 class I2C_QTPY(I2C):
     """I2C Class for QT Py 2if"""
index cb671304ace83fe6fab8940f19a323a3ef23a24d..82707ff3ca343a9bb57e5c9dd339ba4d1a7eed8a 100644 (file)
@@ -4,7 +4,6 @@
 """SPI Classes for RP2040s with u2if firmware"""
 from .rp2040_u2if import rp2040_u2if
 
-
 # pylint: disable=protected-access, no-self-use
 class SPI:
     """SPI Base Class for RP2040 u2if"""
@@ -67,7 +66,6 @@ class SPI:
 
     # pylint: enable=too-many-arguments
 
-
 class SPI_Pico(SPI):
     """SPI Class for Pico u2if"""
 
@@ -93,6 +91,16 @@ class SPI_Feather(SPI):
             raise ValueError("No SPI port on specified pin.")
         super().__init__(index, baudrate=baudrate)
 
+class SPI_Feather_CAN(SPI):
+    """SPI Class for Feather EPD u2if"""
+
+    def __init__(self, clock, *, baudrate=100000):
+        index = None
+        if clock.id == 14:
+            index = 1
+        if index is None:
+            raise ValueError("No SPI port on specified pin.")
+        super().__init__(index, baudrate=baudrate)
 
 class SPI_Feather_EPD(SPI):
     """SPI Class for Feather EPD u2if"""
@@ -107,6 +115,16 @@ class SPI_Feather_EPD(SPI):
             raise ValueError("No SPI port on specified pin.")
         super().__init__(index, baudrate=baudrate)
 
+class SPI_Feather_RFM(SPI):
+    """SPI Class for Feather EPD u2if"""
+
+    def __init__(self, clock, *, baudrate=100000):
+        index = None
+        if clock.id == 14:
+            index = 1
+        if index is None:
+            raise ValueError("No SPI port on specified pin.")
+        super().__init__(index, baudrate=baudrate)
 
 class SPI_QTPY(SPI):
     """SPI Class for QT Py u2if"""
index c1785ff363f6174515ab61e880a9e85aa8272113..89a2a73609c1410643ab49babec6cdd02e440164 100644 (file)
@@ -301,9 +301,15 @@ elif board_id == ap_board.PICO_U2IF:
 elif board_id == ap_board.FEATHER_U2IF:
     from adafruit_blinka.board.feather_u2if import *
 
+elif board_id == ap_board.FEATHER_CAN_U2IF:
+    from adafruit_blinka.board.feather_can_u2if import *
+
 elif board_id == ap_board.FEATHER_EPD_U2IF:
     from adafruit_blinka.board.feather_epd_u2if import *
 
+elif board_id == ap_board.FEATHER_RFM_U2IF:
+    from adafruit_blinka.board.feather_rfm_u2if import *
+
 elif board_id == ap_board.QTPY_U2IF:
     from adafruit_blinka.board.qtpy_u2if import *
 
index c7b9eb3a4af8f0c5f86f65ac7d7715fb73a5d5fa..8f41667113b7d034193367950cbd30fea185bc63 100644 (file)
@@ -67,6 +67,13 @@ class I2C(Lockable):
                 I2C_Feather as _I2C,
             )
 
+            self._i2c = _I2C(scl, sda, frequency=frequency)
+            return
+        if detector.board.feather_can_u2if:
+            from adafruit_blinka.microcontroller.rp2040_u2if.i2c import (
+                I2C_Feather_CAN as _I2C,
+            )
+
             self._i2c = _I2C(scl, sda, frequency=frequency)
             return
         if detector.board.feather_epd_u2if:
@@ -74,6 +81,13 @@ class I2C(Lockable):
                 I2C_Feather_EPD as _I2C,
             )
 
+            self._i2c = _I2C(scl, sda, frequency=frequency)
+            return
+        if detector.board.feather_rfm_u2if:
+            from adafruit_blinka.microcontroller.rp2040_u2if.i2c import (
+                I2C_Feather_RFM as _I2C,
+            )
+
             self._i2c = _I2C(scl, sda, frequency=frequency)
             return
         if detector.board.qtpy_u2if:
@@ -252,6 +266,14 @@ class SPI(Lockable):
                 SPI_Feather as _SPI,
             )
 
+            self._spi = _SPI(clock)  # this is really all that's needed
+            self._pins = (clock, clock, clock)  # will determine MOSI/MISO from clock
+            return
+        if detector.board.feather_can_u2if:
+            from adafruit_blinka.microcontroller.rp2040_u2if.spi import (
+                SPI_Feather_CAN as _SPI,
+            )
+
             self._spi = _SPI(clock)  # this is really all that's needed
             self._pins = (clock, clock, clock)  # will determine MOSI/MISO from clock
             return
@@ -260,6 +282,14 @@ class SPI(Lockable):
                 SPI_Feather_EPD as _SPI,
             )
 
+            self._spi = _SPI(clock)  # this is really all that's needed
+            self._pins = (clock, clock, clock)  # will determine MOSI/MISO from clock
+            return
+        if detector.board.feather_rfm_u2if:
+            from adafruit_blinka.microcontroller.rp2040_u2if.spi import (
+                SPI_Feather_RFM as _SPI,
+            )
+
             self._spi = _SPI(clock)  # this is really all that's needed
             self._pins = (clock, clock, clock)  # will determine MOSI/MISO from clock
             return
index 2c5e34ac71c4762cfcd6a264b40f46d2498f922a..997dd0dec5e75dafbe7dec5cac56f77817274067 100644 (file)
@@ -21,7 +21,9 @@ elif detector.board.pico_u2if:
     from adafruit_blinka.microcontroller.rp2040_u2if import neopixel as _neopixel
 elif (
     detector.board.feather_u2if
+    or detector.board.feather_can_u2if
     or detector.board.feather_epd_u2if
+    or detector.board.feather_rfm_u2if
     or detector.board.qtpy_u2if
     or detector.board.itsybitsy_u2if
     or detector.board.macropad_u2if
index c09e78d7027d0ef83a0410275e278512c6b45a9b..57854df42b736a6fa61ae6a9a9c954ad3791dbee 100644 (file)
@@ -38,7 +38,9 @@ elif detector.board.pico_u2if:
     from adafruit_blinka.microcontroller.rp2040_u2if.pwmio import PWMOut
 elif (
     detector.board.feather_u2if
+    or detector.board.feather_can_u2if
     or detector.board.feather_epd_u2if
+    or detector.board.feather_rfm_u2if
     or detector.board.qtpy_u2if
     or detector.board.itsybitsy_u2if
     or detector.board.macropad_u2if