Zephyr API Documentation 4.0.0
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
usbh.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2022 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
14#ifndef ZEPHYR_INCLUDE_USBH_H_
15#define ZEPHYR_INCLUDE_USBH_H_
16
17#include <stdint.h>
18#include <zephyr/device.h>
19#include <zephyr/net_buf.h>
20#include <zephyr/sys/dlist.h>
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
40 const char *name;
42 struct k_mutex mutex;
44 const struct device *dev;
47};
48
49#define USBH_CONTROLLER_DEFINE(device_name, uhc_dev) \
50 static STRUCT_SECTION_ITERABLE(usbh_contex, device_name) = { \
51 .name = STRINGIFY(device_name), \
52 .mutex = Z_MUTEX_INITIALIZER(device_name.mutex), \
53 .dev = uhc_dev, \
54 }
55
67
74
76 /* int (*init)(struct usbh_contex *const uhs_ctx); */
78 int (*request)(struct usbh_contex *const uhs_ctx,
79 struct uhc_transfer *const xfer, int err);
81 int (*connected)(struct usbh_contex *const uhs_ctx);
83 int (*removed)(struct usbh_contex *const uhs_ctx);
85 int (*rwup)(struct usbh_contex *const uhs_ctx);
87 int (*suspended)(struct usbh_contex *const uhs_ctx);
89 int (*resumed)(struct usbh_contex *const uhs_ctx);
90};
91
94#define USBH_DEFINE_CLASS(name) \
95 static STRUCT_SECTION_ITERABLE(usbh_class_data, name)
96
97
105int usbh_init(struct usbh_contex *uhs_ctx);
106
116int usbh_enable(struct usbh_contex *uhs_ctx);
117
127int usbh_disable(struct usbh_contex *uhs_ctx);
128
138int usbh_shutdown(struct usbh_contex *const uhs_ctx);
139
144#ifdef __cplusplus
145}
146#endif
147
148#endif /* ZEPHYR_INCLUDE_USBH_H_ */
struct _dnode sys_dlist_t
Doubly-linked list structure.
Definition dlist.h:50
int usbh_shutdown(struct usbh_contex *const uhs_ctx)
Shutdown the USB host support.
int usbh_disable(struct usbh_contex *uhs_ctx)
Disable the USB host support.
int usbh_init(struct usbh_contex *uhs_ctx)
Initialize the USB host support;.
int usbh_enable(struct usbh_contex *uhs_ctx)
Enable the USB host support and class instances.
Buffer management.
__UINT8_TYPE__ uint8_t
Definition stdint.h:88
Runtime device structure (in ROM) per driver instance.
Definition device.h:412
Mutex Structure.
Definition kernel.h:2994
UHC endpoint buffer info.
Definition uhc.h:49
USB host class data and class instance API.
Definition usbh.h:71
int(* request)(struct usbh_contex *const uhs_ctx, struct uhc_transfer *const xfer, int err)
Initialization of the class implementation.
Definition usbh.h:78
int(* rwup)(struct usbh_contex *const uhs_ctx)
Bus remote wakeup handler
Definition usbh.h:85
struct usbh_code_triple code
Class code supported by this instance.
Definition usbh.h:73
int(* connected)(struct usbh_contex *const uhs_ctx)
Device connected handler
Definition usbh.h:81
int(* resumed)(struct usbh_contex *const uhs_ctx)
Bus resumed handler
Definition usbh.h:89
int(* suspended)(struct usbh_contex *const uhs_ctx)
Bus suspended handler
Definition usbh.h:87
int(* removed)(struct usbh_contex *const uhs_ctx)
Device removed handler
Definition usbh.h:83
USB Class Code triple.
Definition usbh.h:59
uint8_t proto
Class Protocol Code.
Definition usbh.h:65
uint8_t dclass
Device Class Code.
Definition usbh.h:61
uint8_t sub
Class Subclass Code.
Definition usbh.h:63
USB host support runtime context.
Definition usbh.h:38
const struct device * dev
Pointer to UHC device struct.
Definition usbh.h:44
sys_dlist_t peripherals
peripheral list
Definition usbh.h:46
const char * name
Name of the USB device.
Definition usbh.h:40
struct k_mutex mutex
Access mutex.
Definition usbh.h:42
USB host controller (UHC) driver API.