文件名称:
WATCHDOG.md
所在目录:
Openharmony v1.0 / docs / api / api-SmartVision-Devices
文件大小:
21.02 KB
下载地址:
文本预览:
# WATCHDOG
## **Overview**
Provides watchdog APIs, such as setting the watchdog timeout duration and feeding a watchdog \(resetting a watchdog timer\).
If an error occurs in the main program of the system, for example, if the program crashes or the watchdog timer is not reset in time, the watchdog timer generates a reset signal, and the system restores from the suspending state to the normal state.
**Since:**
1.0
## **Summary**
## Files
## Enumerations
## Functions
## **Details**
## **Enumeration Type Documentation**
## WatchdogStatus
```
enum [WatchdogStatus](WATCHDOG.md#ga3c77a35e1051e3f99238029519ac1954)
```
**Description:**
Enumerates watchdog statuses.
To obtain the watchdog status, call the [WatchdogGetStatus](WATCHDOG.md#ga37d1311664523c25557b1280cb51ebdf) function.
## **Function Documentation**
## WatchdogClose\(\)
```
void WatchdogClose (struct [DevHandle](DevHandle.md) * handle)
```
**Description:**
Closes a watchdog.
If you no longer need a watchdog, call this function to close it and release its device handle to prevent unnecessary use of memory resources.
**Parameters:**
## WatchdogFeed\(\)
```
int32_t WatchdogFeed (struct [DevHandle](DevHandle.md) * handle)
```
**Description:**
Feeds a watchdog, that is, resets a watchdog timer.
After a watchdog is started, you must feed it to reset the watchdog timer periodically. If you do not do so, the watchdog hardware will reset the system upon a timeout.
**Parameters:**
**Returns:**
Returns **0** if the watchdog is fed; returns a negative value otherwise.
## WatchdogGetStatus\(\)
```
int32_t WatchdogGetStatus (struct [DevHandle](DevHandle.md) * handle, int32_t * status )
```
**Description:**
Obtains the watchdog status.
For the available watchdog statuses, see [WatchdogStatus](WATCHDOG.md#ga3c77a35e1051e3f99238029519ac1954).
**Parameters:**
**Returns:**
Returns **0** if the watchdog status is obtained; returns a negative value otherwise.
## WatchdogGetTimeout\(\)
```
int32_t WatchdogGetTimeout (struct [DevHandle](DevHandle.md) * handle, uint32_t * seconds )
```
**Description:**
Obtains the watchdog timeout duration.
**Parameters:**
**Returns:**
Returns **0** if the watchdog timeout duration is obtained; returns a negative value otherwise.
## WatchdogOpen\(\)
```
struct [DevHandle](DevHandle.md)* WatchdogOpen (int16_t wdtId)
```
**Description:**
Opens a watchdog.
Before operating a watchdog, you must call this function to open it and obtain its device handle.
**Parameters:**
**Returns:**
Returns the pointer to the device handle of the watch dog if the operation is successful; returns **NULL** otherwise.
## WatchdogSetTimeout\(\)
```
int32_t WatchdogSetTimeout (struct [DevHandle](DevHandle.md) * handle, uint32_t seconds )
```
**Description:**
Sets the watchdog timeout duration.
**Parameters:**
**Returns:**
Returns **0** if the setting is successful; returns a negative value otherwise.
## WatchdogStart\(\)
```
int32_t WatchdogStart (struct [DevHandle](DevHandle.md) * handle)
```
**Description:**
Starts a watchdog.
This function starts the watchdog timer. You must feed the watchdog periodically; otherwise, the watchdog hardware will reset the system upon a timeout.
**Parameters:**
**Returns:**
Returns **0** if the watchdog is successfully started; returns a negative value otherwise.
**Attention:**
If the watchdog timer has started before this function is called, calling this function will succeed; however, the watchdog hardware determines whether to reset the timer.
## WatchdogStop\(\)
```
int32_t WatchdogStop (struct [DevHandle](DevHandle.md) * handle)
```
**Description:**
Stops a watchdog.
If the watchdog has stopped before this function is called, calling this function will succeed.
**Parameters:**
**Returns:**
Returns **0** if the watchdog is successfully stopped; returns a negative value otherwise.
## **Overview**
Provides watchdog APIs, such as setting the watchdog timeout duration and feeding a watchdog \(resetting a watchdog timer\).
If an error occurs in the main program of the system, for example, if the program crashes or the watchdog timer is not reset in time, the watchdog timer generates a reset signal, and the system restores from the suspending state to the normal state.
**Since:**
1.0
## **Summary**
## Files
Declares standard watchdog APIs. |
## Enumerations
WatchdogStatus { WATCHDOG_STOP, WATCHDOG_START } |
## Functions
WatchdogOpen (int16_t wdtId) | struct DevHandle * |
WatchdogClose (struct DevHandle *handle) | |
WatchdogGetStatus (struct DevHandle *handle, int32_t *status) | |
WatchdogStart (struct DevHandle *handle) | |
WatchdogStop (struct DevHandle *handle) | |
WatchdogSetTimeout (struct DevHandle *handle, uint32_t seconds) | Sets the watchdog timeout duration. |
WatchdogGetTimeout (struct DevHandle *handle, uint32_t *seconds) | Obtains the watchdog timeout duration. |
WatchdogFeed (struct DevHandle *handle) | Feeds a watchdog, that is, resets a watchdog timer. |
## **Details**
## **Enumeration Type Documentation**
## WatchdogStatus
```
enum [WatchdogStatus](WATCHDOG.md#ga3c77a35e1051e3f99238029519ac1954)
```
**Description:**
Enumerates watchdog statuses.
To obtain the watchdog status, call the [WatchdogGetStatus](WATCHDOG.md#ga37d1311664523c25557b1280cb51ebdf) function.
WATCHDOG_STOP | |
WATCHDOG_START |
## **Function Documentation**
## WatchdogClose\(\)
```
void WatchdogClose (struct [DevHandle](DevHandle.md) * handle)
```
**Description:**
Closes a watchdog.
If you no longer need a watchdog, call this function to close it and release its device handle to prevent unnecessary use of memory resources.
**Parameters:**
handle | Indicates the pointer to the watchdog device handle. |
## WatchdogFeed\(\)
```
int32_t WatchdogFeed (struct [DevHandle](DevHandle.md) * handle)
```
**Description:**
Feeds a watchdog, that is, resets a watchdog timer.
After a watchdog is started, you must feed it to reset the watchdog timer periodically. If you do not do so, the watchdog hardware will reset the system upon a timeout.
**Parameters:**
handle | Indicates the pointer to the watchdog handle, which is obtained via WatchdogOpen. |
**Returns:**
Returns **0** if the watchdog is fed; returns a negative value otherwise.
## WatchdogGetStatus\(\)
```
int32_t WatchdogGetStatus (struct [DevHandle](DevHandle.md) * handle, int32_t * status )
```
**Description:**
Obtains the watchdog status.
For the available watchdog statuses, see [WatchdogStatus](WATCHDOG.md#ga3c77a35e1051e3f99238029519ac1954).
**Parameters:**
handle | Indicates the pointer to the watchdog handle, which is obtained via WatchdogOpen. |
status | Indicates the pointer to the watchdog status. |
**Returns:**
Returns **0** if the watchdog status is obtained; returns a negative value otherwise.
## WatchdogGetTimeout\(\)
```
int32_t WatchdogGetTimeout (struct [DevHandle](DevHandle.md) * handle, uint32_t * seconds )
```
**Description:**
Obtains the watchdog timeout duration.
**Parameters:**
handle | Indicates the pointer to the watchdog handle, which is obtained via WatchdogOpen. |
seconds | Indicates the pointer to the timeout duration, in seconds. |
**Returns:**
Returns **0** if the watchdog timeout duration is obtained; returns a negative value otherwise.
## WatchdogOpen\(\)
```
struct [DevHandle](DevHandle.md)* WatchdogOpen (int16_t wdtId)
```
**Description:**
Opens a watchdog.
Before operating a watchdog, you must call this function to open it and obtain its device handle.
**Parameters:**
wdtId | Indicates the watchdog ID. |
**Returns:**
Returns the pointer to the device handle of the watch dog if the operation is successful; returns **NULL** otherwise.
## WatchdogSetTimeout\(\)
```
int32_t WatchdogSetTimeout (struct [DevHandle](DevHandle.md) * handle, uint32_t seconds )
```
**Description:**
Sets the watchdog timeout duration.
**Parameters:**
handle | Indicates the pointer to the watchdog handle, which is obtained via WatchdogOpen. |
seconds | Indicates the timeout duration, in seconds. |
**Returns:**
Returns **0** if the setting is successful; returns a negative value otherwise.
## WatchdogStart\(\)
```
int32_t WatchdogStart (struct [DevHandle](DevHandle.md) * handle)
```
**Description:**
Starts a watchdog.
This function starts the watchdog timer. You must feed the watchdog periodically; otherwise, the watchdog hardware will reset the system upon a timeout.
**Parameters:**
handle | Indicates the pointer to the watchdog handle, which is obtained via WatchdogOpen. |
**Returns:**
Returns **0** if the watchdog is successfully started; returns a negative value otherwise.
**Attention:**
If the watchdog timer has started before this function is called, calling this function will succeed; however, the watchdog hardware determines whether to reset the timer.
## WatchdogStop\(\)
```
int32_t WatchdogStop (struct [DevHandle](DevHandle.md) * handle)
```
**Description:**
Stops a watchdog.
If the watchdog has stopped before this function is called, calling this function will succeed.
**Parameters:**
handle | Indicates the pointer to the watchdog handle, which is obtained via WatchdogOpen. |
**Returns:**
Returns **0** if the watchdog is successfully stopped; returns a negative value otherwise.
点赞
回复
X