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