# Watchdog HAL interface documentation

## Hardware introduction

K230 integrates a watchdog timer (Watchdog Timer) for monitoring the system running status. When the system is abnormal and cannot "feed the dog" in time, the watchdog will trigger a system reset to prevent the system from crashing. The watchdog timeout is configurable and supports start, stop and dog feeding operations.

---

## Function interface description

### `int wdt_set_timeout(uint32_t timeout_sec);`

**Function**: Set watchdog timeout.

**parameter**:

- `timeout_sec`: timeout (seconds)

**Return Value**:

- `0`: Success
- `-1`: failed

---

### `uint32_t wdt_get_timeout(void);`

**Function**: Get the current watchdog timeout setting.

**Return Value**:

- `>=0`: Current timeout (seconds)
- `-1`: failed

---

### `int wdt_start();`

**Function**: Start watchdog. Dogs need to be fed regularly after startup, otherwise the system will reset after timeout.

**Return Value**:

- `0`: Success
- `-1`: failed

---

### `int wdt_stop();`

**Function**: Stop watchdog.

**Return Value**:

- `0`: Success
- `-1`: failed

---

### `int wdt_feed();`

**Function**: Feed the dog operation, refresh the watchdog timer, and prevent system reset.

**Return Value**:

- `0`: Success
- `-1`: failed

---

## Usage example

Please refer to `src/rtsmart/libs/testcases/rtsmart_hal/test_wdt.c`
