Use Python GPIO instead of command line tool
authorJoseph Coffland <joseph@cauldrondevelopment.com>
Sun, 15 Oct 2017 23:18:44 +0000 (16:18 -0700)
committerJoseph Coffland <joseph@cauldrondevelopment.com>
Sun, 15 Oct 2017 23:18:44 +0000 (16:18 -0700)
scripts/avr109-flash.py

index 111d812b485b66e7d1c6b7722a55f8e3d1d2f0d8..2d2628fe8b52142f2ae3309b783622b351f9775e 100755 (executable)
@@ -4,7 +4,6 @@ import sys
 import time
 import serial
 import binascii
-from subprocess import call
 
 
 dev = '/dev/ttyAMA0'
@@ -99,8 +98,12 @@ data = list(read_intel_hex(open(sys.argv[1], 'r')))
 sp = serial.Serial(dev, baud, timeout = 10)
 
 # Reset AVR
-call(['gpio', '-g', 'write', '27', '0'])
-call(['gpio', '-g', 'write', '27', '1'])
+import RPi.GPIO as gpio
+gpio.setwarnings(False)
+gpio.setmode(gpio.BCM)
+gpio.setup(27, gpio.OUT)
+gpio.output(27, 0)
+gpio.output(27, 1)
 time.sleep(0.1)
 
 # Sync