mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 03:05:40 +08:00
After turning on the system by power button, the first press of the power button is ineffective.
Signed-off-by: liushuai25 <liushuai25@xiaomi.com> Co-authored-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
committed by
Petro Karashchenko
parent
1b97c05ab5
commit
10fce11e19
@@ -60,6 +60,7 @@ struct btn_upperhalf_s
|
|||||||
FAR const struct btn_lowerhalf_s *bu_lower;
|
FAR const struct btn_lowerhalf_s *bu_lower;
|
||||||
|
|
||||||
btn_buttonset_t bu_sample; /* Last sampled button states */
|
btn_buttonset_t bu_sample; /* Last sampled button states */
|
||||||
|
bool bu_enabled;
|
||||||
|
|
||||||
/* The following is a singly linked list of open references to the
|
/* The following is a singly linked list of open references to the
|
||||||
* button device.
|
* button device.
|
||||||
@@ -190,6 +191,16 @@ static void btn_enable(FAR struct btn_upperhalf_s *priv)
|
|||||||
DEBUGASSERT(lower->bl_enable);
|
DEBUGASSERT(lower->bl_enable);
|
||||||
if (press != 0 || release != 0)
|
if (press != 0 || release != 0)
|
||||||
{
|
{
|
||||||
|
/* Update last sampled button states when enabling interrupts for
|
||||||
|
* the first time.
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (!priv->bu_enabled)
|
||||||
|
{
|
||||||
|
priv->bu_enabled = true;
|
||||||
|
priv->bu_sample = lower->bl_buttons(lower);
|
||||||
|
}
|
||||||
|
|
||||||
/* Enable interrupts with the new button set */
|
/* Enable interrupts with the new button set */
|
||||||
|
|
||||||
lower->bl_enable(lower, press, release,
|
lower->bl_enable(lower, press, release,
|
||||||
@@ -197,6 +208,8 @@ static void btn_enable(FAR struct btn_upperhalf_s *priv)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
priv->bu_enabled = false;
|
||||||
|
|
||||||
/* Disable further interrupts */
|
/* Disable further interrupts */
|
||||||
|
|
||||||
lower->bl_enable(lower, 0, 0, NULL, NULL);
|
lower->bl_enable(lower, 0, 0, NULL, NULL);
|
||||||
@@ -332,6 +345,7 @@ static int btn_open(FAR struct file *filep)
|
|||||||
supported = lower->bl_supported(lower);
|
supported = lower->bl_supported(lower);
|
||||||
opriv->bo_pollevents.bp_press = supported;
|
opriv->bo_pollevents.bp_press = supported;
|
||||||
opriv->bo_pollevents.bp_release = supported;
|
opriv->bo_pollevents.bp_release = supported;
|
||||||
|
opriv->bo_pending = true;
|
||||||
|
|
||||||
/* Attach the open structure to the device */
|
/* Attach the open structure to the device */
|
||||||
|
|
||||||
@@ -780,9 +794,6 @@ int btn_register(FAR const char *devname,
|
|||||||
|
|
||||||
priv->bu_lower = lower;
|
priv->bu_lower = lower;
|
||||||
|
|
||||||
DEBUGASSERT(lower->bl_buttons);
|
|
||||||
priv->bu_sample = lower->bl_buttons(lower);
|
|
||||||
|
|
||||||
/* And register the button driver */
|
/* And register the button driver */
|
||||||
|
|
||||||
ret = register_driver(devname, &g_btn_fops, 0666, priv);
|
ret = register_driver(devname, &g_btn_fops, 0666, priv);
|
||||||
|
|||||||
Reference in New Issue
Block a user