David Lattimore | bedd66a | 2021-09-10 13:36:05 +1000 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
| 2 | |
| 3 | # Copyright 2021 The Chromium OS Authors. All rights reserved. |
| 4 | # Use of this source code is governed by a BSD-style license that can be |
| 5 | # found in the LICENSE file. |
| 6 | |
| 7 | # Turns the HPS off then back on again. This is useful after flashing the HPS |
| 8 | # MCU for the first time, or after running a factory test in order to get back |
| 9 | # to the system bootloader (provided the MCU flash is empty). |
| 10 | |
| 11 | from pyftdi.gpio import GpioAsyncController |
| 12 | import time |
| 13 | |
| 14 | gpio = GpioAsyncController() |
| 15 | # Set GPIO pin 6 (hps power enable) as an output, then make sure it's pulled |
| 16 | # low (power off) |
| 17 | gpio.configure('ftdi://ftdi:ft4232/1', direction=0x40) |
| 18 | gpio.write(0) |
| 19 | time.sleep(0.1) |
| 20 | # Set GPIO pin 6 back to being an input. It'll get pulled high by the pull-up |
| 21 | # resistor (power on). |
| 22 | gpio.set_direction(0x40, 0) |