before merging master
[inav.git] / lib / main / AT32F43x / Drivers / AT32F43x_StdPeriph_Driver / src / at32f435_437_wwdt.c
blob4f03e650ce650a3638b6f9871e156621d2b9e2ff
1 /**
2 **************************************************************************
3 * @file at32f435_437_wwdt.c
4 * @version v2.1.0
5 * @date 2022-08-16
6 * @brief contains all the functions for the wwdt 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 WWDT
34 * @brief WWDT driver modules
35 * @{
38 #ifdef WWDT_MODULE_ENABLED
40 /** @defgroup WWDT_private_functions
41 * @{
44 /**
45 * @brief wwdt reset by crm reset register
46 * @retval none
48 void wwdt_reset(void)
50 crm_periph_reset(CRM_WWDT_PERIPH_RESET, TRUE);
51 crm_periph_reset(CRM_WWDT_PERIPH_RESET, FALSE);
54 /**
55 * @brief wwdt division set
56 * @param division
57 * this parameter can be one of the following values:
58 * - WWDT_PCLK1_DIV_4096 (wwdt counter clock = (pclk1/4096)/1)
59 * - WWDT_PCLK1_DIV_8192 (wwdt counter clock = (pclk1/4096)/2)
60 * - WWDT_PCLK1_DIV_16384 (wwdt counter clock = (pclk1/4096)/4)
61 * - WWDT_PCLK1_DIV_32768 (wwdt counter clock = (pclk1/4096)/8)
62 * @retval none
64 void wwdt_divider_set(wwdt_division_type division)
66 WWDT->cfg_bit.div = division;
69 /**
70 * @brief wwdt reload counter interrupt flag clear
71 * @param none
72 * @retval none
74 void wwdt_flag_clear(void)
76 WWDT->sts = 0;
79 /**
80 * @brief wwdt enable and the counter value load
81 * @param wwdt_cnt (0x40~0x7f)
82 * @retval none
84 void wwdt_enable(uint8_t wwdt_cnt)
86 WWDT->ctrl = wwdt_cnt | WWDT_EN_BIT;
89 /**
90 * @brief wwdt reload counter interrupt enable
91 * @param none
92 * @retval none
94 void wwdt_interrupt_enable(void)
96 WWDT->cfg_bit.rldien = TRUE;
99 /**
100 * @brief wwdt reload counter interrupt flag get
101 * @param none
102 * @retval state of reload counter interrupt flag
104 flag_status wwdt_flag_get(void)
106 return (flag_status)WWDT->sts_bit.rldf;
110 * @brief wwdt counter value set
111 * @param wwdt_cnt (0x40~0x7f)
112 * @retval none
114 void wwdt_counter_set(uint8_t wwdt_cnt)
116 WWDT->ctrl_bit.cnt = wwdt_cnt;
120 * @brief wwdt window counter value set
121 * @param window_cnt (0x40~0x7f)
122 * @retval none
124 void wwdt_window_counter_set(uint8_t window_cnt)
126 WWDT->cfg_bit.win = window_cnt;
130 * @}
133 #endif
136 * @}
140 * @}