meta-bletchley: use gpiomon instead of polling gpio value
Remove gpio polling of switch detect pin in power-ctrl and motor-init.
Use gpiomon and timeout commands instead to improve performance and
timing issue.
Signed-off-by: Potin Lai <potin.lai@quantatw.com>
Change-Id: I9e1eb26b070a57f424b341890733dc63c170bf79
diff --git a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl
index 8de9e5a..232b6f3 100755
--- a/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl
+++ b/meta-facebook/meta-bletchley/recipes-bletchley/motor-ctrl/files/power-ctrl
@@ -12,7 +12,7 @@
DELAY_POWER_ON="0.5"
DELAY_POWER_OFF="5"
DELAY_POWER_RECOVERY_MODE="10"
-POWER_BTN_TIMEOUT_CNT=60
+POWER_BTN_TIMEOUT_SEC=10
REV_EVT="EVT"
REV_DVT="DVT"
@@ -98,23 +98,6 @@
return 0
}
-#Switch pull low while it be touched
-function wait_for_switch()
-{
- TARGET_PIN=$1
- TARGET_SWITCH=1
- TIME_CNT=0
- while [ "$TARGET_SWITCH" -eq 1 ] ;do
- TARGET_SWITCH=$(get_gpio "$TARGET_PIN")
- sleep 0.1
- TIME_CNT=$(( TIME_CNT +1))
- if [ $TIME_CNT -gt $POWER_BTN_TIMEOUT_CNT ];then
- echo "Error: Too long to get target switch, force exit" >&2
- break
- fi
- done
-}
-
function trigger_power_button()
{
local sled_num=$1
@@ -127,7 +110,7 @@
echo "Motor go forward to press Power key"
motor-ctrl "sled${sled_num}" f >/dev/null
- wait_for_switch "${GPIO_DETECT_PIN0}"
+ wait_gpio_falling "${GPIO_DETECT_PIN0}" "$POWER_BTN_TIMEOUT_SEC"
motor-ctrl "sled${sled_num}" s >/dev/null
if [ "$(get_gpio "$GPIO_DETECT_PIN0")" -eq 0 ];then
@@ -139,7 +122,7 @@
fi
motor-ctrl "sled${sled_num}" r >/dev/null
- wait_for_switch "${GPIO_DETECT_PIN1}"
+ wait_gpio_falling "${GPIO_DETECT_PIN1}" "$POWER_BTN_TIMEOUT_SEC"
motor-ctrl "sled${sled_num}" s >/dev/null
if [ "$(get_gpio "$GPIO_DETECT_PIN1")" -eq 0 ];then
echo "Motor reverse to initial position successful"
@@ -159,7 +142,7 @@
fi
motor-ctrl "sled${sled_num}" r >/dev/null
- wait_for_switch "${GPIO_DETECT_PIN1}"
+ wait_gpio_falling "${GPIO_DETECT_PIN1}" "$POWER_BTN_TIMEOUT_SEC"
motor-ctrl "sled${sled_num}" s >/dev/null
if [ "$(get_gpio "$GPIO_DETECT_PIN1")" -eq 0 ];then
echo "Motor reverse to initial position successful"
@@ -178,7 +161,7 @@
echo "Motor go forward to press Power button"
motor-ctrl "sled${sled_num}" f >/dev/null
- wait_for_switch "${GPIO_DETECT_PIN0}"
+ wait_gpio_falling "${GPIO_DETECT_PIN0}" "$POWER_BTN_TIMEOUT_SEC"
motor-ctrl "sled${sled_num}" s >/dev/null
if [ "$(get_gpio "$GPIO_DETECT_PIN0")" -eq 0 ];then