usb: Begun implementing support for sending the microsoft OS descriptor set structures
This commit is contained in:
committed by
Piotr Esden-Tempski
parent
9e0dbfc137
commit
9efcb120f7
@@ -38,6 +38,7 @@ LGPL License Terms @ref lgpl_license
|
|||||||
#ifndef __MICROSOFT_H
|
#ifndef __MICROSOFT_H
|
||||||
#define __MICROSOFT_H
|
#define __MICROSOFT_H
|
||||||
|
|
||||||
|
#include <libopencm3/usb/usbd.h>
|
||||||
#include <libopencm3/usb/bos.h>
|
#include <libopencm3/usb/bos.h>
|
||||||
|
|
||||||
enum microsoft_req {
|
enum microsoft_req {
|
||||||
@@ -96,6 +97,9 @@ typedef struct __attribute__((packed)) microsoft_os_descriptor_set_header {
|
|||||||
|
|
||||||
#define MICROSOFT_OS_DESCRIPTOR_SET_HEADER_SIZE 10U
|
#define MICROSOFT_OS_DESCRIPTOR_SET_HEADER_SIZE 10U
|
||||||
|
|
||||||
|
extern void microsoft_os_register_descriptor_sets(usbd_device *dev,
|
||||||
|
const microsoft_os_descriptor_set_header *sets, uint8_t num_sets);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/**@}*/
|
/**@}*/
|
||||||
|
|||||||
@@ -56,7 +56,7 @@ OBJS += mac.o mac_stm32fxx7.o
|
|||||||
OBJS += phy.o phy_ksz80x1.o
|
OBJS += phy.o phy_ksz80x1.o
|
||||||
|
|
||||||
OBJS += usb.o usb_control.o usb_standard.o usb_msc.o
|
OBJS += usb.o usb_control.o usb_standard.o usb_msc.o
|
||||||
OBJS += usb_hid.o usb_bos.o
|
OBJS += usb_hid.o usb_bos.o usb_microsoft.o
|
||||||
OBJS += usb_audio.o usb_cdc.o usb_midi.o
|
OBJS += usb_audio.o usb_cdc.o usb_midi.o
|
||||||
OBJS += usb_dwc_common.o usb_f107.o
|
OBJS += usb_dwc_common.o usb_f107.o
|
||||||
OBJS += st_usbfs_core.o st_usbfs_v1.o
|
OBJS += st_usbfs_core.o st_usbfs_v1.o
|
||||||
@@ -64,4 +64,3 @@ OBJS += st_usbfs_core.o st_usbfs_v1.o
|
|||||||
VPATH += ../../usb:../:../../cm3:../common:../../ethernet
|
VPATH += ../../usb:../:../../cm3:../common:../../ethernet
|
||||||
|
|
||||||
include ../../Makefile.include
|
include ../../Makefile.include
|
||||||
|
|
||||||
|
|||||||
52
lib/usb/usb_microsoft.c
Normal file
52
lib/usb/usb_microsoft.c
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* This file is part of the libopencm3 project.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2022 Rachel Mant <git@dragonmux.network>
|
||||||
|
*
|
||||||
|
* This library is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Lesser General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This library is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Lesser General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Lesser General Public License
|
||||||
|
* along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <libopencm3/usb/usbd.h>
|
||||||
|
#include <libopencm3/usb/microsoft.h>
|
||||||
|
#include "usb_private.h"
|
||||||
|
|
||||||
|
static enum usbd_request_return_codes microsoft_os_get_descriptor_set(usbd_device *const usbd_dev,
|
||||||
|
struct usb_setup_data *const req, uint8_t **const buf, uint16_t *const len)
|
||||||
|
{
|
||||||
|
const microsoft_os_descriptor_set_header *sets = usbd_dev->microsoft_os_descriptor_sets;
|
||||||
|
for (size_t i = 0; i < usbd_dev->num_microsoft_os_descriptor_sets; ++i) {
|
||||||
|
//
|
||||||
|
}
|
||||||
|
return USBD_REQ_NOTSUPP;
|
||||||
|
}
|
||||||
|
|
||||||
|
static enum usbd_request_return_codes microsoft_os_control_request(usbd_device *const usbd_dev,
|
||||||
|
struct usb_setup_data *const req, uint8_t **const buf, uint16_t *const len)
|
||||||
|
{
|
||||||
|
switch (req->wIndex) {
|
||||||
|
case MICROSOFT_GET_DESCRIPTOR_SET:
|
||||||
|
return microsoft_os_get_descriptor_set(usbd_dev, req, buf, len);
|
||||||
|
case MICROSOFT_SET_ALTERNATE_ENUM:
|
||||||
|
return USBD_REQ_NOTSUPP;
|
||||||
|
}
|
||||||
|
return USBD_REQ_NEXT_CALLBACK;
|
||||||
|
}
|
||||||
|
|
||||||
|
void microsoft_os_register_descriptor_sets(usbd_device *const dev,
|
||||||
|
const microsoft_os_descriptor_set_header *const sets, const uint8_t num_sets)
|
||||||
|
{
|
||||||
|
dev->microsoft_os_req_callback = microsoft_os_control_request;
|
||||||
|
dev->microsoft_os_descriptor_sets = sets;
|
||||||
|
dev->num_microsoft_os_descriptor_sets = num_sets;
|
||||||
|
}
|
||||||
@@ -79,6 +79,8 @@ struct _usbd_device {
|
|||||||
} control_state;
|
} control_state;
|
||||||
|
|
||||||
usbd_microsoft_os_req_callback microsoft_os_req_callback;
|
usbd_microsoft_os_req_callback microsoft_os_req_callback;
|
||||||
|
const void *microsoft_os_descriptor_sets;
|
||||||
|
uint8_t num_microsoft_os_descriptor_sets;
|
||||||
|
|
||||||
struct user_control_callback {
|
struct user_control_callback {
|
||||||
usbd_control_callback cb;
|
usbd_control_callback cb;
|
||||||
|
|||||||
Reference in New Issue
Block a user