WatchdogTimer.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #ifndef _WatchdogTimer_hpp_
  2. #define _WatchdogTimer_hpp_
  3. #include <FpConfig.hpp>
  4. namespace Os {
  5. class WatchdogTimer {
  6. public:
  7. typedef enum {
  8. WATCHDOG_OK, //!< Call was successful
  9. WATCHDOG_INIT_ERROR, //!< Timer initialization failed
  10. WATCHDOG_START_ERROR, //!< Timer startup failed
  11. WATCHDOG_CANCEL_ERROR //!< Timer cancellation failed
  12. } WatchdogStatus;
  13. typedef void (*WatchdogCb)(void *);
  14. WatchdogTimer();
  15. virtual ~WatchdogTimer();
  16. WatchdogStatus startTicks( I32 delayInTicks, //!< number of ticks to delay. OS/timing dependent
  17. WatchdogCb p_callback, //!< routine to call on time-out
  18. void* parameter //!< parameter with which to call routine
  19. );
  20. WatchdogStatus startMs( I32 delayInMs, //!< number of ms to delay.
  21. WatchdogCb p_callback, //!< routine to call on time-out
  22. void* parameter //!< parameter with which to call routine
  23. );
  24. WatchdogStatus restart(); //!< restart timer with previous value
  25. WatchdogStatus cancel(); //!< cancel timer
  26. void expire(); //!< Invoke the callback function with m_parameter
  27. private:
  28. I32 m_handle; //!< handle for implementation specific watchdog
  29. WatchdogCb m_cb; //!< function callback pointer
  30. void* m_parameter; //!< parameter for timer call
  31. I32 m_timerTicks; //!< number of ticks for timer.
  32. I32 m_timerMs; //!< number of milliseconds for timer.
  33. WatchdogTimer(WatchdogTimer&); //!< disable copy constructor
  34. };
  35. }
  36. #endif