• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022 FuZhou Lockzhiner Electronic Co., Ltd. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 /**
17  * @addtogroup Lockzhiner
18  *
19  * @file device.h
20  *
21  */
22 #ifndef LZ_HARDWARE_DEVICE_H
23 #define LZ_HARDWARE_DEVICE_H
24 
25 #include "lz_hardware/pinctrl.h"
26 
27 typedef struct _DevIo {
28     /** Interrupt gpio for this device; INVALID_GPIO if not used */
29     Pinctrl isr;
30     /** Reset gpio for this device; INVALID_GPIO if not used */
31     Pinctrl rst;
32     /** Controller gpio for this device; INVALID_GPIO if not used */
33     Pinctrl ctrl1;
34     /** Controller gpio for this device; INVALID_GPIO if not used */
35     Pinctrl ctrl2;
36 } DevIo;
37 
38 typedef struct _SpiBusIo {
39     Pinctrl cs;
40     Pinctrl clk;
41     Pinctrl mosi;
42     Pinctrl miso;
43     FuncID id;
44     FuncMode mode;
45 } SpiBusIo;
46 
47 typedef struct _I2cBusIo {
48     Pinctrl scl;
49     Pinctrl sda;
50     FuncID id;
51     FuncMode mode;
52 } I2cBusIo;
53 
54 typedef struct _UartBusIo {
55     Pinctrl tx;
56     Pinctrl rx;
57     Pinctrl ctsn;
58     Pinctrl rtsn;
59     FuncID id;
60     FuncMode mode;
61 } UartBusIo;
62 
63 typedef struct _PwmBusIo {
64     Pinctrl pwm;
65     FuncID id;
66     FuncMode mode;
67 } PwmBusIo;
68 
69 unsigned int DevIoInit(DevIo io);
70 unsigned int SpiIoInit(SpiBusIo io);
71 unsigned int I2cIoInit(I2cBusIo io);
72 unsigned int UartIoInit(UartBusIo io);
73 unsigned int PwmIoInit(PwmBusIo io);
74 
75 #endif