HPM SDK
HPMicro Software Development Kit
hpm_synt_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_SYNT_DRV_H
9 #define HPM_SYNT_DRV_H
10 #include "hpm_common.h"
11 #include "hpm_synt_regs.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 static inline void synt_enable_counter(SYNT_Type *ptr, bool enable)
18 {
19  ptr->GCR = (ptr->GCR & ~(SYNT_GCR_CEN_MASK)) | SYNT_GCR_CEN_SET(enable);
20 }
21 
22 static inline void synt_reset_counter(SYNT_Type *ptr)
23 {
24  ptr->GCR |= SYNT_GCR_CRST_MASK;
25  ptr->GCR &= ~SYNT_GCR_CRST_MASK;
26 }
27 
29  uint8_t cmp_index,
30  uint32_t count)
31 {
32  if (cmp_index > SYNT_CMP_3) {
34  }
35  ptr->CMP[cmp_index] = SYNT_CMP_CMP_SET(count);
36  return status_success;
37 }
38 
39 static inline void synt_set_reload(SYNT_Type *ptr, uint32_t reload_count)
40 {
41  ptr->RLD = SYNT_RLD_RLD_SET(reload_count);
42 }
43 
44 static inline uint32_t synt_get_current_count(SYNT_Type *ptr)
45 {
46  return (ptr->CNT & SYNT_CNT_CNT_MASK) >> SYNT_CNT_CNT_SHIFT;
47 }
48 
49 #if defined(SYNT_SOC_HAS_TIMESTAMP) && SYNT_SOC_HAS_TIMESTAMP
50 
51 static inline void synt_enable_timestamp(SYNT_Type *ptr, bool enable)
52 {
54 }
55 
56 static inline void synt_enable_timestamp_debug_stop(SYNT_Type *ptr, bool enable)
57 {
59 }
60 
61 static inline void synt_reset_timestamp(SYNT_Type *ptr)
62 {
64 }
65 
66 static inline void synt_update_timestamp_new(SYNT_Type *ptr)
67 {
69 }
70 
71 static inline void synt_update_timestamp_dec(SYNT_Type *ptr)
72 {
74 }
75 
76 static inline void synt_update_timestamp_inc(SYNT_Type *ptr)
77 {
79 }
80 
81 static inline void synt_set_timestamp_new_value(SYNT_Type *ptr, uint32_t new_value)
82 {
84 }
85 
86 static inline uint32_t synt_get_timestamp_save_value(SYNT_Type *ptr)
87 {
89 }
90 
91 static inline uint32_t synt_get_timestamp_current_value(SYNT_Type *ptr)
92 {
94 }
95 
96 #endif
97 
98 #ifdef __cplusplus
99 }
100 #endif
101 
102 #endif /* HPM_SYNT_DRV_H */
#define SYNT_GCR_TIMESTAMP_ENABLE_MASK
Definition: hpm_synt_regs.h:80
#define SYNT_GCR_TIMESTAMP_SET_NEW_MASK
Definition: hpm_synt_regs.h:50
#define SYNT_GCR_CRST_MASK
Definition: hpm_synt_regs.h:100
#define SYNT_GCR_TIMESTAMP_DEBUG_EN_SET(x)
Definition: hpm_synt_regs.h:72
#define SYNT_TIMESTAMP_SAV_VALUE_GET(x)
Definition: hpm_synt_regs.h:155
#define SYNT_RLD_RLD_SET(x)
Definition: hpm_synt_regs.h:123
#define SYNT_CMP_CMP_SET(x)
Definition: hpm_synt_regs.h:175
#define SYNT_GCR_TIMESTAMP_DEC_NEW_MASK
Definition: hpm_synt_regs.h:40
#define SYNT_CNT_CNT_MASK
Definition: hpm_synt_regs.h:143
#define SYNT_GCR_TIMESTAMP_INC_NEW_MASK
Definition: hpm_synt_regs.h:30
#define SYNT_CNT_CNT_SHIFT
Definition: hpm_synt_regs.h:144
#define SYNT_GCR_CEN_MASK
Definition: hpm_synt_regs.h:110
#define SYNT_TIMESTAMP_NEW_VALUE_SET(x)
Definition: hpm_synt_regs.h:134
#define SYNT_CMP_3
Definition: hpm_synt_regs.h:184
#define SYNT_GCR_TIMESTAMP_ENABLE_SET(x)
Definition: hpm_synt_regs.h:82
#define SYNT_GCR_TIMESTAMP_RESET_MASK
Definition: hpm_synt_regs.h:60
#define SYNT_TIMESTAMP_CUR_VALUE_GET(x)
Definition: hpm_synt_regs.h:165
#define SYNT_GCR_CEN_SET(x)
Definition: hpm_synt_regs.h:112
#define SYNT_GCR_TIMESTAMP_DEBUG_EN_MASK
Definition: hpm_synt_regs.h:70
uint32_t hpm_stat_t
Definition: hpm_common.h:126
@ status_invalid_argument
Definition: hpm_common.h:182
@ status_success
Definition: hpm_common.h:180
static hpm_stat_t synt_set_comparator(SYNT_Type *ptr, uint8_t cmp_index, uint32_t count)
Definition: hpm_synt_drv.h:28
static void synt_reset_counter(SYNT_Type *ptr)
Definition: hpm_synt_drv.h:22
static void synt_enable_counter(SYNT_Type *ptr, bool enable)
Definition: hpm_synt_drv.h:17
static void synt_set_reload(SYNT_Type *ptr, uint32_t reload_count)
Definition: hpm_synt_drv.h:39
static uint32_t synt_get_current_count(SYNT_Type *ptr)
Definition: hpm_synt_drv.h:44
Definition: hpm_synt_regs.h:12
__RW uint32_t GCR
Definition: hpm_synt_regs.h:13
__R uint32_t TIMESTAMP_SAV
Definition: hpm_synt_regs.h:17
__R uint32_t CNT
Definition: hpm_synt_regs.h:16
__RW uint32_t CMP[4]
Definition: hpm_synt_regs.h:20
__R uint32_t TIMESTAMP_CUR
Definition: hpm_synt_regs.h:18
__RW uint32_t RLD
Definition: hpm_synt_regs.h:14
__RW uint32_t TIMESTAMP_NEW
Definition: hpm_synt_regs.h:15