Lancelot Kao | 96a7ee3 | 2021-02-22 18:50:48 -0600 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # set_gpio_ctrl |
| 4 | # pin #, direction, high(1)/low(0) |
| 5 | function set_gpio_ctrl() { |
Charles Boyer | 0dd8006 | 2022-03-17 14:57:50 -0500 | [diff] [blame] | 6 | echo "$1" > /sys/class/gpio/export |
| 7 | echo "$2" > /sys/class//gpio/gpio"$1"/direction |
| 8 | echo "$3" > /sys/class/gpio/gpio"$1"/value |
| 9 | echo "$1" > /sys/class/gpio/unexport |
Lancelot Kao | 96a7ee3 | 2021-02-22 18:50:48 -0600 | [diff] [blame] | 10 | sleep 1 |
| 11 | } |
| 12 | |
| 13 | # get_gpio_ctrl |
| 14 | # pin # |
| 15 | function get_gpio_ctrl() { |
Charles Boyer | 0dd8006 | 2022-03-17 14:57:50 -0500 | [diff] [blame] | 16 | echo "$1" > /sys/class/gpio/export |
| 17 | cat /sys/class/gpio/gpio"$1"/value |
| 18 | echo "$1" > /sys/class/gpio/unexport |
Lancelot Kao | 96a7ee3 | 2021-02-22 18:50:48 -0600 | [diff] [blame] | 19 | } |