HPM SDK
HPMicro Software Development Kit
hpm_bpor_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_BPOR_DRV_H
9 #define HPM_BPOR_DRV_H
10 
11 #include "hpm_common.h"
12 #include "hpm_bpor_regs.h"
13 
24 typedef enum {
31 
32 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
43 static inline uint32_t bpor_get_power_on_cause(BPOR_Type *ptr)
44 {
45  return ptr->POR_CAUSE;
46 }
47 
54 static inline void bpor_clear_power_on_cause(BPOR_Type *ptr, uint8_t mask)
55 {
56  ptr->POR_CAUSE |= mask;
57 }
58 
66 {
67  ptr->POR_SELECT |= cause;
68 }
69 
77 {
78  ptr->POR_SELECT &= ~cause;
79 }
80 
87 static inline void bpor_set_power_on_cause(BPOR_Type *ptr, uint8_t cause)
88 {
89  ptr->POR_SELECT = (ptr->POR_SELECT & ~BPOR_POR_SELECT_SELECT_MASK) | cause;
90 }
91 
100 {
101  return (ptr->POR_CONFIG & BPOR_POR_CONFIG_RETENTION_MASK) ? true : false;
102 }
103 
110 {
112 }
113 
120 {
122 }
123 
130 static inline void bpor_set_power_down_counter(BPOR_Type *ptr, uint16_t counter)
131 {
133 }
134 
135 #ifdef __cplusplus
136 }
137 #endif
141 #endif /* HPM_BPOR_DRV_H */
#define BPOR_POR_SELECT_SELECT_MASK
Definition: hpm_bpor_regs.h:47
#define BPOR_POR_CONFIG_RETENTION_MASK
Definition: hpm_bpor_regs.h:60
#define BPOR_POR_CONTROL_COUNTER_SET(x)
Definition: hpm_bpor_regs.h:73
bpor_power_on_cause_t
Define BPOR power on cause.
Definition: hpm_bpor_drv.h:24
static void bpor_disable_reg_value_retention(BPOR_Type *ptr)
Disable register value retention when power down occurs.
Definition: hpm_bpor_drv.h:119
static void bpor_disable_power_on_cause(BPOR_Type *ptr, bpor_power_on_cause_t cause)
disable power on cause
Definition: hpm_bpor_drv.h:76
static void bpor_enable_power_on_cause(BPOR_Type *ptr, bpor_power_on_cause_t cause)
enable power on cause
Definition: hpm_bpor_drv.h:65
static void bpor_clear_power_on_cause(BPOR_Type *ptr, uint8_t mask)
Clear power on cause.
Definition: hpm_bpor_drv.h:54
static void bpor_enable_reg_value_retention(BPOR_Type *ptr)
Enable register value retention when power down occurs.
Definition: hpm_bpor_drv.h:109
static bool bpor_is_reg_value_retention_enable(BPOR_Type *ptr)
Check register value retention enable status when power down occurs.
Definition: hpm_bpor_drv.h:99
static void bpor_set_power_on_cause(BPOR_Type *ptr, uint8_t cause)
Set power on cause.
Definition: hpm_bpor_drv.h:87
static void bpor_set_power_down_counter(BPOR_Type *ptr, uint16_t counter)
Set power down counter.
Definition: hpm_bpor_drv.h:130
static uint32_t bpor_get_power_on_cause(BPOR_Type *ptr)
Get power on cause.
Definition: hpm_bpor_drv.h:43
@ bpor_power_on_cause_safety_violation
Definition: hpm_bpor_drv.h:26
@ bpor_power_on_cause_gpio
Definition: hpm_bpor_drv.h:29
@ bpor_power_on_cause_rtc_0
Definition: hpm_bpor_drv.h:27
@ bpor_power_on_cause_rtc_1
Definition: hpm_bpor_drv.h:28
@ bpor_power_on_cause_wbutn
Definition: hpm_bpor_drv.h:25
Definition: hpm_bpor_regs.h:12
__RW uint32_t POR_CAUSE
Definition: hpm_bpor_regs.h:13
__RW uint32_t POR_CONTROL
Definition: hpm_bpor_regs.h:16
__RW uint32_t POR_SELECT
Definition: hpm_bpor_regs.h:14
__RW uint32_t POR_CONFIG
Definition: hpm_bpor_regs.h:15