watchdog.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. #ifndef _watchdog_H
  2. #define _watchdog_H
  3. /*
  4. * Copyright STREAMIT BV, 2010.
  5. *
  6. * Project : SIR
  7. * Module : watchdog
  8. * File name $Workfile: watchdog.h $
  9. * Last Save $Date: 2007/01/16 11:13:53 $
  10. * $Revision: 0.1 $
  11. * Creation Date : 2007/01/16 11:13:53
  12. *
  13. * Description : Watchdog routines for the ATMega128/256
  14. * Inspired by the arch/xxx/dev/watchdog routines in
  15. * NutOS 4.2.1 and higher.
  16. *
  17. */
  18. /*--------------------------------------------------------------------------*/
  19. /* Include files */
  20. /*--------------------------------------------------------------------------*/
  21. /*--------------------------------------------------------------------------*/
  22. /* Constant definitions */
  23. /*--------------------------------------------------------------------------*/
  24. /*--------------------------------------------------------------------------*/
  25. /* Type declarations */
  26. /*--------------------------------------------------------------------------*/
  27. /*--------------------------------------------------------------------------*/
  28. /* Global variables */
  29. /*--------------------------------------------------------------------------*/
  30. /*--------------------------------------------------------------------------*/
  31. /* Global functions */
  32. /*--------------------------------------------------------------------------*/
  33. /*!
  34. * \brief Start the watch dog timer.
  35. *
  36. * This function can be used by applications to prevent hang-ups.
  37. * The watch dog timer will be automatically enabled on return.
  38. *
  39. * \param ms [in] Watch dog time out in milliseconds.
  40. *
  41. * \return -
  42. *
  43. * The following code fragment starts the watch timer with a time out
  44. * of 550 milliseconds and restarts it every 500 milliseconds.
  45. *
  46. * \code
  47. * #include <sys/timer.h>
  48. * #include "watchdog.h"
  49. *
  50. * WatchDogStart(550);
  51. * for(;;)
  52. * {
  53. * WatchDogRestart();
  54. * NutSleep(500);
  55. * }
  56. *
  57. * \endcode
  58. */
  59. extern void WatchDogStart(unsigned long ms);
  60. /*!
  61. * \brief Restart the watch dog timer.
  62. */
  63. extern void WatchDogRestart(void);
  64. /*!
  65. * \brief Disables the watch dog timer.
  66. *
  67. * Applications should call this function to temporarily disable the
  68. * watch dog timer. To re-enable it, call WatchDogEnable().
  69. *
  70. * \code
  71. * #include <dev/watchdog.h>
  72. *
  73. * WatchDogStart(100, 0);
  74. *
  75. * //Some code here.
  76. *
  77. * WatchDogRestart();
  78. *
  79. * //Some code here.
  80. *
  81. * WatchDogDisable();
  82. *
  83. * //Some lengthy code here, like writing to flash memory.
  84. *
  85. * WatchDogEnable();
  86. *
  87. * \endcode
  88. */
  89. extern void WatchDogDisable(void);
  90. /*!
  91. * \brief Enables the watch dog timer.
  92. *
  93. * The function can be safely used within nested subroutines.
  94. * The watch dog will be enabled only, if this function is called
  95. * the same number of times as WatchDogDisable(). If enabled,
  96. * the watch dog timer will also have been re-started and the
  97. * full time out value is available before another WatchDogRestart()
  98. * is required.
  99. *
  100. * If the watch has not been started by WatchDogStart(), then this
  101. * function does nothing.
  102. */
  103. extern void WatchDogEnable(void);
  104. #endif /* _watchdog_H */