Skip to content

Commit 05ffa1c

Browse files
author
Josuah Demangeon
committed
usb: host: class: add a placeholder call after a device is connected
Add an ad-hoc placeholder that allows executing custom code as soon as a device is connected on the bus, so that enumeration can continue with the class-specific parts in the meantime that a complete. The assumption is that this would be replaced in future development. Signed-off-by: Josuah Demangeon <[email protected]>
1 parent 9d0942b commit 05ffa1c

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

subsys/usb/host/usbh_class.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#ifndef ZEPHYR_INCLUDE_USBH_CLASS_H
8+
#define ZEPHYR_INCLUDE_USBH_CLASS_H
9+
10+
#include <stdint.h>
11+
#include <zephyr/usb/usbh.h>
12+
#include <zephyr/drivers/usb/uhc.h>
13+
14+
int usbh_class_init(struct usb_device *udev);
15+
16+
#endif /* ZEPHYR_INCLUDE_USBH_CLASS_H */

subsys/usb/host/usbh_core.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
#include "usbh_internal.h"
1515
#include "usbh_device.h"
16+
#include "usbh_class.h"
1617

1718
#include <zephyr/logging/log.h>
1819
LOG_MODULE_REGISTER(uhs, CONFIG_USBH_LOG_LEVEL);
@@ -70,6 +71,11 @@ static void dev_connected_handler(struct usbh_contex *const ctx,
7071

7172
if (usbh_device_init(ctx->root)) {
7273
LOG_ERR("Failed to reset new USB device");
74+
return;
75+
}
76+
77+
if (usbh_class_init(ctx->root)) {
78+
LOG_ERR("Failed to initialize device class");
7379
}
7480
}
7581

0 commit comments

Comments
 (0)