before merging master
[inav.git] / lib / main / AT32F43x / Drivers / AT32F43x_StdPeriph_Driver / src / at32f435_437_wdt.c
blobe159ed604cc8ee47d0908e386481e5417c6fe466
1 /**
2 **************************************************************************
3 * @file at32f435_437_wdt.c
4 * @version v2.1.0
5 * @date 2022-08-16
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
30 * @{
33 /** @defgroup WDT
34 * @brief WDT driver modules
35 * @{
38 #ifdef WDT_MODULE_ENABLED
40 /** @defgroup WDT_private_functions
41 * @{
44 /**
45 * @brief wdt enable ,the reload value will be sent to the counter
46 * @param none
47 * @retval none
49 void wdt_enable(void)
51 WDT->cmd = WDT_CMD_ENABLE;
54 /**
55 * @brief reload wdt counter
56 * @param none
57 * @retval none
59 void wdt_counter_reload(void)
61 WDT->cmd = WDT_CMD_RELOAD;
64 /**
65 * @brief set wdt counter reload value
66 * @param reload_value (0x0000~0x0FFF)
67 * @retval none
69 void wdt_reload_value_set(uint16_t reload_value)
71 WDT->rld = reload_value;
74 /**
75 * @brief set wdt division divider
76 * @param division
77 * this parameter can be one of the following values:
78 * - WDT_CLK_DIV_4
79 * - WDT_CLK_DIV_8
80 * - WDT_CLK_DIV_16
81 * - WDT_CLK_DIV_32
82 * - WDT_CLK_DIV_64
83 * - WDT_CLK_DIV_128
84 * - WDT_CLK_DIV_256
85 * @retval none
87 void wdt_divider_set(wdt_division_type division)
89 WDT->div_bit.div = division;
92 /**
93 * @brief enable or disable wdt cmd register write
94 * @param new_state (TRUE or FALSE)
95 * @retval none
97 void wdt_register_write_enable( confirm_state new_state)
99 if(new_state == FALSE)
101 WDT->cmd = WDT_CMD_LOCK;
103 else
105 WDT->cmd = WDT_CMD_UNLOCK;
110 * @brief get wdt flag
111 * @param 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)
124 status = SET;
126 else
128 status = RESET;
131 return status;
135 * @brief wdt window counter value set
136 * @param window_cnt (0x0000~0x0FFF)
137 * @retval none
139 void wdt_window_counter_set(uint16_t window_cnt)
141 WDT->win_bit.win = window_cnt;
145 * @}
148 #endif
151 * @}
155 * @}