-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(usb_serial_jtag): make usb_serial_jtag as component
- Loading branch information
1 parent
32e2101
commit 3dc76e9
Showing
33 changed files
with
244 additions
and
168 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
set(srcs) | ||
set(include "include") | ||
|
||
# USB Serial JTAG related source files | ||
if(CONFIG_SOC_USB_SERIAL_JTAG_SUPPORTED) | ||
list(APPEND srcs "src/usb_serial_jtag.c" | ||
"src/usb_serial_jtag_connection_monitor.c") | ||
endif() | ||
|
||
idf_component_register(SRCS ${srcs} | ||
INCLUDE_DIRS ${include} | ||
PRIV_REQUIRES esp_driver_gpio esp_ringbuf esp_pm esp_timer | ||
) | ||
|
||
if(CONFIG_VFS_SUPPORT_IO AND CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED) | ||
target_link_libraries(${COMPONENT_LIB} PUBLIC idf::vfs) | ||
target_sources(${COMPONENT_LIB} PRIVATE "src/usb_serial_jtag_vfs.c") | ||
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u usb_serial_jtag_vfs_include_dev_init") | ||
endif() | ||
|
||
# If system needs to monitor USJ connection status, then usb_serial_jtag_connection_monitor object file has to be linked | ||
# to the binary, to allow tick hook to be registered | ||
if(CONFIG_USJ_NO_AUTO_LS_ON_CONNECTION OR CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED) | ||
target_link_libraries(${COMPONENT_LIB} INTERFACE "-u usb_serial_jtag_connection_monitor_include") | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
menu "ESP-Driver:USB Serial/JTAG Configuration" | ||
depends on SOC_USB_SERIAL_JTAG_SUPPORTED | ||
config USJ_NO_AUTO_LS_ON_CONNECTION | ||
bool "Don't enter the automatic light sleep when USB Serial/JTAG port is connected" | ||
depends on PM_ENABLE && ESP_CONSOLE_USB_SERIAL_JTAG_ENABLED && !SOC_USB_SERIAL_JTAG_SUPPORT_LIGHT_SLEEP | ||
default n | ||
help | ||
If enabled, the chip will constantly monitor the connection status of the USB Serial/JTAG port. As long | ||
as the USB Serial/JTAG is connected, a ESP_PM_NO_LIGHT_SLEEP power management lock will be acquired to | ||
prevent the system from entering light sleep. | ||
This option can be useful if serial monitoring is needed via USB Serial/JTAG while power management is | ||
enabled, as the USB Serial/JTAG cannot work under light sleep and after waking up from light sleep. | ||
Note. This option can only control the automatic Light-Sleep behavior. If esp_light_sleep_start() is | ||
called manually from the program, enabling this option will not prevent light sleep entry even if the | ||
USB Serial/JTAG is in use. | ||
endmenu # USB Serial/JTAG Configuration |
2 changes: 1 addition & 1 deletion
2
...ial_jtag/include/driver/usb_serial_jtag.h → ...ial_jtag/include/driver/usb_serial_jtag.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
components/esp_driver_usb_serial_jtag/include/driver/usb_serial_jtag_vfs.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2021-2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#pragma once | ||
|
||
#include "esp_err.h" | ||
#include "esp_vfs.h" | ||
#include "esp_vfs_common.h" | ||
|
||
#ifdef __cplusplus | ||
extern "C" { | ||
#endif | ||
|
||
/** | ||
* @brief add /dev/usbserjtag virtual filesystem driver | ||
* | ||
* This function is called from startup code to enable console output | ||
*/ | ||
esp_err_t usb_serial_jtag_vfs_register(void); | ||
|
||
/** | ||
* @brief Set the line endings expected to be received | ||
* | ||
* This specifies the conversion between line endings received and | ||
* newlines ('\n', LF) passed into stdin: | ||
* | ||
* - ESP_LINE_ENDINGS_CRLF: convert CRLF to LF | ||
* - ESP_LINE_ENDINGS_CR: convert CR to LF | ||
* - ESP_LINE_ENDINGS_LF: no modification | ||
* | ||
* @note this function is not thread safe w.r.t. reading | ||
* | ||
* @param mode line endings expected | ||
*/ | ||
void usb_serial_jtag_vfs_set_rx_line_endings(esp_line_endings_t mode); | ||
|
||
/** | ||
* @brief Set the line endings to sent | ||
* | ||
* This specifies the conversion between newlines ('\n', LF) on stdout and line | ||
* endings sent: | ||
* | ||
* - ESP_LINE_ENDINGS_CRLF: convert LF to CRLF | ||
* - ESP_LINE_ENDINGS_CR: convert LF to CR | ||
* - ESP_LINE_ENDINGS_LF: no modification | ||
* | ||
* @note this function is not thread safe w.r.t. writing | ||
* | ||
* @param mode line endings to send | ||
*/ | ||
void usb_serial_jtag_vfs_set_tx_line_endings(esp_line_endings_t mode); | ||
|
||
/** | ||
* @brief set VFS to use USB-SERIAL-JTAG driver for reading and writing | ||
* @note application must configure USB-SERIAL-JTAG driver before calling these functions | ||
* With these functions, read and write are blocking and interrupt-driven. | ||
*/ | ||
void usb_serial_jtag_vfs_use_driver(void); | ||
|
||
/** | ||
* @brief set VFS to use simple functions for reading and writing UART | ||
* Read is non-blocking, write is busy waiting until TX FIFO has enough space. | ||
* These functions are used by default. | ||
*/ | ||
void usb_serial_jtag_vfs_use_nonblocking(void); | ||
|
||
#ifdef __cplusplus | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.