2 * Copyright (c) 2013-2020 Arm Limited. All rights reserved.
4 * SPDX-License-Identifier: Apache-2.0
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
10 * www.apache.org/licenses/LICENSE-2.0
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.
19 #include "Driver_I2C.h"
21 #define ARM_I2C_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0) /* driver version */
24 static const ARM_DRIVER_VERSION DriverVersion = {
29 /* Driver Capabilities */
30 static const ARM_I2C_CAPABILITIES DriverCapabilities = {
31 0 /* supports 10-bit addressing */
38 static ARM_DRIVER_VERSION ARM_I2C_GetVersion(void)
43 static ARM_I2C_CAPABILITIES ARM_I2C_GetCapabilities(void)
45 return DriverCapabilities;
48 static int32_t ARM_I2C_Initialize(ARM_I2C_SignalEvent_t cb_event)
52 static int32_t ARM_I2C_Uninitialize(void)
56 static int32_t ARM_I2C_PowerControl(ARM_POWER_STATE state)
72 static int32_t ARM_I2C_MasterTransmit(uint32_t addr, const 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)
80 static int32_t ARM_I2C_SlaveTransmit(const uint8_t *data, uint32_t num)
84 static int32_t ARM_I2C_SlaveReceive(uint8_t *data, uint32_t num)
88 static int32_t ARM_I2C_GetDataCount(void)
92 static int32_t ARM_I2C_Control(uint32_t control, uint32_t arg)
96 case ARM_I2C_OWN_ADDRESS:
99 case ARM_I2C_BUS_SPEED:
102 case ARM_I2C_BUS_SPEED_STANDARD:
104 case ARM_I2C_BUS_SPEED_FAST:
106 case ARM_I2C_BUS_SPEED_FAST_PLUS:
109 return ARM_DRIVER_ERROR_UNSUPPORTED;
113 case ARM_I2C_BUS_CLEAR:
116 case ARM_I2C_ABORT_TRANSFER:
120 return ARM_DRIVER_ERROR_UNSUPPORTED;
124 static ARM_I2C_STATUS ARM_I2C_GetStatus(void)
128 static void ARM_I2C_SignalEvent(uint32_t event)
136 ARM_DRIVER_I2C Driver_I2C0;
137 ARM_DRIVER_I2C Driver_I2C0 = {
139 ARM_I2C_GetCapabilities,
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,