On Fri, 2014-04-25 at 12:20 +0200, Przemyslaw Marczak wrote: > > This change prevents gpio keys bouncing by adding 50 ms delay > when key pressed condition met. > > [ ... ] > @@ -105,6 +105,10 @@ static int check_keys(void) > if (key_pressed(KEY_VOLUMEDOWN)) > keys += KEY_VOLUMEDOWN; > > + /* Avoids gpio keys debouncing */ > + if (keys) > + mdelay(50); > + > return keys; > }
The approach might have helped in your case, since you tested it and found it's good. I'm just wondering whether the code really does correct de-bouncing. The delay does decrease the polling frequency (assuming that the routine is called in a loop). But you return data that was sampled before the delay. You don't re-fetch samples after the delay. And this would not necessarily help either, I'm afraid. In case the GPIO (or the key_pressed() call) does debouncing, you wouldn't need it here. If the key_pressed() result still is bouncy, then the above logic would not debounce it. What you need is some kind of "trigger" where you notice that the line levels are changing, and a delayed fetch of the lines' values after they have settled. Without the first condition, you always have the risk of sampling arbitrary data that does not reflect the keys' status. nit: The comment still appears to be misleading, you don't want to avoid debouncing. :) virtually yours Gerhard Sittig -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr. 5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: off...@denx.de _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot