2023-01-30 01:01:19 -05:00
|
|
|
/*
|
2024-01-17 04:19:49 -05:00
|
|
|
* SPDX-FileCopyrightText: 2010-2024 Espressif Systems (Shanghai) CO LTD
|
2023-01-30 01:01:19 -05:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
2020-07-13 09:33:23 -04:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2023-09-24 23:12:09 -04:00
|
|
|
#include "hal/uart_ll.h"
|
2020-07-13 09:33:23 -04:00
|
|
|
|
|
|
|
#define ESP_ROM_CDC_ACM_WORK_BUF_MIN 128
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
ESP_ROM_UART_0,
|
|
|
|
ESP_ROM_UART_1,
|
|
|
|
ESP_ROM_UART_USB
|
|
|
|
} esp_rom_uart_num_t;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Wait for UART TX FIFO is empty and all data has been sent out.
|
|
|
|
*
|
2024-01-17 04:19:49 -05:00
|
|
|
* @param serial_num The serial number defined in ROM, including UART_x, USB_OTG, USB_SERIAL_JTAG..
|
2020-07-13 09:33:23 -04:00
|
|
|
*/
|
2024-01-17 04:19:49 -05:00
|
|
|
void esp_rom_output_tx_wait_idle(uint8_t serial_num);
|
|
|
|
|
|
|
|
void esp_rom_uart_tx_wait_idle(uint8_t serial_num) __attribute__((deprecated("Please use esp_rom_output_tx_wait_idle instead")));
|
2020-07-13 09:33:23 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set clock source and baud rate for UART.
|
|
|
|
*
|
2024-01-17 04:19:49 -05:00
|
|
|
* @param serial_num UART port number
|
2020-07-13 09:33:23 -04:00
|
|
|
* @param clock_hz Source clock (in Hz)
|
|
|
|
* @param baud_rate Baud rate to set
|
2023-09-26 05:42:03 -04:00
|
|
|
*
|
|
|
|
* @note Only for HP UART
|
2020-07-13 09:33:23 -04:00
|
|
|
*/
|
2024-01-17 04:19:49 -05:00
|
|
|
#define esp_rom_uart_set_clock_baudrate(serial_num, clock_hz, baud_rate) uart_ll_set_baudrate(UART_LL_GET_HW(serial_num), baud_rate, clock_hz)
|
2020-07-13 09:33:23 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Wait until UART TX FIFO is empty (i.e. flush TX FIFO)
|
|
|
|
*
|
2024-01-17 04:19:49 -05:00
|
|
|
* @param serial_num UART port number
|
2020-07-13 09:33:23 -04:00
|
|
|
*/
|
2024-01-17 04:19:49 -05:00
|
|
|
void esp_rom_output_flush_tx(uint8_t serial_num);
|
|
|
|
|
|
|
|
void esp_rom_uart_flush_tx(uint8_t serial_num) __attribute__((deprecated("Please use esp_rom_output_flush_tx instead")));
|
2020-07-13 09:33:23 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Transmit one character to the console channel.
|
|
|
|
*
|
|
|
|
* @param c Character to send
|
|
|
|
* @return
|
|
|
|
* - 0 on success
|
|
|
|
* - 1 on failure
|
|
|
|
*/
|
2024-01-17 04:19:49 -05:00
|
|
|
int esp_rom_output_tx_one_char(uint8_t c);
|
|
|
|
|
|
|
|
int esp_rom_uart_tx_one_char(uint8_t c) __attribute__((deprecated("Please use esp_rom_output_tx_one_char instead")));
|
2020-07-13 09:33:23 -04:00
|
|
|
|
2020-07-21 01:07:34 -04:00
|
|
|
/**
|
|
|
|
* @brief Transmit one character to the console channel.
|
|
|
|
* @note This function is a wrapper over esp_rom_uart_tx_one_char, it can help handle line ending issue by replacing '\n' with '\r\n'.
|
2020-11-10 02:40:01 -05:00
|
|
|
*
|
2020-07-21 01:07:34 -04:00
|
|
|
* @param c Character to send
|
|
|
|
*/
|
2024-01-17 04:19:49 -05:00
|
|
|
void esp_rom_output_putc(char c);
|
|
|
|
|
|
|
|
void esp_rom_uart_putc(char c) __attribute__((deprecated("Please use esp_rom_output_putc instead")));
|
2020-07-21 01:07:34 -04:00
|
|
|
|
2020-07-13 09:33:23 -04:00
|
|
|
/**
|
|
|
|
* @brief Get one character from the console channel.
|
|
|
|
*
|
|
|
|
* @param c Where to store the character
|
|
|
|
* @return
|
|
|
|
* - 0 on success
|
|
|
|
* - 1 on failure or no data available
|
|
|
|
*/
|
2024-01-17 04:19:49 -05:00
|
|
|
int esp_rom_output_rx_one_char(uint8_t *c);
|
|
|
|
|
|
|
|
int esp_rom_uart_rx_one_char(uint8_t *c) __attribute__((deprecated("Please use esp_rom_output_rx_one_char instead")));
|
2020-07-13 09:33:23 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Get one line of string from console channel (line ending won't be stored in the buffer).
|
|
|
|
*
|
|
|
|
* @param str Where to store the string
|
|
|
|
* @param max_len Maximum length of the buffer (including the NULL delimiter)
|
|
|
|
* @return always return 0 when on success or wait in a loop for rx data
|
|
|
|
*/
|
2024-01-17 04:19:49 -05:00
|
|
|
int esp_rom_output_rx_string(uint8_t *str, uint8_t max_len);
|
|
|
|
|
|
|
|
int esp_rom_uart_rx_string(uint8_t *str, uint8_t max_len) __attribute__((deprecated("Please use esp_rom_output_rx_string instead")));
|
2020-07-13 09:33:23 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Set the UART port used by ets_printf.
|
|
|
|
*
|
2023-01-30 01:01:19 -05:00
|
|
|
* @note USB-CDC port is also treated as "UART" port in the ROM code.
|
|
|
|
* Use ESP_ROM_USB_SERIAL_DEVICE_NUM or ESP_ROM_USB_OTG_NUM to identify USB_SERIAL_JTAG and USB_OTG, respectively.
|
|
|
|
*
|
2024-01-17 04:19:49 -05:00
|
|
|
* @param serial_num UART port number
|
2020-07-13 09:33:23 -04:00
|
|
|
*/
|
2024-01-17 04:19:49 -05:00
|
|
|
void esp_rom_output_set_as_console(uint8_t serial_num);
|
|
|
|
|
|
|
|
void esp_rom_uart_set_as_console(uint8_t serial_num) __attribute__((deprecated("Please use esp_rom_output_set_as_console instead")));
|
2020-07-13 09:33:23 -04:00
|
|
|
|
2023-01-30 01:01:19 -05:00
|
|
|
/**
|
|
|
|
* @brief Switch the UART port that will use a buffer for TX and RX.
|
|
|
|
*
|
|
|
|
* @note USB-CDC port is also treated as "UART" port in the ROM code.
|
|
|
|
* Use ESP_ROM_USB_SERIAL_DEVICE_NUM or ESP_ROM_USB_OTG_NUM to identify USB_SERIAL_JTAG and USB_OTG, respectively.
|
|
|
|
*
|
2024-01-17 04:19:49 -05:00
|
|
|
* @param serial_num UART port number
|
2023-01-30 01:01:19 -05:00
|
|
|
*/
|
2024-01-17 04:19:49 -05:00
|
|
|
void esp_rom_output_switch_buffer(uint8_t serial_num);
|
|
|
|
|
|
|
|
void esp_rom_uart_switch_buffer(uint8_t serial_num) __attribute__((deprecated("Please use esp_rom_output_switch_buffer instead")));
|
2023-01-30 01:01:19 -05:00
|
|
|
|
2020-07-13 09:33:23 -04:00
|
|
|
/**
|
|
|
|
* @brief Initialize the USB ACM UART
|
|
|
|
* @note The ACM working memroy should be at least 128 bytes (ESP_ROM_CDC_ACM_WORK_BUF_MIN) in size.
|
|
|
|
*
|
|
|
|
* @param cdc_acm_work_mem Pointer to the work memroy used for CDC-ACM
|
|
|
|
* @param cdc_acm_work_mem_len Length of work memory
|
|
|
|
*/
|
2024-01-17 04:19:49 -05:00
|
|
|
void esp_rom_output_usb_acm_init(void *cdc_acm_work_mem, int cdc_acm_work_mem_len);
|
|
|
|
|
|
|
|
void esp_rom_uart_usb_acm_init(uint8_t serial_num) __attribute__((deprecated("Please use esp_rom_output_usb_acm_init instead")));
|
2020-07-13 09:33:23 -04:00
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|