blob: 0d45f82886082fa88ab8603cf5f3c03644984a83 [file] [log] [blame]
Roman Okhrimenko0c7aebc2020-09-02 13:37:51 +03001/***************************************************************************//**
2* \file cy_wdg.h
3*
4* \brief
5* Provides a high level interface for interacting with the Watchdog Timer.
6* This interface abstracts out the chip specific details. If any chip specific
7* functionality is necessary, or performance is critical the low level functions
8* can be used directly.
9*
10********************************************************************************
11* \copyright
12* Copyright 2019-2020 Cypress Semiconductor Corporation
13* SPDX-License-Identifier: Apache-2.0
14*
15* Licensed under the Apache License, Version 2.0 (the "License");
16* you may not use this file except in compliance with the License.
17* You may obtain a copy of the License at
18*
19* http://www.apache.org/licenses/LICENSE-2.0
20*
21* Unless required by applicable law or agreed to in writing, software
22* distributed under the License is distributed on an "AS IS" BASIS,
23* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24* See the License for the specific language governing permissions and
25* limitations under the License.
26*******************************************************************************/
27
28#pragma once
29
30#if defined(__cplusplus)
31extern "C" {
32#endif
33
34#include <stdint.h>
35#include <stdbool.h>
36#include "cy_result.h"
37
38/** Initialize and start the WDT
39*
40* The specified timeout must be at least 1ms and at most the WDT's maximum timeout (see cy_wdg_get_max_timeout_ms()).
41* @param[inout] timeout_ms The time in milliseconds before the WDT times out (1ms - max) (see cy_wdg_get_max_timeout_ms())
42* @return The status of the init request
43*
44* Returns CY_RSLT_SUCCESS if the operation was successfull.
45*/
46cy_rslt_t cy_wdg_init(uint32_t timeout_ms);
47
48/** Free the WDT
49*
50* Powers down the WDT.
51* After calling this function no other WDT functions should be called except
52* cy_wdg_init().
53*/
54
55void cy_wdg_free();
56
57/** Resets the WDT
58*
59* This function should be called periodically to prevent the WDT from timing out and resetting the device.
60*/
61void cy_wdg_kick();
62
63/** Start (enable) the WDT
64*
65* @return The status of the start request
66*/
67void cy_wdg_start();
68
69/** Stop (disable) the WDT
70*
71* @return The status of the stop request
72*/
73void cy_wdg_stop();
74
75/** Get the WDT timeout
76*
77* Gets the time in milliseconds before the WDT times out.
78* @return The time in milliseconds before the WDT times out
79*/
80uint32_t cy_wdg_get_timeout_ms();
81
82/** Gets the maximum WDT timeout in milliseconds
83*
84* @return The maximum timeout for the WDT
85*/
86uint32_t cy_wdg_get_max_timeout_ms(void);
87
88#if defined(__cplusplus)
89}
90#endif