1 /*
2 * Copyright (c) 2013-2020 Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Licensed under the Apache License, Version 2.0 (the License); you may
7 * not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an AS IS BASIS, WITHOUT
14 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 #include "Driver_I2C.h"
20
21 #define ARM_I2C_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0) /* driver version */
22
23 /* Driver Version */
24 static const ARM_DRIVER_VERSION DriverVersion = {
25 ARM_I2C_API_VERSION,
26 ARM_I2C_DRV_VERSION
27 };
28
29 /* Driver Capabilities */
30 static const ARM_I2C_CAPABILITIES DriverCapabilities = {
31 0 /* supports 10-bit addressing */
32 };
33
34 //
35 // Functions
36 //
37
ARM_I2C_GetVersion(void)38 static ARM_DRIVER_VERSION ARM_I2C_GetVersion(void)
39 {
40 return DriverVersion;
41 }
42
ARM_I2C_GetCapabilities(void)43 static ARM_I2C_CAPABILITIES ARM_I2C_GetCapabilities(void)
44 {
45 return DriverCapabilities;
46 }
47
ARM_I2C_Initialize(ARM_I2C_SignalEvent_t cb_event)48 static int32_t ARM_I2C_Initialize(ARM_I2C_SignalEvent_t cb_event)
49 {
50 }
51
ARM_I2C_Uninitialize(void)52 static int32_t ARM_I2C_Uninitialize(void)
53 {
54 }
55
ARM_I2C_PowerControl(ARM_POWER_STATE state)56 static int32_t ARM_I2C_PowerControl(ARM_POWER_STATE state)
57 {
58 switch (state)
59 {
60 case ARM_POWER_OFF:
61 break;
62
63 case ARM_POWER_LOW:
64 break;
65
66 case ARM_POWER_FULL:
67 break;
68 }
69 return ARM_DRIVER_OK;
70 }
71
ARM_I2C_MasterTransmit(uint32_t addr,const uint8_t * data,uint32_t num,bool xfer_pending)72 static int32_t ARM_I2C_MasterTransmit(uint32_t addr, const uint8_t *data, uint32_t num, bool xfer_pending)
73 {
74 }
75
ARM_I2C_MasterReceive(uint32_t addr,uint8_t * data,uint32_t num,bool xfer_pending)76 static int32_t ARM_I2C_MasterReceive(uint32_t addr, uint8_t *data, uint32_t num, bool xfer_pending)
77 {
78 }
79
ARM_I2C_SlaveTransmit(const uint8_t * data,uint32_t num)80 static int32_t ARM_I2C_SlaveTransmit(const uint8_t *data, uint32_t num)
81 {
82 }
83
ARM_I2C_SlaveReceive(uint8_t * data,uint32_t num)84 static int32_t ARM_I2C_SlaveReceive(uint8_t *data, uint32_t num)
85 {
86 }
87
ARM_I2C_GetDataCount(void)88 static int32_t ARM_I2C_GetDataCount(void)
89 {
90 }
91
ARM_I2C_Control(uint32_t control,uint32_t arg)92 static int32_t ARM_I2C_Control(uint32_t control, uint32_t arg)
93 {
94 switch (control)
95 {
96 case ARM_I2C_OWN_ADDRESS:
97 break;
98
99 case ARM_I2C_BUS_SPEED:
100 switch (arg)
101 {
102 case ARM_I2C_BUS_SPEED_STANDARD:
103 break;
104 case ARM_I2C_BUS_SPEED_FAST:
105 break;
106 case ARM_I2C_BUS_SPEED_FAST_PLUS:
107 break;
108 default:
109 return ARM_DRIVER_ERROR_UNSUPPORTED;
110 }
111 break;
112
113 case ARM_I2C_BUS_CLEAR:
114 break;
115
116 case ARM_I2C_ABORT_TRANSFER:
117 break;
118
119 default:
120 return ARM_DRIVER_ERROR_UNSUPPORTED;
121 }
122 }
123
ARM_I2C_GetStatus(void)124 static ARM_I2C_STATUS ARM_I2C_GetStatus(void)
125 {
126 }
127
ARM_I2C_SignalEvent(uint32_t event)128 static void ARM_I2C_SignalEvent(uint32_t event)
129 {
130 // function body
131 }
132
133 // End I2C Interface
134
135 extern \
136 ARM_DRIVER_I2C Driver_I2C0;
137 ARM_DRIVER_I2C Driver_I2C0 = {
138 ARM_I2C_GetVersion,
139 ARM_I2C_GetCapabilities,
140 ARM_I2C_Initialize,
141 ARM_I2C_Uninitialize,
142 ARM_I2C_PowerControl,
143 ARM_I2C_MasterTransmit,
144 ARM_I2C_MasterReceive,
145 ARM_I2C_SlaveTransmit,
146 ARM_I2C_SlaveReceive,
147 ARM_I2C_GetDataCount,
148 ARM_I2C_Control,
149 ARM_I2C_GetStatus
150 };
151