]> begriffs open source - cmsis/blob - CMSIS/Driver/DriverTemplates/Driver_USBH.c
CMSIS-Driver: minor update of the USB Host driver template
[cmsis] / CMSIS / Driver / DriverTemplates / Driver_USBH.c
1 /*
2  * Copyright (c) 2013-2018 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_USBH.h"
20
21 /* USB Host Driver */
22
23 #define ARM_USBH_DRV_VERSION    ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0) /* driver version */
24
25 /* Driver Version */
26 static const ARM_DRIVER_VERSION usbh_driver_version = { 
27     ARM_USBH_API_VERSION,
28     ARM_USBH_DRV_VERSION
29 };
30
31 /* Driver Capabilities */
32 static const ARM_USBH_CAPABILITIES usbd_driver_capabilities = {
33     0x0001, /* Root HUB available Ports Mask   */
34     0,      /* Automatic SPLIT packet handling */
35     0,      /* Signal Connect event */
36     0,      /* Signal Disconnect event */
37     0       /* Signal Overcurrent event */
38 };
39
40 //
41 // Functions
42 //
43
44 static ARM_DRIVER_VERSION ARM_USBH_GetVersion(void)
45 {
46   return usbh_driver_version;
47 }
48
49 static ARM_USBH_CAPABILITIES ARM_USBH_GetCapabilities(void)
50 {
51   return usbd_driver_capabilities;
52 }
53
54 static int32_t ARM_USBH_Initialize(ARM_USBH_SignalPortEvent_t cb_port_event,
55                                    ARM_USBH_SignalPipeEvent_t cb_pipe_event)
56 {
57 }
58
59 static int32_t ARM_USBH_Uninitialize(void)
60 {
61 }
62
63 static int32_t ARM_USBH_PowerControl(ARM_POWER_STATE state)
64 {
65     switch (state)
66     {
67     case ARM_POWER_OFF:
68         break;
69
70     case ARM_POWER_LOW:
71         break;
72
73     case ARM_POWER_FULL:
74         break;
75
76     default:
77         return ARM_DRIVER_ERROR_UNSUPPORTED;
78     }
79 }
80
81 static int32_t ARM_USBH_PortVbusOnOff(uint8_t port, bool vbus)
82 {
83 }
84
85 static int32_t ARM_USBH_PortReset(uint8_t port)
86 {
87 }
88
89 static int32_t ARM_USBH_PortSuspend(uint8_t port)
90 {
91 }
92
93 static int32_t ARM_USBH_PortResume(uint8_t port)
94 {
95 }
96
97 static ARM_USBH_PORT_STATE ARM_USBH_PortGetState(uint8_t port)
98 {
99 }
100
101 static ARM_USBH_PIPE_HANDLE ARM_USBH_PipeCreate(uint8_t  dev_addr,
102                                                 uint8_t  dev_speed,
103                                                 uint8_t  hub_addr,
104                                                 uint8_t  hub_port,
105                                                 uint8_t  ep_addr,
106                                                 uint8_t  ep_type,
107                                                 uint16_t ep_max_packet_size,
108                                                 uint8_t  ep_interval)
109 {
110 }
111
112 static int32_t ARM_USBH_PipeModify(ARM_USBH_PIPE_HANDLE pipe_hndl,
113                             uint8_t  dev_addr,
114                             uint8_t  dev_speed,
115                             uint8_t  hub_addr,
116                             uint8_t  hub_port,
117                             uint16_t ep_max_packet_size)
118 {
119 }
120
121 static int32_t ARM_USBH_PipeDelete(ARM_USBH_PIPE_HANDLE pipe_hndl)
122 {
123 }
124
125 static int32_t ARM_USBH_PipeReset(ARM_USBH_PIPE_HANDLE pipe_hndl)
126 {
127 }
128
129 static int32_t ARM_USBH_PipeTransfer(ARM_USBH_PIPE_HANDLE pipe_hndl,
130                               uint32_t packet,
131                               uint8_t *data,
132                               uint32_t num)
133 {
134 }
135
136 static uint32_t ARM_USBH_PipeTransferGetResult(ARM_USBH_PIPE_HANDLE pipe_hndl)
137 {
138 }
139
140 static int32_t ARM_USBH_PipeTransferAbort(ARM_USBH_PIPE_HANDLE pipe_hndl)
141 {
142 }
143
144 static uint16_t ARM_USBH_GetFrameNumber(void)
145 {
146 }
147
148 static void ARM_USBH_SignalPortEvent(uint8_t port, uint32_t event)
149 {
150     // function body
151 }
152
153 static void ARM_USBH_SignalPipeEvent(ARM_USBH_PIPE_HANDLE pipe_hndl, uint32_t event)
154 {
155     // function body
156 }
157
158 // End USBH Interface
159
160 ARM_DRIVER_USBH Driver_USBH0 = {
161   ARM_USBH_GetVersion,
162   ARM_USBH_GetCapabilities,
163   ARM_USBH_Initialize,
164   ARM_USBH_Uninitialize,
165   ARM_USBH_PowerControl,
166   ARM_USBH_PortVbusOnOff,
167   ARM_USBH_PortReset,
168   ARM_USBH_PortSuspend,
169   ARM_USBH_PortResume,
170   ARM_USBH_PortGetState,
171   ARM_USBH_PipeCreate,
172   ARM_USBH_PipeModify,
173   ARM_USBH_PipeDelete,
174   ARM_USBH_PipeReset,
175   ARM_USBH_PipeTransfer,
176   ARM_USBH_PipeTransferGetResult,
177   ARM_USBH_PipeTransferAbort,
178   ARM_USBH_GetFrameNumber
179 };
180