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_SPI.h"
20 
21 #define ARM_SPI_DRV_VERSION    ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0) /* driver version */
22 
23 /* Driver Version */
24 static const ARM_DRIVER_VERSION DriverVersion = {
25     ARM_SPI_API_VERSION,
26     ARM_SPI_DRV_VERSION
27 };
28 
29 /* Driver Capabilities */
30 static const ARM_SPI_CAPABILITIES DriverCapabilities = {
31     0, /* Reserved (must be zero) */
32     0, /* TI Synchronous Serial Interface */
33     0, /* Microwire Interface */
34     0, /* Signal Mode Fault event: \ref ARM_SPI_EVENT_MODE_FAULT */
35     0  /* Reserved (must be zero) */
36 };
37 
38 //
39 //  Functions
40 //
41 
ARM_SPI_GetVersion(void)42 static ARM_DRIVER_VERSION ARM_SPI_GetVersion(void)
43 {
44   return DriverVersion;
45 }
46 
ARM_SPI_GetCapabilities(void)47 static ARM_SPI_CAPABILITIES ARM_SPI_GetCapabilities(void)
48 {
49   return DriverCapabilities;
50 }
51 
ARM_SPI_Initialize(ARM_SPI_SignalEvent_t cb_event)52 static int32_t ARM_SPI_Initialize(ARM_SPI_SignalEvent_t cb_event)
53 {
54 }
55 
ARM_SPI_Uninitialize(void)56 static int32_t ARM_SPI_Uninitialize(void)
57 {
58 }
59 
ARM_SPI_PowerControl(ARM_POWER_STATE state)60 static int32_t ARM_SPI_PowerControl(ARM_POWER_STATE state)
61 {
62     switch (state)
63     {
64     case ARM_POWER_OFF:
65         break;
66 
67     case ARM_POWER_LOW:
68         break;
69 
70     case ARM_POWER_FULL:
71         break;
72     }
73     return ARM_DRIVER_OK;
74 }
75 
ARM_SPI_Send(const void * data,uint32_t num)76 static int32_t ARM_SPI_Send(const void *data, uint32_t num)
77 {
78 }
79 
ARM_SPI_Receive(void * data,uint32_t num)80 static int32_t ARM_SPI_Receive(void *data, uint32_t num)
81 {
82 }
83 
ARM_SPI_Transfer(const void * data_out,void * data_in,uint32_t num)84 static int32_t ARM_SPI_Transfer(const void *data_out, void *data_in, uint32_t num)
85 {
86 }
87 
ARM_SPI_GetDataCount(void)88 static uint32_t ARM_SPI_GetDataCount(void)
89 {
90 }
91 
ARM_SPI_Control(uint32_t control,uint32_t arg)92 static int32_t ARM_SPI_Control(uint32_t control, uint32_t arg)
93 {
94     switch (control & ARM_SPI_CONTROL_Msk)
95     {
96     default:
97         return ARM_DRIVER_ERROR_UNSUPPORTED;
98 
99     case ARM_SPI_MODE_INACTIVE:             // SPI Inactive
100         return ARM_DRIVER_OK;
101 
102     case ARM_SPI_MODE_MASTER:               // SPI Master (Output on MOSI, Input on MISO); arg = Bus Speed in bps
103         break;
104 
105     case ARM_SPI_MODE_SLAVE:                // SPI Slave  (Output on MISO, Input on MOSI)
106         break;
107 
108     case ARM_SPI_SET_BUS_SPEED:             // Set Bus Speed in bps; arg = value
109         break;
110 
111     case ARM_SPI_GET_BUS_SPEED:             // Get Bus Speed in bps
112         break;
113 
114     case ARM_SPI_SET_DEFAULT_TX_VALUE:      // Set default Transmit value; arg = value
115         break;
116 
117     case ARM_SPI_CONTROL_SS:                // Control Slave Select; arg = 0:inactive, 1:active
118         break;
119 
120     case ARM_SPI_ABORT_TRANSFER:            // Abort current data transfer
121         break;
122     }
123 }
124 
ARM_SPI_GetStatus(void)125 static ARM_SPI_STATUS ARM_SPI_GetStatus(void)
126 {
127 }
128 
ARM_SPI_SignalEvent(uint32_t event)129 static void ARM_SPI_SignalEvent(uint32_t event)
130 {
131     // function body
132 }
133 
134 // End SPI Interface
135 
136 extern \
137 ARM_DRIVER_SPI Driver_SPI0;
138 ARM_DRIVER_SPI Driver_SPI0 = {
139     ARM_SPI_GetVersion,
140     ARM_SPI_GetCapabilities,
141     ARM_SPI_Initialize,
142     ARM_SPI_Uninitialize,
143     ARM_SPI_PowerControl,
144     ARM_SPI_Send,
145     ARM_SPI_Receive,
146     ARM_SPI_Transfer,
147     ARM_SPI_GetDataCount,
148     ARM_SPI_Control,
149     ARM_SPI_GetStatus
150 };
151