HPM SDK
HPMicro Software Development Kit
hpm_bgpr_drv.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2023 HPMicro
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  *
6  */
7 
8 #ifndef HPM_BGPR_DRV_H
9 #define HPM_BGPR_DRV_H
10 
11 #include "hpm_common.h"
12 #include "hpm_soc_feature.h"
13 #include "hpm_bgpr_regs.h"
14 
23 #if defined(__cplusplus)
24 extern "C" {
25 #endif /* __cplusplus */
26 
38 static inline hpm_stat_t bgpr_read32(BGPR_Type *ptr, uint8_t bgpr_index, uint32_t *bgpr_val)
39 {
41  uint8_t gpr_count = sizeof(ptr->GPR) / sizeof(uint32_t);
42  if (bgpr_index < gpr_count) {
43  (*bgpr_val) = ptr->GPR[bgpr_index];
44  stat = status_success;
45  }
46  return stat;
47 }
48 
60 static inline hpm_stat_t bgpr_write32(BGPR_Type *ptr, uint8_t bgpr_index, uint32_t bgpr_val)
61 {
63  uint8_t gpr_count = sizeof(ptr->GPR) / sizeof(uint32_t);
64  if (bgpr_index < gpr_count) {
65  ptr->GPR[bgpr_index] = bgpr_val;
66  stat = status_success;
67  }
68  return stat;
69 }
70 
75 #if defined(__cplusplus)
76 }
77 #endif /* __cplusplus */
78 #endif
static hpm_stat_t bgpr_read32(BGPR_Type *ptr, uint8_t bgpr_index, uint32_t *bgpr_val)
read BGPR value
Definition: hpm_bgpr_drv.h:38
static hpm_stat_t bgpr_write32(BGPR_Type *ptr, uint8_t bgpr_index, uint32_t bgpr_val)
write BGPR value
Definition: hpm_bgpr_drv.h:60
uint32_t hpm_stat_t
Definition: hpm_common.h:123
@ status_invalid_argument
Definition: hpm_common.h:179
@ status_success
Definition: hpm_common.h:177
Definition: hpm_bgpr_regs.h:12
__RW uint32_t GPR[8]
Definition: hpm_bgpr_regs.h:13