Skip to content

Commit 35a39ce

Browse files
authored
Merge pull request #828 from brentru/add-generic-board
Add "generic os-agnostic" board and remove "fake_mcp2221" board
2 parents b3beba7 + cc31ea4 commit 35a39ce

19 files changed

+583
-207
lines changed

src/adafruit_blinka/board/fake_microchip_mcp2221.py

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# SPDX-FileCopyrightText: 2024 Brent Rubell for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
"""Pin definitions for a generic, os-agnostic, board."""
5+
from adafruit_blinka.microcontroller.generic_agnostic_board import pin
6+
7+
# Digital pins
8+
Dx_INPUT_TRUE = pin.D0
9+
Dx_INPUT_FALSE = pin.D1
10+
Dx_INPUT_TRUE_PULL_UP = pin.D2
11+
Dx_INPUT_TRUE_PULL_DOWN = pin.D3
12+
Dx_OUTPUT = pin.D4
13+
Dx_INPUT_TOGGLE = pin.D7
14+
# Special "digital" pins
15+
NEOPIXEL = pin.D6
16+
17+
18+
# Analog pins
19+
Ax_INPUT_RAND_INT = pin.A0
20+
Ax_INPUT_FIXED_INT_PI = pin.A1
21+
Ax_INPUT_WAVE_SINE = pin.A2
22+
Ax_INPUT_WAVE_SAW = pin.A3
23+
Ax_OUTPUT = pin.A4
24+
25+
# I2C pins
26+
SDA = pin.SDA
27+
SCL = pin.SCL
28+
29+
# SPI pins
30+
SCLK = pin.SCLK
31+
SCK = pin.SCK
32+
MOSI = pin.MOSI
33+
MISO = pin.MISO
34+
CS = pin.D6
35+
36+
# UART pins
37+
UART_TX = pin.UART_TX
38+
UART_RX = pin.UART_RX

src/adafruit_blinka/microcontroller/fake_mcp2221/fake_mcp2221.py

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/adafruit_blinka/microcontroller/fake_mcp2221/i2c.py

Lines changed: 0 additions & 30 deletions
This file was deleted.

src/adafruit_blinka/microcontroller/fake_mcp2221/pin.py

Lines changed: 0 additions & 95 deletions
This file was deleted.
File renamed without changes.

src/adafruit_blinka/microcontroller/fake_mcp2221/analogio.py renamed to src/adafruit_blinka/microcontroller/generic_agnostic_board/analogio.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
1+
# SPDX-FileCopyrightText: 2024 Brent Rubell for Adafruit Industries
22
#
33
# SPDX-License-Identifier: MIT
44
"""
@@ -8,7 +8,7 @@
88
* Author(s): Carter Nelson
99
"""
1010

11-
from adafruit_blinka.microcontroller.fake_mcp2221.pin import Pin
11+
from adafruit_blinka.microcontroller.generic_agnostic_board.pin import Pin
1212
from adafruit_blinka import ContextManaged
1313

1414

@@ -45,9 +45,8 @@ def __init__(self, pin):
4545

4646
@property
4747
def value(self):
48-
"""Return an error. This is output only."""
49-
# emulate what CircuitPython does
50-
raise AttributeError("unreadable attribute")
48+
"""Fake the output."""
49+
return self._pin.value()
5150

5251
@value.setter
5352
def value(self, value):
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# SPDX-FileCopyrightText: 2024 Brent Rubell for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
"""Chip Definition for a generic, os-agnostic, board."""
5+
6+
7+
class GENERIC_AGNOSTIC_BOARD:
8+
"""Generic Agnostic Board Device Class Definition"""
9+
10+
def __init__(self):
11+
pass # This implementation is for a generic board, no initialization is required
12+
13+
def __del__(self):
14+
# try to close the device before destroying the instance
15+
return
16+
17+
# pylint: enable=unused-argument
18+
19+
20+
generic_agnostic_board = GENERIC_AGNOSTIC_BOARD()
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# SPDX-FileCopyrightText: 2024 Brent Rubell for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
"""I2C Class for Generic Agnostic Board"""
5+
from random import randint
6+
7+
# from .generic_agnostic_board.pin import generic_agnostic_board
8+
9+
10+
class I2C:
11+
"""Custom I2C Class for a Generic Agnostic Board"""
12+
13+
def __init__(self, *, frequency=100000):
14+
# self._generic_agnostic_board = generic_agnostic_board
15+
self.freq = frequency
16+
17+
@staticmethod
18+
def scan():
19+
"""Mocks an I2C scan and returns a list of 3 randomly generated
20+
I2C addresses from 0x0 to 0x79.
21+
"""
22+
# Generate a list of 3 randomly generated addresses from 0x0 to 0x79
23+
address_list = []
24+
for _ in range(3):
25+
address_list.append(randint(0x0, 0x79))
26+
return address_list

0 commit comments

Comments
 (0)