1 /**************************************************************************//**
2  * @file     wdt.c
3  * @version  V3.00
4  * @brief    M480 series WDT driver source file
5  *
6  * SPDX-License-Identifier: Apache-2.0
7  * @copyright (C) 2016-2020 Nuvoton Technology Corp. All rights reserved.
8 *****************************************************************************/
9 #include "NuMicro.h"
10 
11 
12 /** @addtogroup Standard_Driver Standard Driver
13   @{
14 */
15 
16 /** @addtogroup WDT_Driver WDT Driver
17   @{
18 */
19 
20 /** @addtogroup WDT_EXPORTED_FUNCTIONS WDT Exported Functions
21   @{
22 */
23 
24 /**
25   * @brief      Initialize WDT and start counting
26   *
27   * @param[in]  u32TimeoutInterval  Time-out interval period of WDT module. Valid values are:
28   *                                 - \ref WDT_TIMEOUT_2POW4
29   *                                 - \ref WDT_TIMEOUT_2POW6
30   *                                 - \ref WDT_TIMEOUT_2POW8
31   *                                 - \ref WDT_TIMEOUT_2POW10
32   *                                 - \ref WDT_TIMEOUT_2POW12
33   *                                 - \ref WDT_TIMEOUT_2POW14
34   *                                 - \ref WDT_TIMEOUT_2POW16
35   *                                 - \ref WDT_TIMEOUT_2POW18
36   * @param[in]  u32ResetDelay       Configure WDT time-out reset delay period. Valid values are:
37   *                                 - \ref WDT_RESET_DELAY_1026CLK
38   *                                 - \ref WDT_RESET_DELAY_130CLK
39   *                                 - \ref WDT_RESET_DELAY_18CLK
40   *                                 - \ref WDT_RESET_DELAY_3CLK
41   * @param[in]  u32EnableReset      Enable WDT time-out reset system function. Valid values are TRUE and FALSE.
42   * @param[in]  u32EnableWakeup     Enable WDT time-out wake-up system function. Valid values are TRUE and FALSE.
43   *
44   * @return     None
45   *
46   * @details    This function makes WDT module start counting with different time-out interval, reset delay period and choose to \n
47   *             enable or disable WDT time-out reset system or wake-up system.
48   * @note       Please make sure that Register Write-Protection Function has been disabled before using this function.
49   */
WDT_Open(uint32_t u32TimeoutInterval,uint32_t u32ResetDelay,uint32_t u32EnableReset,uint32_t u32EnableWakeup)50 void WDT_Open(uint32_t u32TimeoutInterval,
51               uint32_t u32ResetDelay,
52               uint32_t u32EnableReset,
53               uint32_t u32EnableWakeup)
54 {
55     WDT->ALTCTL = u32ResetDelay;
56 
57     WDT->CTL = u32TimeoutInterval | WDT_CTL_WDTEN_Msk |
58                (u32EnableReset << WDT_CTL_RSTEN_Pos) |
59                (u32EnableWakeup << WDT_CTL_WKEN_Pos);
60     return;
61 }
62 
63 /*@}*/ /* end of group WDT_EXPORTED_FUNCTIONS */
64 
65 /*@}*/ /* end of group WDT_Driver */
66 
67 /*@}*/ /* end of group Standard_Driver */
68 
69 /*** (C) COPYRIGHT 2016 Nuvoton Technology Corp. ***/
70