Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add emonpi GPIO reset on GPIO4 / pin7 #687

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions platformio/builder/scripts/atmelavr.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,29 @@ def _rpi_sysgpio(path, value):
if upload_options.get("wait_for_upload_port", False):
env.Replace(UPLOAD_PORT=env.WaitForNewSerialPort(before_ports))

if env.subst("$BOARD") == "emonpi":

def _rpi_sysgpio(path, value):
with open(path, "w") as f:
f.write(str(value))

_rpi_sysgpio("/sys/class/gpio/export", 4)
_rpi_sysgpio("/sys/class/gpio/gpio4/direction", "out")
_rpi_sysgpio("/sys/class/gpio/gpio4/value", 1)
sleep(0.1)
_rpi_sysgpio("/sys/class/gpio/gpio4/value", 0)
_rpi_sysgpio("/sys/class/gpio/unexport", 4)
else:
if not upload_options.get("disable_flushing", False):
env.FlushSerialBuffer("$UPLOAD_PORT")

before_ports = get_serialports()

if upload_options.get("use_1200bps_touch", False):
env.TouchSerialPort("$UPLOAD_PORT", 1200)

if upload_options.get("wait_for_upload_port", False):
env.Replace(UPLOAD_PORT=env.WaitForNewSerialPort(before_ports))

env = DefaultEnvironment()

Expand Down