Skip to content

Commit

Permalink
Merge pull request #828 from brentru/add-generic-board
Browse files Browse the repository at this point in the history
Add "generic os-agnostic" board and remove "fake_mcp2221" board
  • Loading branch information
makermelissa authored May 21, 2024
2 parents b3beba7 + cc31ea4 commit 35a39ce
Show file tree
Hide file tree
Showing 19 changed files with 583 additions and 207 deletions.
13 changes: 0 additions & 13 deletions src/adafruit_blinka/board/fake_microchip_mcp2221.py

This file was deleted.

38 changes: 38 additions & 0 deletions src/adafruit_blinka/board/generic_agnostic_board.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-FileCopyrightText: 2024 Brent Rubell for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""Pin definitions for a generic, os-agnostic, board."""
from adafruit_blinka.microcontroller.generic_agnostic_board import pin

# Digital pins
Dx_INPUT_TRUE = pin.D0
Dx_INPUT_FALSE = pin.D1
Dx_INPUT_TRUE_PULL_UP = pin.D2
Dx_INPUT_TRUE_PULL_DOWN = pin.D3
Dx_OUTPUT = pin.D4
Dx_INPUT_TOGGLE = pin.D7
# Special "digital" pins
NEOPIXEL = pin.D6


# Analog pins
Ax_INPUT_RAND_INT = pin.A0
Ax_INPUT_FIXED_INT_PI = pin.A1
Ax_INPUT_WAVE_SINE = pin.A2
Ax_INPUT_WAVE_SAW = pin.A3
Ax_OUTPUT = pin.A4

# I2C pins
SDA = pin.SDA
SCL = pin.SCL

# SPI pins
SCLK = pin.SCLK
SCK = pin.SCK
MOSI = pin.MOSI
MISO = pin.MISO
CS = pin.D6

# UART pins
UART_TX = pin.UART_TX
UART_RX = pin.UART_RX
20 changes: 0 additions & 20 deletions src/adafruit_blinka/microcontroller/fake_mcp2221/fake_mcp2221.py

This file was deleted.

30 changes: 0 additions & 30 deletions src/adafruit_blinka/microcontroller/fake_mcp2221/i2c.py

This file was deleted.

95 changes: 0 additions & 95 deletions src/adafruit_blinka/microcontroller/fake_mcp2221/pin.py

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2021 Melissa LeBlanc-Williams for Adafruit Industries
# SPDX-FileCopyrightText: 2024 Brent Rubell for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""
Expand All @@ -8,7 +8,7 @@
* Author(s): Carter Nelson
"""

from adafruit_blinka.microcontroller.fake_mcp2221.pin import Pin
from adafruit_blinka.microcontroller.generic_agnostic_board.pin import Pin
from adafruit_blinka import ContextManaged


Expand Down Expand Up @@ -45,9 +45,8 @@ def __init__(self, pin):

@property
def value(self):
"""Return an error. This is output only."""
# emulate what CircuitPython does
raise AttributeError("unreadable attribute")
"""Fake the output."""
return self._pin.value()

@value.setter
def value(self, value):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# SPDX-FileCopyrightText: 2024 Brent Rubell for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""Chip Definition for a generic, os-agnostic, board."""


class GENERIC_AGNOSTIC_BOARD:
"""Generic Agnostic Board Device Class Definition"""

def __init__(self):
pass # This implementation is for a generic board, no initialization is required

def __del__(self):
# try to close the device before destroying the instance
return

# pylint: enable=unused-argument


generic_agnostic_board = GENERIC_AGNOSTIC_BOARD()
26 changes: 26 additions & 0 deletions src/adafruit_blinka/microcontroller/generic_agnostic_board/i2c.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: 2024 Brent Rubell for Adafruit Industries
#
# SPDX-License-Identifier: MIT
"""I2C Class for Generic Agnostic Board"""
from random import randint

# from .generic_agnostic_board.pin import generic_agnostic_board


class I2C:
"""Custom I2C Class for a Generic Agnostic Board"""

def __init__(self, *, frequency=100000):
# self._generic_agnostic_board = generic_agnostic_board
self.freq = frequency

@staticmethod
def scan():
"""Mocks an I2C scan and returns a list of 3 randomly generated
I2C addresses from 0x0 to 0x79.
"""
# Generate a list of 3 randomly generated addresses from 0x0 to 0x79
address_list = []
for _ in range(3):
address_list.append(randint(0x0, 0x79))
return address_list
Loading

0 comments on commit 35a39ce

Please sign in to comment.