Skip to content

Commit

Permalink
Merge pull request #77 from shaneapowell/AddSupportForOrangePi
Browse files Browse the repository at this point in the history
Added support for Orange Pi boards.
  • Loading branch information
Chr157i4n authored Aug 31, 2024
2 parents 727f83c + 568c987 commit 7795c11
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
16 changes: 9 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ You can read more about this in the datasheet from Trinamic.
Because the TMC2209 uses one shared pin for transmit and receive in the UART communication line, the Raspberry Pi also receives what it sends.
Well, the Pi receives 4 bytes from itself and 8 bytes from the driver. So the Pi receives a total of 12 bytes and only the last 8 are the reply, of which only 4 are data bytes.

The Documentation of the TMC2209 can be found here:
The Documentation of the TMC2209 can be found here:
[TMC2209 - Datsheet](https://www.trinamic.com/fileadmin/assets/Products/ICs_Documents/TMC2209_Datasheet_rev1.06.pdf)

The code is also available on [PyPI](https://pypi.org/project/TMC-2209-Raspberry-Pi).
Expand Down Expand Up @@ -60,12 +60,14 @@ pip3 install TMC-2209-Raspberry-Pi

The following table shows the supported boards and which libraries for GPIO access is beeing used for that board.

Library | Installation Parameter | Boards
-- | -- | --
RPi.GPIO | RASPBERRY_PI | Pi4, Pi3 etc.
gpiozero | RASPBERRY_PI5 | Pi5
Jetson.GPIO | NVIDIA_JETSON | Nvidia Jetson
pheriphery | LUCKFOX_PICO | Luckfox Pico
Library | Installation Parameter | Boards
----------- | ------------------------- | -----------
RPi.GPIO | RASPBERRY_PI | Pi4, Pi3 etc.
gpiozero | RASPBERRY_PI5 | Pi5
Jetson.GPIO | NVIDIA_JETSON | Nvidia Jetson
pheriphery | LUCKFOX_PICO | Luckfox Pico
pheriphery | LUCKFOX_PICO | Luckfox Pico
OPi.GPIO | ORANGE_PI | Orange Pi

Those libraries are needed for this library to work. You can either install the correct library yourself.
You can also install the needed GPIO library by specifing the Installation Parameter while installing this library:
Expand Down
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,6 @@ RASPBERRY_PI5 =
NVIDIA_JETSON =
Jetson.GPIO
LUCKFOX_PICO =
python-periphery
python-periphery
ORANGE_PI =
OPi.GPIO
17 changes: 17 additions & 0 deletions src/TMC_2209/_TMC_2209_GPIO_board.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
# Jetson.GPIO | Nvidia Jetson
# gpiozero | Pi5
# pheriphery | Luckfox Pico
# OPi.GPIO | Orange Pi
# ------------------------------

class Board(Enum):
Expand All @@ -33,6 +34,7 @@ class Board(Enum):
RASPBERRY_PI5 = 2
NVIDIA_JETSON = 3
LUCKFOX_PICO = 4
ORANGE_PI = 5

class Gpio(IntEnum):
"""GPIO value"""
Expand Down Expand Up @@ -150,6 +152,19 @@ class GpioPUD(IntEnum):
"Exiting..."),
Loglevel.ERROR)
raise
elif "orange" in model:
try:
from OPi import GPIO
BOARD = Board.ORANGE_PI
except ModuleNotFoundError as err:
dependencies_logger.log(
(f"ModuleNotFoundError: {err}\n"
"Board is Orange Pi but module OPi.GPIO isn't installed.\n"
"Follow the installation instructions in the link below to resolve the issue:\n"
"https://github.com/rm-hull/OPi.GPIO\n"
"Exiting..."),
Loglevel.ERROR)
raise
else:
# just in case
dependencies_logger.log(
Expand All @@ -175,6 +190,8 @@ def init(gpio_mode=None):
pass
elif BOARD == Board.LUCKFOX_PICO:
pass
elif BOARD == Board.ORANGE_PI:
pass
else:
GPIO.setwarnings(False)
if gpio_mode is None:
Expand Down

0 comments on commit 7795c11

Please sign in to comment.