Skip to content

Commit 168728a

Browse files
author
Josuah Demangeon
committed
usb: host: add host status to the host context
Add a "struct usbh_status" that contains a bitmask of flags to keep track of the global state of the host context, like done for the device_next implementation. Add helpers to check the status. Signed-off-by: Josuah Demangeon <[email protected]>
1 parent 1bad1d0 commit 168728a

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

include/zephyr/usb/usbh.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ extern "C" {
3333
* @{
3434
*/
3535

36+
/**
37+
* USB host support status
38+
*/
39+
struct usbh_status {
40+
/** USB host support is initialized */
41+
unsigned int initialized : 1;
42+
};
43+
3644
/**
3745
* USB host support runtime context
3846
*/
@@ -43,6 +51,8 @@ struct usbh_context {
4351
struct k_mutex mutex;
4452
/** Pointer to UHC device struct */
4553
const struct device *dev;
54+
/** Status of the USB host support */
55+
struct usbh_status status;
4656
/** USB device list */
4757
sys_dlist_t udevs;
4858
/** USB root device */

subsys/usb/host/usbh_host.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_INCLUDE_USBH_HOST_H
8+
#define ZEPHYR_INCLUDE_USBH_HOST_H
9+
10+
#include <stdbool.h>
11+
#include <zephyr/usb/usbh.h>
12+
13+
/**
14+
* @brief Check whether USB host is enabled
15+
*
16+
* @param[in] uhs_ctx Pointer to a host context
17+
*
18+
* @return true if USB host is in enabled, false otherwise
19+
*/
20+
static inline bool usbh_is_initialized(const struct usbh_context *const uhs_ctx)
21+
{
22+
return uhs_ctx->status.initialized;
23+
}
24+
25+
#endif /* ZEPHYR_INCLUDE_USBH_HOST_H */

0 commit comments

Comments
 (0)