HPM SDK
HPMicro Software Development Kit
hpm_pmon_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_PMON_DRV_H
9 #define HPM_PMON_DRV_H
10 #include "hpm_common.h"
11 #include "hpm_pmon_regs.h"
12 
13 #define PMON_EVENT_GLITCH0 (1U << 0)
14 #define PMON_EVENT_GLITCH1 (1U << 1)
15 #define PMON_EVENT_CLOCK0 (1U << 2)
16 #define PMON_EVENT_CLOCK1 (1U << 3)
17 
18 #ifdef __cplusplus
19 extern "C" {
20 #endif
21 
22 static inline void pmon_enable(PMON_Type *ptr,
23  uint8_t monitor_index,
24  bool enable)
25 {
26  ptr->MONITOR[monitor_index].CONTROL = (ptr->MONITOR[monitor_index].CONTROL
29 }
30 
31 static inline void pmon_select_glitch_mode(PMON_Type *ptr,
32  uint8_t monitor_index,
33  bool active_mode)
34 {
35  ptr->MONITOR[monitor_index].CONTROL = (ptr->MONITOR[monitor_index].CONTROL
37  | PMON_MONITOR_CONTROL_ACTIVE_SET(active_mode);
38 }
39 
40 static inline bool pmon_glich_detected(PMON_Type *ptr, uint8_t monitor_index)
41 {
42  return ptr->MONITOR[monitor_index].STATUS;
43 }
44 
45 static inline void pmon_test_mode_enable(PMON_Type *ptr, bool enable)
46 {
47  ptr->TEST_MODE = (ptr->TEST_MODE & ~PMON_TEST_MODE_DISABLE_MASK)
48  | PMON_TEST_MODE_DISABLE_SET(!enable);
49 }
50 
51 static inline void pmon_irq_enable(PMON_Type *ptr, uint32_t mask, bool enable)
52 {
53  ptr->IRQ_ENABLE = (ptr->IRQ_ENABLE & ~mask) | (enable ? mask : 0);
54 }
55 
56 static inline uint32_t pmon_irq_get_status(PMON_Type *ptr)
57 {
58  return ptr->IRQ_FLAG;
59 }
60 
61 #ifdef __cplusplus
62 }
63 #endif
64 
65 #endif /* HPM_PMON_DRV_H */
#define PMON_MONITOR_CONTROL_ACTIVE_MASK
Definition: hpm_pmon_regs.h:31
#define PMON_MONITOR_CONTROL_ENABLE_SET(x)
Definition: hpm_pmon_regs.h:45
#define PMON_MONITOR_CONTROL_ENABLE_MASK
Definition: hpm_pmon_regs.h:43
#define PMON_MONITOR_CONTROL_ACTIVE_SET(x)
Definition: hpm_pmon_regs.h:33
static void pmon_select_glitch_mode(PMON_Type *ptr, uint8_t monitor_index, bool active_mode)
Definition: hpm_pmon_drv.h:31
static bool pmon_glich_detected(PMON_Type *ptr, uint8_t monitor_index)
Definition: hpm_pmon_drv.h:40
static uint32_t pmon_irq_get_status(PMON_Type *ptr)
Definition: hpm_pmon_drv.h:56
static void pmon_irq_enable(PMON_Type *ptr, uint32_t mask, bool enable)
Definition: hpm_pmon_drv.h:51
static void pmon_test_mode_enable(PMON_Type *ptr, bool enable)
Definition: hpm_pmon_drv.h:45
static void pmon_enable(PMON_Type *ptr, uint8_t monitor_index, bool enable)
Definition: hpm_pmon_drv.h:22
Definition: hpm_pmon_regs.h:12
__RW uint32_t STATUS
Definition: hpm_pmon_regs.h:15
struct PMON_Type::@388 MONITOR[4]
__RW uint32_t CONTROL
Definition: hpm_pmon_regs.h:14
__RW uint32_t IRQ_ENABLE
Definition: hpm_pmon_regs.h:19
__RW uint32_t IRQ_FLAG
Definition: hpm_pmon_regs.h:18