• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3  *
4  * HDF is dual licensed: you can use it either under the terms of
5  * the GPL, or the BSD license, at your option.
6  * See the LICENSE file in the root of this repository for complete details.
7  */
8 
9 #include "pin_if.h"
10 #include "pin_core.h"
11 #include "hdf_log.h"
12 
13 #define HDF_LOG_TAG pin_if
14 
PinGet(const char * pinName)15 DevHandle PinGet(const char *pinName)
16 {
17     return (DevHandle)PinCntlrGetPinDescByName(pinName);
18 }
19 
PinPut(DevHandle handle)20 void PinPut(DevHandle handle)
21 {
22     if (handle == NULL) {
23         HDF_LOGE("PinPut: handle is null!");
24         return;
25     }
26     return PinCntlrPutPin((struct PinDesc *)handle);
27 }
28 
PinSetPull(DevHandle handle,enum PinPullType pullType)29 int32_t PinSetPull(DevHandle handle, enum PinPullType pullType)
30 {
31     struct PinCntlr *cntlr = NULL;
32 
33     if (handle == NULL) {
34         HDF_LOGE("PinSetPull: handle is null!");
35         return HDF_ERR_INVALID_PARAM;
36     }
37 
38     cntlr = PinCntlrGetByPin((struct PinDesc *)handle);
39     return PinCntlrSetPinPull(cntlr, (struct PinDesc *)handle, pullType);
40 }
41 
PinGetPull(DevHandle handle,enum PinPullType * pullType)42 int32_t PinGetPull(DevHandle handle, enum PinPullType *pullType)
43 {
44     struct PinCntlr *cntlr = NULL;
45 
46     if (handle == NULL || pullType == NULL) {
47         HDF_LOGE("PinGetPull: handle or pullType is null!");
48         return HDF_ERR_INVALID_PARAM;
49     }
50 
51     cntlr = PinCntlrGetByPin((struct PinDesc *)handle);
52     return PinCntlrGetPinPull(cntlr, (struct PinDesc *)handle, pullType);
53 }
54 
PinSetStrength(DevHandle handle,uint32_t strength)55 int32_t PinSetStrength(DevHandle handle, uint32_t strength)
56 {
57     struct PinCntlr *cntlr = NULL;
58 
59     if (handle == NULL) {
60         HDF_LOGE("PinSetStrength: handle is null!");
61         return HDF_ERR_INVALID_PARAM;
62     }
63 
64     cntlr = PinCntlrGetByPin((struct PinDesc *)handle);
65     return PinCntlrSetPinStrength(cntlr, (struct PinDesc *)handle, strength);
66 }
67 
PinGetStrength(DevHandle handle,uint32_t * strength)68 int32_t PinGetStrength(DevHandle handle, uint32_t *strength)
69 {
70     struct PinCntlr *cntlr = NULL;
71 
72     if (handle == NULL || strength == NULL) {
73         HDF_LOGE("PinGetStrength: handle or strength is null!");
74         return HDF_ERR_INVALID_PARAM;
75     }
76 
77     cntlr = PinCntlrGetByPin((struct PinDesc *)handle);
78     return PinCntlrGetPinStrength(cntlr, (struct PinDesc *)handle, strength);
79 }
80 
PinSetFunc(DevHandle handle,const char * funcName)81 int32_t PinSetFunc(DevHandle handle, const char *funcName)
82 {
83     struct PinCntlr *cntlr = NULL;
84 
85     if (handle == NULL || funcName == NULL) {
86         HDF_LOGE("PinSetFunc: handle or funcName is null!");
87         return HDF_ERR_INVALID_PARAM;
88     }
89 
90     cntlr = PinCntlrGetByPin((struct PinDesc *)handle);
91     return PinCntlrSetPinFunc(cntlr, (struct PinDesc *)handle, funcName);
92 }
93 
PinGetFunc(DevHandle handle,const char ** funcName)94 int32_t PinGetFunc(DevHandle handle, const char **funcName)
95 {
96     struct PinCntlr *cntlr = NULL;
97 
98     if (handle == NULL || funcName == NULL) {
99         HDF_LOGE("PinGetFunc: handle or funcName is null!");
100         return HDF_ERR_INVALID_PARAM;
101     }
102 
103     cntlr = PinCntlrGetByPin((struct PinDesc *)handle);
104     return PinCntlrGetPinFunc(cntlr, (struct PinDesc *)handle, funcName);
105 }