fix(usb_host): Run esp-usb pre-commit:

- trailing whitespaces
    - end-of-file-fixer
    - codespell
    - astyle_py: align pointer name
This commit is contained in:
peter.marcisovsky
2025-07-28 18:52:51 +02:00
parent 844dc17b43
commit 4deccbc4a6
28 changed files with 105 additions and 110 deletions

View File

@@ -145,7 +145,7 @@ typedef struct {
struct {
ext_hub_cb_t proc_req_cb; /**< Process callback */
void *proc_req_cb_arg; /**< Process callback argument */
const ext_port_driver_api_t* port_driver; /**< External Port Driver */
const ext_port_driver_api_t *port_driver; /**< External Port Driver */
} constant; /**< Constant members. Do not change after installation thus do not require a critical section or mutex */
} ext_hub_driver_t;
@@ -180,7 +180,7 @@ DEFINE_CRIT_SECTION_LOCK_STATIC(ext_hub_driver_lock);
// -----------------------------------------------------------------------------
static bool _device_set_actions(ext_hub_dev_t *ext_hub_dev, uint32_t action_flags);
static void device_error(ext_hub_dev_t *ext_hub_dev);
static void device_status_change_handle(ext_hub_dev_t *ext_hub_dev, const uint8_t* data, const int length);
static void device_status_change_handle(ext_hub_dev_t *ext_hub_dev, const uint8_t *data, const int length);
// -----------------------------------------------------------------------------
// ---------------------- Callbacks (implementation) ---------------------------
@@ -361,7 +361,7 @@ static void device_has_changed(ext_hub_dev_t *ext_hub_dev)
// | ...
// +---------------------------- Port N change detected
//
static void device_status_change_handle(ext_hub_dev_t *ext_hub_dev, const uint8_t* data, const int length)
static void device_status_change_handle(ext_hub_dev_t *ext_hub_dev, const uint8_t *data, const int length)
{
uint32_t device_status = 0;
// Driver does not support Hubs with EP IN wMaxPacketSize > 4
@@ -415,14 +415,14 @@ static void device_error(ext_hub_dev_t *ext_hub_dev)
static esp_err_t device_port_new(ext_hub_dev_t *ext_hub_dev, uint8_t port_idx)
{
ext_port_config_t port_config = {
.context = (void*) ext_hub_dev,
.context = (void *) ext_hub_dev,
.parent_dev_hdl = ext_hub_dev->constant.dev_hdl,
.parent_port_num = port_idx + 1,
.port_power_delay_ms = ext_hub_dev->constant.hub_desc->bPwrOn2PwrGood * 2,
};
assert(p_ext_hub_driver->constant.port_driver);
esp_err_t ret = p_ext_hub_driver->constant.port_driver->new (&port_config, (void**) &ext_hub_dev->constant.ports[port_idx]);
esp_err_t ret = p_ext_hub_driver->constant.port_driver->new (&port_config, (void **) &ext_hub_dev->constant.ports[port_idx]);
if (ret != ESP_OK) {
ESP_LOGE(EXT_HUB_TAG, "[%d:%d] Port allocation error: %s", ext_hub_dev->constant.dev_addr, port_idx + 1, esp_err_to_name(ret));
goto fail;
@@ -1208,7 +1208,7 @@ void *ext_hub_get_client(void)
EXT_HUB_ENTER_CRITICAL();
driver_installed = (p_ext_hub_driver != NULL);
EXT_HUB_EXIT_CRITICAL();
return (driver_installed) ? (void*) p_ext_hub_driver : NULL;
return (driver_installed) ? (void *) p_ext_hub_driver : NULL;
}
// -----------------------------------------------------------------------------

View File

@@ -78,7 +78,7 @@ struct ext_port_s {
usb_device_handle_t parent_dev_hdl; /**< Ports' parent device handle */
uint8_t parent_dev_addr; /**< Ports' parent device bus address */
// Port related constant members
void* context; /**< Ports' parent External Hub handle */
void *context; /**< Ports' parent External Hub handle */
uint8_t port_num; /**< Ports' parent External Hub Port number */
int power_on_delay_ms; /**< Ports' Power on time to Power Good, ms */
} constant; /**< Constant members. Do not change after installation thus do not require a critical section or mutex */
@@ -181,7 +181,7 @@ static inline bool port_is_enabled(ext_port_t *ext_port)
* - true Port connection changed
* - false Port connection not changed
*/
static inline bool port_has_changed_connection(ext_port_t * ext_port)
static inline bool port_has_changed_connection(ext_port_t *ext_port)
{
return ext_port->status.wPortChange.C_PORT_CONNECTION ? true : false;
}
@@ -230,7 +230,7 @@ static inline bool port_has_finished_reset(ext_port_t *ext_port)
* - ESP_ERR_NOT_SUPPORTED: The request type is not supported by the External Hub Driver
* - ESP_OK: Status has been requested
*/
static esp_err_t port_request_status(ext_port_t* ext_port)
static esp_err_t port_request_status(ext_port_t *ext_port)
{
ext_port_parent_request_data_t data = {
.type = EXT_PORT_PARENT_REQ_CONTROL,
@@ -469,7 +469,7 @@ static ext_port_t *get_port_from_pending_list(void)
* - ESP_ERR_NOT_FINISHED: Unable to allocate the port object: parent device is not available
* - ESP_OK: Port object created successfully
*/
static esp_err_t port_alloc(void* context, usb_device_handle_t parent_dev_hdl, uint8_t parent_port_num, uint16_t port_delay_ms, ext_port_t **port_obj)
static esp_err_t port_alloc(void *context, usb_device_handle_t parent_dev_hdl, uint8_t parent_port_num, uint16_t port_delay_ms, ext_port_t **port_obj)
{
uint8_t parent_dev_addr = 0;
EXT_PORT_CHECK(context != NULL && parent_dev_hdl != NULL, ESP_ERR_INVALID_ARG);
@@ -1247,7 +1247,7 @@ static esp_err_t port_gone(void *port_hdl)
* - ESP_ERR_INVALID_ARG: The port handle can't be NULL
* - ESP_OK: Port action was requested
*/
static esp_err_t port_get_status(void* port_hdl)
static esp_err_t port_get_status(void *port_hdl)
{
EXT_PORT_CHECK(p_ext_port_driver != NULL, ESP_ERR_NOT_ALLOWED);
EXT_PORT_CHECK(port_hdl != NULL, ESP_ERR_INVALID_ARG);
@@ -1269,7 +1269,7 @@ static esp_err_t port_get_status(void* port_hdl)
* - ESP_ERR_INVALID_ARG: The port handle can't be NULL, the status data can't be NULL
* - ESP_OK: Port action was requested
*/
static esp_err_t port_set_status(void* port_hdl, const usb_port_status_t *port_status)
static esp_err_t port_set_status(void *port_hdl, const usb_port_status_t *port_status)
{
EXT_PORT_CHECK(p_ext_port_driver != NULL, ESP_ERR_NOT_ALLOWED);
EXT_PORT_CHECK(port_hdl != NULL && port_status != NULL, ESP_ERR_INVALID_ARG);
@@ -1298,7 +1298,7 @@ static esp_err_t port_set_status(void* port_hdl, const usb_port_status_t *port_s
* - ESP_ERR_INVALID_ARG: The port handle can't be NULL
* - ESP_OK: Port action was requested
*/
static esp_err_t port_req_process(void* port_hdl)
static esp_err_t port_req_process(void *port_hdl)
{
EXT_PORT_CHECK(p_ext_port_driver != NULL, ESP_ERR_NOT_ALLOWED);
EXT_PORT_CHECK(port_hdl != NULL, ESP_ERR_INVALID_ARG);
@@ -1443,7 +1443,7 @@ const ext_port_driver_api_t *ext_port_get_driver(void)
return &ext_port_driver;
}
void* ext_port_get_context(ext_port_hdl_t port_hdl)
void *ext_port_get_context(ext_port_hdl_t port_hdl)
{
EXT_PORT_CHECK(p_ext_port_driver != NULL, NULL);
ext_port_t *ext_port = (ext_port_t *)port_hdl;

View File

@@ -1407,7 +1407,7 @@ esp_err_t hcd_port_init(int port_number, const hcd_port_config_t *port_config, h
// USB-HAL's size is dependent on its configuration, namely on number of channels in the configuration
// We must first initialize the HAL, to get the number of channels and then allocate memory for the channels
usb_dwc_hal_init(port_obj->hal, port_number);
port_obj->hal->channels.hdls = calloc(port_obj->hal->constant_config.chan_num_total, sizeof(usb_dwc_hal_chan_t*));
port_obj->hal->channels.hdls = calloc(port_obj->hal->constant_config.chan_num_total, sizeof(usb_dwc_hal_chan_t *));
HCD_CHECK_FROM_CRIT(port_obj->hal->channels.hdls != NULL, ESP_ERR_NO_MEM);
port_obj->initialized = true;
@@ -1669,7 +1669,7 @@ static bool pipe_args_usb_compliance_verification(const hcd_pipe_config_t *pipe_
return true;
}
static bool pipe_alloc_hcd_support_verification(usb_dwc_hal_context_t *hal, const usb_ep_desc_t * ep_desc)
static bool pipe_alloc_hcd_support_verification(usb_dwc_hal_context_t *hal, const usb_ep_desc_t *ep_desc)
{
assert(hal != NULL);
assert(ep_desc != NULL);

View File

@@ -29,7 +29,7 @@ extern "C" {
/**
* @brief Handle of enumeration control object
*/
typedef struct enum_ctx_handle_s * enum_ctx_handle_t;
typedef struct enum_ctx_handle_s *enum_ctx_handle_t;
// ------------------------------ Events ---------------------------------------

View File

@@ -37,7 +37,7 @@ typedef bool (*ext_hub_cb_t)(bool in_isr, void *user_arg);
typedef struct {
ext_hub_cb_t proc_req_cb; /**< External Hub process callback */
void *proc_req_cb_arg; /**< External Hub process callback argument */
const ext_port_driver_api_t* port_driver; /**< External Port Driver */
const ext_port_driver_api_t *port_driver; /**< External Port Driver */
} ext_hub_config_t;
// ------------------------------ Driver ---------------------------------------
@@ -55,7 +55,7 @@ typedef struct {
* - ESP_ERR_NO_MEM: Insufficient memory
* - ESP_ERR_INVALID_STATE: External Hub driver already installed
*/
esp_err_t ext_hub_install(const ext_hub_config_t* config);
esp_err_t ext_hub_install(const ext_hub_config_t *config);
/**
* @brief Uninstall External Hub Driver

View File

@@ -128,7 +128,7 @@ typedef struct {
* Structure is used to create new port
*/
typedef struct {
void* context; /**< Ports' parent external Hub handle */
void *context; /**< Ports' parent external Hub handle */
usb_device_handle_t parent_dev_hdl; /**< Ports' parent device handle */
uint8_t parent_port_num; /**< Ports' parent port number */
uint16_t port_power_delay_ms; /**< Ports' Power on time to Power Good, ms */
@@ -193,7 +193,7 @@ const ext_port_driver_api_t *ext_port_get_driver(void);
* @return
* - Pointer to the External Port Driver context
*/
void* ext_port_get_context(ext_port_hdl_t port_hdl);
void *ext_port_get_context(ext_port_hdl_t port_hdl);
/**
* @brief Returns External Port's port number

View File

@@ -87,7 +87,7 @@ bLength : 0x22 (34 bytes)
bDescriptorType : 0x03 (String Descriptor)
wData : " SanDisk 3.2Gen1"
----------------------------- String Descriptor Ser ----------------------------
----------------------------- String Descriptor Set ----------------------------
bLength : 0xF2 (242 bytes)
bDescriptorType : 0x03 (String Descriptor)
wData : "0101cdd1e856b427bbb796f870561a4b2b817af9da9872c8d75217cccdd5d5eccb3a0000000000000000000096abe1a3ff83610095558107aea948b4"

View File

@@ -346,4 +346,3 @@ E (121120) USBH: Dev 33 EP 0 STALL
E (121120) ENUM: Bad transfer status 4: CHECK_CONFIG
E (121120) ENUM: [0:0] CHECK_CONFIG FAILED
```

View File

@@ -202,7 +202,7 @@ uint16_t const *tud_descriptor_string_cb(uint8_t index, uint16_t langid)
}
// Advanced
uint8_t const * tud_descriptor_bos_cb(void)
uint8_t const *tud_descriptor_bos_cb(void)
{
printf("\t <- BOS Descriptor request\n");
return NULL;

View File

@@ -77,7 +77,7 @@ typedef struct {
ext_port_parent_request_data_t data;
} ext_port_hub_request_msg_t;
static const ext_port_driver_api_t* port_api;
static const ext_port_driver_api_t *port_api;
SemaphoreHandle_t _process_cd_req = NULL;
QueueHandle_t _ext_port_hub_req_queue = NULL;
QueueHandle_t _ext_port_event_queue = NULL;
@@ -180,11 +180,11 @@ void test_ext_port_setup(void)
// Install External Port driver
ext_port_driver_config_t ext_port_config = {
.proc_req_cb = test_ext_port_callback,
.proc_req_cb_arg = (void*)_process_cd_req,
.proc_req_cb_arg = (void *)_process_cd_req,
.event_cb = test_ext_port_event_callback,
.event_cb_arg = (void*)_ext_port_event_queue,
.event_cb_arg = (void *)_ext_port_event_queue,
.hub_request_cb = test_ext_port_hub_request,
.hub_request_cb_arg = (void*)_ext_port_hub_req_queue,
.hub_request_cb_arg = (void *)_ext_port_hub_req_queue,
};
TEST_ASSERT_EQUAL(ESP_OK, ext_port_install(&ext_port_config));
port_api = ext_port_get_driver();
@@ -203,7 +203,7 @@ void test_ext_port_teardown(void)
ext_port_hdl_t test_ext_port_new(ext_port_config_t *config)
{
ext_port_hdl_t port = NULL;
TEST_ASSERT_EQUAL(ESP_OK, port_api->new (config, (void**) &port));
TEST_ASSERT_EQUAL(ESP_OK, port_api->new (config, (void **) &port));
TEST_ASSERT_NOT_NULL(port);
// Adding the port should trigger the process request callback
test_wait_ext_port_process_request();

View File

@@ -199,9 +199,9 @@ void hub_detach(void)
test_hcd_wait_for_disconn(hub.root_port_hdl, true);
}
void* hub_get_context(void)
void *hub_get_context(void)
{
return (void*) &hub;
return (void *) &hub;
}
uint8_t hub_get_port_num(void)

View File

@@ -72,7 +72,7 @@ void hub_child_quick_enum(hcd_pipe_handle_t ctrl_pipe, uint8_t dev_addr, uint8_t
*
* @return void* pointer to a Hub context
*/
void* hub_get_context(void);
void *hub_get_context(void);
/**
* @brief Get number of ports

View File

@@ -92,8 +92,8 @@ TEST_CASE("Port: disconnected", "[low_speed][full_speed][high_speed]")
TEST_ASSERT_TRUE(TEST_PORT_NUM_EMPTY <= port_num);
// Create External Port
ext_port_config_t port_config = {
.context = (void*) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void*) hub_get_context() /* use any before IDF-10023 */,
.context = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_port_num = TEST_PORT_NUM_EMPTY,
.port_power_delay_ms = hub_get_port_poweron_delay_ms(),
};
@@ -136,8 +136,8 @@ TEST_CASE("Port: enumerate child device Low-speed", "[ext_port][low_speed]")
TEST_ASSERT_TRUE(TEST_PORT_NUM_DEVICE_LS <= port_num);
// Create External Port
ext_port_config_t port_config = {
.context = (void*) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void*) hub_get_context() /* use any before IDF-10023 */,
.context = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_port_num = TEST_PORT_NUM_DEVICE_LS,
.port_power_delay_ms = hub_get_port_poweron_delay_ms(),
};
@@ -146,7 +146,7 @@ TEST_CASE("Port: enumerate child device Low-speed", "[ext_port][low_speed]")
test_ext_port_power_on(TEST_PORT_NUM_DEVICE_LS, port_hdl);
// Wait connection
usb_speed_t port_speed = test_ext_port_connected(TEST_PORT_NUM_DEVICE_LS, port_hdl);
printf("Hub port: %s speed device \n", (char*[]) {
printf("Hub port: %s speed device \n", (char *[]) {
"Low", "Full", "High"
}[port_speed]);
// Check the device speed
@@ -193,8 +193,8 @@ TEST_CASE("Port: enumerate child device Full-speed", "[ext_port][full_speed]")
TEST_ASSERT_TRUE(TEST_PORT_NUM_DEVICE_FSHS <= port_num);
// Create External Port
ext_port_config_t port_config = {
.context = (void*) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void*) hub_get_context() /* use any before IDF-10023 */,
.context = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_port_num = TEST_PORT_NUM_DEVICE_FSHS,
.port_power_delay_ms = hub_get_port_poweron_delay_ms(),
};
@@ -203,7 +203,7 @@ TEST_CASE("Port: enumerate child device Full-speed", "[ext_port][full_speed]")
test_ext_port_power_on(TEST_PORT_NUM_DEVICE_FSHS, port_hdl);
// Wait connection
usb_speed_t port_speed = test_ext_port_connected(TEST_PORT_NUM_DEVICE_FSHS, port_hdl);
printf("Hub port: %s speed device \n", (char*[]) {
printf("Hub port: %s speed device \n", (char *[]) {
"Low", "Full", "High"
}[port_speed]);
// Check the device speed
@@ -250,8 +250,8 @@ TEST_CASE("Port: enumerate child device High-speed", "[ext_port][high_speed]")
TEST_ASSERT_TRUE(TEST_PORT_NUM_DEVICE_FSHS <= port_num);
// Create External Port
ext_port_config_t port_config = {
.context = (void*) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void*) hub_get_context() /* use any before IDF-10023 */,
.context = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_port_num = TEST_PORT_NUM_DEVICE_FSHS,
.port_power_delay_ms = hub_get_port_poweron_delay_ms(),
};
@@ -260,7 +260,7 @@ TEST_CASE("Port: enumerate child device High-speed", "[ext_port][high_speed]")
test_ext_port_power_on(TEST_PORT_NUM_DEVICE_FSHS, port_hdl);
// Wait connection
usb_speed_t port_speed = test_ext_port_connected(TEST_PORT_NUM_DEVICE_FSHS, port_hdl);
printf("Hub port: %s speed device \n", (char*[]) {
printf("Hub port: %s speed device \n", (char *[]) {
"Low", "Full", "High"
}[port_speed]);
// Check the device speed
@@ -307,8 +307,8 @@ TEST_CASE("Port: recycle", "[ext_port][full_speed][high_speed]")
TEST_ASSERT_TRUE(TEST_PORT_NUM_DEVICE_FSHS <= port_num);
// Create External Port
ext_port_config_t port_config = {
.context = (void*) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void*) hub_get_context() /* use any before IDF-10023 */,
.context = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_port_num = TEST_PORT_NUM_DEVICE_FSHS,
.port_power_delay_ms = hub_get_port_poweron_delay_ms(),
};
@@ -317,7 +317,7 @@ TEST_CASE("Port: recycle", "[ext_port][full_speed][high_speed]")
test_ext_port_power_on(TEST_PORT_NUM_DEVICE_FSHS, port_hdl);
// Wait connection
usb_speed_t port_speed = test_ext_port_connected(TEST_PORT_NUM_DEVICE_FSHS, port_hdl);
printf("Hub port: %s speed device \n", (char*[]) {
printf("Hub port: %s speed device \n", (char *[]) {
"Low", "Full", "High"
}[port_speed]);
// Wait disconnection
@@ -331,7 +331,7 @@ TEST_CASE("Port: recycle", "[ext_port][full_speed][high_speed]")
// Verify that port still available
printf("Verify the port is still available...\n");
port_speed = test_ext_port_connected(TEST_PORT_NUM_DEVICE_FSHS, port_hdl);
printf("Hub port: %s speed device \n", (char*[]) {
printf("Hub port: %s speed device \n", (char *[]) {
"Low", "Full", "High"
}[port_speed]);
// Wait disconnection
@@ -352,8 +352,8 @@ TEST_CASE("Port: recycle when port is gone", "[ext_port][low_speed][full_speed][
TEST_ASSERT_TRUE(TEST_PORT_NUM_DEVICE_FSHS <= port_num);
// Create External Port
ext_port_config_t port_config = {
.context = (void*) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void*) hub_get_context() /* use any before IDF-10023 */,
.context = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_port_num = TEST_PORT_NUM_DEVICE_FSHS,
.port_power_delay_ms = hub_get_port_poweron_delay_ms(),
};
@@ -362,7 +362,7 @@ TEST_CASE("Port: recycle when port is gone", "[ext_port][low_speed][full_speed][
test_ext_port_power_on(TEST_PORT_NUM_DEVICE_FSHS, port_hdl);
// Wait connection
usb_speed_t port_speed = test_ext_port_connected(TEST_PORT_NUM_DEVICE_FSHS, port_hdl);
printf("Hub port: %s speed device \n", (char*[]) {
printf("Hub port: %s speed device \n", (char *[]) {
"Low", "Full", "High"
}[port_speed]);
@@ -397,8 +397,8 @@ TEST_CASE("Port: disable", "[ext_port][full_speed][high_speed]")
TEST_ASSERT_TRUE(TEST_PORT_NUM_DEVICE_FSHS <= port_num);
// Create External Port
ext_port_config_t port_config = {
.context = (void*) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void*) hub_get_context() /* use any before IDF-10023 */,
.context = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_port_num = TEST_PORT_NUM_DEVICE_FSHS,
.port_power_delay_ms = hub_get_port_poweron_delay_ms(),
};
@@ -407,7 +407,7 @@ TEST_CASE("Port: disable", "[ext_port][full_speed][high_speed]")
test_ext_port_power_on(TEST_PORT_NUM_DEVICE_FSHS, port_hdl);
// Wait connection
usb_speed_t port_speed = test_ext_port_connected(TEST_PORT_NUM_DEVICE_FSHS, port_hdl);
printf("Hub port: %s speed device \n", (char*[]) {
printf("Hub port: %s speed device \n", (char *[]) {
"Low", "Full", "High"
}[port_speed]);
printf("Disable the port ...\n");
@@ -440,8 +440,8 @@ TEST_CASE("Port: gone in state - powered on", "[ext_port][full_speed][high_speed
TEST_ASSERT_TRUE(TEST_PORT_NUM_DEVICE_FSHS <= port_num);
// Create External Port
ext_port_config_t port_config = {
.context = (void*) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void*) hub_get_context() /* use any before IDF-10023 */,
.context = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_port_num = TEST_PORT_NUM_DEVICE_FSHS,
.port_power_delay_ms = hub_get_port_poweron_delay_ms(),
};
@@ -478,8 +478,8 @@ TEST_CASE("Port: gone in state - enabled", "[ext_port][full_speed][high_speed]")
TEST_ASSERT_TRUE(TEST_PORT_NUM_DEVICE_FSHS <= port_num);
// Create External Port
ext_port_config_t port_config = {
.context = (void*) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void*) hub_get_context() /* use any before IDF-10023 */,
.context = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_dev_hdl = (void *) hub_get_context() /* use any before IDF-10023 */,
.parent_port_num = TEST_PORT_NUM_DEVICE_FSHS,
.port_power_delay_ms = hub_get_port_poweron_delay_ms(),
};
@@ -488,7 +488,7 @@ TEST_CASE("Port: gone in state - enabled", "[ext_port][full_speed][high_speed]")
test_ext_port_power_on(TEST_PORT_NUM_DEVICE_FSHS, port_hdl);
// Wait connection
usb_speed_t port_speed = test_ext_port_connected(TEST_PORT_NUM_DEVICE_FSHS, port_hdl);
printf("Hub port: %s speed device \n", (char*[]) {
printf("Hub port: %s speed device \n", (char *[]) {
"Low", "Full", "High"
}[port_speed]);
//

View File

@@ -33,7 +33,7 @@ Procedure:
TEST_CASE("Test HCD port disconnect event, port enabled", "[port][low_speed][full_speed][high_speed]")
{
usb_speed_t port_speed = test_hcd_wait_for_conn(port_hdl); // Trigger a connection
printf("Connected %s speed device \n", (char*[]) {
printf("Connected %s speed device \n", (char *[]) {
"Low", "Full", "High"
}[port_speed]);
vTaskDelay(pdMS_TO_TICKS(100)); // Short delay send of SOF (for FS) or EOPs (for LS)

View File

@@ -9,4 +9,3 @@ There are three sets of tests in this application:
3. High-speed: Expects high-speed USB flash disk with 2 bulk endpoints to be connected
For running these tests locally, you will have to update device definitions (VID, PID, ...) in [dev_msc.c](../common/dev_msc.c) and [dev_hid.c](../common/dev_hid.c).

View File

@@ -327,7 +327,7 @@ TEST_CASE("Test USB Host multiconfig client (single client)", "[usb_host][full_s
.bConfigurationValue = B_CONFIGURATION_VALUE,
};
xTaskCreatePinnedToCore(multiconf_client_async_task, "async client", 4096, (void*)&multiconf_params, 2, &client_task, 0);
xTaskCreatePinnedToCore(multiconf_client_async_task, "async client", 4096, (void *)&multiconf_params, 2, &client_task, 0);
TEST_ASSERT_NOT_NULL_MESSAGE(client_task, "Failed to create async client task");
// Start the task
xTaskNotifyGive(client_task);
@@ -335,7 +335,7 @@ TEST_CASE("Test USB Host multiconfig client (single client)", "[usb_host][full_s
TaskHandle_t host_lib_task_hdl;
// Get Current task handle
TaskHandle_t pending_task = xTaskGetCurrentTaskHandle();
xTaskCreatePinnedToCore(host_lib_task, "host lib", 4096, (void*)pending_task, 2, &host_lib_task_hdl, 0);
xTaskCreatePinnedToCore(host_lib_task, "host lib", 4096, (void *)pending_task, 2, &host_lib_task_hdl, 0);
TEST_ASSERT_NOT_NULL_MESSAGE(host_lib_task_hdl, "Failed to create host lib task");
// Wait for the device to be open

View File

@@ -1235,7 +1235,7 @@ exit:
esp_err_t usb_host_free_config_desc(const usb_config_desc_t *config_desc)
{
HOST_CHECK(config_desc != NULL, ESP_ERR_INVALID_ARG);
heap_caps_free((usb_config_desc_t*)config_desc);
heap_caps_free((usb_config_desc_t *)config_desc);
return ESP_OK;
}

View File

@@ -1,5 +1,5 @@
/*
* SPDX-FileCopyrightText: 2022-2024 Espressif Systems (Shanghai) CO LTD
* SPDX-FileCopyrightText: 2022-2025 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Unlicense OR CC0-1.0
*/
@@ -33,7 +33,7 @@ const uint8_t hid_report_descriptor[] = {
/**
* @brief String descriptor
*/
const char* hid_string_descriptor[5] = {
const char *hid_string_descriptor[5] = {
// array of pointer to string descriptors
(char[]){0x09, 0x04}, // 0: is supported language is English (0x0409)
"TinyUSB", // 1: Manufacturer
@@ -68,7 +68,7 @@ uint8_t const *tud_hid_descriptor_report_cb(uint8_t instance)
// Invoked when received GET_REPORT control request
// Application must fill buffer report's content and return its length.
// Return zero will cause the stack to STALL request
uint16_t tud_hid_get_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t* buffer, uint16_t reqlen)
uint16_t tud_hid_get_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t *buffer, uint16_t reqlen)
{
(void) instance;
(void) report_id;
@@ -81,7 +81,7 @@ uint16_t tud_hid_get_report_cb(uint8_t instance, uint8_t report_id, hid_report_t
// Invoked when received SET_REPORT control request or
// received data on OUT endpoint ( Report ID = 0, Type = 0 )
void tud_hid_set_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize)
void tud_hid_set_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t const *buffer, uint16_t bufsize)
{
}

View File

@@ -42,7 +42,7 @@ enum usb_endpoints {
/**
* @brief String descriptor
*/
static const char* s_str_desc[5] = {
static const char *s_str_desc[5] = {
// array of pointer to string descriptors
(char[]){0x09, 0x04}, // 0: is supported language is English (0x0409)
"TinyUSB", // 1: Manufacturer

View File

@@ -24,7 +24,7 @@ As a USB stack, a TinyUSB component is used.
1. USB which accesses the ESP MSC Partition is unplugged initially and the board is powered-on.
- Result: Host PC can't access the partition over USB MSC. Application example can perform operations (read, write) on partition.
2. USB which accesses the ESP MSC Partition is already plugged-in at boot time.
- Result: Host PC recongnize it as removable device and can access the partition over USB MSC. Application example can't perform any operation on partition.
- Result: Host PC recognize it as removable device and can access the partition over USB MSC. Application example can't perform any operation on partition.
3. USB which accesses the ESP MSC Partition is plugged-in at boot-up. After boot-up, it is ejected on Host PC manually by user.
- Result: Host PC can't access the partition over USB MSC. Application example can perform operations (read, write) on partition.
4. USB which accesses the ESP MSC Partition is plugged-in at boot-up. It is then unplugged(removed) from Host PC manually by user.

View File

@@ -14,7 +14,6 @@
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#define MOCK_CHECK(cond, ret_val) ({ \
if (!(cond)) { \
return (ret_val); \
@@ -32,7 +31,6 @@
#define IS_VALID_ADDRESS(address) ((address) != 0xFF)
#define IS_EMPTY_ADDRESS(address) ((address) == 0xFF)
const char *MOCK_TAG_CB = "USB MOCK CB"; // Tag for callback functions
const char *MOCK_TAG = "USB MOCK"; // Tag for the rest of the functions
@@ -56,10 +54,9 @@ typedef struct {
static device_list_t device_list[MAX_DEV_COUNT];
static unsigned mocked_devices_count = 0;
void usb_host_mock_dev_list_init(void)
{
for(int index = 0; index < MAX_DEV_COUNT; index++) {
for (int index = 0; index < MAX_DEV_COUNT; index++) {
device_list[index].address = 0xFF;
device_list[index].opened = 0;
device_list[index].dev_desc = NULL;
@@ -98,7 +95,7 @@ esp_err_t usb_host_mock_add_device(uint8_t dev_address, const usb_device_desc_t
*/
static void _print_mocked_device(int index)
{
ESP_LOGI(MOCK_TAG, "Device handle = %p", (void*)(&device_list[index]));
ESP_LOGI(MOCK_TAG, "Device handle = %p", (void *)(&device_list[index]));
ESP_LOGI(MOCK_TAG, "Device address = %d", device_list[index].address);
ESP_LOGI(MOCK_TAG, "Device opened by = %d clients", device_list[index].opened);
@@ -113,8 +110,8 @@ esp_err_t usb_host_mock_print_mocked_devices(uint8_t dev_address)
// dev_address is 0xFF, print all devices from device_list
if (IS_EMPTY_ADDRESS(dev_address)) {
for(int index = 0; index < MAX_DEV_COUNT; index++) {
if(IS_VALID_ADDRESS(device_list[index].address)) {
for (int index = 0; index < MAX_DEV_COUNT; index++) {
if (IS_VALID_ADDRESS(device_list[index].address)) {
_print_mocked_device(index);
}
}
@@ -194,7 +191,7 @@ esp_err_t usb_host_client_register_mock_callback(const usb_host_client_config_t
esp_err_t ret;
// Create client object
client_t *client_obj = (client_t*)calloc(1, sizeof(client_t));
client_t *client_obj = (client_t *)calloc(1, sizeof(client_t));
SemaphoreHandle_t event_sem = xSemaphoreCreateBinary();
if (client_obj == NULL || event_sem == NULL) {
ret = ESP_ERR_NO_MEM;
@@ -261,7 +258,7 @@ esp_err_t usb_host_device_open_mock_callback(usb_host_client_handle_t client_hdl
MOCK_CHECK(dev_address < MAX_DEV_COUNT && client_hdl != NULL && dev_hdl_ret != NULL, ESP_ERR_INVALID_ARG);
// Find a device in dev_list by dev_address
for (int index = 0; index < MAX_DEV_COUNT; index++) {
if(device_list[index].address == dev_address) {
if (device_list[index].address == dev_address) {
// We should check, if the device has not been opened by the same client
// But we are keeping this mock implementation simple
@@ -282,7 +279,7 @@ esp_err_t usb_host_device_open_mock_callback(usb_host_client_handle_t client_hdl
esp_err_t usb_host_device_close_mock_callback(usb_host_client_handle_t client_hdl, usb_device_handle_t dev_hdl, int call_count)
{
MOCK_CHECK(dev_hdl != NULL && client_hdl != NULL, ESP_ERR_INVALID_ARG);
device_list_t* current_device = (device_list_t *) dev_hdl;
device_list_t *current_device = (device_list_t *) dev_hdl;
if (current_device->opened == 0) {
// Device was never opened
@@ -305,7 +302,7 @@ esp_err_t usb_host_device_addr_list_fill_mock_callback(int list_len, uint8_t *de
int found_devices_count = 0;
for (int index = 0; index < MAX_DEV_COUNT; index++) {
if(IS_VALID_ADDRESS(device_list[index].address) && (found_devices_count < list_len)) {
if (IS_VALID_ADDRESS(device_list[index].address) && (found_devices_count < list_len)) {
dev_addr_list[found_devices_count++] = device_list[index].address;
}
}
@@ -325,7 +322,7 @@ esp_err_t usb_host_get_device_descriptor_mock_callback(usb_device_handle_t dev_h
MOCK_CHECK(dev_hdl != NULL && device_desc != NULL, ESP_ERR_INVALID_ARG);
ESP_LOGD(MOCK_TAG_CB, "Get device descriptor");
const device_list_t* current_device = (const device_list_t *) dev_hdl;
const device_list_t *current_device = (const device_list_t *) dev_hdl;
*device_desc = current_device->dev_desc;
return ESP_OK;
}
@@ -335,7 +332,7 @@ esp_err_t usb_host_get_active_config_descriptor_mock_callback(usb_device_handle_
MOCK_CHECK(dev_hdl != NULL && config_desc != NULL, ESP_ERR_INVALID_ARG);
ESP_LOGD(MOCK_TAG_CB, "Get active config descriptor");
const device_list_t* current_device = (const device_list_t *) dev_hdl;
const device_list_t *current_device = (const device_list_t *) dev_hdl;
*config_desc = current_device->config_desc;
return ESP_OK;
}