HPM SDK
HPMicro Software Development Kit
hpm_ppor_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2024 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef HPM_PPOR_DRV_H
9 #define HPM_PPOR_DRV_H
10 #include "hpm_ppor_regs.h"
11 
12 typedef enum {
14  ppor_reset_debug = 1 << 4,
15  ppor_reset_wdog0 = 1 << 16,
16  ppor_reset_wdog1 = 1 << 17,
17  ppor_reset_wdog2 = 1 << 18,
18  ppor_reset_wdog3 = 1 << 19,
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /*
28  * perform software reset in counter * (1/24Mhz) seconds
29  */
30 static inline void ppor_sw_reset(PPOR_Type *ptr, uint32_t counter)
31 {
33 
34 /*
35  * clear enable reset source according to the given mask
36  */
37 static inline void ppor_reset_mask_clear_source_enable(PPOR_Type *ptr, uint32_t mask)
38 {
39  ptr->RESET_ENABLE &= ~mask;
40 }
41 
42 /*
43  * set enable reset source according to the given mask
44  */
45 static inline void ppor_reset_mask_set_source_enable(PPOR_Type *ptr, uint32_t mask)
46 {
47  ptr->RESET_ENABLE |= mask;
48 }
49 
50 /*
51  * set enable reset source
52  */
53 static inline void ppor_reset_set_source_enable(PPOR_Type *ptr, uint32_t reset_sources)
54 {
55  ptr->RESET_ENABLE = reset_sources;
56 }
57 
58 /*
59  * get enabled reset source
60  */
61 static inline uint32_t ppor_reset_get_enabled_source(PPOR_Type *ptr)
62 {
63  return ptr->RESET_ENABLE;
64 }
65 
66 /*
67  * get reset status
68  */
69 static inline uint32_t ppor_reset_get_status(PPOR_Type *ptr)
70 {
71  return ptr->RESET_STATUS;
72 }
73 
74 /*
75  * get reset flags
76  */
77 static inline uint32_t ppor_reset_get_flags(PPOR_Type *ptr)
78 {
79  return ptr->RESET_FLAG;
80 }
81 
82 /*
83  * clear reset flags
84  */
85 static inline void ppor_reset_clear_flags(PPOR_Type *ptr, uint32_t mask)
86 {
87  ptr->RESET_FLAG = mask;
88 }
89 
90 /*
91  * get reset hold
92  */
93 static inline uint32_t ppor_reset_get_hold(PPOR_Type *ptr)
94 {
95  return ptr->RESET_HOLD;
96 }
97 
98 /*
99  * set reset hold
100  */
101 static inline void ppor_reset_set_hold_enable(PPOR_Type *ptr, uint32_t mask)
102 {
103  ptr->RESET_HOLD |= mask;
104 }
105 
106 /*
107  * clear reset hold
108  */
109 static inline void ppor_reset_clear_hold_enable(PPOR_Type *ptr, uint32_t mask)
110 {
111  ptr->RESET_HOLD &= ~mask;
112 }
113 
114 /*
115  * set cold reset
116  */
117 static inline void ppor_reset_set_cold_reset_enable(PPOR_Type *ptr, uint32_t mask)
118 {
119  ptr->RESET_TYPE &= ~mask;
120 }
121 
122 /*
123  * clear cold reset
124  */
125 static inline void ppor_reset_clear_cold_reset_enable(PPOR_Type *ptr, uint32_t mask)
126 {
127  ptr->RESET_TYPE |= mask;
128 }
129 
130 /*
131  * set hot reset
132  */
133 static inline void ppor_reset_set_hot_reset_enable(PPOR_Type *ptr, uint32_t mask)
134 {
135  ptr->RESET_TYPE |= mask;
136 }
137 
138 /*
139  * clear hot reset
140  */
141 static inline void ppor_reset_clear_hot_reset_enable(PPOR_Type *ptr, uint32_t mask)
142 {
143  ptr->RESET_TYPE &= ~mask;
144 }
145 
146 #ifdef __cplusplus
147 }
148 #endif
149 #endif
ppor_reset_source_t
Definition: hpm_ppor_drv.h:12
@ ppor_reset_debug
Definition: hpm_ppor_drv.h:14
@ ppor_reset_software
Definition: hpm_ppor_drv.h:18
@ ppor_reset_pmic_wdog
Definition: hpm_ppor_drv.h:17
@ ppor_reset_brownout
Definition: hpm_ppor_drv.h:13
@ ppor_reset_wdog1
Definition: hpm_ppor_drv.h:16
@ ppor_reset_wdog0
Definition: hpm_ppor_drv.h:15
#define PPOR_SOFTWARE_RESET_COUNTER_SET(x)
Definition: hpm_ppor_regs.h:160
static uint32_t ppor_reset_get_flags(PPOR_Type *ptr)
Definition: hpm_ppor_drv.h:77
@ ppor_reset_wdog2
Definition: hpm_ppor_drv.h:17
@ ppor_reset_wdog3
Definition: hpm_ppor_drv.h:18
static uint32_t ppor_reset_get_enabled_source(PPOR_Type *ptr)
Definition: hpm_ppor_drv.h:61
static void ppor_reset_clear_flags(PPOR_Type *ptr, uint32_t mask)
Definition: hpm_ppor_drv.h:85
static void ppor_reset_mask_set_source_enable(PPOR_Type *ptr, uint32_t mask)
Definition: hpm_ppor_drv.h:45
static void ppor_reset_set_hold_enable(PPOR_Type *ptr, uint32_t mask)
Definition: hpm_ppor_drv.h:101
static void ppor_reset_set_source_enable(PPOR_Type *ptr, uint32_t reset_sources)
Definition: hpm_ppor_drv.h:53
static void ppor_reset_set_cold_reset_enable(PPOR_Type *ptr, uint32_t mask)
Definition: hpm_ppor_drv.h:117
static uint32_t ppor_reset_get_status(PPOR_Type *ptr)
Definition: hpm_ppor_drv.h:69
static void ppor_sw_reset(PPOR_Type *ptr, uint32_t counter)
Definition: hpm_ppor_drv.h:30
static void ppor_reset_clear_cold_reset_enable(PPOR_Type *ptr, uint32_t mask)
Definition: hpm_ppor_drv.h:125
static void ppor_reset_clear_hold_enable(PPOR_Type *ptr, uint32_t mask)
Definition: hpm_ppor_drv.h:109
static void ppor_reset_clear_hot_reset_enable(PPOR_Type *ptr, uint32_t mask)
Definition: hpm_ppor_drv.h:141
static void ppor_reset_set_hot_reset_enable(PPOR_Type *ptr, uint32_t mask)
Definition: hpm_ppor_drv.h:133
static uint32_t ppor_reset_get_hold(PPOR_Type *ptr)
Definition: hpm_ppor_drv.h:93
static void ppor_reset_mask_clear_source_enable(PPOR_Type *ptr, uint32_t mask)
Definition: hpm_ppor_drv.h:37
Definition: hpm_ppor_regs.h:12
__RW uint32_t RESET_HOLD
Definition: hpm_ppor_regs.h:15
__RW uint32_t RESET_TYPE
Definition: hpm_ppor_regs.h:17
__RW uint32_t RESET_ENABLE
Definition: hpm_ppor_regs.h:16
__R uint32_t RESET_STATUS
Definition: hpm_ppor_regs.h:14
__W uint32_t RESET_FLAG
Definition: hpm_ppor_regs.h:13
__RW uint32_t SOFTWARE_RESET
Definition: hpm_ppor_regs.h:19