1 /*
2  * Copyright (c) 2021 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef HPM_MONO_DRV_H
9 #define HPM_MONO_DRV_H
10 
11 #include "hpm_common.h"
12 #include "hpm_mono_regs.h"
13 
14 /**
15  *
16  * @brief MONO driver APIs
17  * @defgroup mono_interface MONO driver APIs
18  * @ingroup io_interfaces
19  * @{
20  */
21 
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /**
28  * @brief   Get counter
29  *
30  * @param[in] ptr MONO base address
31  *
32  * @return 64 bits counter value
33  */
mono_get_counter(MONO_Type * ptr)34 static inline uint64_t mono_get_counter(MONO_Type *ptr)
35 {
36     return (uint64_t)((uint64_t)((ptr->MONOH) << 32))
37         | (uint64_t)((ptr->MONOL));
38 }
39 
40 /**
41  * @brief   Update MONO counter by 1
42  *
43  * @param[in] ptr MONO base
44  */
mono_update(MONO_Type * ptr)45 static inline void mono_update(MONO_Type *ptr)
46 {
47     ptr->MONOL = 1;
48 }
49 
50 #ifdef __cplusplus
51 }
52 #endif
53 /**
54  * @}
55  */
56 #endif /* HPM_MONO_DRV_H */
57 
58