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