watchdog.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /*
  2. * File : watchdog.h
  3. * This file is part of RT-Thread RTOS
  4. * COPYRIGHT (C) 2012-2014, Shanghai Real-Thread Electronic Technology Co.,Ltd
  5. *
  6. * This program is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program; if not, write to the Free Software Foundation, Inc.,
  18. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  19. *
  20. * Change Logs:
  21. * Date Author Notes
  22. * 2012-09-12 heyuanjie87 first version.
  23. */
  24. #ifndef __WATCHDOG_H__
  25. #define __WATCHDOG_H__
  26. #include <rtthread.h>
  27. #define RT_DEVICE_CTRL_WDT_GET_TIMEOUT (1) /* get timeout(in seconds) */
  28. #define RT_DEVICE_CTRL_WDT_SET_TIMEOUT (2) /* set timeout(in seconds) */
  29. #define RT_DEVICE_CTRL_WDT_GET_TIMELEFT (3) /* get the left time before reboot(in seconds) */
  30. #define RT_DEVICE_CTRL_WDT_KEEPALIVE (4) /* refresh watchdog */
  31. #define RT_DEVICE_CTRL_WDT_START (5) /* start watchdog */
  32. #define RT_DEVICE_CTRL_WDT_STOP (6) /* stop watchdog */
  33. struct rt_watchdog_ops;
  34. struct rt_watchdog_device
  35. {
  36. struct rt_device parent;
  37. struct rt_watchdog_ops *ops;
  38. };
  39. typedef struct rt_watchdog_device rt_watchdog_t;
  40. struct rt_watchdog_ops
  41. {
  42. rt_err_t (*init)(rt_watchdog_t *wdt);
  43. rt_err_t (*control)(rt_watchdog_t *wdt, int cmd, void *arg);
  44. };
  45. rt_err_t rt_hw_watchdog_register(rt_watchdog_t *wdt,
  46. const char *name,
  47. rt_uint32_t flag,
  48. void *data);
  49. #endif /* __WATCHDOG_H__ */