ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
tusb_tasks.h File Reference
#include "esp_err.h"
Include dependency graph for tusb_tasks.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

esp_err_t tusb_run_task (void)
 This helper function creates and starts a task which wraps tud_task().
esp_err_t tusb_stop_task (void)
 This helper function stops and destroys the task created by tusb_run_task().

Function Documentation

◆ tusb_run_task()

esp_err_t tusb_run_task ( void )

This helper function creates and starts a task which wraps tud_task().

The wrapper function basically wraps tud_task and some log. Default parameters: stack size and priority as configured, argument = NULL, not pinned to any core. If you have more requirements for this task, you can create your own task which calls tud_task as the last step.

Return values
ESP_OKrun tinyusb main task successfully
ESP_FAILrun tinyusb main task failed of internal error
ESP_ERR_INVALID_STATEtinyusb main task has been created before

Definition at line 29 of file tusb_tasks.c.

30{
31 // This function is not garanteed to be thread safe, if invoked multiple times without calling `tusb_stop_task`, will cause memory leak
32 // doing a sanity check anyway
33 ESP_RETURN_ON_FALSE(!s_tusb_tskh, ESP_ERR_INVALID_STATE, TAG, "TinyUSB main task already started");
34 // Create a task for tinyusb device stack:
35 xTaskCreate(tusb_device_task, "TinyUSB", CONFIG_TINYUSB_TASK_STACK_SIZE, NULL, CONFIG_TINYUSB_TASK_PRIORITY, &s_tusb_tskh);
36 ESP_RETURN_ON_FALSE(s_tusb_tskh, ESP_FAIL, TAG, "create TinyUSB main task failed");
37 return ESP_OK;
38}
#define ESP_OK
Definition esp_err.h:23
static const char * TAG
Definition main/main.c:31
static void tusb_device_task(void *arg)
This top level thread processes all usb events and invokes callbacks.
Definition tusb_tasks.c:21
static TaskHandle_t s_tusb_tskh
Definition tusb_tasks.c:16

References ESP_OK, s_tusb_tskh, TAG, and tusb_device_task().

Referenced by tinyusb_driver_install().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ tusb_stop_task()

esp_err_t tusb_stop_task ( void )

This helper function stops and destroys the task created by tusb_run_task().

Return values
ESP_OKstop and destory tinyusb main task successfully
ESP_ERR_INVALID_STATEtinyusb main task hasn't been created yet

Definition at line 40 of file tusb_tasks.c.

41{
42 ESP_RETURN_ON_FALSE(s_tusb_tskh, ESP_ERR_INVALID_STATE, TAG, "TinyUSB main task not started yet");
43 vTaskDelete(s_tusb_tskh);
44 s_tusb_tskh = NULL;
45 return ESP_OK;
46}

References ESP_OK, s_tusb_tskh, and TAG.