40#include "usb_private.h"
45 const char *
const *strings,
int num_strings,
46 uint8_t *control_buffer, uint16_t control_buffer_size)
60 usbd_dev->ctrl_buf_len = control_buffer_size;
62 usbd_dev->user_callback_ctr[0][USB_TRANSACTION_SETUP] =
64 usbd_dev->user_callback_ctr[0][USB_TRANSACTION_OUT] =
66 usbd_dev->user_callback_ctr[0][USB_TRANSACTION_IN] =
70 for (i = 0; i < MAX_USER_SET_CONFIG_CALLBACK; i++) {
71 usbd_dev->user_callback_set_config[i] = NULL;
79 usbd_dev->user_callback_reset = callback;
83 void (*callback)(
void))
85 usbd_dev->user_callback_suspend = callback;
89 void (*callback)(
void))
91 usbd_dev->user_callback_resume = callback;
96 usbd_dev->user_callback_sof = callback;
105 if (
string != NULL && index > 0) {
120 if (
usbd_dev->user_callback_reset) {
147 const void *buf, uint16_t len)
struct _usbd_device usbd_device
void(* usbd_endpoint_callback)(usbd_device *usbd_dev, uint8_t ep)
struct _usbd_driver usbd_driver
void usbd_register_resume_callback(usbd_device *usbd_dev, void(*callback)(void))
Registers a resume callback.
void usbd_register_suspend_callback(usbd_device *usbd_dev, void(*callback)(void))
Registers a suspend callback.
void usbd_register_reset_callback(usbd_device *usbd_dev, void(*callback)(void))
Registers a reset callback.
void usbd_ep_nak_set(usbd_device *usbd_dev, uint8_t addr, uint8_t nak)
Set an Out endpoint to NAK.
uint8_t usbd_ep_stall_get(usbd_device *usbd_dev, uint8_t addr)
Get STALL status of an endpoint.
void _usbd_reset(usbd_device *usbd_dev)
usbd_device * usbd_init(const usbd_driver *driver, const struct usb_device_descriptor *dev, const struct usb_config_descriptor *conf, const char *const *strings, int num_strings, uint8_t *control_buffer, uint16_t control_buffer_size)
Main initialization entry point.
void usbd_ep_stall_set(usbd_device *usbd_dev, uint8_t addr, uint8_t stall)
Set/clear STALL condition on an endpoint.
void usbd_poll(usbd_device *usbd_dev)
uint16_t usbd_ep_write_packet(usbd_device *usbd_dev, uint8_t addr, const void *buf, uint16_t len)
Write a packet.
void usbd_ep_setup(usbd_device *usbd_dev, uint8_t addr, uint8_t type, uint16_t max_size, usbd_endpoint_callback callback)
Setup an endpoint.
uint16_t usbd_ep_read_packet(usbd_device *usbd_dev, uint8_t addr, void *buf, uint16_t len)
Read a packet.
void usbd_register_sof_callback(usbd_device *usbd_dev, void(*callback)(void))
Registers a SOF callback.
void usbd_register_extra_string(usbd_device *usbd_dev, int index, const char *string)
Registers a non-contiguous string descriptor.
void usbd_disconnect(usbd_device *usbd_dev, bool disconnected)
Disconnect, if supported by the driver.
#define USB_ENDPOINT_ATTR_CONTROL
void _usbd_control_out(usbd_device *usbd_dev, uint8_t ea)
void _usbd_control_in(usbd_device *usbd_dev, uint8_t ea)
void _usbd_control_setup(usbd_device *usbd_dev, uint8_t ea)
static struct _usbd_device usbd_dev