mirror of https://github.com/Desuuuu/klipper.git
usb_cdc: Add usb_read_ep0_setup() interface function
Use new usb_read_ep0_setup() function when reading a setup packet - this allows the low-level usb hardware code to better handle errors. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
This commit is contained in:
parent
731236cf20
commit
93e4897044
|
@ -412,9 +412,8 @@ static void
|
||||||
usb_state_ready(void)
|
usb_state_ready(void)
|
||||||
{
|
{
|
||||||
struct usb_ctrlrequest req;
|
struct usb_ctrlrequest req;
|
||||||
int_fast8_t ret = usb_read_ep0(&req, sizeof(req));
|
int_fast8_t ret = usb_read_ep0_setup(&req, sizeof(req));
|
||||||
if (ret != sizeof(req))
|
if (ret != sizeof(req))
|
||||||
// XXX - should verify that packet was sent with a setup token
|
|
||||||
return;
|
return;
|
||||||
switch (req.bRequest) {
|
switch (req.bRequest) {
|
||||||
case USB_REQ_GET_DESCRIPTOR: usb_req_get_descriptor(&req); break;
|
case USB_REQ_GET_DESCRIPTOR: usb_req_get_descriptor(&req); break;
|
||||||
|
|
|
@ -15,6 +15,7 @@ enum {
|
||||||
int_fast8_t usb_read_bulk_out(void *data, uint_fast8_t max_len);
|
int_fast8_t usb_read_bulk_out(void *data, uint_fast8_t max_len);
|
||||||
int_fast8_t usb_send_bulk_in(void *data, uint_fast8_t len);
|
int_fast8_t usb_send_bulk_in(void *data, uint_fast8_t len);
|
||||||
int_fast8_t usb_read_ep0(void *data, uint_fast8_t max_len);
|
int_fast8_t usb_read_ep0(void *data, uint_fast8_t max_len);
|
||||||
|
int_fast8_t usb_read_ep0_setup(void *data, uint_fast8_t max_len);
|
||||||
int_fast8_t usb_send_ep0(const void *data, uint_fast8_t len);
|
int_fast8_t usb_send_ep0(const void *data, uint_fast8_t len);
|
||||||
int_fast8_t usb_send_ep0_progmem(const void *data, uint_fast8_t len);
|
int_fast8_t usb_send_ep0_progmem(const void *data, uint_fast8_t len);
|
||||||
void usb_stall_ep0(void);
|
void usb_stall_ep0(void);
|
||||||
|
|
|
@ -189,6 +189,12 @@ usb_read_ep0(void *data, uint_fast8_t max_len)
|
||||||
return usb_read_packet(EP0OUT, data, max_len);
|
return usb_read_packet(EP0OUT, data, max_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int_fast8_t
|
||||||
|
usb_read_ep0_setup(void *data, uint_fast8_t max_len)
|
||||||
|
{
|
||||||
|
return usb_read_ep0(data, max_len);
|
||||||
|
}
|
||||||
|
|
||||||
int_fast8_t
|
int_fast8_t
|
||||||
usb_send_ep0(const void *data, uint_fast8_t len)
|
usb_send_ep0(const void *data, uint_fast8_t len)
|
||||||
{
|
{
|
||||||
|
|
|
@ -127,6 +127,12 @@ usb_read_ep0(void *data, uint_fast8_t max_len)
|
||||||
return usb_read_packet(0, 0, data, max_len);
|
return usb_read_packet(0, 0, data, max_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int_fast8_t
|
||||||
|
usb_read_ep0_setup(void *data, uint_fast8_t max_len)
|
||||||
|
{
|
||||||
|
return usb_read_ep0(data, max_len);
|
||||||
|
}
|
||||||
|
|
||||||
int_fast8_t
|
int_fast8_t
|
||||||
usb_send_ep0(const void *data, uint_fast8_t len)
|
usb_send_ep0(const void *data, uint_fast8_t len)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue