Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions include/zephyr/usb/usbd_msg.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ enum usbd_msg_type {
USBD_MSG_SUSPEND,
/** Bus reset detected */
USBD_MSG_RESET,
/** Device changed configuration */
USBD_MSG_CONFIGURATION,
/** Non-correctable UDC error message */
USBD_MSG_UDC_ERROR,
/** Unrecoverable device stack error message */
Expand All @@ -61,6 +63,7 @@ static const char *const usbd_msg_type_list[] = {
"Device resumed",
"Device suspended",
"Bus reset",
"New device configuration",
"Controller error",
"Stack error",
"CDC ACM line coding",
Expand Down
4 changes: 4 additions & 0 deletions samples/subsys/usb/hid-keyboard/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ static void msg_cb(struct usbd_context *const usbd_ctx,
{
LOG_INF("USBD message: %s", usbd_msg_type_string(msg->type));

if (msg->type == USBD_MSG_CONFIGURATION) {
LOG_INF("\tConfiguration value %d", msg->status);
}

if (usbd_can_detect_vbus(usbd_ctx)) {
if (msg->type == USBD_MSG_VBUS_READY) {
if (usbd_enable(usbd_ctx)) {
Expand Down
5 changes: 5 additions & 0 deletions subsys/usb/device_next/usbd_ch9.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "usbd_class.h"
#include "usbd_class_api.h"
#include "usbd_interface.h"
#include "usbd_msg.h"

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(usbd_ch9, CONFIG_USBD_LOG_LEVEL);
Expand Down Expand Up @@ -171,6 +172,10 @@ static int sreq_set_configuration(struct usbd_context *const uds_ctx)
uds_ctx->ch9_data.state = USBD_STATE_CONFIGURED;
}

if (ret == 0) {
usbd_msg_pub_simple(uds_ctx, USBD_MSG_CONFIGURATION, setup->wValue);
}

return ret;
}

Expand Down