drv_wdt.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. /******************************************************************************
  17. * @file drv_wdt.h
  18. * @brief header file for wdt driver
  19. * @version V1.0
  20. * @date 02. June 2017
  21. ******************************************************************************/
  22. #ifndef _CSI_WDT_H_
  23. #define _CSI_WDT_H_
  24. #ifdef __cplusplus
  25. extern "C" {
  26. #endif
  27. #include <stdint.h>
  28. #include <drv_common.h>
  29. /// definition for wdt handle.
  30. typedef void *wdt_handle_t;
  31. /****** WDT Event *****/
  32. typedef enum {
  33. WDT_EVENT_TIMEOUT = 0 ///< generate the interrupt
  34. } wdt_event_e;
  35. typedef void (*wdt_event_cb_t)(wdt_event_e event); ///< Pointer to \ref wdt_event_cb_t : WDT Event call back.
  36. /**
  37. \brief WDT Device Driver Capabilities.
  38. */
  39. typedef struct {
  40. uint32_t interrupt : 1; ///< supports interrupt
  41. } wdt_capabilities_t;
  42. /**
  43. \brief get wdt instance count.
  44. \return wdt instance count
  45. */
  46. int32_t csi_wdt_get_instance_count(void);
  47. /**
  48. \brief Initialize WDT Interface. 1. Initializes the resources needed for the WDT interface 2.registers event callback function
  49. \param[in] idx must not exceed return value of csi_wdt_get_instance_count()
  50. \param[in] cb_event Pointer to \ref wdt_event_cb_t
  51. \return pointer to wdt instance
  52. */
  53. wdt_handle_t csi_wdt_initialize(int32_t idx, wdt_event_cb_t cb_event);
  54. /**
  55. \brief De-initialize WDT Interface. stops operation and releases the software resources used by the interface
  56. \param[in] handle wdt handle to operate.
  57. \return error code
  58. */
  59. int32_t csi_wdt_uninitialize(wdt_handle_t handle);
  60. /**
  61. \brief Get driver capabilities.
  62. \param[in] handle wdt handle to operate.
  63. \return \ref wdt_capabilities_t
  64. */
  65. wdt_capabilities_t csi_wdt_get_capabilities(wdt_handle_t handle);
  66. /**
  67. \brief Set the WDT value.
  68. \param[in] handle wdt handle to operate.
  69. \param[in] value the timeout value(ms).
  70. \return error code
  71. */
  72. int32_t csi_wdt_set_timeout(wdt_handle_t handle, uint32_t value);
  73. /**
  74. \brief Start the WDT.
  75. \param[in] handle wdt handle to operate.
  76. \return error code
  77. */
  78. int32_t csi_wdt_start(wdt_handle_t handle);
  79. /**
  80. \brief Stop the WDT.
  81. \param[in] handle wdt handle to operate.
  82. \return error code
  83. */
  84. int32_t csi_wdt_stop(wdt_handle_t handle);
  85. /**
  86. \brief Restart the WDT.
  87. \param[in] handle wdt handle to operate.
  88. \return error code
  89. */
  90. int32_t csi_wdt_restart(wdt_handle_t handle);
  91. /**
  92. \brief Read the WDT Current value.
  93. \param[in] handle wdt handle to operate.
  94. \param[in] value Pointer to the Value.
  95. \return error code
  96. */
  97. int32_t csi_wdt_read_current_value(wdt_handle_t handle, uint32_t *value);
  98. #ifdef __cplusplus
  99. }
  100. #endif
  101. #endif /* _CSI_WDT_H_ */