2 * Copyright (c) 2013-2024 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_USBH.h"
23 #define ARM_USBH_DRV_VERSION ARM_DRIVER_VERSION_MAJOR_MINOR(1, 0) /* driver version */
26 static const ARM_DRIVER_VERSION usbh_driver_version = {
31 /* Driver Capabilities */
32 static const ARM_USBH_CAPABILITIES usbh_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 0 /* Reserved (must be zero) */
45 static ARM_DRIVER_VERSION ARM_USBH_GetVersion(void)
47 return usbh_driver_version;
50 static ARM_USBH_CAPABILITIES ARM_USBH_GetCapabilities(void)
52 return usbh_driver_capabilities;
55 static int32_t ARM_USBH_Initialize(ARM_USBH_SignalPortEvent_t cb_port_event,
56 ARM_USBH_SignalPipeEvent_t cb_pipe_event)
60 static int32_t ARM_USBH_Uninitialize(void)
64 static int32_t ARM_USBH_PowerControl(ARM_POWER_STATE state)
80 static int32_t ARM_USBH_PortVbusOnOff(uint8_t port, bool vbus)
84 static int32_t ARM_USBH_PortReset(uint8_t port)
88 static int32_t ARM_USBH_PortSuspend(uint8_t port)
92 static int32_t ARM_USBH_PortResume(uint8_t port)
96 static ARM_USBH_PORT_STATE ARM_USBH_PortGetState(uint8_t port)
100 static ARM_USBH_PIPE_HANDLE ARM_USBH_PipeCreate(uint8_t dev_addr,
106 uint16_t ep_max_packet_size,
111 static int32_t ARM_USBH_PipeModify(ARM_USBH_PIPE_HANDLE pipe_hndl,
116 uint16_t ep_max_packet_size)
120 static int32_t ARM_USBH_PipeDelete(ARM_USBH_PIPE_HANDLE pipe_hndl)
124 static int32_t ARM_USBH_PipeReset(ARM_USBH_PIPE_HANDLE pipe_hndl)
128 static int32_t ARM_USBH_PipeTransfer(ARM_USBH_PIPE_HANDLE pipe_hndl,
135 static uint32_t ARM_USBH_PipeTransferGetResult(ARM_USBH_PIPE_HANDLE pipe_hndl)
139 static int32_t ARM_USBH_PipeTransferAbort(ARM_USBH_PIPE_HANDLE pipe_hndl)
143 static uint16_t ARM_USBH_GetFrameNumber(void)
147 static void ARM_USBH_SignalPortEvent(uint8_t port, uint32_t event)
152 static void ARM_USBH_SignalPipeEvent(ARM_USBH_PIPE_HANDLE pipe_hndl, uint32_t event)
157 // End USBH Interface
160 ARM_DRIVER_USBH Driver_USBH0;
161 ARM_DRIVER_USBH Driver_USBH0 = {
163 ARM_USBH_GetCapabilities,
165 ARM_USBH_Uninitialize,
166 ARM_USBH_PowerControl,
167 ARM_USBH_PortVbusOnOff,
169 ARM_USBH_PortSuspend,
171 ARM_USBH_PortGetState,
176 ARM_USBH_PipeTransfer,
177 ARM_USBH_PipeTransferGetResult,
178 ARM_USBH_PipeTransferAbort,
179 ARM_USBH_GetFrameNumber