ESP-IDF Firmware
Firmware architecture and call graph
Loading...
Searching...
No Matches
tusb_cdc_acm.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2020-2022 Espressif Systems (Shanghai) CO LTD
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7#pragma once
8
9#ifdef __cplusplus
10extern "C" {
11#endif
12
13#include <stdint.h>
14#include "freertos/FreeRTOS.h"
15#include "freertos/semphr.h"
16#include "freertos/timers.h"
17#include "tusb.h"
18#include "tinyusb.h"
19
28
29/* Callbacks and events
30 ********************************************************************* */
31
38
42typedef struct {
43 bool dtr;
44 bool rts;
46
50typedef struct {
51 cdc_line_coding_t const *p_line_coding;
53
63
75
79typedef void(*tusb_cdcacm_callback_t)(int itf, cdcacm_event_t *event);
80
81/*********************************************************************** Callbacks and events*/
82/* Other structs
83 ********************************************************************* */
84
97
98/*********************************************************************** Other structs*/
99/* Public functions
100 ********************************************************************* */
109
110
121 cdcacm_event_type_t event_type,
122 tusb_cdcacm_callback_t callback);
123
124
133
134
143
144
153size_t tinyusb_cdcacm_write_queue(tinyusb_cdcacm_itf_t itf, const uint8_t *in_buf, size_t in_size);
154
170
180esp_err_t tinyusb_cdcacm_read(tinyusb_cdcacm_itf_t itf, uint8_t *out_buf, size_t out_buf_sz, size_t *rx_data_size);
181
182
190
191/*********************************************************************** Public functions*/
192
193#ifdef __cplusplus
194}
195#endif
int esp_err_t
Definition esp_err.h:21
Data provided to the input of the line_coding_changed callback.
cdc_line_coding_t const * p_line_coding
Data provided to the input of the callback_line_state_changed callback.
Data provided to the input of the callback_rx_wanted_char callback.
Describes an event passing to the input of a callbacks.
cdcacm_event_line_state_changed_data_t line_state_changed_data
cdcacm_event_type_t type
cdcacm_event_rx_wanted_char_data_t rx_wanted_char_data
cdcacm_event_line_coding_changed_data_t line_coding_changed_data
Configuration structure for CDC-ACM.
tusb_cdcacm_callback_t callback_rx_wanted_char
tusb_cdcacm_callback_t callback_line_coding_changed
tinyusb_usbdev_t usb_dev
tusb_cdcacm_callback_t callback_rx
tusb_cdcacm_callback_t callback_line_state_changed
tinyusb_cdcacm_itf_t cdc_port
tinyusb_usbdev_t
size_t tinyusb_cdcacm_write_queue(tinyusb_cdcacm_itf_t itf, const uint8_t *in_buf, size_t in_size)
Write data to write buffer from a byte array.
cdcacm_event_type_t
Types of CDC ACM events.
@ CDC_EVENT_LINE_STATE_CHANGED
@ CDC_EVENT_RX_WANTED_CHAR
@ CDC_EVENT_LINE_CODING_CHANGED
@ CDC_EVENT_RX
void(* tusb_cdcacm_callback_t)(int itf, cdcacm_event_t *event)
CDC-ACM callback type.
esp_err_t tinyusb_cdcacm_register_callback(tinyusb_cdcacm_itf_t itf, cdcacm_event_type_t event_type, tusb_cdcacm_callback_t callback)
Register a callback invoking on CDC event. If the callback had been already registered,...
bool tusb_cdc_acm_initialized(tinyusb_cdcacm_itf_t itf)
Check if the ACM initialized.
esp_err_t tinyusb_cdcacm_read(tinyusb_cdcacm_itf_t itf, uint8_t *out_buf, size_t out_buf_sz, size_t *rx_data_size)
Read a content to the array, and defines it's size to the sz_store.
esp_err_t tusb_cdc_acm_init(const tinyusb_config_cdcacm_t *cfg)
Initialize CDC ACM. Initialization will be finished with the tud_cdc_line_state_cb callback.
tinyusb_cdcacm_itf_t
CDC ports available to setup.
@ TINYUSB_CDC_ACM_1
@ TINYUSB_CDC_ACM_MAX
@ TINYUSB_CDC_ACM_0
esp_err_t tinyusb_cdcacm_unregister_callback(tinyusb_cdcacm_itf_t itf, cdcacm_event_type_t event_type)
Unregister a callback invoking on CDC event.
size_t tinyusb_cdcacm_write_queue_char(tinyusb_cdcacm_itf_t itf, char ch)
Sent one character to a write buffer.
esp_err_t tinyusb_cdcacm_write_flush(tinyusb_cdcacm_itf_t itf, uint32_t timeout_ticks)
Send all data from a write buffer. Use tinyusb_cdcacm_write_queue to add data to the buffer.