watchdog.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * Copyright (C) 2006 by egnite Software GmbH. All rights reserved.
  3. *
  4. * Redistribution and use in source and binary forms, with or without
  5. * modification, are permitted provided that the following conditions
  6. * are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. * 3. Neither the name of the copyright holders nor the names of
  14. * contributors may be used to endorse or promote products derived
  15. * from this software without specific prior written permission.
  16. *
  17. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  18. * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  19. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
  20. * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
  21. * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  22. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  23. * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
  24. * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  25. * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  26. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
  27. * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  28. * SUCH DAMAGE.
  29. *
  30. * For additional information see http://www.ethernut.de/
  31. *
  32. */
  33. /*
  34. * $Log$
  35. * Revision 1.2 2008/08/11 06:59:42 haraldkipp
  36. * BSD types replaced by stdint types (feature request #1282721).
  37. *
  38. * Revision 1.1 2006/06/06 19:08:05 haraldkipp
  39. * First release
  40. *
  41. */
  42. #include <sys/timer.h>
  43. #include <dev/watchdog.h>
  44. /*
  45. * Start the hardware watch dog timer.
  46. */
  47. uint32_t NutWatchDogStart(uint32_t ms, uint32_t xmode)
  48. {
  49. #if defined(__AVR__)
  50. return AvrWatchDogStart(ms);
  51. #elif defined(MCU_AT91R40008) || defined(MCU_AT91SAM7X) || defined(MCU_AT91SAM7S) || defined(MCU_AT91SAM7SE)
  52. return At91WatchDogStart(ms, xmode);
  53. #elif defined(__AVR32__)
  54. return Avr32WatchDogStart(ms);
  55. #elif defined(MCU_LPC17xx)
  56. return Lpc17xxWatchDogStart(ms, xmode);
  57. #elif defined(MCU_MCF5225X)
  58. return Mcf5225xWatchDogStart(ms);
  59. #else
  60. return 0;
  61. #endif
  62. }
  63. /*
  64. * Re-start the hardware watch dog timer.
  65. */
  66. void NutWatchDogRestart(void)
  67. {
  68. #if defined(__AVR__)
  69. AvrWatchDogRestart();
  70. #elif defined(MCU_AT91R40008) || defined(MCU_AT91SAM7X) || defined(MCU_AT91SAM7S) || defined(MCU_AT91SAM7SE)
  71. At91WatchDogRestart();
  72. #elif defined(__AVR32__)
  73. Avr32WatchDogRestart();
  74. #elif defined(MCU_LPC17xx)
  75. Lpc17xxWatchDogRestart();
  76. #elif defined(MCU_MCF5225X)
  77. Mcf5225xWatchDogRestart();
  78. #endif
  79. }
  80. /*
  81. * Disable the hardware watch dog timer.
  82. */
  83. void NutWatchDogDisable(void)
  84. {
  85. #if defined(__AVR__)
  86. AvrWatchDogDisable();
  87. #elif defined(MCU_AT91R40008) || defined(MCU_AT91SAM7X) || defined(MCU_AT91SAM7S) || defined(MCU_AT91SAM7SE)
  88. At91WatchDogDisable();
  89. #elif defined(__AVR32__)
  90. Avr32WatchDogDisable();
  91. #elif defined(MCU_LPC17xx)
  92. Lpc17xxWatchDogDisable();
  93. #elif defined(MCU_MCF5225X)
  94. Mcf5225xWatchDogDisable();
  95. #endif
  96. }
  97. /*
  98. * Enable the hardware watch dog timer.
  99. */
  100. void NutWatchDogEnable(void)
  101. {
  102. #if defined(__AVR__)
  103. AvrWatchDogEnable();
  104. #elif defined(MCU_AT91R40008) || defined(MCU_AT91SAM7X) || defined(MCU_AT91SAM7S) || defined(MCU_AT91SAM7SE)
  105. At91WatchDogEnable();
  106. #elif defined(__AVR32__)
  107. Avr32WatchDogEnable();
  108. #elif defined(MCU_LPC17xx)
  109. Lpc17xxWatchDogEnable();
  110. #elif defined(MCU_MCF5225X)
  111. Mcf5225xWatchDogEnable();
  112. #endif
  113. }