fh_wdt.h 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * This file is part of FH8620 BSP for RT-Thread distribution.
  3. *
  4. * Copyright (c) 2016 Shanghai Fullhan Microelectronics Co., Ltd.
  5. * All rights reserved
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or
  10. * (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License along
  18. * with this program; if not, write to the Free Software Foundation, Inc.,
  19. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  20. *
  21. * Visit http://www.fullhan.com to get contact with Fullhan.
  22. *
  23. * Change Logs:
  24. * Date Author Notes
  25. */
  26. #ifndef FH_WDT_H_
  27. #define FH_WDT_H_
  28. #include "fh_def.h"
  29. #define WDOG_CONTROL_REG_OFFSET 0x00
  30. #define WDOG_CONTROL_REG_WDT_EN_MASK 0x01
  31. #define WDOG_CONTROL_REG_RMOD_MASK 0x02
  32. #define WDOG_TIMEOUT_RANGE_REG_OFFSET 0x04
  33. #define WDOG_CURRENT_COUNT_REG_OFFSET 0x08
  34. #define WDOG_COUNTER_RESTART_REG_OFFSET 0x0c
  35. #define WDOG_COUNTER_RESTART_KICK_VALUE 0x76
  36. /* Hardware timeout in seconds */
  37. #define WDT_HW_TIMEOUT 2
  38. /* User land timeout */
  39. #define WDT_HEARTBEAT 15
  40. /* The maximum TOP (timeout period) value that can be set in the watchdog. */
  41. #define FH_WDT_MAX_TOP 15
  42. #define WDT_TIMEOUT (HZ / 2)
  43. struct fh_wdt_obj
  44. {
  45. int id;
  46. int irq;
  47. unsigned int base;
  48. };
  49. void WDT_Enable(struct fh_wdt_obj *wdt_obj, int enable);
  50. rt_inline int WDT_IsEnable(struct fh_wdt_obj *wdt_obj)
  51. {
  52. return GET_REG(wdt_obj->base + WDOG_CONTROL_REG_OFFSET) &
  53. WDOG_CONTROL_REG_WDT_EN_MASK;
  54. }
  55. void WDT_SetTopValue(struct fh_wdt_obj *wdt_obj, int top);
  56. void WDT_SetCtrl(struct fh_wdt_obj *wdt_obj, UINT32 reg);
  57. void WDT_Kick(struct fh_wdt_obj *wdt_obj);
  58. unsigned int WDT_GetCurrCount(struct fh_wdt_obj *wdt_obj);
  59. #endif /* FH_WDT_H_ */