2 **************************************************************************
3 * @file at32f435_437_wdt.c
6 * @brief contains all the functions for the wdt firmware library
7 **************************************************************************
8 * Copyright notice & Disclaimer
10 * The software Board Support Package (BSP) that is made available to
11 * download from Artery official website is the copyrighted work of Artery.
12 * Artery authorizes customers to use, copy, and distribute the BSP
13 * software and its related documentation for the purpose of design and
14 * development in conjunction with Artery microcontrollers. Use of the
15 * software is governed by this copyright notice and the following disclaimer.
17 * THIS SOFTWARE IS PROVIDED ON "AS IS" BASIS WITHOUT WARRANTIES,
18 * GUARANTEES OR REPRESENTATIONS OF ANY KIND. ARTERY EXPRESSLY DISCLAIMS,
19 * TO THE FULLEST EXTENT PERMITTED BY LAW, ALL EXPRESS, IMPLIED OR
20 * STATUTORY OR OTHER WARRANTIES, GUARANTEES OR REPRESENTATIONS,
21 * INCLUDING BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT.
24 **************************************************************************
27 #include "at32f435_437_conf.h"
29 /** @addtogroup AT32F435_437_periph_driver
34 * @brief WDT driver modules
38 #ifdef WDT_MODULE_ENABLED
40 /** @defgroup WDT_private_functions
45 * @brief wdt enable ,the reload value will be sent to the counter
51 WDT
->cmd
= WDT_CMD_ENABLE
;
55 * @brief reload wdt counter
59 void wdt_counter_reload(void)
61 WDT
->cmd
= WDT_CMD_RELOAD
;
65 * @brief set wdt counter reload value
66 * @param reload_value (0x0000~0x0FFF)
69 void wdt_reload_value_set(uint16_t reload_value
)
71 WDT
->rld
= reload_value
;
75 * @brief set wdt division divider
77 * this parameter can be one of the following values:
87 void wdt_divider_set(wdt_division_type division
)
89 WDT
->div_bit
.div
= division
;
93 * @brief enable or disable wdt cmd register write
94 * @param new_state (TRUE or FALSE)
97 void wdt_register_write_enable( confirm_state new_state
)
99 if(new_state
== FALSE
)
101 WDT
->cmd
= WDT_CMD_LOCK
;
105 WDT
->cmd
= WDT_CMD_UNLOCK
;
110 * @brief get wdt flag
112 * this parameter can be one of the following values:
113 * - WDT_DIVF_UPDATE_FLAG: division value update complete flag.
114 * - WDT_RLDF_UPDATE_FLAG: reload value update complete flag.
115 * - WDT_WINF_UPDATE_FLAG: window value update complete flag.
116 * @retval state of wdt flag
118 flag_status
wdt_flag_get(uint16_t wdt_flag
)
120 flag_status status
= RESET
;
122 if ((WDT
->sts
& wdt_flag
) != (uint16_t)RESET
)
135 * @brief wdt window counter value set
136 * @param window_cnt (0x0000~0x0FFF)
139 void wdt_window_counter_set(uint16_t window_cnt
)
141 WDT
->win_bit
.win
= window_cnt
;