No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.
 
 
 
 
 

69 líneas
1.9 KiB

  1. /*
  2. * lowPower.c:
  3. * Check the Pi's LOW-Power signal.
  4. *
  5. * This is a demonstration program that could be turned into some sort
  6. * of logger via e.g. syslog - however it's also probably something
  7. * that might be better handled by a future kernel - who knows.
  8. *
  9. * Copyright (c) 2014 Gordon Henderson.
  10. ***********************************************************************
  11. * This file is part of wiringPi:
  12. * https://github.com/WiringPi/WiringPi/
  13. *
  14. * wiringPi is free software: you can redistribute it and/or modify
  15. * it under the terms of the GNU Lesser General Public License as published by
  16. * the Free Software Foundation, either version 3 of the License, or
  17. * (at your option) any later version.
  18. *
  19. * wiringPi is distributed in the hope that it will be useful,
  20. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  21. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  22. * GNU Lesser General Public License for more details.
  23. *
  24. * You should have received a copy of the GNU Lesser General Public License
  25. * along with wiringPi. If not, see <http://www.gnu.org/licenses/>.
  26. ***********************************************************************
  27. */
  28. #include <stdio.h>
  29. #include <time.h>
  30. #include <wiringPi.h>
  31. #define LOW_POWER 35
  32. /*
  33. * lowPower:
  34. * This is an ISR that waits for the low-power signal going low and
  35. * prints the result.
  36. *********************************************************************************
  37. */
  38. void lowPower (int pin)
  39. {
  40. time_t t ;
  41. time (&t) ;
  42. printf ("%s: LOW POWER DETECTED\n", ctime (&t)) ;
  43. }
  44. /*
  45. *********************************************************************************
  46. * main
  47. *********************************************************************************
  48. */
  49. int main (void)
  50. {
  51. wiringPiSetupGpio () ; // GPIO mode as it's an internal pin
  52. wiringPiISR (LOW_POWER, INT_EDGE_FALLING, &lowPower) ;
  53. for (;;)
  54. delay (1000) ;
  55. return 0 ;
  56. }