Skip to content

Commit

Permalink
ref(esp_tinyusb): Solve review converstaions
Browse files Browse the repository at this point in the history
  • Loading branch information
roma-jam committed Feb 15, 2024
1 parent 81c70fa commit 80d5db2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 24 deletions.
26 changes: 25 additions & 1 deletion device/esp_tinyusb/descriptors_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,31 @@
#define MAX_DESC_BUF_SIZE 32 // Max length of string descriptor (can be extended, USB supports lengths up to 255 bytes)

static const char *TAG = "tusb_desc";

// =============================================================================
// STRUCTS
// =============================================================================

/**
* @brief Descriptor pointers for tinyusb descriptor requests callbacks
*
*/
typedef struct {
const tusb_desc_device_t *dev; /*!< Pointer to device descriptor */
union {
const uint8_t *cfg; /*!< Pointer to FS configuration descriptor when device one-speed only */
const uint8_t *hs_cfg; /*!< Pointer to HS configuration descriptor when device one-speed only */
};
#if (TUD_OPT_HIGH_SPEED)
const uint8_t *fs_cfg; /*!< Pointer to FS configuration descriptor when device support HS */
tusb_desc_device_qualifier_t *qualifier; /*!< Pointer to Qualifier descriptor */
bool qualifier_alloc_internally; /*!< Qualifier descriptor was allocated internally */
uint8_t *other_speed; /*!< Pointer for other speed configuration descriptor */
#endif // TUD_OPT_HIGH_SPEED
const char *str[USB_STRING_DESCRIPTOR_ARRAY_SIZE]; /*!< Pointer to array of UTF-8 strings */
int str_count; /*!< Number of descriptors in str */
} tinyusb_descriptor_config_t;

static tinyusb_descriptor_config_t *s_desc_cfg;

// =============================================================================
Expand Down Expand Up @@ -71,7 +96,6 @@ uint8_t const *tud_descriptor_device_qualifier_cb(void)
return (uint8_t const *)s_desc_cfg->qualifier;
}


/**
* @brief Invoked when received GET OTHER SPEED CONFIGURATION DESCRIPTOR request
* Descriptor contents must exist long enough for transfer to complete
Expand Down
2 changes: 0 additions & 2 deletions device/esp_tinyusb/include/tinyusb.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ typedef struct {
union {
struct {
const uint8_t *configuration_descriptor; /*!< Pointer to a configuration descriptor. If set to NULL, TinyUSB device will use a default configuration descriptor whose values are set in Kconfig */
const uint8_t *reserved1; /*!< For backward compatibility */
const uint8_t *reserved2; /*!< For backward compatibility */
};
#if (TUD_OPT_HIGH_SPEED)
struct {
Expand Down
21 changes: 0 additions & 21 deletions device/esp_tinyusb/include_private/descriptors_control.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#pragma once

// #include "tusb.h"
#include "tinyusb.h"

#ifdef __cplusplus
Expand All @@ -15,26 +14,6 @@ extern "C" {

#define USB_STRING_DESCRIPTOR_ARRAY_SIZE 8 // Max 8 string descriptors for a device. LANGID, Manufacturer, Product, Serial number + 4 user defined

/**
* @brief USB Device descriptor pointers for tinyusb configuration
*
*/
typedef struct {
const tusb_desc_device_t *dev; /*!< Pointer to device descriptor */
union {
const uint8_t *cfg; /*!< Pointer to FS configuration descriptor when device one-speed only */
const uint8_t *hs_cfg; /*!< Pointer to HS configuration descriptor when device one-speed only */
};
#if (TUD_OPT_HIGH_SPEED)
const uint8_t *fs_cfg; /*!< Pointer to FS configuration descriptor when device support HS */
tusb_desc_device_qualifier_t *qualifier; /*!< Pointer to Qualifier descriptor */
bool qualifier_alloc_internally; /*!< Qualifier descriptor was allocated internally */
uint8_t *other_speed; /*!< Pointer for other speed configuration descriptor */
#endif // TUD_OPT_HIGH_SPEED
const char *str[USB_STRING_DESCRIPTOR_ARRAY_SIZE]; /*!< Pointer to array of UTF-8 strings */
int str_count; /*!< Number of descriptors in str */
} tinyusb_descriptor_config_t;

/**
* @brief Parse tinyusb configuration and prepare the device configuration pointer list to configure tinyusb driver
*
Expand Down
6 changes: 6 additions & 0 deletions device/esp_tinyusb/test/local/libusb_test.c
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
/*
* SPDX-FileCopyrightText: 2024 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <assert.h>
#include <stdio.h>
#include <libusb-1.0/libusb.h>
Expand Down

0 comments on commit 80d5db2

Please sign in to comment.