2 * Copyright (c) 2013-2016 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_SPI.h"
21 #define ARM_SPI_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(2, 0) /* driver version */
24 static const ARM_DRIVER_VERSION DriverVersion = {
29 /* Driver Capabilities */
30 static const ARM_SPI_CAPABILITIES DriverCapabilities = {
31 1, /* Simplex Mode (Master and Slave) */
32 1, /* TI Synchronous Serial Interface */
33 1, /* Microwire Interface */
34 0 /* Signal Mode Fault event: \ref ARM_SPI_EVENT_MODE_FAULT */
41 ARM_DRIVER_VERSION ARM_SPI_GetVersion(void)
45 ARM_SPI_CAPABILITIES ARM_SPI_GetCapabilities(void)
49 int32_t ARM_SPI_Initialize(ARM_SPI_SignalEvent_t cb_event)
53 int32_t ARM_SPI_Uninitialize(void)
57 int32_t ARM_SPI_PowerControl(ARM_POWER_STATE state)
71 return ARM_DRIVER_ERROR_UNSUPPORTED;
75 int32_t ARM_SPI_Send(const void *data, uint32_t num)
79 int32_t ARM_SPI_Receive(void *data, uint32_t num)
83 int32_t ARM_SPI_Transfer(const void *data_out, void *data_in, uint32_t num)
87 uint32_t ARM_SPI_GetDataCount(void)
91 int32_t ARM_SPI_Control(uint32_t control, uint32_t arg)
93 switch (control & ARM_SPI_CONTROL_Msk)
96 return ARM_DRIVER_ERROR_UNSUPPORTED;
98 case ARM_SPI_MODE_INACTIVE: // SPI Inactive
101 case ARM_SPI_MODE_MASTER: // SPI Master (Output on MOSI, Input on MISO); arg = Bus Speed in bps
104 case ARM_SPI_MODE_SLAVE: // SPI Slave (Output on MISO, Input on MOSI)
107 case ARM_SPI_MODE_MASTER_SIMPLEX: // SPI Master (Output/Input on MOSI); arg = Bus Speed in bps
108 case ARM_SPI_MODE_SLAVE_SIMPLEX: // SPI Slave (Output/Input on MISO)
109 return ARM_SPI_ERROR_MODE;
111 case ARM_SPI_SET_BUS_SPEED: // Set Bus Speed in bps; arg = value
114 case ARM_SPI_GET_BUS_SPEED: // Get Bus Speed in bps
117 case ARM_SPI_SET_DEFAULT_TX_VALUE: // Set default Transmit value; arg = value
120 case ARM_SPI_CONTROL_SS: // Control Slave Select; arg = 0:inactive, 1:active
123 case ARM_SPI_ABORT_TRANSFER: // Abort current data transfer
128 ARM_SPI_STATUS ARM_SPI_GetStatus(void)
132 void ARM_SPI_SignalEvent(uint32_t event)
139 ARM_DRIVER_SPI Driver_SPI = {
141 ARM_SPI_GetCapabilities,
143 ARM_SPI_Uninitialize,
144 ARM_SPI_PowerControl,
148 ARM_SPI_GetDataCount,