From: Liz Date: Tue, 11 Apr 2023 15:41:59 +0000 (-0400) Subject: adding support for RFM and CAN feathers X-Git-Tag: 8.18.1~1^2~3 X-Git-Url: https://git.ayoreis.com/Adafruit_Blinka-hackapet.git/commitdiff_plain/70f249a0d53ee0756edc872404fe9c8000b0d17b adding support for RFM and CAN feathers --- diff --git a/src/adafruit_blinka/board/feather_can_u2if.py b/src/adafruit_blinka/board/feather_can_u2if.py new file mode 100644 index 0000000..1593dbd --- /dev/null +++ b/src/adafruit_blinka/board/feather_can_u2if.py @@ -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) diff --git a/src/adafruit_blinka/board/feather_epd_u2if.py b/src/adafruit_blinka/board/feather_epd_u2if.py index 4ac0b29..f31096f 100644 --- a/src/adafruit_blinka/board/feather_epd_u2if.py +++ b/src/adafruit_blinka/board/feather_epd_u2if.py @@ -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 index 0000000..eacad83 --- /dev/null +++ b/src/adafruit_blinka/board/feather_rfm_u2if.py @@ -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) diff --git a/src/adafruit_blinka/microcontroller/rp2040_u2if/i2c.py b/src/adafruit_blinka/microcontroller/rp2040_u2if/i2c.py index 179af82..2573b2c 100644 --- a/src/adafruit_blinka/microcontroller/rp2040_u2if/i2c.py +++ b/src/adafruit_blinka/microcontroller/rp2040_u2if/i2c.py @@ -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""" diff --git a/src/adafruit_blinka/microcontroller/rp2040_u2if/spi.py b/src/adafruit_blinka/microcontroller/rp2040_u2if/spi.py index cb67130..82707ff 100644 --- a/src/adafruit_blinka/microcontroller/rp2040_u2if/spi.py +++ b/src/adafruit_blinka/microcontroller/rp2040_u2if/spi.py @@ -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""" diff --git a/src/board.py b/src/board.py index c1785ff..89a2a73 100644 --- a/src/board.py +++ b/src/board.py @@ -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 * diff --git a/src/busio.py b/src/busio.py index c7b9eb3..8f41667 100644 --- a/src/busio.py +++ b/src/busio.py @@ -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 diff --git a/src/neopixel_write.py b/src/neopixel_write.py index 2c5e34a..997dd0d 100644 --- a/src/neopixel_write.py +++ b/src/neopixel_write.py @@ -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 diff --git a/src/pwmio.py b/src/pwmio.py index c09e78d..57854df 100644 --- a/src/pwmio.py +++ b/src/pwmio.py @@ -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