1 /**************************************************************************//**
2  * @file     wwdt.c
3  * @version  V3.00
4  * @brief    Window Watchdog Timer(WWDT) driver source file
5  *
6  * @copyright SPDX-License-Identifier: Apache-2.0
7  * @copyright Copyright (C) 2021 Nuvoton Technology Corp. All rights reserved.
8  *****************************************************************************/
9 #include "NuMicro.h"
10 
11 
12 /** @addtogroup Standard_Driver Standard Driver
13   @{
14 */
15 
16 /** @addtogroup WWDT_Driver WWDT Driver
17   @{
18 */
19 
20 /** @addtogroup WWDT_EXPORTED_FUNCTIONS WWDT Exported Functions
21   @{
22 */
23 
24 /**
25   * @brief      Open WWDT and start counting
26   *
27   * @param[in]  u32PreScale     Pre-scale setting of WWDT counter. Valid values are:
28   *                             - \ref WWDT_PRESCALER_1
29   *                             - \ref WWDT_PRESCALER_2
30   *                             - \ref WWDT_PRESCALER_4
31   *                             - \ref WWDT_PRESCALER_8
32   *                             - \ref WWDT_PRESCALER_16
33   *                             - \ref WWDT_PRESCALER_32
34   *                             - \ref WWDT_PRESCALER_64
35   *                             - \ref WWDT_PRESCALER_128
36   *                             - \ref WWDT_PRESCALER_192
37   *                             - \ref WWDT_PRESCALER_256
38   *                             - \ref WWDT_PRESCALER_384
39   *                             - \ref WWDT_PRESCALER_512
40   *                             - \ref WWDT_PRESCALER_768
41   *                             - \ref WWDT_PRESCALER_1024
42   *                             - \ref WWDT_PRESCALER_1536
43   *                             - \ref WWDT_PRESCALER_2048
44   * @param[in]  u32CmpValue     Setting the window compared value. Valid values are between 0x0 to 0x3F.
45   * @param[in]  u32EnableInt    Enable WWDT time-out interrupt function. Valid values are TRUE and FALSE.
46   *
47   * @return     None
48   *
49   * @details    This function makes WWDT module start counting with different counter period by pre-scale setting and compared window value.
50   * @note       Application can call this function only once after boot up.
51   */
WWDT_Open(uint32_t u32PreScale,uint32_t u32CmpValue,uint32_t u32EnableInt)52 void WWDT_Open(uint32_t u32PreScale,
53                uint32_t u32CmpValue,
54                uint32_t u32EnableInt)
55 {
56     WWDT->CTL = u32PreScale |
57                 (u32CmpValue << WWDT_CTL_CMPDAT_Pos) |
58                 ((u32EnableInt == (uint32_t)TRUE) ? WWDT_CTL_INTEN_Msk : 0UL) |
59                 WWDT_CTL_WWDTEN_Msk;
60 }
61 
62 /**@}*/ /* end of group WWDT_EXPORTED_FUNCTIONS */
63 
64 /**@}*/ /* end of group WWDT_Driver */
65 
66 /**@}*/ /* end of group Standard_Driver */
67