tests: usb: use new USB framework header

Replace all macros with the new ones from usb/usb_ch9.h header.

Signed-off-by: Johann Fischer <johann.fischer@nordicsemi.no>
This commit is contained in:
Johann Fischer 2021-05-12 11:45:57 +02:00 committed by Carles Cufí
commit c0ea13ba85
4 changed files with 16 additions and 20 deletions

View file

@ -9,7 +9,6 @@
#include <sys/byteorder.h>
#include <usb/usb_device.h>
#include <usb/usb_common.h>
#include <usb/bos.h>
@ -33,7 +32,7 @@ static struct webusb_bos_desc {
} __packed webusb_bos_descriptor = {
.bos = {
.bLength = sizeof(struct usb_bos_descriptor),
.bDescriptorType = USB_BINARY_OBJECT_STORE_DESC,
.bDescriptorType = USB_DESC_BOS,
.wTotalLength = sizeof(struct webusb_bos_desc),
.bNumDeviceCaps = 2,
},
@ -43,7 +42,7 @@ static struct webusb_bos_desc {
.platform_webusb = {
.bLength = sizeof(struct usb_bos_platform_descriptor)
+ sizeof(struct usb_bos_capability_webusb),
.bDescriptorType = USB_DEVICE_CAPABILITY_DESC,
.bDescriptorType = USB_DESC_DEVICE_CAPABILITY,
.bDevCapabilityType = USB_BOS_CAPABILITY_PLATFORM,
.bReserved = 0,
/* WebUSB Platform Capability UUID
@ -72,7 +71,7 @@ static struct webusb_bos_desc {
.platform_msos = {
.bLength = sizeof(struct usb_bos_platform_descriptor)
+ sizeof(struct usb_bos_capability_msos),
.bDescriptorType = USB_DEVICE_CAPABILITY_DESC,
.bDescriptorType = USB_DESC_DEVICE_CAPABILITY,
.bDevCapabilityType = USB_BOS_CAPABILITY_PLATFORM,
.bReserved = 0,
.PlatformCapabilityUUID = {
@ -113,7 +112,7 @@ USB_DEVICE_BOS_DESC_DEFINE_CAP struct usb_bos_webusb {
.platform = {
.bLength = sizeof(struct usb_bos_platform_descriptor) +
sizeof(struct usb_bos_capability_webusb),
.bDescriptorType = USB_DEVICE_CAPABILITY_DESC,
.bDescriptorType = USB_DESC_DEVICE_CAPABILITY,
.bDevCapabilityType = USB_BOS_CAPABILITY_PLATFORM,
.bReserved = 0,
/* WebUSB Platform Capability UUID
@ -141,7 +140,7 @@ USB_DEVICE_BOS_DESC_DEFINE_CAP struct usb_bos_msosv2 {
.platform = {
.bLength = sizeof(struct usb_bos_platform_descriptor)
+ sizeof(struct usb_bos_capability_msos),
.bDescriptorType = USB_DEVICE_CAPABILITY_DESC,
.bDescriptorType = USB_DESC_DEVICE_CAPABILITY,
.bDevCapabilityType = USB_BOS_CAPABILITY_PLATFORM,
.bReserved = 0,
.PlatformCapabilityUUID = {
@ -203,7 +202,7 @@ static void test_usb_bos(void)
/* Already registered due to previous test */
setup.wValue = (DESCRIPTOR_TYPE_BOS & 0xFF) << 8;
setup.wValue = (USB_DESC_BOS & 0xFF) << 8;
ret = usb_handle_bos(&setup, &len, &data);

View file

@ -9,7 +9,6 @@
#include <sys/byteorder.h>
#include <usb/usb_device.h>
#include <usb/usb_common.h>
#include <usb_descriptor.h>
#include <logging/log.h>
@ -40,11 +39,11 @@ struct usb_test_config {
#define INITIALIZER_IF \
{ \
.bLength = sizeof(struct usb_if_descriptor), \
.bDescriptorType = USB_INTERFACE_DESC, \
.bDescriptorType = USB_DESC_INTERFACE, \
.bInterfaceNumber = 0, \
.bAlternateSetting = 0, \
.bNumEndpoints = 3, \
.bInterfaceClass = CUSTOM_CLASS, \
.bInterfaceClass = USB_BCC_VENDOR, \
.bInterfaceSubClass = 0, \
.bInterfaceProtocol = 0, \
.iInterface = 0, \
@ -53,7 +52,7 @@ struct usb_test_config {
#define INITIALIZER_IF_EP(addr, attr, mps) \
{ \
.bLength = sizeof(struct usb_ep_descriptor), \
.bDescriptorType = USB_ENDPOINT_DESC, \
.bDescriptorType = USB_DESC_ENDPOINT, \
.bEndpointAddress = addr, \
.bmAttributes = attr, \
.wMaxPacketSize = sys_cpu_to_le16(mps), \
@ -163,7 +162,7 @@ static void check_endpoint_allocation(struct usb_desc_header *head)
uint8_t ep_count = 0;
while (head->bLength != 0) {
if (head->bDescriptorType == USB_INTERFACE_DESC) {
if (head->bDescriptorType == USB_DESC_INTERFACE) {
struct usb_if_descriptor *if_descr = (void *)head;
ep_count = 0;
@ -180,7 +179,7 @@ static void check_endpoint_allocation(struct usb_desc_header *head)
zassert_not_null(cfg_data, "Check available cfg data");
}
if (head->bDescriptorType == USB_ENDPOINT_DESC) {
if (head->bDescriptorType == USB_DESC_ENDPOINT) {
struct usb_ep_descriptor *ep_descr =
(struct usb_ep_descriptor *)head;

View file

@ -9,7 +9,6 @@
#include <sys/byteorder.h>
#include <usb/usb_device.h>
#include <usb/usb_common.h>
/* Max packet size for endpoints */
#define BULK_EP_MPS 64
@ -27,11 +26,11 @@ struct usb_device_desc {
#define INITIALIZER_IF \
{ \
.bLength = sizeof(struct usb_if_descriptor), \
.bDescriptorType = USB_INTERFACE_DESC, \
.bDescriptorType = USB_DESC_INTERFACE, \
.bInterfaceNumber = 0, \
.bAlternateSetting = 0, \
.bNumEndpoints = 1, \
.bInterfaceClass = CUSTOM_CLASS, \
.bInterfaceClass = USB_BCC_VENDOR, \
.bInterfaceSubClass = 0, \
.bInterfaceProtocol = 0, \
.iInterface = 0, \
@ -40,7 +39,7 @@ struct usb_device_desc {
#define INITIALIZER_IF_EP(addr, attr, mps, interval) \
{ \
.bLength = sizeof(struct usb_ep_descriptor), \
.bDescriptorType = USB_ENDPOINT_DESC, \
.bDescriptorType = USB_DESC_ENDPOINT, \
.bEndpointAddress = addr, \
.bmAttributes = attr, \
.wMaxPacketSize = sys_cpu_to_le16(mps), \

View file

@ -9,7 +9,6 @@
#include <sys/byteorder.h>
#include <usb/usb_device.h>
#include <usb/usb_common.h>
#include <os_desc.h>
#define MSOS_STRING_LENGTH 18
@ -21,7 +20,7 @@ static struct string_desc {
uint8_t bPad;
} __packed msosv1_string_descriptor = {
.bLength = MSOS_STRING_LENGTH,
.bDescriptorType = USB_STRING_DESC,
.bDescriptorType = USB_DESC_STRING,
/* Signature MSFT100 */
.bString = {
'M', 0x00, 'S', 0x00, 'F', 0x00, 'T', 0x00,
@ -94,7 +93,7 @@ static void test_handle_os_desc(void)
uint8_t *data = NULL;
int ret;
setup.wValue = (USB_STRING_DESC & 0xFF) << 8;
setup.wValue = (USB_DESC_STRING & 0xFF) << 8;
setup.wValue |= USB_OSDESC_STRING_DESC_INDEX;
ret = usb_handle_os_desc(&setup, &len, &data);