Skip to content

Commit

Permalink
esp_system: usb_console support for ESP32-S3
Browse files Browse the repository at this point in the history
Closes #8879
Closes #8738
  • Loading branch information
igrr committed Jul 18, 2023
1 parent ce8f2dc commit 28e6b35
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 437 deletions.
32 changes: 32 additions & 0 deletions components/esp_system/include/esp_private/usb_console.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,14 +50,46 @@ esp_err_t esp_usb_console_init(void);
*/
ssize_t esp_usb_console_write_buf(const char* buf, size_t size);

/**
* @brief Wait until all buffered USB CDC output is written
*
* @return ssize_t Number of bytes written, or -1 if the driver is not initialized
*/
ssize_t esp_usb_console_flush(void);

/**
* @brief Read data from USB CDC
*
* May read less data than requested.
*
* @param buf Buffer to read data into
* @param buf_size Size of the buffer
* @return ssize_t Number of bytes written into the buffer, or -1 if the driver is not initialized
*/
ssize_t esp_usb_console_read_buf(char* buf, size_t buf_size);

/**
* @brief Get the number of bytes available for reading from USB CDC
*
* @return ssize_t Number of bytes available, or -1 if the driver is not initialized
*/
ssize_t esp_usb_console_available_for_read(void);

/**
* @brief Check if data can be written into USB CDC
*
* @return true if data can be written now without blocking
*/
bool esp_usb_console_write_available(void);

/**
* @brief Set RX/TX callback functions to be called from ISR
*
* @param rx_cb RX callback function
* @param tx_cb TX callback function
* @param arg callback-specific context pointer
* @return ESP_OK if the callbacks were set, ESP_ERR_INVALID_STATE if the driver is not initialized
*/
esp_err_t esp_usb_console_set_cb(esp_usb_console_cb_t rx_cb, esp_usb_console_cb_t tx_cb, void* arg);

#ifdef __cplusplus
Expand Down
4 changes: 4 additions & 0 deletions components/esp_system/port/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ endif()
target_include_directories(${COMPONENT_LIB} PRIVATE ${INCLUDE_FILES} include/private)

set(srcs "cpu_start.c" "panic_handler.c" "brownout.c")
if(CONFIG_ESP_CONSOLE_USB_CDC)
list(APPEND srcs "usb_console.c")
endif()

add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" ${srcs})

target_sources(${COMPONENT_LIB} PRIVATE ${srcs})
Expand Down
3 changes: 0 additions & 3 deletions components/esp_system/port/soc/esp32s2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ endif()
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" ${srcs})

target_sources(${COMPONENT_LIB} PRIVATE ${srcs})
if(CONFIG_ESP_CONSOLE_USB_CDC)
target_sources(${COMPONENT_LIB} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/usb_console.c")
endif()

#ld_include_highint_hdl is added as an undefined symbol because otherwise the
#linker will ignore highint_hdl.S as it has no other files depending on any
Expand Down
3 changes: 0 additions & 3 deletions components/esp_system/port/soc/esp32s3/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@ endif()
add_prefix(srcs "${CMAKE_CURRENT_LIST_DIR}/" ${srcs})

target_sources(${COMPONENT_LIB} PRIVATE ${srcs})
if(CONFIG_ESP_CONSOLE_USB_CDC)
target_sources(${COMPONENT_LIB} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/usb_console.c")
endif()

#ld_include_highint_hdl is added as an undefined symbol because otherwise the
#linker will ignore panic_highint_hdl.S as it has no other files depending on any
Expand Down
Loading

0 comments on commit 28e6b35

Please sign in to comment.