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_USBD.h"
21 #define ARM_USBD_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0) /* driver version */
24 static const ARM_DRIVER_VERSION usbd_driver_version = {
29 /* Driver Capabilities */
30 static const ARM_USBD_CAPABILITIES usbd_driver_capabilities = {
31 0, /* vbus_detection */
32 0, /* event_vbus_on */
33 0, /* event_vbus_off */
41 static ARM_DRIVER_VERSION ARM_USBD_GetVersion(void)
43 return usbd_driver_version;
46 static ARM_USBD_CAPABILITIES ARM_USBD_GetCapabilities(void)
48 return usbd_driver_capabilities;
51 static int32_t ARM_USBD_Initialize(ARM_USBD_SignalDeviceEvent_t cb_device_event,
52 ARM_USBD_SignalEndpointEvent_t cb_endpoint_event)
56 static int32_t ARM_USBD_Uninitialize(void)
60 static int32_t ARM_USBD_PowerControl(ARM_POWER_STATE state)
76 static int32_t ARM_USBD_DeviceConnect(void)
80 static int32_t ARM_USBD_DeviceDisconnect(void)
84 static ARM_USBD_STATE ARM_USBD_DeviceGetState(void)
88 static int32_t ARM_USBD_DeviceRemoteWakeup(void)
92 static int32_t ARM_USBD_DeviceSetAddress(uint8_t dev_addr)
96 static int32_t ARM_USBD_ReadSetupPacket(uint8_t *setup)
100 static int32_t ARM_USBD_EndpointConfigure(uint8_t ep_addr,
102 uint16_t ep_max_packet_size)
106 static int32_t ARM_USBD_EndpointUnconfigure(uint8_t ep_addr)
110 static int32_t ARM_USBD_EndpointStall(uint8_t ep_addr, bool stall)
114 static int32_t ARM_USBD_EndpointTransfer(uint8_t ep_addr, uint8_t *data, uint32_t num)
118 static uint32_t ARM_USBD_EndpointTransferGetResult(uint8_t ep_addr)
122 static int32_t ARM_USBD_EndpointTransferAbort(uint8_t ep_addr)
126 static uint16_t ARM_USBD_GetFrameNumber(void)
130 static void ARM_USBD_SignalDeviceEvent(uint32_t event)
135 static void ARM_USBD_SignalEndpointEvent(uint8_t ep_addr, uint32_t ep_event)
140 // End USBD Interface
143 ARM_DRIVER_USBD Driver_USBD0;
144 ARM_DRIVER_USBD Driver_USBD0 =
147 ARM_USBD_GetCapabilities,
149 ARM_USBD_Uninitialize,
150 ARM_USBD_PowerControl,
151 ARM_USBD_DeviceConnect,
152 ARM_USBD_DeviceDisconnect,
153 ARM_USBD_DeviceGetState,
154 ARM_USBD_DeviceRemoteWakeup,
155 ARM_USBD_DeviceSetAddress,
156 ARM_USBD_ReadSetupPacket,
157 ARM_USBD_EndpointConfigure,
158 ARM_USBD_EndpointUnconfigure,
159 ARM_USBD_EndpointStall,
160 ARM_USBD_EndpointTransfer,
161 ARM_USBD_EndpointTransferGetResult,
162 ARM_USBD_EndpointTransferAbort,
163 ARM_USBD_GetFrameNumber