summaryrefslogtreecommitdiff
path: root/bsp/qemu-virt64-aarch64/applications/pin.c
blob: 37d1927b0033dd8242e9d075b29228b33e3a2bdd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
 * Copyright (c) 2006-2022, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author         Notes
 * 2022-6-30      GuEe-GUI       first version
 */

#include <rthw.h>
#include <rtthread.h>
#include <rtdevice.h>

#ifdef RT_USING_PIN

void qemu_gpio3_key_poweroff(void *args)
{
    rt_kprintf("\nYou power off the machine.\n");

    rt_hw_cpu_shutdown();
}

static int pin_init()
{
    rt_pin_attach_irq(3, PIN_IRQ_MODE_FALLING, qemu_gpio3_key_poweroff, RT_NULL);
    rt_pin_irq_enable(3, RT_TRUE);

    return 0;
}
INIT_ENV_EXPORT(pin_init);

#endif /* RT_USING_PIN */