control.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Koen Zandberg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
21 #ifndef USB_USBUS_CONTROL_H
22 #define USB_USBUS_CONTROL_H
23 
24 #include "usb/usbus.h"
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 
34 typedef struct {
35  size_t start;
36  size_t cur;
37  size_t len;
38  size_t transferred;
39  size_t reqlen;
41 
45 typedef struct {
46 
51 
56 
61 
66 
70  size_t received_len;
71 
76 
82 
90 
100 size_t usbus_control_slicer_put_bytes(usbus_t *usbus, const uint8_t *buf,
101  size_t len);
102 
113 
120 
130 
141 uint8_t *usbus_control_get_out_data(usbus_t *usbus, size_t *len);
142 
143 #ifdef __cplusplus
144 }
145 #endif
146 #endif /* USB_USBUS_CONTROL_H */
147 
usbus.h
USBUS basic interface.
usbus_control_slicer_t::cur
size_t cur
Current position in the message
Definition: control.h:36
usbus_control_slicer_t::reqlen
size_t reqlen
Maximum length of the request
Definition: control.h:39
usbus_control_init
void usbus_control_init(usbus_t *usbus, usbus_control_handler_t *handler)
Initialize the control endpoint handler.
usbus_control_get_out_data
uint8_t * usbus_control_get_out_data(usbus_t *usbus, size_t *len)
Retrieve the data from the OUT pipe of the control endpoint.
usbus_control_handler_t::slicer
usbus_control_slicer_t slicer
Slicer state for multipart control request messages.
Definition: control.h:65
usbus_control_slicer_t::start
size_t start
Start offset of the current part.
Definition: control.h:35
usb_setup_t
USB setup packet (USB 2.0 spec table 9-2)
Definition: descriptor.h:198
usbus_control_request_state_t
usbus_control_request_state_t
USBUS control request state machine.
Definition: usbus.h:161
usbus_control_handler_t::control_request_state
usbus_control_request_state_t control_request_state
Control request state machine state.
Definition: control.h:60
usbus_control_slicer_put_char
size_t usbus_control_slicer_put_char(usbus_t *usbus, char c)
Helper function for adding single bytes to the current control message part.
usbdev_ep
usbdev endpoint descriptor
Definition: usbdev.h:229
usbus_control_slicer_t::len
size_t len
Length of the full message
Definition: control.h:37
usbus_control_slicer_ready
void usbus_control_slicer_ready(usbus_t *usbus)
Helper function to signal the end of the control message.
usbus_handler
USBUS handler struct.
Definition: usbus.h:385
usbus_control_handler_t::received_len
size_t received_len
Received bytes for set requests.
Definition: control.h:70
usbus_control_slicer_t::transferred
size_t transferred
Number of bytes transferred
Definition: control.h:38
usbus_control_slicer_nextslice
int usbus_control_slicer_nextslice(usbus_t *usbus)
Initialize the next slice of the control message.
usbus_control_handler_t::out
usbdev_ep_t * out
EP0 OUT endpoint.
Definition: control.h:75
usbus_control_slicer_t
helper struct to divide control messages in multiple parts
Definition: control.h:34
usbus_control_slicer_put_bytes
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.
usbus_control_handler_t
Endpoint zero event handler.
Definition: control.h:45
usbus_control_handler_t::in
usbdev_ep_t * in
EP0 IN endpoint.
Definition: control.h:80
usbus_control_handler_t::setup
usb_setup_t setup
Last received setup packet.
Definition: control.h:55
usbus
USBUS context struct.
Definition: usbus.h:397
usbus_control_handler_t::handler
usbus_handler_t handler
inherited generic handler
Definition: control.h:50