2 **************************************************************************
3 * @file at32f435_437_wwdt.c
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
34 * @brief WWDT driver modules
38 #ifdef WWDT_MODULE_ENABLED
40 /** @defgroup WWDT_private_functions
45 * @brief wwdt reset by crm reset register
50 crm_periph_reset(CRM_WWDT_PERIPH_RESET
, TRUE
);
51 crm_periph_reset(CRM_WWDT_PERIPH_RESET
, FALSE
);
55 * @brief wwdt division set
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)
64 void wwdt_divider_set(wwdt_division_type division
)
66 WWDT
->cfg_bit
.div
= division
;
70 * @brief wwdt reload counter interrupt flag clear
74 void wwdt_flag_clear(void)
80 * @brief wwdt enable and the counter value load
81 * @param wwdt_cnt (0x40~0x7f)
84 void wwdt_enable(uint8_t wwdt_cnt
)
86 WWDT
->ctrl
= wwdt_cnt
| WWDT_EN_BIT
;
90 * @brief wwdt reload counter interrupt enable
94 void wwdt_interrupt_enable(void)
96 WWDT
->cfg_bit
.rldien
= TRUE
;
100 * @brief wwdt reload counter interrupt flag get
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)
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)
124 void wwdt_window_counter_set(uint8_t window_cnt
)
126 WWDT
->cfg_bit
.win
= window_cnt
;