usb: device_next: Rename usbd_contex to usbd_context
Add the missing "t" to struct usbd_contex. No functional changes. Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
This commit is contained in:
parent
b76fde64a1
commit
8d344cc9d8
38 changed files with 209 additions and 209 deletions
|
@ -116,7 +116,7 @@ endif()
|
||||||
|
|
||||||
if(CONFIG_USB_DEVICE_STACK OR CONFIG_USB_DEVICE_STACK_NEXT)
|
if(CONFIG_USB_DEVICE_STACK OR CONFIG_USB_DEVICE_STACK_NEXT)
|
||||||
zephyr_iterable_section(NAME usb_cfg_data GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN CONFIG_LINKER_ITERABLE_SUBALIGN)
|
zephyr_iterable_section(NAME usb_cfg_data GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN CONFIG_LINKER_ITERABLE_SUBALIGN)
|
||||||
zephyr_iterable_section(NAME usbd_contex GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN CONFIG_LINKER_ITERABLE_SUBALIGN)
|
zephyr_iterable_section(NAME usbd_context GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN CONFIG_LINKER_ITERABLE_SUBALIGN)
|
||||||
zephyr_iterable_section(NAME usbd_class_fs GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN CONFIG_LINKER_ITERABLE_SUBALIGN)
|
zephyr_iterable_section(NAME usbd_class_fs GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN CONFIG_LINKER_ITERABLE_SUBALIGN)
|
||||||
zephyr_iterable_section(NAME usbd_class_hs GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN CONFIG_LINKER_ITERABLE_SUBALIGN)
|
zephyr_iterable_section(NAME usbd_class_hs GROUP DATA_REGION ${XIP_ALIGN_WITH_INPUT} SUBALIGN CONFIG_LINKER_ITERABLE_SUBALIGN)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -199,7 +199,7 @@ struct usbd_status {
|
||||||
enum usbd_speed speed : 2;
|
enum usbd_speed speed : 2;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct usbd_contex;
|
struct usbd_context;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Callback type definition for USB device message delivery
|
* @brief Callback type definition for USB device message delivery
|
||||||
|
@ -212,7 +212,7 @@ struct usbd_contex;
|
||||||
* @param[in] ctx Pointer to USB device support context
|
* @param[in] ctx Pointer to USB device support context
|
||||||
* @param[in] msg Pointer to USB device message
|
* @param[in] msg Pointer to USB device message
|
||||||
*/
|
*/
|
||||||
typedef void (*usbd_msg_cb_t)(struct usbd_contex *const ctx,
|
typedef void (*usbd_msg_cb_t)(struct usbd_context *const ctx,
|
||||||
const struct usbd_msg *const msg);
|
const struct usbd_msg *const msg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -221,7 +221,7 @@ typedef void (*usbd_msg_cb_t)(struct usbd_contex *const ctx,
|
||||||
* Main structure that organizes all descriptors, configuration,
|
* Main structure that organizes all descriptors, configuration,
|
||||||
* and interfaces. An UDC device must be assigned to this structure.
|
* and interfaces. An UDC device must be assigned to this structure.
|
||||||
*/
|
*/
|
||||||
struct usbd_contex {
|
struct usbd_context {
|
||||||
/** Name of the USB device */
|
/** Name of the USB device */
|
||||||
const char *name;
|
const char *name;
|
||||||
/** Access mutex */
|
/** Access mutex */
|
||||||
|
@ -320,7 +320,7 @@ struct usbd_class_data {
|
||||||
/** Name of the USB device class instance */
|
/** Name of the USB device class instance */
|
||||||
const char *name;
|
const char *name;
|
||||||
/** Pointer to USB device stack context structure */
|
/** Pointer to USB device stack context structure */
|
||||||
struct usbd_contex *uds_ctx;
|
struct usbd_context *uds_ctx;
|
||||||
/** Pointer to device support class API */
|
/** Pointer to device support class API */
|
||||||
const struct usbd_class_api *api;
|
const struct usbd_class_api *api;
|
||||||
/** Supported vendor request table, can be NULL */
|
/** Supported vendor request table, can be NULL */
|
||||||
|
@ -368,7 +368,7 @@ struct usbd_class_node {
|
||||||
*
|
*
|
||||||
* @return Pointer to USB device runtime context
|
* @return Pointer to USB device runtime context
|
||||||
*/
|
*/
|
||||||
static inline struct usbd_contex *usbd_class_get_ctx(const struct usbd_class_data *const c_data)
|
static inline struct usbd_context *usbd_class_get_ctx(const struct usbd_class_data *const c_data)
|
||||||
{
|
{
|
||||||
return c_data->uds_ctx;
|
return c_data->uds_ctx;
|
||||||
}
|
}
|
||||||
|
@ -423,7 +423,7 @@ static inline void *usbd_class_get_private(const struct usbd_class_data *const c
|
||||||
.iSerialNumber = 0, \
|
.iSerialNumber = 0, \
|
||||||
.bNumConfigurations = 0, \
|
.bNumConfigurations = 0, \
|
||||||
}; \
|
}; \
|
||||||
static STRUCT_SECTION_ITERABLE(usbd_contex, device_name) = { \
|
static STRUCT_SECTION_ITERABLE(usbd_context, device_name) = { \
|
||||||
.name = STRINGIFY(device_name), \
|
.name = STRINGIFY(device_name), \
|
||||||
.dev = uhc_dev, \
|
.dev = uhc_dev, \
|
||||||
.fs_desc = &fs_desc_##device_name, \
|
.fs_desc = &fs_desc_##device_name, \
|
||||||
|
@ -609,7 +609,7 @@ static inline void *usbd_class_get_private(const struct usbd_class_data *const c
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_add_descriptor(struct usbd_contex *uds_ctx,
|
int usbd_add_descriptor(struct usbd_context *uds_ctx,
|
||||||
struct usbd_desc_node *dn);
|
struct usbd_desc_node *dn);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -639,7 +639,7 @@ void usbd_remove_descriptor(struct usbd_desc_node *const desc_nd);
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_add_configuration(struct usbd_contex *uds_ctx,
|
int usbd_add_configuration(struct usbd_context *uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
struct usbd_config_node *cd);
|
struct usbd_config_node *cd);
|
||||||
|
|
||||||
|
@ -664,7 +664,7 @@ int usbd_add_configuration(struct usbd_contex *uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_register_class(struct usbd_contex *uds_ctx,
|
int usbd_register_class(struct usbd_context *uds_ctx,
|
||||||
const char *name,
|
const char *name,
|
||||||
const enum usbd_speed speed, uint8_t cfg);
|
const enum usbd_speed speed, uint8_t cfg);
|
||||||
|
|
||||||
|
@ -682,7 +682,7 @@ int usbd_register_class(struct usbd_contex *uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_unregister_class(struct usbd_contex *uds_ctx,
|
int usbd_unregister_class(struct usbd_context *uds_ctx,
|
||||||
const char *name,
|
const char *name,
|
||||||
const enum usbd_speed speed, uint8_t cfg);
|
const enum usbd_speed speed, uint8_t cfg);
|
||||||
|
|
||||||
|
@ -694,7 +694,7 @@ int usbd_unregister_class(struct usbd_contex *uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_msg_register_cb(struct usbd_contex *const uds_ctx,
|
int usbd_msg_register_cb(struct usbd_context *const uds_ctx,
|
||||||
const usbd_msg_cb_t cb);
|
const usbd_msg_cb_t cb);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -710,7 +710,7 @@ int usbd_msg_register_cb(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_init(struct usbd_contex *uds_ctx);
|
int usbd_init(struct usbd_context *uds_ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Enable the USB device support and registered class instances
|
* @brief Enable the USB device support and registered class instances
|
||||||
|
@ -721,7 +721,7 @@ int usbd_init(struct usbd_contex *uds_ctx);
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_enable(struct usbd_contex *uds_ctx);
|
int usbd_enable(struct usbd_context *uds_ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Disable the USB device support
|
* @brief Disable the USB device support
|
||||||
|
@ -732,7 +732,7 @@ int usbd_enable(struct usbd_contex *uds_ctx);
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_disable(struct usbd_contex *uds_ctx);
|
int usbd_disable(struct usbd_context *uds_ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Shutdown the USB device support
|
* @brief Shutdown the USB device support
|
||||||
|
@ -743,7 +743,7 @@ int usbd_disable(struct usbd_contex *uds_ctx);
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_shutdown(struct usbd_contex *const uds_ctx);
|
int usbd_shutdown(struct usbd_context *const uds_ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Halt endpoint
|
* @brief Halt endpoint
|
||||||
|
@ -753,7 +753,7 @@ int usbd_shutdown(struct usbd_contex *const uds_ctx);
|
||||||
*
|
*
|
||||||
* @return 0 on success, or error from udc_ep_set_halt()
|
* @return 0 on success, or error from udc_ep_set_halt()
|
||||||
*/
|
*/
|
||||||
int usbd_ep_set_halt(struct usbd_contex *uds_ctx, uint8_t ep);
|
int usbd_ep_set_halt(struct usbd_context *uds_ctx, uint8_t ep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Clear endpoint halt
|
* @brief Clear endpoint halt
|
||||||
|
@ -763,7 +763,7 @@ int usbd_ep_set_halt(struct usbd_contex *uds_ctx, uint8_t ep);
|
||||||
*
|
*
|
||||||
* @return 0 on success, or error from udc_ep_clear_halt()
|
* @return 0 on success, or error from udc_ep_clear_halt()
|
||||||
*/
|
*/
|
||||||
int usbd_ep_clear_halt(struct usbd_contex *uds_ctx, uint8_t ep);
|
int usbd_ep_clear_halt(struct usbd_context *uds_ctx, uint8_t ep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Checks whether the endpoint is halted.
|
* @brief Checks whether the endpoint is halted.
|
||||||
|
@ -773,7 +773,7 @@ int usbd_ep_clear_halt(struct usbd_contex *uds_ctx, uint8_t ep);
|
||||||
*
|
*
|
||||||
* @return true if endpoint is halted, false otherwise
|
* @return true if endpoint is halted, false otherwise
|
||||||
*/
|
*/
|
||||||
bool usbd_ep_is_halted(struct usbd_contex *uds_ctx, uint8_t ep);
|
bool usbd_ep_is_halted(struct usbd_context *uds_ctx, uint8_t ep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Allocate buffer for USB device request
|
* @brief Allocate buffer for USB device request
|
||||||
|
@ -799,7 +799,7 @@ struct net_buf *usbd_ep_buf_alloc(const struct usbd_class_data *const c_data,
|
||||||
*
|
*
|
||||||
* @return 0 on success, all other values should be treated as error.
|
* @return 0 on success, all other values should be treated as error.
|
||||||
*/
|
*/
|
||||||
int usbd_ep_ctrl_enqueue(struct usbd_contex *const uds_ctx,
|
int usbd_ep_ctrl_enqueue(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf);
|
struct net_buf *const buf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -823,7 +823,7 @@ int usbd_ep_enqueue(const struct usbd_class_data *const c_data,
|
||||||
*
|
*
|
||||||
* @return 0 on success, or error from udc_ep_dequeue()
|
* @return 0 on success, or error from udc_ep_dequeue()
|
||||||
*/
|
*/
|
||||||
int usbd_ep_dequeue(struct usbd_contex *uds_ctx, const uint8_t ep);
|
int usbd_ep_dequeue(struct usbd_context *uds_ctx, const uint8_t ep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Free USB device request buffer
|
* @brief Free USB device request buffer
|
||||||
|
@ -835,7 +835,7 @@ int usbd_ep_dequeue(struct usbd_contex *uds_ctx, const uint8_t ep);
|
||||||
*
|
*
|
||||||
* @return 0 on success, all other values should be treated as error.
|
* @return 0 on success, all other values should be treated as error.
|
||||||
*/
|
*/
|
||||||
int usbd_ep_buf_free(struct usbd_contex *uds_ctx, struct net_buf *buf);
|
int usbd_ep_buf_free(struct usbd_context *uds_ctx, struct net_buf *buf);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Checks whether the USB device controller is suspended.
|
* @brief Checks whether the USB device controller is suspended.
|
||||||
|
@ -844,14 +844,14 @@ int usbd_ep_buf_free(struct usbd_contex *uds_ctx, struct net_buf *buf);
|
||||||
*
|
*
|
||||||
* @return true if endpoint is halted, false otherwise
|
* @return true if endpoint is halted, false otherwise
|
||||||
*/
|
*/
|
||||||
bool usbd_is_suspended(struct usbd_contex *uds_ctx);
|
bool usbd_is_suspended(struct usbd_context *uds_ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Initiate the USB remote wakeup (TBD)
|
* @brief Initiate the USB remote wakeup (TBD)
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_wakeup_request(struct usbd_contex *uds_ctx);
|
int usbd_wakeup_request(struct usbd_context *uds_ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get actual device speed
|
* @brief Get actual device speed
|
||||||
|
@ -860,7 +860,7 @@ int usbd_wakeup_request(struct usbd_contex *uds_ctx);
|
||||||
*
|
*
|
||||||
* @return Actual device speed
|
* @return Actual device speed
|
||||||
*/
|
*/
|
||||||
enum usbd_speed usbd_bus_speed(const struct usbd_contex *const uds_ctx);
|
enum usbd_speed usbd_bus_speed(const struct usbd_context *const uds_ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get highest speed supported by the controller
|
* @brief Get highest speed supported by the controller
|
||||||
|
@ -869,7 +869,7 @@ enum usbd_speed usbd_bus_speed(const struct usbd_contex *const uds_ctx);
|
||||||
*
|
*
|
||||||
* @return Highest supported speed
|
* @return Highest supported speed
|
||||||
*/
|
*/
|
||||||
enum usbd_speed usbd_caps_speed(const struct usbd_contex *const uds_ctx);
|
enum usbd_speed usbd_caps_speed(const struct usbd_context *const uds_ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Set USB device descriptor value bcdUSB
|
* @brief Set USB device descriptor value bcdUSB
|
||||||
|
@ -880,7 +880,7 @@ enum usbd_speed usbd_caps_speed(const struct usbd_contex *const uds_ctx);
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_device_set_bcd(struct usbd_contex *const uds_ctx,
|
int usbd_device_set_bcd(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed, const uint16_t bcd);
|
const enum usbd_speed speed, const uint16_t bcd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -891,7 +891,7 @@ int usbd_device_set_bcd(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_device_set_vid(struct usbd_contex *const uds_ctx,
|
int usbd_device_set_vid(struct usbd_context *const uds_ctx,
|
||||||
const uint16_t vid);
|
const uint16_t vid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -902,7 +902,7 @@ int usbd_device_set_vid(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_device_set_pid(struct usbd_contex *const uds_ctx,
|
int usbd_device_set_pid(struct usbd_context *const uds_ctx,
|
||||||
const uint16_t pid);
|
const uint16_t pid);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -916,7 +916,7 @@ int usbd_device_set_pid(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_device_set_code_triple(struct usbd_contex *const uds_ctx,
|
int usbd_device_set_code_triple(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t base_class,
|
const uint8_t base_class,
|
||||||
const uint8_t subclass, const uint8_t protocol);
|
const uint8_t subclass, const uint8_t protocol);
|
||||||
|
@ -931,7 +931,7 @@ int usbd_device_set_code_triple(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_config_attrib_rwup(struct usbd_contex *const uds_ctx,
|
int usbd_config_attrib_rwup(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t cfg, const bool enable);
|
const uint8_t cfg, const bool enable);
|
||||||
|
|
||||||
|
@ -945,7 +945,7 @@ int usbd_config_attrib_rwup(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_config_attrib_self(struct usbd_contex *const uds_ctx,
|
int usbd_config_attrib_self(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t cfg, const bool enable);
|
const uint8_t cfg, const bool enable);
|
||||||
|
|
||||||
|
@ -959,7 +959,7 @@ int usbd_config_attrib_self(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_config_maxpower(struct usbd_contex *const uds_ctx,
|
int usbd_config_maxpower(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t cfg, const uint8_t power);
|
const uint8_t cfg, const uint8_t power);
|
||||||
|
|
||||||
|
@ -975,7 +975,7 @@ int usbd_config_maxpower(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return true if controller can detect VBUS state change, false otherwise
|
* @return true if controller can detect VBUS state change, false otherwise
|
||||||
*/
|
*/
|
||||||
bool usbd_can_detect_vbus(struct usbd_contex *const uds_ctx);
|
bool usbd_can_detect_vbus(struct usbd_context *const uds_ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
|
|
||||||
static int enable_usb_device_next(void)
|
static int enable_usb_device_next(void)
|
||||||
{
|
{
|
||||||
struct usbd_contex *sample_usbd = sample_usbd_init_device(NULL);
|
struct usbd_context *sample_usbd = sample_usbd_init_device(NULL);
|
||||||
|
|
||||||
if (sample_usbd == NULL) {
|
if (sample_usbd == NULL) {
|
||||||
printk("Failed to initialize USB device");
|
printk("Failed to initialize USB device");
|
||||||
|
|
|
@ -49,10 +49,10 @@ static inline void print_baudrate(const struct device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
|
#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
|
||||||
static struct usbd_contex *sample_usbd;
|
static struct usbd_context *sample_usbd;
|
||||||
K_SEM_DEFINE(dtr_sem, 0, 1);
|
K_SEM_DEFINE(dtr_sem, 0, 1);
|
||||||
|
|
||||||
static void sample_msg_cb(struct usbd_contex *const ctx, const struct usbd_msg *msg)
|
static void sample_msg_cb(struct usbd_context *const ctx, const struct usbd_msg *msg)
|
||||||
{
|
{
|
||||||
LOG_INF("USBD message: %s", usbd_msg_type_string(msg->type));
|
LOG_INF("USBD message: %s", usbd_msg_type_string(msg->type));
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,6 @@
|
||||||
* It returns the configured and initialized USB device context on success,
|
* It returns the configured and initialized USB device context on success,
|
||||||
* otherwise it returns NULL.
|
* otherwise it returns NULL.
|
||||||
*/
|
*/
|
||||||
struct usbd_contex *sample_usbd_init_device(usbd_msg_cb_t msg_cb);
|
struct usbd_context *sample_usbd_init_device(usbd_msg_cb_t msg_cb);
|
||||||
|
|
||||||
#endif /* ZEPHYR_SAMPLES_SUBSYS_USB_COMMON_SAMPLE_USBD_H */
|
#endif /* ZEPHYR_SAMPLES_SUBSYS_USB_COMMON_SAMPLE_USBD_H */
|
||||||
|
|
|
@ -51,7 +51,7 @@ static const struct usb_bos_capability_lpm bos_cap_lpm = {
|
||||||
|
|
||||||
USBD_DESC_BOS_DEFINE(sample_usbext, sizeof(bos_cap_lpm), &bos_cap_lpm);
|
USBD_DESC_BOS_DEFINE(sample_usbext, sizeof(bos_cap_lpm), &bos_cap_lpm);
|
||||||
|
|
||||||
static int register_fs_classes(struct usbd_contex *uds_ctx)
|
static int register_fs_classes(struct usbd_context *uds_ctx)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ static int register_fs_classes(struct usbd_contex *uds_ctx)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int register_hs_classes(struct usbd_contex *uds_ctx)
|
static int register_hs_classes(struct usbd_context *uds_ctx)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
|
||||||
|
@ -91,7 +91,7 @@ static int register_hs_classes(struct usbd_contex *uds_ctx)
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sample_add_configuration(struct usbd_contex *uds_ctx,
|
static int sample_add_configuration(struct usbd_context *uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
struct usbd_config_node *config)
|
struct usbd_config_node *config)
|
||||||
{
|
{
|
||||||
|
@ -131,7 +131,7 @@ static int sample_add_configuration(struct usbd_contex *uds_ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct usbd_contex *sample_usbd_init_device(usbd_msg_cb_t msg_cb)
|
struct usbd_context *sample_usbd_init_device(usbd_msg_cb_t msg_cb)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ BUILD_ASSERT(DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_console), zephyr_cdc_acm_uart),
|
||||||
"Console device is not ACM CDC UART device");
|
"Console device is not ACM CDC UART device");
|
||||||
|
|
||||||
#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
|
#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
|
||||||
static struct usbd_contex *sample_usbd;
|
static struct usbd_context *sample_usbd;
|
||||||
|
|
||||||
static int enable_usb_device_next(void)
|
static int enable_usb_device_next(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -143,7 +143,7 @@ struct hid_device_ops kb_ops = {
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
struct usbd_contex *sample_usbd;
|
struct usbd_context *sample_usbd;
|
||||||
const struct device *hid_dev;
|
const struct device *hid_dev;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ INPUT_CALLBACK_DEFINE(NULL, input_cb);
|
||||||
#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
|
#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
|
||||||
static int enable_usb_device_next(void)
|
static int enable_usb_device_next(void)
|
||||||
{
|
{
|
||||||
struct usbd_contex *sample_usbd;
|
struct usbd_context *sample_usbd;
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
sample_usbd = sample_usbd_init_device(NULL);
|
sample_usbd = sample_usbd_init_device(NULL);
|
||||||
|
|
|
@ -36,7 +36,7 @@ FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage);
|
||||||
static struct fs_mount_t fs_mnt;
|
static struct fs_mount_t fs_mnt;
|
||||||
|
|
||||||
#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
|
#if defined(CONFIG_USB_DEVICE_STACK_NEXT)
|
||||||
static struct usbd_contex *sample_usbd;
|
static struct usbd_context *sample_usbd;
|
||||||
|
|
||||||
#if CONFIG_DISK_DRIVER_RAM
|
#if CONFIG_DISK_DRIVER_RAM
|
||||||
USBD_DEFINE_MSC_LUN(RAM, "Zephyr", "RAMDisk", "0.00");
|
USBD_DEFINE_MSC_LUN(RAM, "Zephyr", "RAMDisk", "0.00");
|
||||||
|
|
|
@ -255,7 +255,7 @@ static struct usb_i2s_ctx main_ctx;
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
const struct device *dev = DEVICE_DT_GET(DT_NODELABEL(uac2_headphones));
|
const struct device *dev = DEVICE_DT_GET(DT_NODELABEL(uac2_headphones));
|
||||||
struct usbd_contex *sample_usbd;
|
struct usbd_context *sample_usbd;
|
||||||
struct i2s_config config;
|
struct i2s_config config;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
|
|
@ -134,7 +134,7 @@ static uint8_t bt_hci_get_int_in(struct usbd_class_data *const c_data)
|
||||||
|
|
||||||
static uint8_t bt_hci_get_bulk_in(struct usbd_class_data *const c_data)
|
static uint8_t bt_hci_get_bulk_in(struct usbd_class_data *const c_data)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
struct bt_hci_data *data = usbd_class_get_private(c_data);
|
struct bt_hci_data *data = usbd_class_get_private(c_data);
|
||||||
struct usbd_bt_hci_desc *desc = data->desc;
|
struct usbd_bt_hci_desc *desc = data->desc;
|
||||||
|
|
||||||
|
@ -147,7 +147,7 @@ static uint8_t bt_hci_get_bulk_in(struct usbd_class_data *const c_data)
|
||||||
|
|
||||||
static uint8_t bt_hci_get_bulk_out(struct usbd_class_data *const c_data)
|
static uint8_t bt_hci_get_bulk_out(struct usbd_class_data *const c_data)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
struct bt_hci_data *data = usbd_class_get_private(c_data);
|
struct bt_hci_data *data = usbd_class_get_private(c_data);
|
||||||
struct usbd_bt_hci_desc *desc = data->desc;
|
struct usbd_bt_hci_desc *desc = data->desc;
|
||||||
|
|
||||||
|
@ -370,7 +370,7 @@ restart_out_transfer:
|
||||||
static int bt_hci_request(struct usbd_class_data *const c_data,
|
static int bt_hci_request(struct usbd_class_data *const c_data,
|
||||||
struct net_buf *buf, int err)
|
struct net_buf *buf, int err)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
struct bt_hci_data *hci_data = usbd_class_get_private(c_data);
|
struct bt_hci_data *hci_data = usbd_class_get_private(c_data);
|
||||||
struct udc_buf_info *bi;
|
struct udc_buf_info *bi;
|
||||||
|
|
||||||
|
|
|
@ -112,7 +112,7 @@ static int lb_control_to_dev(struct usbd_class_data *c_data,
|
||||||
static int lb_request_handler(struct usbd_class_data *c_data,
|
static int lb_request_handler(struct usbd_class_data *c_data,
|
||||||
struct net_buf *buf, int err)
|
struct net_buf *buf, int err)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
struct udc_buf_info *bi = NULL;
|
struct udc_buf_info *bi = NULL;
|
||||||
|
|
||||||
bi = (struct udc_buf_info *)net_buf_user_data(buf);
|
bi = (struct udc_buf_info *)net_buf_user_data(buf);
|
||||||
|
|
|
@ -143,7 +143,7 @@ static ALWAYS_INLINE bool check_wq_ctx(const struct device *dev)
|
||||||
|
|
||||||
static uint8_t cdc_acm_get_int_in(struct usbd_class_data *const c_data)
|
static uint8_t cdc_acm_get_int_in(struct usbd_class_data *const c_data)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
const struct device *dev = usbd_class_get_private(c_data);
|
const struct device *dev = usbd_class_get_private(c_data);
|
||||||
struct cdc_acm_uart_data *data = dev->data;
|
struct cdc_acm_uart_data *data = dev->data;
|
||||||
struct usbd_cdc_acm_desc *desc = data->desc;
|
struct usbd_cdc_acm_desc *desc = data->desc;
|
||||||
|
@ -157,7 +157,7 @@ static uint8_t cdc_acm_get_int_in(struct usbd_class_data *const c_data)
|
||||||
|
|
||||||
static uint8_t cdc_acm_get_bulk_in(struct usbd_class_data *const c_data)
|
static uint8_t cdc_acm_get_bulk_in(struct usbd_class_data *const c_data)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
const struct device *dev = usbd_class_get_private(c_data);
|
const struct device *dev = usbd_class_get_private(c_data);
|
||||||
struct cdc_acm_uart_data *data = dev->data;
|
struct cdc_acm_uart_data *data = dev->data;
|
||||||
struct usbd_cdc_acm_desc *desc = data->desc;
|
struct usbd_cdc_acm_desc *desc = data->desc;
|
||||||
|
@ -171,7 +171,7 @@ static uint8_t cdc_acm_get_bulk_in(struct usbd_class_data *const c_data)
|
||||||
|
|
||||||
static uint8_t cdc_acm_get_bulk_out(struct usbd_class_data *const c_data)
|
static uint8_t cdc_acm_get_bulk_out(struct usbd_class_data *const c_data)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
const struct device *dev = usbd_class_get_private(c_data);
|
const struct device *dev = usbd_class_get_private(c_data);
|
||||||
struct cdc_acm_uart_data *data = dev->data;
|
struct cdc_acm_uart_data *data = dev->data;
|
||||||
struct usbd_cdc_acm_desc *desc = data->desc;
|
struct usbd_cdc_acm_desc *desc = data->desc;
|
||||||
|
@ -185,7 +185,7 @@ static uint8_t cdc_acm_get_bulk_out(struct usbd_class_data *const c_data)
|
||||||
|
|
||||||
static size_t cdc_acm_get_bulk_mps(struct usbd_class_data *const c_data)
|
static size_t cdc_acm_get_bulk_mps(struct usbd_class_data *const c_data)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
|
|
||||||
if (usbd_bus_speed(uds_ctx) == USBD_SPEED_HS) {
|
if (usbd_bus_speed(uds_ctx) == USBD_SPEED_HS) {
|
||||||
return 512U;
|
return 512U;
|
||||||
|
@ -197,7 +197,7 @@ static size_t cdc_acm_get_bulk_mps(struct usbd_class_data *const c_data)
|
||||||
static int usbd_cdc_acm_request(struct usbd_class_data *const c_data,
|
static int usbd_cdc_acm_request(struct usbd_class_data *const c_data,
|
||||||
struct net_buf *buf, int err)
|
struct net_buf *buf, int err)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
const struct device *dev = usbd_class_get_private(c_data);
|
const struct device *dev = usbd_class_get_private(c_data);
|
||||||
struct cdc_acm_uart_data *data = dev->data;
|
struct cdc_acm_uart_data *data = dev->data;
|
||||||
struct udc_buf_info *bi;
|
struct udc_buf_info *bi;
|
||||||
|
@ -421,7 +421,7 @@ static int usbd_cdc_acm_ctd(struct usbd_class_data *const c_data,
|
||||||
const struct usb_setup_packet *const setup,
|
const struct usb_setup_packet *const setup,
|
||||||
const struct net_buf *const buf)
|
const struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
const struct device *dev = usbd_class_get_private(c_data);
|
const struct device *dev = usbd_class_get_private(c_data);
|
||||||
struct cdc_acm_uart_data *data = dev->data;
|
struct cdc_acm_uart_data *data = dev->data;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
|
|
@ -102,7 +102,7 @@ static uint8_t cdc_ecm_get_ctrl_if(struct cdc_ecm_eth_data *const data)
|
||||||
|
|
||||||
static uint8_t cdc_ecm_get_int_in(struct usbd_class_data *const c_data)
|
static uint8_t cdc_ecm_get_int_in(struct usbd_class_data *const c_data)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
const struct device *dev = usbd_class_get_private(c_data);
|
const struct device *dev = usbd_class_get_private(c_data);
|
||||||
struct cdc_ecm_eth_data *data = dev->data;
|
struct cdc_ecm_eth_data *data = dev->data;
|
||||||
struct usbd_cdc_ecm_desc *desc = data->desc;
|
struct usbd_cdc_ecm_desc *desc = data->desc;
|
||||||
|
@ -116,7 +116,7 @@ static uint8_t cdc_ecm_get_int_in(struct usbd_class_data *const c_data)
|
||||||
|
|
||||||
static uint8_t cdc_ecm_get_bulk_in(struct usbd_class_data *const c_data)
|
static uint8_t cdc_ecm_get_bulk_in(struct usbd_class_data *const c_data)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
const struct device *dev = usbd_class_get_private(c_data);
|
const struct device *dev = usbd_class_get_private(c_data);
|
||||||
struct cdc_ecm_eth_data *data = dev->data;
|
struct cdc_ecm_eth_data *data = dev->data;
|
||||||
struct usbd_cdc_ecm_desc *desc = data->desc;
|
struct usbd_cdc_ecm_desc *desc = data->desc;
|
||||||
|
@ -130,7 +130,7 @@ static uint8_t cdc_ecm_get_bulk_in(struct usbd_class_data *const c_data)
|
||||||
|
|
||||||
static uint16_t cdc_ecm_get_bulk_in_mps(struct usbd_class_data *const c_data)
|
static uint16_t cdc_ecm_get_bulk_in_mps(struct usbd_class_data *const c_data)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
|
|
||||||
if (usbd_bus_speed(uds_ctx) == USBD_SPEED_HS) {
|
if (usbd_bus_speed(uds_ctx) == USBD_SPEED_HS) {
|
||||||
return 512U;
|
return 512U;
|
||||||
|
@ -141,7 +141,7 @@ static uint16_t cdc_ecm_get_bulk_in_mps(struct usbd_class_data *const c_data)
|
||||||
|
|
||||||
static uint8_t cdc_ecm_get_bulk_out(struct usbd_class_data *const c_data)
|
static uint8_t cdc_ecm_get_bulk_out(struct usbd_class_data *const c_data)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
const struct device *dev = usbd_class_get_private(c_data);
|
const struct device *dev = usbd_class_get_private(c_data);
|
||||||
struct cdc_ecm_eth_data *data = dev->data;
|
struct cdc_ecm_eth_data *data = dev->data;
|
||||||
struct usbd_cdc_ecm_desc *desc = data->desc;
|
struct usbd_cdc_ecm_desc *desc = data->desc;
|
||||||
|
@ -283,7 +283,7 @@ restart_out_transfer:
|
||||||
static int usbd_cdc_ecm_request(struct usbd_class_data *const c_data,
|
static int usbd_cdc_ecm_request(struct usbd_class_data *const c_data,
|
||||||
struct net_buf *buf, int err)
|
struct net_buf *buf, int err)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
const struct device *dev = usbd_class_get_private(c_data);
|
const struct device *dev = usbd_class_get_private(c_data);
|
||||||
struct cdc_ecm_eth_data *data = dev->data;
|
struct cdc_ecm_eth_data *data = dev->data;
|
||||||
struct udc_buf_info *bi;
|
struct udc_buf_info *bi;
|
||||||
|
@ -442,7 +442,7 @@ static int usbd_cdc_ecm_ctd(struct usbd_class_data *const c_data,
|
||||||
|
|
||||||
static int usbd_cdc_ecm_init(struct usbd_class_data *const c_data)
|
static int usbd_cdc_ecm_init(struct usbd_class_data *const c_data)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
const struct device *dev = usbd_class_get_private(c_data);
|
const struct device *dev = usbd_class_get_private(c_data);
|
||||||
struct cdc_ecm_eth_data *const data = dev->data;
|
struct cdc_ecm_eth_data *const data = dev->data;
|
||||||
struct usbd_cdc_ecm_desc *desc = data->desc;
|
struct usbd_cdc_ecm_desc *desc = data->desc;
|
||||||
|
|
|
@ -98,7 +98,7 @@ static inline uint8_t hid_get_out_ep(struct usbd_class_data *const c_data)
|
||||||
static int usbd_hid_request(struct usbd_class_data *const c_data,
|
static int usbd_hid_request(struct usbd_class_data *const c_data,
|
||||||
struct net_buf *const buf, const int err)
|
struct net_buf *const buf, const int err)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
const struct device *dev = usbd_class_get_private(c_data);
|
const struct device *dev = usbd_class_get_private(c_data);
|
||||||
struct hid_device_data *ddata = dev->data;
|
struct hid_device_data *ddata = dev->data;
|
||||||
const struct hid_device_ops *ops = ddata->ops;
|
const struct hid_device_ops *ops = ddata->ops;
|
||||||
|
|
|
@ -146,7 +146,7 @@ static struct net_buf *msc_buf_alloc(const uint8_t ep)
|
||||||
|
|
||||||
static uint8_t msc_get_bulk_in(struct usbd_class_data *const c_data)
|
static uint8_t msc_get_bulk_in(struct usbd_class_data *const c_data)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
struct msc_bot_ctx *ctx = usbd_class_get_private(c_data);
|
struct msc_bot_ctx *ctx = usbd_class_get_private(c_data);
|
||||||
struct msc_bot_desc *desc = ctx->desc;
|
struct msc_bot_desc *desc = ctx->desc;
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ static uint8_t msc_get_bulk_in(struct usbd_class_data *const c_data)
|
||||||
|
|
||||||
static uint8_t msc_get_bulk_out(struct usbd_class_data *const c_data)
|
static uint8_t msc_get_bulk_out(struct usbd_class_data *const c_data)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
struct msc_bot_ctx *ctx = usbd_class_get_private(c_data);
|
struct msc_bot_ctx *ctx = usbd_class_get_private(c_data);
|
||||||
struct msc_bot_desc *desc = ctx->desc;
|
struct msc_bot_desc *desc = ctx->desc;
|
||||||
|
|
||||||
|
@ -566,7 +566,7 @@ static void msc_send_csw(struct msc_bot_ctx *ctx)
|
||||||
static void usbd_msc_handle_request(struct usbd_class_data *c_data,
|
static void usbd_msc_handle_request(struct usbd_class_data *c_data,
|
||||||
struct net_buf *buf, int err)
|
struct net_buf *buf, int err)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
struct msc_bot_ctx *ctx = usbd_class_get_private(c_data);
|
struct msc_bot_ctx *ctx = usbd_class_get_private(c_data);
|
||||||
struct udc_buf_info *bi;
|
struct udc_buf_info *bi;
|
||||||
|
|
||||||
|
|
|
@ -337,7 +337,7 @@ static void write_explicit_feedback(struct usbd_class_data *const c_data,
|
||||||
uint8_t ep, uint8_t terminal)
|
uint8_t ep, uint8_t terminal)
|
||||||
{
|
{
|
||||||
const struct device *dev = usbd_class_get_private(c_data);
|
const struct device *dev = usbd_class_get_private(c_data);
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
struct uac2_ctx *ctx = dev->data;
|
struct uac2_ctx *ctx = dev->data;
|
||||||
struct net_buf *buf;
|
struct net_buf *buf;
|
||||||
struct udc_buf_info *bi;
|
struct udc_buf_info *bi;
|
||||||
|
@ -382,7 +382,7 @@ void uac2_update(struct usbd_class_data *const c_data,
|
||||||
uint8_t iface, uint8_t alternate)
|
uint8_t iface, uint8_t alternate)
|
||||||
{
|
{
|
||||||
const struct device *dev = usbd_class_get_private(c_data);
|
const struct device *dev = usbd_class_get_private(c_data);
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
const struct uac2_cfg *cfg = dev->config;
|
const struct uac2_cfg *cfg = dev->config;
|
||||||
struct uac2_ctx *ctx = dev->data;
|
struct uac2_ctx *ctx = dev->data;
|
||||||
const struct usb_association_descriptor *iad;
|
const struct usb_association_descriptor *iad;
|
||||||
|
@ -568,7 +568,7 @@ static int uac2_request(struct usbd_class_data *const c_data, struct net_buf *bu
|
||||||
const struct device *dev = usbd_class_get_private(c_data);
|
const struct device *dev = usbd_class_get_private(c_data);
|
||||||
const struct uac2_cfg *cfg = dev->config;
|
const struct uac2_cfg *cfg = dev->config;
|
||||||
struct uac2_ctx *ctx = dev->data;
|
struct uac2_ctx *ctx = dev->data;
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
struct udc_buf_info *bi;
|
struct udc_buf_info *bi;
|
||||||
uint8_t ep, terminal;
|
uint8_t ep, terminal;
|
||||||
uint16_t mps;
|
uint16_t mps;
|
||||||
|
|
|
@ -29,7 +29,7 @@ LOG_MODULE_REGISTER(usbd_ch9, CONFIG_USBD_LOG_LEVEL);
|
||||||
#define SF_TEST_MODE_SELECTOR(wIndex) ((uint8_t)((wIndex) >> 8))
|
#define SF_TEST_MODE_SELECTOR(wIndex) ((uint8_t)((wIndex) >> 8))
|
||||||
#define SF_TEST_LOWER_BYTE(wIndex) ((uint8_t)(wIndex))
|
#define SF_TEST_LOWER_BYTE(wIndex) ((uint8_t)(wIndex))
|
||||||
|
|
||||||
static int nonstd_request(struct usbd_contex *const uds_ctx,
|
static int nonstd_request(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const dbuf);
|
struct net_buf *const dbuf);
|
||||||
|
|
||||||
static bool reqtype_is_to_host(const struct usb_setup_packet *const setup)
|
static bool reqtype_is_to_host(const struct usb_setup_packet *const setup)
|
||||||
|
@ -42,18 +42,18 @@ static bool reqtype_is_to_device(const struct usb_setup_packet *const setup)
|
||||||
return !reqtype_is_to_host(setup);
|
return !reqtype_is_to_host(setup);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ch9_set_ctrl_type(struct usbd_contex *const uds_ctx,
|
static void ch9_set_ctrl_type(struct usbd_context *const uds_ctx,
|
||||||
const int type)
|
const int type)
|
||||||
{
|
{
|
||||||
uds_ctx->ch9_data.ctrl_type = type;
|
uds_ctx->ch9_data.ctrl_type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ch9_get_ctrl_type(struct usbd_contex *const uds_ctx)
|
static int ch9_get_ctrl_type(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
return uds_ctx->ch9_data.ctrl_type;
|
return uds_ctx->ch9_data.ctrl_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int post_status_stage(struct usbd_contex *const uds_ctx)
|
static int post_status_stage(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -80,7 +80,7 @@ static int post_status_stage(struct usbd_contex *const uds_ctx)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sreq_set_address(struct usbd_contex *const uds_ctx)
|
static int sreq_set_address(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
struct udc_device_caps caps = udc_caps(uds_ctx->dev);
|
struct udc_device_caps caps = udc_caps(uds_ctx->dev);
|
||||||
|
@ -123,7 +123,7 @@ static int sreq_set_address(struct usbd_contex *const uds_ctx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sreq_set_configuration(struct usbd_contex *const uds_ctx)
|
static int sreq_set_configuration(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
const enum usbd_speed speed = usbd_bus_speed(uds_ctx);
|
const enum usbd_speed speed = usbd_bus_speed(uds_ctx);
|
||||||
|
@ -174,7 +174,7 @@ static int sreq_set_configuration(struct usbd_contex *const uds_ctx)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sreq_set_interface(struct usbd_contex *const uds_ctx)
|
static int sreq_set_interface(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -210,7 +210,7 @@ static int sreq_set_interface(struct usbd_contex *const uds_ctx)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sreq_feature_halt_notify(struct usbd_contex *const uds_ctx,
|
static void sreq_feature_halt_notify(struct usbd_context *const uds_ctx,
|
||||||
const uint8_t ep, const bool halted)
|
const uint8_t ep, const bool halted)
|
||||||
{
|
{
|
||||||
struct usbd_class_node *c_nd = usbd_class_get_by_ep(uds_ctx, ep);
|
struct usbd_class_node *c_nd = usbd_class_get_by_ep(uds_ctx, ep);
|
||||||
|
@ -220,7 +220,7 @@ static void sreq_feature_halt_notify(struct usbd_contex *const uds_ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sreq_clear_feature(struct usbd_contex *const uds_ctx)
|
static int sreq_clear_feature(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
uint8_t ep = setup->wIndex;
|
uint8_t ep = setup->wIndex;
|
||||||
|
@ -275,7 +275,7 @@ static int sreq_clear_feature(struct usbd_contex *const uds_ctx)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int set_feature_test_mode(struct usbd_contex *const uds_ctx)
|
static int set_feature_test_mode(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
uint8_t mode = SF_TEST_MODE_SELECTOR(setup->wIndex);
|
uint8_t mode = SF_TEST_MODE_SELECTOR(setup->wIndex);
|
||||||
|
@ -296,7 +296,7 @@ static int set_feature_test_mode(struct usbd_contex *const uds_ctx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sreq_set_feature(struct usbd_contex *const uds_ctx)
|
static int sreq_set_feature(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
uint8_t ep = setup->wIndex;
|
uint8_t ep = setup->wIndex;
|
||||||
|
@ -358,7 +358,7 @@ static int sreq_set_feature(struct usbd_contex *const uds_ctx)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int std_request_to_device(struct usbd_contex *const uds_ctx,
|
static int std_request_to_device(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
|
@ -389,7 +389,7 @@ static int std_request_to_device(struct usbd_contex *const uds_ctx,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sreq_get_status(struct usbd_contex *const uds_ctx,
|
static int sreq_get_status(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
|
@ -449,7 +449,7 @@ static int sreq_get_status(struct usbd_contex *const uds_ctx,
|
||||||
* This function handles configuration and USB2.0 other-speed-configuration
|
* This function handles configuration and USB2.0 other-speed-configuration
|
||||||
* descriptor type requests.
|
* descriptor type requests.
|
||||||
*/
|
*/
|
||||||
static int sreq_get_desc_cfg(struct usbd_contex *const uds_ctx,
|
static int sreq_get_desc_cfg(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf,
|
struct net_buf *const buf,
|
||||||
const uint8_t idx,
|
const uint8_t idx,
|
||||||
const bool other_cfg)
|
const bool other_cfg)
|
||||||
|
@ -601,7 +601,7 @@ static void string_ascii7_to_utf16le(struct usbd_desc_node *const dn,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sreq_get_desc_dev(struct usbd_contex *const uds_ctx,
|
static int sreq_get_desc_dev(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
|
@ -627,7 +627,7 @@ static int sreq_get_desc_dev(struct usbd_contex *const uds_ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sreq_get_desc_str(struct usbd_contex *const uds_ctx,
|
static int sreq_get_desc_str(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf, const uint8_t idx)
|
struct net_buf *const buf, const uint8_t idx)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
|
@ -659,7 +659,7 @@ static int sreq_get_desc_str(struct usbd_contex *const uds_ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sreq_get_dev_qualifier(struct usbd_contex *const uds_ctx,
|
static int sreq_get_dev_qualifier(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
|
@ -696,7 +696,7 @@ static int sreq_get_dev_qualifier(struct usbd_contex *const uds_ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void desc_fill_bos_root(struct usbd_contex *const uds_ctx,
|
static void desc_fill_bos_root(struct usbd_context *const uds_ctx,
|
||||||
struct usb_bos_descriptor *const root)
|
struct usb_bos_descriptor *const root)
|
||||||
{
|
{
|
||||||
struct usbd_desc_node *desc_nd;
|
struct usbd_desc_node *desc_nd;
|
||||||
|
@ -714,7 +714,7 @@ static void desc_fill_bos_root(struct usbd_contex *const uds_ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sreq_get_desc_bos(struct usbd_contex *const uds_ctx,
|
static int sreq_get_desc_bos(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
|
@ -769,7 +769,7 @@ static int sreq_get_desc_bos(struct usbd_contex *const uds_ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sreq_get_descriptor(struct usbd_contex *const uds_ctx,
|
static int sreq_get_descriptor(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
|
@ -812,7 +812,7 @@ static int sreq_get_descriptor(struct usbd_contex *const uds_ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sreq_get_configuration(struct usbd_contex *const uds_ctx,
|
static int sreq_get_configuration(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -840,7 +840,7 @@ static int sreq_get_configuration(struct usbd_contex *const uds_ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int sreq_get_interface(struct usbd_contex *const uds_ctx,
|
static int sreq_get_interface(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
|
@ -885,7 +885,7 @@ static int sreq_get_interface(struct usbd_contex *const uds_ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int std_request_to_host(struct usbd_contex *const uds_ctx,
|
static int std_request_to_host(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
|
@ -913,7 +913,7 @@ static int std_request_to_host(struct usbd_contex *const uds_ctx,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int nonstd_request(struct usbd_contex *const uds_ctx,
|
static int nonstd_request(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const dbuf)
|
struct net_buf *const dbuf)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
|
@ -947,7 +947,7 @@ static int nonstd_request(struct usbd_contex *const uds_ctx,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int handle_setup_request(struct usbd_contex *const uds_ctx,
|
static int handle_setup_request(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
|
@ -987,7 +987,7 @@ static int handle_setup_request(struct usbd_contex *const uds_ctx,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int ctrl_xfer_get_setup(struct usbd_contex *const uds_ctx,
|
static int ctrl_xfer_get_setup(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
|
@ -1061,7 +1061,7 @@ static struct net_buf *spool_data_out(struct net_buf *const buf)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_handle_ctrl_xfer(struct usbd_contex *const uds_ctx,
|
int usbd_handle_ctrl_xfer(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf, const int err)
|
struct net_buf *const buf, const int err)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
|
@ -1193,7 +1193,7 @@ ctrl_xfer_stall:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_init_control_pipe(struct usbd_contex *const uds_ctx)
|
int usbd_init_control_pipe(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
uds_ctx->ch9_data.state = USBD_STATE_DEFAULT;
|
uds_ctx->ch9_data.state = USBD_STATE_DEFAULT;
|
||||||
ch9_set_ctrl_type(uds_ctx, CTRL_AWAIT_SETUP_DATA);
|
ch9_set_ctrl_type(uds_ctx, CTRL_AWAIT_SETUP_DATA);
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @return true if USB device is in default state, false otherwise
|
* @return true if USB device is in default state, false otherwise
|
||||||
*/
|
*/
|
||||||
static inline bool usbd_state_is_default(const struct usbd_contex *const uds_ctx)
|
static inline bool usbd_state_is_default(const struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
return (uds_ctx->ch9_data.state == USBD_STATE_DEFAULT) ? true : false;
|
return (uds_ctx->ch9_data.state == USBD_STATE_DEFAULT) ? true : false;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ static inline bool usbd_state_is_default(const struct usbd_contex *const uds_ctx
|
||||||
*
|
*
|
||||||
* @return true if USB device is in address state, false otherwise
|
* @return true if USB device is in address state, false otherwise
|
||||||
*/
|
*/
|
||||||
static inline bool usbd_state_is_address(const struct usbd_contex *const uds_ctx)
|
static inline bool usbd_state_is_address(const struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
return (uds_ctx->ch9_data.state == USBD_STATE_ADDRESS) ? true : false;
|
return (uds_ctx->ch9_data.state == USBD_STATE_ADDRESS) ? true : false;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,7 @@ static inline bool usbd_state_is_address(const struct usbd_contex *const uds_ctx
|
||||||
*
|
*
|
||||||
* @return true if USB device is in configured state, false otherwise
|
* @return true if USB device is in configured state, false otherwise
|
||||||
*/
|
*/
|
||||||
static inline bool usbd_state_is_configured(const struct usbd_contex *const uds_ctx)
|
static inline bool usbd_state_is_configured(const struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
return (uds_ctx->ch9_data.state == USBD_STATE_CONFIGURED) ? true : false;
|
return (uds_ctx->ch9_data.state == USBD_STATE_CONFIGURED) ? true : false;
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ static inline bool usbd_state_is_configured(const struct usbd_contex *const uds_
|
||||||
*
|
*
|
||||||
* @return current configuration value
|
* @return current configuration value
|
||||||
*/
|
*/
|
||||||
static inline uint8_t usbd_get_config_value(const struct usbd_contex *const uds_ctx)
|
static inline uint8_t usbd_get_config_value(const struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
return uds_ctx->ch9_data.configuration;
|
return uds_ctx->ch9_data.configuration;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ static inline uint8_t usbd_get_config_value(const struct usbd_contex *const uds_
|
||||||
* @param[in] uds_ctx Pointer to a device context
|
* @param[in] uds_ctx Pointer to a device context
|
||||||
* @param[in] value New configuration value
|
* @param[in] value New configuration value
|
||||||
*/
|
*/
|
||||||
static inline void usbd_set_config_value(struct usbd_contex *const uds_ctx,
|
static inline void usbd_set_config_value(struct usbd_context *const uds_ctx,
|
||||||
const uint8_t value)
|
const uint8_t value)
|
||||||
{
|
{
|
||||||
uds_ctx->ch9_data.configuration = value;
|
uds_ctx->ch9_data.configuration = value;
|
||||||
|
@ -78,7 +78,7 @@ static inline void usbd_set_config_value(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
static inline int usbd_get_alt_value(const struct usbd_contex *const uds_ctx,
|
static inline int usbd_get_alt_value(const struct usbd_context *const uds_ctx,
|
||||||
const uint8_t iface,
|
const uint8_t iface,
|
||||||
uint8_t *const alt)
|
uint8_t *const alt)
|
||||||
{
|
{
|
||||||
|
@ -100,7 +100,7 @@ static inline int usbd_get_alt_value(const struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
static inline int usbd_set_alt_value(struct usbd_contex *const uds_ctx,
|
static inline int usbd_set_alt_value(struct usbd_context *const uds_ctx,
|
||||||
const uint8_t iface,
|
const uint8_t iface,
|
||||||
const uint8_t alt)
|
const uint8_t alt)
|
||||||
{
|
{
|
||||||
|
@ -121,7 +121,7 @@ static inline int usbd_set_alt_value(struct usbd_contex *const uds_ctx,
|
||||||
* @return Pointer to last received setup packet
|
* @return Pointer to last received setup packet
|
||||||
*/
|
*/
|
||||||
static inline struct usb_setup_packet *
|
static inline struct usb_setup_packet *
|
||||||
usbd_get_setup_pkt(struct usbd_contex *const uds_ctx)
|
usbd_get_setup_pkt(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
return &uds_ctx->ch9_data.setup;
|
return &uds_ctx->ch9_data.setup;
|
||||||
}
|
}
|
||||||
|
@ -135,7 +135,7 @@ usbd_get_setup_pkt(struct usbd_contex *const uds_ctx)
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_handle_ctrl_xfer(struct usbd_contex *uds_ctx,
|
int usbd_handle_ctrl_xfer(struct usbd_context *uds_ctx,
|
||||||
struct net_buf *buf, int err);
|
struct net_buf *buf, int err);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -145,7 +145,7 @@ int usbd_handle_ctrl_xfer(struct usbd_contex *uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_init_control_pipe(struct usbd_contex *uds_ctx);
|
int usbd_init_control_pipe(struct usbd_context *uds_ctx);
|
||||||
|
|
||||||
|
|
||||||
#endif /* ZEPHYR_INCLUDE_USBD_CH9_H */
|
#endif /* ZEPHYR_INCLUDE_USBD_CH9_H */
|
||||||
|
|
|
@ -44,7 +44,7 @@ size_t usbd_class_desc_len(struct usbd_class_data *const c_data,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct usbd_class_node *
|
struct usbd_class_node *
|
||||||
usbd_class_get_by_config(struct usbd_contex *const uds_ctx,
|
usbd_class_get_by_config(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t cnum,
|
const uint8_t cnum,
|
||||||
const uint8_t inum)
|
const uint8_t inum)
|
||||||
|
@ -67,7 +67,7 @@ usbd_class_get_by_config(struct usbd_contex *const uds_ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct usbd_class_node *
|
struct usbd_class_node *
|
||||||
usbd_class_get_by_iface(struct usbd_contex *const uds_ctx,
|
usbd_class_get_by_iface(struct usbd_context *const uds_ctx,
|
||||||
const uint8_t inum)
|
const uint8_t inum)
|
||||||
{
|
{
|
||||||
struct usbd_class_node *c_nd;
|
struct usbd_class_node *c_nd;
|
||||||
|
@ -87,7 +87,7 @@ usbd_class_get_by_iface(struct usbd_contex *const uds_ctx,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool xfer_owner_exist(struct usbd_contex *const uds_ctx,
|
static bool xfer_owner_exist(struct usbd_context *const uds_ctx,
|
||||||
struct usbd_config_node *const cfg_nd,
|
struct usbd_config_node *const cfg_nd,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
|
@ -114,7 +114,7 @@ static bool xfer_owner_exist(struct usbd_contex *const uds_ctx,
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_class_handle_xfer(struct usbd_contex *const uds_ctx,
|
int usbd_class_handle_xfer(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf,
|
struct net_buf *const buf,
|
||||||
const int err)
|
const int err)
|
||||||
{
|
{
|
||||||
|
@ -137,7 +137,7 @@ int usbd_class_handle_xfer(struct usbd_contex *const uds_ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct usbd_class_node *
|
struct usbd_class_node *
|
||||||
usbd_class_get_by_ep(struct usbd_contex *const uds_ctx,
|
usbd_class_get_by_ep(struct usbd_context *const uds_ctx,
|
||||||
const uint8_t ep)
|
const uint8_t ep)
|
||||||
{
|
{
|
||||||
struct usbd_class_node *c_nd;
|
struct usbd_class_node *c_nd;
|
||||||
|
@ -175,7 +175,7 @@ usbd_class_get_by_ep(struct usbd_contex *const uds_ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct usbd_class_node *
|
struct usbd_class_node *
|
||||||
usbd_class_get_by_req(struct usbd_contex *const uds_ctx,
|
usbd_class_get_by_req(struct usbd_context *const uds_ctx,
|
||||||
const uint8_t request)
|
const uint8_t request)
|
||||||
{
|
{
|
||||||
struct usbd_config_node *cfg_nd;
|
struct usbd_config_node *cfg_nd;
|
||||||
|
@ -229,7 +229,7 @@ usbd_class_node_get(const char *name, const enum usbd_speed speed)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int usbd_class_append(struct usbd_contex *const uds_ctx,
|
static int usbd_class_append(struct usbd_context *const uds_ctx,
|
||||||
struct usbd_class_node *const c_nd,
|
struct usbd_class_node *const c_nd,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t cfg)
|
const uint8_t cfg)
|
||||||
|
@ -246,7 +246,7 @@ static int usbd_class_append(struct usbd_contex *const uds_ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int usbd_class_remove(struct usbd_contex *const uds_ctx,
|
static int usbd_class_remove(struct usbd_context *const uds_ctx,
|
||||||
struct usbd_class_node *const c_nd,
|
struct usbd_class_node *const c_nd,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t cfg)
|
const uint8_t cfg)
|
||||||
|
@ -265,7 +265,7 @@ static int usbd_class_remove(struct usbd_contex *const uds_ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_class_remove_all(struct usbd_contex *const uds_ctx,
|
int usbd_class_remove_all(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t cfg)
|
const uint8_t cfg)
|
||||||
{
|
{
|
||||||
|
@ -292,7 +292,7 @@ int usbd_class_remove_all(struct usbd_contex *const uds_ctx,
|
||||||
* All the functions below are part of public USB device support API.
|
* All the functions below are part of public USB device support API.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int usbd_register_class(struct usbd_contex *const uds_ctx,
|
int usbd_register_class(struct usbd_context *const uds_ctx,
|
||||||
const char *name,
|
const char *name,
|
||||||
const enum usbd_speed speed, const uint8_t cfg)
|
const enum usbd_speed speed, const uint8_t cfg)
|
||||||
{
|
{
|
||||||
|
@ -340,7 +340,7 @@ register_class_error:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_unregister_class(struct usbd_contex *const uds_ctx,
|
int usbd_unregister_class(struct usbd_context *const uds_ctx,
|
||||||
const char *name,
|
const char *name,
|
||||||
const enum usbd_speed speed, const uint8_t cfg)
|
const enum usbd_speed speed, const uint8_t cfg)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*
|
*
|
||||||
* @return usbd_class_request() return value
|
* @return usbd_class_request() return value
|
||||||
*/
|
*/
|
||||||
int usbd_class_handle_xfer(struct usbd_contex *const uds_ctx,
|
int usbd_class_handle_xfer(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf,
|
struct net_buf *const buf,
|
||||||
const int err);
|
const int err);
|
||||||
|
|
||||||
|
@ -47,7 +47,7 @@ size_t usbd_class_desc_len(struct usbd_class_data *const c_data,
|
||||||
*
|
*
|
||||||
* @return Class c_nd pointer or NULL
|
* @return Class c_nd pointer or NULL
|
||||||
*/
|
*/
|
||||||
struct usbd_class_node *usbd_class_get_by_iface(struct usbd_contex *uds_ctx,
|
struct usbd_class_node *usbd_class_get_by_iface(struct usbd_context *uds_ctx,
|
||||||
uint8_t i_n);
|
uint8_t i_n);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -60,7 +60,7 @@ struct usbd_class_node *usbd_class_get_by_iface(struct usbd_contex *uds_ctx,
|
||||||
*
|
*
|
||||||
* @return Class c_nd pointer or NULL
|
* @return Class c_nd pointer or NULL
|
||||||
*/
|
*/
|
||||||
struct usbd_class_node *usbd_class_get_by_config(struct usbd_contex *uds_ctx,
|
struct usbd_class_node *usbd_class_get_by_config(struct usbd_context *uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
uint8_t cnum,
|
uint8_t cnum,
|
||||||
uint8_t inum);
|
uint8_t inum);
|
||||||
|
@ -75,7 +75,7 @@ struct usbd_class_node *usbd_class_get_by_config(struct usbd_contex *uds_ctx,
|
||||||
*
|
*
|
||||||
* @return Class c_nd pointer or NULL
|
* @return Class c_nd pointer or NULL
|
||||||
*/
|
*/
|
||||||
struct usbd_class_node *usbd_class_get_by_ep(struct usbd_contex *uds_ctx,
|
struct usbd_class_node *usbd_class_get_by_ep(struct usbd_context *uds_ctx,
|
||||||
uint8_t ep);
|
uint8_t ep);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -92,7 +92,7 @@ struct usbd_class_node *usbd_class_get_by_ep(struct usbd_contex *uds_ctx,
|
||||||
*
|
*
|
||||||
* @return Class c_nd pointer or NULL
|
* @return Class c_nd pointer or NULL
|
||||||
*/
|
*/
|
||||||
struct usbd_class_node *usbd_class_get_by_req(struct usbd_contex *uds_ctx,
|
struct usbd_class_node *usbd_class_get_by_req(struct usbd_context *uds_ctx,
|
||||||
uint8_t request);
|
uint8_t request);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -104,7 +104,7 @@ struct usbd_class_node *usbd_class_get_by_req(struct usbd_contex *uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_class_remove_all(struct usbd_contex *const uds_ctx,
|
int usbd_class_remove_all(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t cfg);
|
const uint8_t cfg);
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include <zephyr/logging/log.h>
|
#include <zephyr/logging/log.h>
|
||||||
LOG_MODULE_REGISTER(usbd_cfg, CONFIG_USBD_LOG_LEVEL);
|
LOG_MODULE_REGISTER(usbd_cfg, CONFIG_USBD_LOG_LEVEL);
|
||||||
|
|
||||||
static sys_slist_t *usbd_configs(struct usbd_contex *uds_ctx,
|
static sys_slist_t *usbd_configs(struct usbd_context *uds_ctx,
|
||||||
const enum usbd_speed speed)
|
const enum usbd_speed speed)
|
||||||
{
|
{
|
||||||
switch (speed) {
|
switch (speed) {
|
||||||
|
@ -29,7 +29,7 @@ static sys_slist_t *usbd_configs(struct usbd_contex *uds_ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct usbd_config_node *usbd_config_get(struct usbd_contex *const uds_ctx,
|
struct usbd_config_node *usbd_config_get(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t cfg)
|
const uint8_t cfg)
|
||||||
{
|
{
|
||||||
|
@ -45,7 +45,7 @@ struct usbd_config_node *usbd_config_get(struct usbd_contex *const uds_ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct usbd_config_node *
|
struct usbd_config_node *
|
||||||
usbd_config_get_current(struct usbd_contex *const uds_ctx)
|
usbd_config_get_current(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
if (!usbd_state_is_configured(uds_ctx)) {
|
if (!usbd_state_is_configured(uds_ctx)) {
|
||||||
LOG_INF("No configuration set (Address state?)");
|
LOG_INF("No configuration set (Address state?)");
|
||||||
|
@ -71,7 +71,7 @@ static void usbd_config_classes_enable(struct usbd_config_node *const cfg_nd,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Reset configuration to addressed state, shutdown all endpoints */
|
/* Reset configuration to addressed state, shutdown all endpoints */
|
||||||
static int usbd_config_reset(struct usbd_contex *const uds_ctx)
|
static int usbd_config_reset(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
struct usbd_config_node *cfg_nd;
|
struct usbd_config_node *cfg_nd;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -92,7 +92,7 @@ static int usbd_config_reset(struct usbd_contex *const uds_ctx)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool usbd_config_exist(struct usbd_contex *const uds_ctx,
|
bool usbd_config_exist(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t cfg)
|
const uint8_t cfg)
|
||||||
{
|
{
|
||||||
|
@ -103,7 +103,7 @@ bool usbd_config_exist(struct usbd_contex *const uds_ctx,
|
||||||
return (config != NULL) ? true : false;
|
return (config != NULL) ? true : false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_config_set(struct usbd_contex *const uds_ctx,
|
int usbd_config_set(struct usbd_context *const uds_ctx,
|
||||||
const uint8_t new_cfg)
|
const uint8_t new_cfg)
|
||||||
{
|
{
|
||||||
struct usbd_config_node *cfg_nd;
|
struct usbd_config_node *cfg_nd;
|
||||||
|
@ -143,7 +143,7 @@ int usbd_config_set(struct usbd_contex *const uds_ctx,
|
||||||
* All the functions below are part of public USB device support API.
|
* All the functions below are part of public USB device support API.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int usbd_config_attrib_rwup(struct usbd_contex *const uds_ctx,
|
int usbd_config_attrib_rwup(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t cfg, const bool enable)
|
const uint8_t cfg, const bool enable)
|
||||||
{
|
{
|
||||||
|
@ -185,7 +185,7 @@ attrib_rwup_exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_config_attrib_self(struct usbd_contex *const uds_ctx,
|
int usbd_config_attrib_self(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t cfg, const bool enable)
|
const uint8_t cfg, const bool enable)
|
||||||
{
|
{
|
||||||
|
@ -219,7 +219,7 @@ attrib_self_exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_config_maxpower(struct usbd_contex *const uds_ctx,
|
int usbd_config_maxpower(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t cfg, const uint8_t power)
|
const uint8_t cfg, const uint8_t power)
|
||||||
{
|
{
|
||||||
|
@ -249,7 +249,7 @@ maxpower_exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_add_configuration(struct usbd_contex *const uds_ctx,
|
int usbd_add_configuration(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
struct usbd_config_node *const cfg_nd)
|
struct usbd_config_node *const cfg_nd)
|
||||||
{
|
{
|
||||||
|
|
|
@ -47,7 +47,7 @@ static inline void usbd_config_set_value(const struct usbd_config_node *const cf
|
||||||
*
|
*
|
||||||
* @return pointer to configuration node or NULL if does not exist
|
* @return pointer to configuration node or NULL if does not exist
|
||||||
*/
|
*/
|
||||||
struct usbd_config_node *usbd_config_get(struct usbd_contex *uds_ctx,
|
struct usbd_config_node *usbd_config_get(struct usbd_context *uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
uint8_t cfg);
|
uint8_t cfg);
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ struct usbd_config_node *usbd_config_get(struct usbd_contex *uds_ctx,
|
||||||
*
|
*
|
||||||
* @return pointer to configuration node or NULL if does not exist
|
* @return pointer to configuration node or NULL if does not exist
|
||||||
*/
|
*/
|
||||||
struct usbd_config_node *usbd_config_get_current(struct usbd_contex *uds_ctx);
|
struct usbd_config_node *usbd_config_get_current(struct usbd_context *uds_ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Check whether a configuration exist
|
* @brief Check whether a configuration exist
|
||||||
|
@ -71,7 +71,7 @@ struct usbd_config_node *usbd_config_get_current(struct usbd_contex *uds_ctx);
|
||||||
*
|
*
|
||||||
* @return True if a configuration exist.
|
* @return True if a configuration exist.
|
||||||
*/
|
*/
|
||||||
bool usbd_config_exist(struct usbd_contex *const uds_ctx,
|
bool usbd_config_exist(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t cfg);
|
const uint8_t cfg);
|
||||||
|
|
||||||
|
@ -87,6 +87,6 @@ bool usbd_config_exist(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_config_set(struct usbd_contex *uds_ctx, uint8_t new_cfg);
|
int usbd_config_set(struct usbd_context *uds_ctx, uint8_t new_cfg);
|
||||||
|
|
||||||
#endif /* ZEPHYR_INCLUDE_USBD_CONFIG_H */
|
#endif /* ZEPHYR_INCLUDE_USBD_CONFIG_H */
|
||||||
|
|
|
@ -37,7 +37,7 @@ static int usbd_event_carrier(const struct device *dev,
|
||||||
return k_msgq_put(&usbd_msgq, event, K_NO_WAIT);
|
return k_msgq_put(&usbd_msgq, event, K_NO_WAIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int event_handler_ep_request(struct usbd_contex *const uds_ctx,
|
static int event_handler_ep_request(struct usbd_context *const uds_ctx,
|
||||||
const struct udc_event *const event)
|
const struct udc_event *const event)
|
||||||
{
|
{
|
||||||
struct udc_buf_info *bi;
|
struct udc_buf_info *bi;
|
||||||
|
@ -59,7 +59,7 @@ static int event_handler_ep_request(struct usbd_contex *const uds_ctx,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usbd_class_bcast_event(struct usbd_contex *const uds_ctx,
|
static void usbd_class_bcast_event(struct usbd_context *const uds_ctx,
|
||||||
struct udc_event *const event)
|
struct udc_event *const event)
|
||||||
{
|
{
|
||||||
struct usbd_config_node *cfg_nd;
|
struct usbd_config_node *cfg_nd;
|
||||||
|
@ -92,7 +92,7 @@ static void usbd_class_bcast_event(struct usbd_contex *const uds_ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int event_handler_bus_reset(struct usbd_contex *const uds_ctx)
|
static int event_handler_bus_reset(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
enum udc_bus_speed udc_speed;
|
enum udc_bus_speed udc_speed;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -131,7 +131,7 @@ static int event_handler_bus_reset(struct usbd_contex *const uds_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static ALWAYS_INLINE void usbd_event_handler(struct usbd_contex *const uds_ctx,
|
static ALWAYS_INLINE void usbd_event_handler(struct usbd_context *const uds_ctx,
|
||||||
struct udc_event *const event)
|
struct udc_event *const event)
|
||||||
{
|
{
|
||||||
int err = 0;
|
int err = 0;
|
||||||
|
@ -192,7 +192,7 @@ static void usbd_thread(void *p1, void *p2, void *p3)
|
||||||
while (true) {
|
while (true) {
|
||||||
k_msgq_get(&usbd_msgq, &event, K_FOREVER);
|
k_msgq_get(&usbd_msgq, &event, K_FOREVER);
|
||||||
|
|
||||||
STRUCT_SECTION_FOREACH(usbd_contex, uds_ctx) {
|
STRUCT_SECTION_FOREACH(usbd_context, uds_ctx) {
|
||||||
if (uds_ctx->dev == event.dev) {
|
if (uds_ctx->dev == event.dev) {
|
||||||
usbd_event_handler(uds_ctx, &event);
|
usbd_event_handler(uds_ctx, &event);
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ static void usbd_thread(void *p1, void *p2, void *p3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_device_init_core(struct usbd_contex *const uds_ctx)
|
int usbd_device_init_core(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ int usbd_device_init_core(struct usbd_contex *const uds_ctx)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_device_shutdown_core(struct usbd_contex *const uds_ctx)
|
int usbd_device_shutdown_core(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
struct usbd_config_node *cfg_nd;
|
struct usbd_config_node *cfg_nd;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include <zephyr/linker/iterable_sections.h>
|
#include <zephyr/linker/iterable_sections.h>
|
||||||
|
|
||||||
ITERABLE_SECTION_RAM(usbd_contex, Z_LINK_ITERABLE_SUBALIGN)
|
ITERABLE_SECTION_RAM(usbd_context, Z_LINK_ITERABLE_SUBALIGN)
|
||||||
ITERABLE_SECTION_RAM(usbd_class_fs, Z_LINK_ITERABLE_SUBALIGN)
|
ITERABLE_SECTION_RAM(usbd_class_fs, Z_LINK_ITERABLE_SUBALIGN)
|
||||||
ITERABLE_SECTION_RAM(usbd_class_hs, Z_LINK_ITERABLE_SUBALIGN)
|
ITERABLE_SECTION_RAM(usbd_class_hs, Z_LINK_ITERABLE_SUBALIGN)
|
||||||
|
|
|
@ -28,7 +28,7 @@ static inline bool desc_type_equal(const struct usbd_desc_node *const a,
|
||||||
* does not care about index zero for the language string descriptor,
|
* does not care about index zero for the language string descriptor,
|
||||||
* so if it is not added first, the device will be non-compliant.
|
* so if it is not added first, the device will be non-compliant.
|
||||||
*/
|
*/
|
||||||
static int desc_add_and_update_idx(struct usbd_contex *const uds_ctx,
|
static int desc_add_and_update_idx(struct usbd_context *const uds_ctx,
|
||||||
struct usbd_desc_node *const new_nd)
|
struct usbd_desc_node *const new_nd)
|
||||||
{
|
{
|
||||||
struct usbd_desc_node *tmp_nd;
|
struct usbd_desc_node *tmp_nd;
|
||||||
|
@ -80,7 +80,7 @@ static int desc_add_and_update_idx(struct usbd_contex *const uds_ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct usbd_desc_node *usbd_get_descriptor(struct usbd_contex *const uds_ctx,
|
struct usbd_desc_node *usbd_get_descriptor(struct usbd_context *const uds_ctx,
|
||||||
const uint8_t type, const uint8_t idx)
|
const uint8_t type, const uint8_t idx)
|
||||||
{
|
{
|
||||||
struct usbd_desc_node *desc_nd;
|
struct usbd_desc_node *desc_nd;
|
||||||
|
@ -102,7 +102,7 @@ struct usbd_desc_node *usbd_get_descriptor(struct usbd_contex *const uds_ctx,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_desc_remove_all(struct usbd_contex *const uds_ctx)
|
int usbd_desc_remove_all(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
struct usbd_desc_node *tmp;
|
struct usbd_desc_node *tmp;
|
||||||
sys_dnode_t *node;
|
sys_dnode_t *node;
|
||||||
|
@ -115,7 +115,7 @@ int usbd_desc_remove_all(struct usbd_contex *const uds_ctx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_add_descriptor(struct usbd_contex *const uds_ctx,
|
int usbd_add_descriptor(struct usbd_context *const uds_ctx,
|
||||||
struct usbd_desc_node *const desc_nd)
|
struct usbd_desc_node *const desc_nd)
|
||||||
{
|
{
|
||||||
struct usb_device_descriptor *hs_desc, *fs_desc;
|
struct usb_device_descriptor *hs_desc, *fs_desc;
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
*
|
*
|
||||||
* @return pointer to descriptor node or NULL if not found.
|
* @return pointer to descriptor node or NULL if not found.
|
||||||
*/
|
*/
|
||||||
struct usbd_desc_node *usbd_get_descriptor(struct usbd_contex *const uds_ctx,
|
struct usbd_desc_node *usbd_get_descriptor(struct usbd_context *const uds_ctx,
|
||||||
const uint8_t type, const uint8_t idx);
|
const uint8_t type, const uint8_t idx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -34,6 +34,6 @@ struct usbd_desc_node *usbd_get_descriptor(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_desc_remove_all(struct usbd_contex *const uds_ctx);
|
int usbd_desc_remove_all(struct usbd_context *const uds_ctx);
|
||||||
|
|
||||||
#endif /* ZEPHYR_INCLUDE_USBD_DESC_H */
|
#endif /* ZEPHYR_INCLUDE_USBD_DESC_H */
|
||||||
|
|
|
@ -20,12 +20,12 @@ LOG_MODULE_REGISTER(usbd_dev, CONFIG_USBD_LOG_LEVEL);
|
||||||
* All the functions below are part of public USB device support API.
|
* All the functions below are part of public USB device support API.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
enum usbd_speed usbd_bus_speed(const struct usbd_contex *const uds_ctx)
|
enum usbd_speed usbd_bus_speed(const struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
return uds_ctx->status.speed;
|
return uds_ctx->status.speed;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum usbd_speed usbd_caps_speed(const struct usbd_contex *const uds_ctx)
|
enum usbd_speed usbd_caps_speed(const struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
struct udc_device_caps caps = udc_caps(uds_ctx->dev);
|
struct udc_device_caps caps = udc_caps(uds_ctx->dev);
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ enum usbd_speed usbd_caps_speed(const struct usbd_contex *const uds_ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct usb_device_descriptor *
|
static struct usb_device_descriptor *
|
||||||
get_device_descriptor(struct usbd_contex *const uds_ctx,
|
get_device_descriptor(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed)
|
const enum usbd_speed speed)
|
||||||
{
|
{
|
||||||
switch (speed) {
|
switch (speed) {
|
||||||
|
@ -52,7 +52,7 @@ get_device_descriptor(struct usbd_contex *const uds_ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_device_set_bcd(struct usbd_contex *const uds_ctx,
|
int usbd_device_set_bcd(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed, const uint16_t bcd)
|
const enum usbd_speed speed, const uint16_t bcd)
|
||||||
{
|
{
|
||||||
struct usb_device_descriptor *desc;
|
struct usb_device_descriptor *desc;
|
||||||
|
@ -73,7 +73,7 @@ set_bcd_exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_device_set_vid(struct usbd_contex *const uds_ctx,
|
int usbd_device_set_vid(struct usbd_context *const uds_ctx,
|
||||||
const uint16_t vid)
|
const uint16_t vid)
|
||||||
{
|
{
|
||||||
struct usb_device_descriptor *fs_desc, *hs_desc;
|
struct usb_device_descriptor *fs_desc, *hs_desc;
|
||||||
|
@ -97,7 +97,7 @@ set_vid_exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_device_set_pid(struct usbd_contex *const uds_ctx,
|
int usbd_device_set_pid(struct usbd_context *const uds_ctx,
|
||||||
const uint16_t pid)
|
const uint16_t pid)
|
||||||
{
|
{
|
||||||
struct usb_device_descriptor *fs_desc, *hs_desc;
|
struct usb_device_descriptor *fs_desc, *hs_desc;
|
||||||
|
@ -121,7 +121,7 @@ set_pid_exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_device_set_code_triple(struct usbd_contex *const uds_ctx,
|
int usbd_device_set_code_triple(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t base_class,
|
const uint8_t base_class,
|
||||||
const uint8_t subclass, const uint8_t protocol)
|
const uint8_t subclass, const uint8_t protocol)
|
||||||
|
@ -146,7 +146,7 @@ set_code_triple_exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_wakeup_request(struct usbd_contex *const uds_ctx)
|
int usbd_wakeup_request(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
struct udc_device_caps caps = udc_caps(uds_ctx->dev);
|
struct udc_device_caps caps = udc_caps(uds_ctx->dev);
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -173,12 +173,12 @@ wakeup_request_error:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool usbd_is_suspended(struct usbd_contex *uds_ctx)
|
bool usbd_is_suspended(struct usbd_context *uds_ctx)
|
||||||
{
|
{
|
||||||
return uds_ctx->status.suspended;
|
return uds_ctx->status.suspended;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_init(struct usbd_contex *const uds_ctx)
|
int usbd_init(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -221,7 +221,7 @@ init_exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_enable(struct usbd_contex *const uds_ctx)
|
int usbd_enable(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -258,7 +258,7 @@ enable_exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_disable(struct usbd_contex *const uds_ctx)
|
int usbd_disable(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -286,7 +286,7 @@ int usbd_disable(struct usbd_contex *const uds_ctx)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_shutdown(struct usbd_contex *const uds_ctx)
|
int usbd_shutdown(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -304,7 +304,7 @@ int usbd_shutdown(struct usbd_contex *const uds_ctx)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool usbd_can_detect_vbus(struct usbd_contex *const uds_ctx)
|
bool usbd_can_detect_vbus(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
const struct udc_device_caps caps = udc_caps(uds_ctx->dev);
|
const struct udc_device_caps caps = udc_caps(uds_ctx->dev);
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
*
|
*
|
||||||
* @return bNumConfigurations value
|
* @return bNumConfigurations value
|
||||||
*/
|
*/
|
||||||
static inline uint8_t usbd_get_num_configs(const struct usbd_contex *const uds_ctx,
|
static inline uint8_t usbd_get_num_configs(const struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed)
|
const enum usbd_speed speed)
|
||||||
{
|
{
|
||||||
struct usb_device_descriptor *desc;
|
struct usb_device_descriptor *desc;
|
||||||
|
@ -42,7 +42,7 @@ static inline uint8_t usbd_get_num_configs(const struct usbd_contex *const uds_c
|
||||||
* @param[in] speed Speed for which the bNumConfigurations should be set
|
* @param[in] speed Speed for which the bNumConfigurations should be set
|
||||||
* @param[in] value new bNumConfigurations value
|
* @param[in] value new bNumConfigurations value
|
||||||
*/
|
*/
|
||||||
static inline void usbd_set_num_configs(struct usbd_contex *const uds_ctx,
|
static inline void usbd_set_num_configs(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
const uint8_t value)
|
const uint8_t value)
|
||||||
{
|
{
|
||||||
|
@ -66,7 +66,7 @@ static inline void usbd_set_num_configs(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return true if USB device is in enabled, false otherwise
|
* @return true if USB device is in enabled, false otherwise
|
||||||
*/
|
*/
|
||||||
static inline bool usbd_is_enabled(const struct usbd_contex *const uds_ctx)
|
static inline bool usbd_is_enabled(const struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
return uds_ctx->status.enabled;
|
return uds_ctx->status.enabled;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ static inline bool usbd_is_enabled(const struct usbd_contex *const uds_ctx)
|
||||||
*
|
*
|
||||||
* @return true if USB device is in enabled, false otherwise
|
* @return true if USB device is in enabled, false otherwise
|
||||||
*/
|
*/
|
||||||
static inline bool usbd_is_initialized(const struct usbd_contex *const uds_ctx)
|
static inline bool usbd_is_initialized(const struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
return uds_ctx->status.initialized;
|
return uds_ctx->status.initialized;
|
||||||
}
|
}
|
||||||
|
@ -89,7 +89,7 @@ static inline bool usbd_is_initialized(const struct usbd_contex *const uds_ctx)
|
||||||
* @param[in] uds_ctx Pointer to a device context
|
* @param[in] uds_ctx Pointer to a device context
|
||||||
* @param[in] value new suspended value
|
* @param[in] value new suspended value
|
||||||
*/
|
*/
|
||||||
static inline void usbd_status_suspended(struct usbd_contex *const uds_ctx,
|
static inline void usbd_status_suspended(struct usbd_context *const uds_ctx,
|
||||||
const bool value)
|
const bool value)
|
||||||
{
|
{
|
||||||
uds_ctx->status.suspended = value;
|
uds_ctx->status.suspended = value;
|
||||||
|
@ -100,7 +100,7 @@ static inline void usbd_status_suspended(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @param[in] node Pointer to a device context
|
* @param[in] node Pointer to a device context
|
||||||
*/
|
*/
|
||||||
static inline void usbd_device_lock(struct usbd_contex *const uds_ctx)
|
static inline void usbd_device_lock(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
k_mutex_lock(&uds_ctx->mutex, K_FOREVER);
|
k_mutex_lock(&uds_ctx->mutex, K_FOREVER);
|
||||||
}
|
}
|
||||||
|
@ -110,7 +110,7 @@ static inline void usbd_device_lock(struct usbd_contex *const uds_ctx)
|
||||||
*
|
*
|
||||||
* @param[in] node Pointer to a device context
|
* @param[in] node Pointer to a device context
|
||||||
*/
|
*/
|
||||||
static inline void usbd_device_unlock(struct usbd_contex *const uds_ctx)
|
static inline void usbd_device_unlock(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
k_mutex_unlock(&uds_ctx->mutex);
|
k_mutex_unlock(&uds_ctx->mutex);
|
||||||
}
|
}
|
||||||
|
@ -122,7 +122,7 @@ static inline void usbd_device_unlock(struct usbd_contex *const uds_ctx)
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_device_init_core(struct usbd_contex *uds_ctx);
|
int usbd_device_init_core(struct usbd_context *uds_ctx);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Shutdown USB device stack core
|
* @brief Shutdown USB device stack core
|
||||||
|
@ -131,6 +131,6 @@ int usbd_device_init_core(struct usbd_contex *uds_ctx);
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_device_shutdown_core(struct usbd_contex *const uds_ctx);
|
int usbd_device_shutdown_core(struct usbd_context *const uds_ctx);
|
||||||
|
|
||||||
#endif /* ZEPHYR_INCLUDE_USBD_DEVICE_H */
|
#endif /* ZEPHYR_INCLUDE_USBD_DEVICE_H */
|
||||||
|
|
|
@ -55,7 +55,7 @@ int usbd_ep_disable(const struct device *dev,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usbd_ep_ctrl_set_zlp(struct usbd_contex *const uds_ctx,
|
static void usbd_ep_ctrl_set_zlp(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
struct usb_setup_packet *setup = usbd_get_setup_pkt(uds_ctx);
|
||||||
|
@ -86,7 +86,7 @@ static void usbd_ep_ctrl_set_zlp(struct usbd_contex *const uds_ctx,
|
||||||
* All the functions below are part of public USB device support API.
|
* All the functions below are part of public USB device support API.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int usbd_ep_ctrl_enqueue(struct usbd_contex *const uds_ctx,
|
int usbd_ep_ctrl_enqueue(struct usbd_context *const uds_ctx,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
struct udc_buf_info *bi;
|
struct udc_buf_info *bi;
|
||||||
|
@ -112,7 +112,7 @@ int usbd_ep_ctrl_enqueue(struct usbd_contex *const uds_ctx,
|
||||||
struct net_buf *usbd_ep_buf_alloc(const struct usbd_class_data *const c_data,
|
struct net_buf *usbd_ep_buf_alloc(const struct usbd_class_data *const c_data,
|
||||||
const uint8_t ep, const size_t size)
|
const uint8_t ep, const size_t size)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
|
|
||||||
return udc_ep_buf_alloc(uds_ctx->dev, ep, size);
|
return udc_ep_buf_alloc(uds_ctx->dev, ep, size);
|
||||||
}
|
}
|
||||||
|
@ -120,7 +120,7 @@ struct net_buf *usbd_ep_buf_alloc(const struct usbd_class_data *const c_data,
|
||||||
int usbd_ep_enqueue(const struct usbd_class_data *const c_data,
|
int usbd_ep_enqueue(const struct usbd_class_data *const c_data,
|
||||||
struct net_buf *const buf)
|
struct net_buf *const buf)
|
||||||
{
|
{
|
||||||
struct usbd_contex *uds_ctx = usbd_class_get_ctx(c_data);
|
struct usbd_context *uds_ctx = usbd_class_get_ctx(c_data);
|
||||||
struct udc_buf_info *bi = udc_get_buf_info(buf);
|
struct udc_buf_info *bi = udc_get_buf_info(buf);
|
||||||
|
|
||||||
if (USB_EP_DIR_IS_IN(bi->ep)) {
|
if (USB_EP_DIR_IS_IN(bi->ep)) {
|
||||||
|
@ -134,17 +134,17 @@ int usbd_ep_enqueue(const struct usbd_class_data *const c_data,
|
||||||
return udc_ep_enqueue(uds_ctx->dev, buf);
|
return udc_ep_enqueue(uds_ctx->dev, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_ep_buf_free(struct usbd_contex *const uds_ctx, struct net_buf *buf)
|
int usbd_ep_buf_free(struct usbd_context *const uds_ctx, struct net_buf *buf)
|
||||||
{
|
{
|
||||||
return udc_ep_buf_free(uds_ctx->dev, buf);
|
return udc_ep_buf_free(uds_ctx->dev, buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_ep_dequeue(struct usbd_contex *const uds_ctx, const uint8_t ep)
|
int usbd_ep_dequeue(struct usbd_context *const uds_ctx, const uint8_t ep)
|
||||||
{
|
{
|
||||||
return udc_ep_dequeue(uds_ctx->dev, ep);
|
return udc_ep_dequeue(uds_ctx->dev, ep);
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_ep_set_halt(struct usbd_contex *const uds_ctx, const uint8_t ep)
|
int usbd_ep_set_halt(struct usbd_context *const uds_ctx, const uint8_t ep)
|
||||||
{
|
{
|
||||||
struct usbd_ch9_data *ch9_data = &uds_ctx->ch9_data;
|
struct usbd_ch9_data *ch9_data = &uds_ctx->ch9_data;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -160,7 +160,7 @@ int usbd_ep_set_halt(struct usbd_contex *const uds_ctx, const uint8_t ep)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_ep_clear_halt(struct usbd_contex *const uds_ctx, const uint8_t ep)
|
int usbd_ep_clear_halt(struct usbd_context *const uds_ctx, const uint8_t ep)
|
||||||
{
|
{
|
||||||
struct usbd_ch9_data *ch9_data = &uds_ctx->ch9_data;
|
struct usbd_ch9_data *ch9_data = &uds_ctx->ch9_data;
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -176,7 +176,7 @@ int usbd_ep_clear_halt(struct usbd_contex *const uds_ctx, const uint8_t ep)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool usbd_ep_is_halted(struct usbd_contex *const uds_ctx, const uint8_t ep)
|
bool usbd_ep_is_halted(struct usbd_context *const uds_ctx, const uint8_t ep)
|
||||||
{
|
{
|
||||||
struct usbd_ch9_data *ch9_data = &uds_ctx->ch9_data;
|
struct usbd_ch9_data *ch9_data = &uds_ctx->ch9_data;
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ static int assign_ep_addr(const struct device *dev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unassign all endpoint of a class instance based on class_ep_bm */
|
/* Unassign all endpoint of a class instance based on class_ep_bm */
|
||||||
static int unassign_eps(struct usbd_contex *const uds_ctx,
|
static int unassign_eps(struct usbd_context *const uds_ctx,
|
||||||
uint32_t *const config_ep_bm,
|
uint32_t *const config_ep_bm,
|
||||||
uint32_t *const class_ep_bm)
|
uint32_t *const class_ep_bm)
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,7 @@ static int unassign_eps(struct usbd_contex *const uds_ctx,
|
||||||
* We use config_ep_bm variable as map for assigned endpoint for an
|
* We use config_ep_bm variable as map for assigned endpoint for an
|
||||||
* USB device configuration.
|
* USB device configuration.
|
||||||
*/
|
*/
|
||||||
static int init_configuration_inst(struct usbd_contex *const uds_ctx,
|
static int init_configuration_inst(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
struct usbd_class_node *const c_nd,
|
struct usbd_class_node *const c_nd,
|
||||||
uint32_t *const config_ep_bm,
|
uint32_t *const config_ep_bm,
|
||||||
|
@ -191,7 +191,7 @@ static int init_configuration_inst(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* Iterate on a list of all classes in a configuration
|
* Iterate on a list of all classes in a configuration
|
||||||
*/
|
*/
|
||||||
static int init_configuration(struct usbd_contex *const uds_ctx,
|
static int init_configuration(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
struct usbd_config_node *const cfg_nd)
|
struct usbd_config_node *const cfg_nd)
|
||||||
{
|
{
|
||||||
|
@ -243,7 +243,7 @@ static int init_configuration(struct usbd_contex *const uds_ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void usbd_init_update_fs_mps0(struct usbd_contex *const uds_ctx)
|
static void usbd_init_update_fs_mps0(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
struct udc_device_caps caps = udc_caps(uds_ctx->dev);
|
struct udc_device_caps caps = udc_caps(uds_ctx->dev);
|
||||||
struct usb_device_descriptor *desc = uds_ctx->fs_desc;
|
struct usb_device_descriptor *desc = uds_ctx->fs_desc;
|
||||||
|
@ -264,7 +264,7 @@ static void usbd_init_update_fs_mps0(struct usbd_contex *const uds_ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_init_configurations(struct usbd_contex *const uds_ctx)
|
int usbd_init_configurations(struct usbd_context *const uds_ctx)
|
||||||
{
|
{
|
||||||
struct usbd_config_node *cfg_nd;
|
struct usbd_config_node *cfg_nd;
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,6 @@
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_init_configurations(struct usbd_contex *const uds_ctx);
|
int usbd_init_configurations(struct usbd_context *const uds_ctx);
|
||||||
|
|
||||||
#endif /* ZEPHYR_INCLUDE_USBD_INIT_H */
|
#endif /* ZEPHYR_INCLUDE_USBD_INIT_H */
|
||||||
|
|
|
@ -22,7 +22,7 @@ enum ep_op {
|
||||||
EP_OP_DOWN, /* Disable endpoint and update endpoints bitmap */
|
EP_OP_DOWN, /* Disable endpoint and update endpoints bitmap */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int handle_ep_op(struct usbd_contex *const uds_ctx,
|
static int handle_ep_op(struct usbd_context *const uds_ctx,
|
||||||
const enum ep_op op,
|
const enum ep_op op,
|
||||||
struct usb_ep_descriptor *const ed,
|
struct usb_ep_descriptor *const ed,
|
||||||
uint32_t *const ep_bm)
|
uint32_t *const ep_bm)
|
||||||
|
@ -50,7 +50,7 @@ static int handle_ep_op(struct usbd_contex *const uds_ctx,
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int usbd_interface_modify(struct usbd_contex *const uds_ctx,
|
static int usbd_interface_modify(struct usbd_context *const uds_ctx,
|
||||||
struct usbd_class_node *const c_nd,
|
struct usbd_class_node *const c_nd,
|
||||||
const enum ep_op op,
|
const enum ep_op op,
|
||||||
const uint8_t iface,
|
const uint8_t iface,
|
||||||
|
@ -107,7 +107,7 @@ static int usbd_interface_modify(struct usbd_contex *const uds_ctx,
|
||||||
return found_iface ? 0 : -ENODATA;
|
return found_iface ? 0 : -ENODATA;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_interface_shutdown(struct usbd_contex *const uds_ctx,
|
int usbd_interface_shutdown(struct usbd_context *const uds_ctx,
|
||||||
struct usbd_config_node *const cfg_nd)
|
struct usbd_config_node *const cfg_nd)
|
||||||
{
|
{
|
||||||
struct usbd_class_node *c_nd;
|
struct usbd_class_node *c_nd;
|
||||||
|
@ -139,7 +139,7 @@ int usbd_interface_shutdown(struct usbd_contex *const uds_ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_interface_default(struct usbd_contex *const uds_ctx,
|
int usbd_interface_default(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
struct usbd_config_node *const cfg_nd)
|
struct usbd_config_node *const cfg_nd)
|
||||||
{
|
{
|
||||||
|
@ -165,7 +165,7 @@ int usbd_interface_default(struct usbd_contex *const uds_ctx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_interface_set(struct usbd_contex *const uds_ctx,
|
int usbd_interface_set(struct usbd_context *const uds_ctx,
|
||||||
const uint8_t iface,
|
const uint8_t iface,
|
||||||
const uint8_t alt)
|
const uint8_t alt)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_interface_shutdown(struct usbd_contex *const uds_ctx,
|
int usbd_interface_shutdown(struct usbd_context *const uds_ctx,
|
||||||
struct usbd_config_node *const cfg_nd);
|
struct usbd_config_node *const cfg_nd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,7 +31,7 @@ int usbd_interface_shutdown(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_interface_default(struct usbd_contex *const uds_ctx,
|
int usbd_interface_default(struct usbd_context *const uds_ctx,
|
||||||
const enum usbd_speed speed,
|
const enum usbd_speed speed,
|
||||||
struct usbd_config_node *const cfg_nd);
|
struct usbd_config_node *const cfg_nd);
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ int usbd_interface_default(struct usbd_contex *const uds_ctx,
|
||||||
*
|
*
|
||||||
* @return 0 on success, other values on fail.
|
* @return 0 on success, other values on fail.
|
||||||
*/
|
*/
|
||||||
int usbd_interface_set(struct usbd_contex *uds_ctx,
|
int usbd_interface_set(struct usbd_context *uds_ctx,
|
||||||
const uint8_t iface,
|
const uint8_t iface,
|
||||||
const uint8_t alternate);
|
const uint8_t alternate);
|
||||||
|
|
||||||
|
|
|
@ -22,14 +22,14 @@ static sys_slist_t msg_list;
|
||||||
|
|
||||||
struct usbd_msg_pkt {
|
struct usbd_msg_pkt {
|
||||||
sys_snode_t node;
|
sys_snode_t node;
|
||||||
struct usbd_contex *ctx;
|
struct usbd_context *ctx;
|
||||||
struct usbd_msg msg;
|
struct usbd_msg msg;
|
||||||
};
|
};
|
||||||
|
|
||||||
K_MEM_SLAB_DEFINE_STATIC(usbd_msg_slab, sizeof(struct usbd_msg_pkt),
|
K_MEM_SLAB_DEFINE_STATIC(usbd_msg_slab, sizeof(struct usbd_msg_pkt),
|
||||||
CONFIG_USBD_MSG_SLAB_COUNT, sizeof(void *));
|
CONFIG_USBD_MSG_SLAB_COUNT, sizeof(void *));
|
||||||
|
|
||||||
static inline void usbd_msg_pub(struct usbd_contex *const ctx,
|
static inline void usbd_msg_pub(struct usbd_context *const ctx,
|
||||||
const struct usbd_msg msg)
|
const struct usbd_msg msg)
|
||||||
{
|
{
|
||||||
struct usbd_msg_pkt *m_pkt;
|
struct usbd_msg_pkt *m_pkt;
|
||||||
|
@ -87,7 +87,7 @@ static void msg_work_handler(struct k_work *work)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int usbd_msg_register_cb(struct usbd_contex *const uds_ctx,
|
int usbd_msg_register_cb(struct usbd_context *const uds_ctx,
|
||||||
const usbd_msg_cb_t cb)
|
const usbd_msg_cb_t cb)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
@ -107,7 +107,7 @@ register_cb_exit:
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
void usbd_msg_pub_simple(struct usbd_contex *const ctx,
|
void usbd_msg_pub_simple(struct usbd_context *const ctx,
|
||||||
const enum usbd_msg_type type, const int status)
|
const enum usbd_msg_type type, const int status)
|
||||||
{
|
{
|
||||||
const struct usbd_msg msg = {
|
const struct usbd_msg msg = {
|
||||||
|
@ -120,7 +120,7 @@ void usbd_msg_pub_simple(struct usbd_contex *const ctx,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void usbd_msg_pub_device(struct usbd_contex *const ctx,
|
void usbd_msg_pub_device(struct usbd_context *const ctx,
|
||||||
const enum usbd_msg_type type, const struct device *const dev)
|
const enum usbd_msg_type type, const struct device *const dev)
|
||||||
{
|
{
|
||||||
const struct usbd_msg msg = {
|
const struct usbd_msg msg = {
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
* @param[in] type Message type
|
* @param[in] type Message type
|
||||||
* @param[in] status Status or error code
|
* @param[in] status Status or error code
|
||||||
*/
|
*/
|
||||||
void usbd_msg_pub_simple(struct usbd_contex *const ctx,
|
void usbd_msg_pub_simple(struct usbd_context *const ctx,
|
||||||
const enum usbd_msg_type type, const int status);
|
const enum usbd_msg_type type, const int status);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@ void usbd_msg_pub_simple(struct usbd_contex *const ctx,
|
||||||
* @param[in] type Message type
|
* @param[in] type Message type
|
||||||
* @param[in] dev Pointer to a device structure
|
* @param[in] dev Pointer to a device structure
|
||||||
*/
|
*/
|
||||||
void usbd_msg_pub_device(struct usbd_contex *const ctx,
|
void usbd_msg_pub_device(struct usbd_context *const ctx,
|
||||||
const enum usbd_msg_type type, const struct device *const dev);
|
const enum usbd_msg_type type, const struct device *const dev);
|
||||||
|
|
||||||
#endif /* ZEPHYR_INCLUDE_USBD_MSG_H */
|
#endif /* ZEPHYR_INCLUDE_USBD_MSG_H */
|
||||||
|
|
|
@ -49,7 +49,7 @@ USBD_DESC_SERIAL_NUMBER_DEFINE(sn);
|
||||||
USBD_DEVICE_DEFINE(sh_uds_ctx, DEVICE_DT_GET(DT_NODELABEL(zephyr_udc0)),
|
USBD_DEVICE_DEFINE(sh_uds_ctx, DEVICE_DT_GET(DT_NODELABEL(zephyr_udc0)),
|
||||||
0x2fe3, 0xffff);
|
0x2fe3, 0xffff);
|
||||||
|
|
||||||
static struct usbd_contex *my_uds_ctx = &sh_uds_ctx;
|
static struct usbd_context *my_uds_ctx = &sh_uds_ctx;
|
||||||
static enum usbd_speed current_cmd_speed = USBD_SPEED_FS;
|
static enum usbd_speed current_cmd_speed = USBD_SPEED_FS;
|
||||||
|
|
||||||
static int cmd_wakeup_request(const struct shell *sh,
|
static int cmd_wakeup_request(const struct shell *sh,
|
||||||
|
@ -269,7 +269,7 @@ static int cmd_usbd_shutdown(const struct shell *sh,
|
||||||
|
|
||||||
static int cmd_select(const struct shell *sh, size_t argc, char **argv)
|
static int cmd_select(const struct shell *sh, size_t argc, char **argv)
|
||||||
{
|
{
|
||||||
STRUCT_SECTION_FOREACH(usbd_contex, ctx) {
|
STRUCT_SECTION_FOREACH(usbd_context, ctx) {
|
||||||
if (strcmp(argv[1], ctx->name) == 0) {
|
if (strcmp(argv[1], ctx->name) == 0) {
|
||||||
my_uds_ctx = ctx;
|
my_uds_ctx = ctx;
|
||||||
shell_print(sh,
|
shell_print(sh,
|
||||||
|
@ -546,7 +546,7 @@ static void device_context_lookup(size_t idx, struct shell_static_entry *entry)
|
||||||
entry->help = NULL;
|
entry->help = NULL;
|
||||||
entry->subcmd = NULL;
|
entry->subcmd = NULL;
|
||||||
|
|
||||||
STRUCT_SECTION_FOREACH(usbd_contex, ctx) {
|
STRUCT_SECTION_FOREACH(usbd_context, ctx) {
|
||||||
if ((ctx->name != NULL) && (strlen(ctx->name) != 0)) {
|
if ((ctx->name != NULL) && (strlen(ctx->name) != 0)) {
|
||||||
if (match_idx == idx) {
|
if (match_idx == idx) {
|
||||||
entry->syntax = ctx->name;
|
entry->syntax = ctx->name;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue