xbee-init: script updated to use libgpiod tools
Additionally: - The handling of gpios has been swapped so 'Set low XBEE_SLEEP_RQ' is done before 'Power cycle XBEE_RESET_N' to assure the device doesn't enter sleep mode. - Removed ExecStop entry from systemd service since it's doing nothing. https://jira.digi.com/browse/DEL-6424 https://jira.digi.com/browse/DEL-6423 Signed-off-by: Hector Bujanda <hector.bujanda@digi.com>
This commit is contained in:
parent
baa4a6f57e
commit
f14d79f5a6
|
|
@ -25,8 +25,8 @@ SERIAL_CONSOLES ?= "115200;ttymxc0"
|
||||||
BT_TTY ?= "ttymxc1"
|
BT_TTY ?= "ttymxc1"
|
||||||
|
|
||||||
# XBees
|
# XBees
|
||||||
XBEE_RESET_N_GPIO ?= "508,8"
|
XBEE_RESET_N_GPIO ?= "mca-gpio@15,gpio1@8"
|
||||||
XBEE_SLEEP_RQ_GPIO ?= "504,7"
|
XBEE_SLEEP_RQ_GPIO ?= "mca-gpio@11,gpio1@7"
|
||||||
XBEE_TTY ?= "ttymxc3"
|
XBEE_TTY ?= "ttymxc3"
|
||||||
|
|
||||||
# U-Boot script to be copied to the boot image
|
# U-Boot script to be copied to the boot image
|
||||||
|
|
|
||||||
|
|
@ -23,8 +23,8 @@ SERIAL_CONSOLES ?= "115200;ttyLP2"
|
||||||
BT_TTY ?= "ttyLP1"
|
BT_TTY ?= "ttyLP1"
|
||||||
|
|
||||||
# XBee
|
# XBee
|
||||||
XBEE_RESET_N_GPIO ?= "397"
|
XBEE_RESET_N_GPIO ?= "gpio3@13"
|
||||||
XBEE_SLEEP_RQ_GPIO ?= "400"
|
XBEE_SLEEP_RQ_GPIO ?= "gpio3@16"
|
||||||
XBEE_TTY ?= "ttyLP0"
|
XBEE_TTY ?= "ttyLP0"
|
||||||
|
|
||||||
# U-Boot script to be copied to the boot image
|
# U-Boot script to be copied to the boot image
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ SERIAL_CONSOLES ?= "115200;ttyLP2"
|
||||||
BT_TTY ?= "ttyLP1"
|
BT_TTY ?= "ttyLP1"
|
||||||
|
|
||||||
# XBee
|
# XBee
|
||||||
XBEE_RESET_N_GPIO ?= "220"
|
XBEE_RESET_N_GPIO ?= "mca-gpio@15"
|
||||||
XBEE_SLEEP_RQ_GPIO ?= "216"
|
XBEE_SLEEP_RQ_GPIO ?= "mca-gpio@11"
|
||||||
XBEE_TTY ?= "ttyMCA0"
|
XBEE_TTY ?= "ttyMCA0"
|
||||||
|
|
||||||
# U-Boot script to be copied to the boot image
|
# U-Boot script to be copied to the boot image
|
||||||
|
|
|
||||||
|
|
@ -4,47 +4,13 @@
|
||||||
XBEE_RESET_N_GPIO="##XBEE_RESET_N_GPIO##"
|
XBEE_RESET_N_GPIO="##XBEE_RESET_N_GPIO##"
|
||||||
XBEE_SLEEP_RQ_GPIO="##XBEE_SLEEP_RQ_GPIO##"
|
XBEE_SLEEP_RQ_GPIO="##XBEE_SLEEP_RQ_GPIO##"
|
||||||
|
|
||||||
# request_gpio <gpio_nr>
|
|
||||||
request_gpio_out() {
|
|
||||||
local SG_GPIONR="${1}"
|
|
||||||
local SG_GPIOPATH="/sys/class/gpio/gpio${SG_GPIONR}"
|
|
||||||
|
|
||||||
[ -d "${SG_GPIOPATH}" ] || printf "%s" "${SG_GPIONR}" > /sys/class/gpio/export
|
|
||||||
printf out > "${SG_GPIOPATH}/direction" && sleep .2
|
|
||||||
}
|
|
||||||
|
|
||||||
# free_gpio <gpio_nr>
|
|
||||||
free_gpio() {
|
|
||||||
local SG_GPIONR="${1}"
|
|
||||||
local SG_GPIOPATH="/sys/class/gpio/gpio${SG_GPIONR}"
|
|
||||||
|
|
||||||
[ -d "${SG_GPIOPATH}" ] && printf "%s" "${SG_GPIONR}" > /sys/class/gpio/unexport
|
|
||||||
}
|
|
||||||
|
|
||||||
# set_gpio_value <gpio_nr> <value>
|
|
||||||
set_gpio_value() {
|
|
||||||
local SG_GPIONR="${1}"
|
|
||||||
local SG_GPIOVAL="${2}"
|
|
||||||
local SG_GPIOPATH="/sys/class/gpio/gpio${SG_GPIONR}"
|
|
||||||
|
|
||||||
printf out > "${SG_GPIOPATH}/direction" && sleep .2
|
|
||||||
printf "${SG_GPIOVAL}" > "${SG_GPIOPATH}/value" && sleep .2
|
|
||||||
}
|
|
||||||
|
|
||||||
xbee_init() {
|
xbee_init() {
|
||||||
# Power cycle XBEE_RESET_N
|
|
||||||
request_gpio_out ${1}
|
|
||||||
set_gpio_value ${1} 0
|
|
||||||
set_gpio_value ${1} 1
|
|
||||||
|
|
||||||
# Set low XBEE_SLEEP_RQ
|
# Set low XBEE_SLEEP_RQ
|
||||||
request_gpio_out ${2}
|
gpioset ${3} ${4}=0
|
||||||
set_gpio_value ${2} 0
|
|
||||||
}
|
|
||||||
|
|
||||||
xbee_stop() {
|
# Power cycle XBEE_RESET_N
|
||||||
free_gpio ${1}
|
gpioset ${1} ${2}=0
|
||||||
free_gpio ${2}
|
gpioset ${1} ${2}=1
|
||||||
}
|
}
|
||||||
|
|
||||||
xbee_iterate_list() {
|
xbee_iterate_list() {
|
||||||
|
|
@ -54,9 +20,7 @@ xbee_iterate_list() {
|
||||||
for SLEEP in $(echo ${XBEE_SLEEP_RQ_GPIO} | sed "s/,/ /g"); do
|
for SLEEP in $(echo ${XBEE_SLEEP_RQ_GPIO} | sed "s/,/ /g"); do
|
||||||
if [ "${i}" = "${j}" ]; then
|
if [ "${i}" = "${j}" ]; then
|
||||||
if [ "${1}" = "start" ]; then
|
if [ "${1}" = "start" ]; then
|
||||||
xbee_init ${RESET} ${SLEEP}
|
xbee_init $(echo ${RESET} | sed "s/@/ /g") $(echo ${SLEEP} | sed "s/@/ /g")
|
||||||
elif [ "${1}" = "stop" ]; then
|
|
||||||
xbee_stop ${RESET} ${SLEEP}
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
j="$((j + 1))"
|
j="$((j + 1))"
|
||||||
|
|
@ -72,9 +36,6 @@ case "$1" in
|
||||||
echo "done."
|
echo "done."
|
||||||
;;
|
;;
|
||||||
stop)
|
stop)
|
||||||
echo -n "Stopping XBee hardware: "
|
|
||||||
xbee_iterate_list stop
|
|
||||||
echo "done."
|
|
||||||
;;
|
;;
|
||||||
restart)
|
restart)
|
||||||
$0 stop
|
$0 stop
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,6 @@ Before=ModemManager.service
|
||||||
Type=oneshot
|
Type=oneshot
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
ExecStart=/etc/xbee-init start
|
ExecStart=/etc/xbee-init start
|
||||||
ExecStop=/etc/xbee-init stop
|
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue