./
Coverage:
low: ≥ 0%
medium: ≥ 50.0%
high: ≥ 80.0%
Lines:
22 / 26
84.6%
Branches:
13 / 18
72.2%
Functions:
3 / 3
100.0%

kfsw-platform/src/reset.c
Line Branch Exec Source
1 #include <errno.h>
2 #include <stdbool.h>
3 #include <stdint.h>
4
5 #include <zephyr/drivers/hwinfo.h>
6
7 #include <kfsw/platform/reset.h>
8
9 4 int kfsw_platform_get_reset_cause(uint32_t *cause)
10 {
11 int rc;
12
13
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 if (cause == NULL) {
14 ✗ return -EINVAL;
15 }
16
17 4 *cause = 0U;
18
19 4 rc = hwinfo_get_reset_cause(cause);
20
21
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if (rc == 0) {
22 /* Clear latched flags so the next boot reports a new reset event. */
23 4 (void)hwinfo_clear_reset_cause();
24 }
25
26 4 return rc;
27 }
28
29 24 bool kfsw_platform_reset_cause_is_watchdog(uint32_t cause)
30 {
31 24 return (cause & RESET_WATCHDOG) != 0U;
32 }
33
34 22 const char *kfsw_platform_reset_cause_name(uint32_t cause)
35 {
36 /* Priority order for the reported name, watchdog first. */
37
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 16 times.
22 if ((cause & RESET_WATCHDOG) != 0U) {
38 6 return "watchdog";
39 }
40
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16 times.
16 if ((cause & RESET_BROWNOUT) != 0U) {
41 ✗ return "brownout";
42 }
43
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 6 times.
16 if ((cause & RESET_POR) != 0U) {
44 10 return "power-on";
45 }
46
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
6 if ((cause & RESET_SOFTWARE) != 0U) {
47 2 return "software";
48 }
49
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 2 times.
4 if ((cause & RESET_PIN) != 0U) {
50 2 return "pin";
51 }
52
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ((cause & RESET_DEBUG) != 0U) {
53 ✗ return "debug";
54 }
55
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if ((cause & RESET_LOW_POWER_WAKE) != 0U) {
56 ✗ return "low-power-wake";
57 }
58
59 2 return "unknown";
60 }
61