1 /**************************************************************************//**
2  * @file     ewwdt.c
3  * @version  V3.00
4  * @brief    Extra Window Watchdog Timer(EWWDT) driver source file
5  *
6  * @copyright SPDX-License-Identifier: Apache-2.0
7  * @copyright Copyright (C) 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 EWWDT_Driver EWWDT Driver
17   @{
18 */
19 
20 /** @addtogroup EWWDT_EXPORTED_FUNCTIONS EWWDT Exported Functions
21   @{
22 */
23 
24 /**
25   * @brief      Open EWWDT and start counting
26   *
27   * @param[in]  u32PreScale     Pre-scale setting of EWWDT counter. Valid values are:
28   *                             - \ref EWWDT_PRESCALER_1
29   *                             - \ref EWWDT_PRESCALER_2
30   *                             - \ref EWWDT_PRESCALER_4
31   *                             - \ref EWWDT_PRESCALER_8
32   *                             - \ref EWWDT_PRESCALER_16
33   *                             - \ref EWWDT_PRESCALER_32
34   *                             - \ref EWWDT_PRESCALER_64
35   *                             - \ref EWWDT_PRESCALER_128
36   *                             - \ref EWWDT_PRESCALER_192
37   *                             - \ref EWWDT_PRESCALER_256
38   *                             - \ref EWWDT_PRESCALER_384
39   *                             - \ref EWWDT_PRESCALER_512
40   *                             - \ref EWWDT_PRESCALER_768
41   *                             - \ref EWWDT_PRESCALER_1024
42   *                             - \ref EWWDT_PRESCALER_1536
43   *                             - \ref EWWDT_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 EWWDT 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   */
EWWDT_Open(uint32_t u32PreScale,uint32_t u32CmpValue,uint32_t u32EnableInt)52 void EWWDT_Open(uint32_t u32PreScale,
53                 uint32_t u32CmpValue,
54                 uint32_t u32EnableInt)
55 {
56     EWWDT->CTL = u32PreScale |
57                  (u32CmpValue << EWWDT_CTL_CMPDAT_Pos) |
58                  ((u32EnableInt == (uint32_t)TRUE) ? EWWDT_CTL_INTEN_Msk : 0UL) |
59                  EWWDT_CTL_WWDTEN_Msk;
60 }
61 
62 /**@}*/ /* end of group EWWDT_EXPORTED_FUNCTIONS */
63 
64 /**@}*/ /* end of group EWWDT_Driver */
65 
66 /**@}*/ /* end of group Standard_Driver */
67