1
- /* mbed Microcontroller Library
2
- * Copyright (c) 2017-2018 Nuvoton
1
+ /*
2
+ * Copyright (c) 2017-2018, Nuvoton Technology Corporation
3
+ *
4
+ * SPDX-License-Identifier: Apache-2.0
3
5
*
4
6
* Licensed under the Apache License, Version 2.0 (the "License");
5
7
* you may not use this file except in compliance with the License.
@@ -37,6 +39,12 @@ reset_reason_t hal_reset_reason_get(void)
37
39
reset_reason_t reset_reason_cast ;
38
40
uint32_t reset_reason_count = 0 ;
39
41
42
+ /* Get around h/w limit with WDT reset from PD */
43
+ if (CLK -> PMUSTS & CLK_PMUSTS_TMRWK_Msk ) {
44
+ /* Per test, these reset reason flags will set with WKT reset. Clear them for this resolution. */
45
+ SYS_CLEAR_RST_SOURCE (SYS_RSTSTS_PINRF_Msk | SYS_RSTSTS_PORF_Msk );
46
+ }
47
+
40
48
if (SYS_IS_POR_RST ()) {
41
49
reset_reason_cast = RESET_REASON_POWER_ON ;
42
50
reset_reason_count ++ ;
@@ -47,7 +55,8 @@ reset_reason_t hal_reset_reason_get(void)
47
55
reset_reason_count ++ ;
48
56
}
49
57
50
- if (SYS_IS_WDT_RST ()) {
58
+ /* Get around h/w limit with WDT reset from PD */
59
+ if (SYS_IS_WDT_RST () || (CLK -> PMUSTS & CLK_PMUSTS_TMRWK_Msk )) {
51
60
reset_reason_cast = RESET_REASON_WATCHDOG ;
52
61
reset_reason_count ++ ;
53
62
}
@@ -101,6 +110,15 @@ uint32_t hal_reset_reason_get_raw(void)
101
110
void hal_reset_reason_clear (void )
102
111
{
103
112
SYS_CLEAR_RST_SOURCE (SYS -> RSTSTS );
113
+
114
+ /* Re-unlock protected clock setting */
115
+ SYS_UnlockReg ();
116
+
117
+ /* Get around h/w limit with WDT reset from PD */
118
+ CLK -> PMUSTS |= (CLK_PMUSTS_CLRWK_Msk | CLK_PMUSTS_TMRWK_Msk );
119
+
120
+ /* Lock protected registers */
121
+ SYS_LockReg ();
104
122
}
105
123
106
124
#endif
0 commit comments