HPM SDK
HPMicro Software Development Kit
hpm_mchtmr_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_MCHTMR_DRV_H
9 #define HPM_MCHTMR_DRV_H
10 #include "hpm_common.h"
11 #include "hpm_mchtmr_regs.h"
12 
20 #ifdef __cplusplus
21 extern "C" {
22 #endif
23 
29 static inline uint64_t mchtmr_get_count(MCHTMR_Type *ptr)
30 {
32 }
33 
40 static inline void mchtmr_set_compare_value(MCHTMR_Type *ptr, uint64_t target)
41 {
43 }
44 
51 static inline void mchtmr_delay(MCHTMR_Type *ptr, uint64_t delay)
52 {
53  mchtmr_set_compare_value(ptr, mchtmr_get_count(ptr) + delay);
54 }
55 
62 void mchtmr_init_counter(MCHTMR_Type *ptr, uint64_t v);
63 
67 #ifdef __cplusplus
68 }
69 #endif
70 #endif /* HPM_MCHTMR_DRV_H */
#define MCHTMR_MTIME_MTIME_SHIFT
Definition: hpm_mchtmr_regs.h:25
#define MCHTMR_MTIME_MTIME_MASK
Definition: hpm_mchtmr_regs.h:24
#define MCHTMR_MTIMECMP_MTIMECMP_SET(x)
Definition: hpm_mchtmr_regs.h:37
static uint64_t mchtmr_get_count(MCHTMR_Type *ptr)
mchtmr get counter value
Definition: hpm_mchtmr_drv.h:29
void mchtmr_init_counter(MCHTMR_Type *ptr, uint64_t v)
initialize mchtmr counter
Definition: hpm_mchtmr_drv.c:10
static void mchtmr_set_compare_value(MCHTMR_Type *ptr, uint64_t target)
mchtmr set comparator value
Definition: hpm_mchtmr_drv.h:40
static void mchtmr_delay(MCHTMR_Type *ptr, uint64_t delay)
mchtmr set delay value
Definition: hpm_mchtmr_drv.h:51
Definition: hpm_mchtmr_regs.h:12
__RW uint64_t MTIME
Definition: hpm_mchtmr_regs.h:13
__RW uint64_t MTIMECMP
Definition: hpm_mchtmr_regs.h:14