Loading...
Searching...
No Matches
control.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2019 Koen Zandberg
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
19
23#define USBUS_CONTROL_EP_IN_REQUIRED_NUMOF 1
24
28#define USBUS_CONTROL_EP_OUT_REQUIRED_NUMOF 1
29
30#include "usb/usbus.h"
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
39typedef struct {
40 size_t start;
41 size_t cur;
42 size_t len;
43 size_t transferred;
44 size_t reqlen;
46
97
105
115size_t usbus_control_slicer_put_bytes(usbus_t *usbus, const uint8_t *buf,
116 size_t len);
117
128
135
145
157
158#ifdef __cplusplus
159}
160#endif
void usbus_control_slicer_ready(usbus_t *usbus)
Helper function to signal the end of the control message.
uint8_t * usbus_control_get_out_data(usbus_t *usbus, size_t *len)
Retrieve the data from the OUT pipe of the control endpoint.
size_t usbus_control_slicer_put_char(usbus_t *usbus, char c)
Helper function for adding single bytes to the current control message part.
int usbus_control_slicer_nextslice(usbus_t *usbus)
Initialize the next slice of the control message.
void usbus_control_init(usbus_t *usbus, usbus_control_handler_t *handler)
Initialize the control endpoint handler.
size_t usbus_control_slicer_put_bytes(usbus_t *usbus, const uint8_t *buf, size_t len)
Helper function for adding bytes to the current control message part.
struct usbdev_ep usbdev_ep_t
usbdev_ep_t forward declaration
Definition usbdev.h:96
#define usbdev_ep_buf_t
Instantiation type for usbdev endpoint buffers.
Definition usbdev.h:123
#define CONFIG_USBUS_EP0_SIZE
USBUS endpoint 0 buffer size.
Definition usbus.h:101
usbus_control_request_state_t
USBUS control request state machine.
Definition usbus.h:192
struct usbus_handler usbus_handler_t
USBUS event handler forward declaration.
Definition usbus.h:220
struct usbus usbus_t
USBUS context forward declaration.
Definition usbus.h:215
USB setup packet (USB 2.0 spec table 9-2)
Definition descriptor.h:205
Endpoint zero event handler.
Definition control.h:50
size_t received_len
Received bytes for set requests.
Definition control.h:75
usbdev_ep_buf_t in_buf[CONFIG_USBUS_EP0_SIZE]
Device to host control request buffer.
Definition control.h:95
usbus_handler_t handler
inherited generic handler
Definition control.h:55
usbdev_ep_buf_t out_buf[CONFIG_USBUS_EP0_SIZE]
Host to device control request buffer.
Definition control.h:90
usbus_control_slicer_t slicer
Slicer state for multipart control request messages.
Definition control.h:70
usb_setup_t setup
Last received setup packet.
Definition control.h:60
usbdev_ep_t * out
EP0 OUT endpoint reference.
Definition control.h:80
usbdev_ep_t * in
EP0 IN endpoint reference.
Definition control.h:85
usbus_control_request_state_t control_request_state
Control request state machine state.
Definition control.h:65
helper struct to divide control messages in multiple parts
Definition control.h:39
size_t len
Length of the full message.
Definition control.h:42
size_t reqlen
Maximum length of the request.
Definition control.h:44
size_t start
Start offset of the current part.
Definition control.h:40
size_t transferred
Number of bytes transferred.
Definition control.h:43
size_t cur
Current position in the message.
Definition control.h:41
USBUS context struct.
Definition usbus.h:444
USBUS basic interface.