pin.c 629 B

123456789101112131415161718192021222324252627282930313233
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2022-6-30 GuEe-GUI first version
  9. */
  10. #include <rthw.h>
  11. #include <rtthread.h>
  12. #include <rtdevice.h>
  13. #ifdef RT_USING_PIN
  14. void qemu_gpio3_key_poweroff(void *args)
  15. {
  16. rt_kprintf("\nYou power off the machine.\n");
  17. rt_hw_cpu_shutdown();
  18. }
  19. static int pin_init()
  20. {
  21. rt_pin_attach_irq(3, PIN_IRQ_MODE_FALLING, qemu_gpio3_key_poweroff, RT_NULL);
  22. rt_pin_irq_enable(3, RT_TRUE);
  23. return 0;
  24. }
  25. INIT_ENV_EXPORT(pin_init);
  26. #endif /* RT_USING_PIN */