Add Serial Terminal App & WebUi Theme
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
#ifndef SYS_UART_H
|
||||
#define SYS_UART_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include "esp_err.h"
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/uart.h"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define SYS_UART_NUM UART_NUM_1
|
||||
#define SYS_UART_PIN_TX GPIO_NUM_21
|
||||
#define SYS_UART_PIN_RX GPIO_NUM_20
|
||||
#define SYS_UART_DEFAULT_BAUD 115200
|
||||
#define SYS_UART_BUFFER_SIZE 4096
|
||||
|
||||
/**
|
||||
* @brief Initialize the hardware UART subsystem and RX background task.
|
||||
* @param baud_rate Initial baud rate (e.g., 115200).
|
||||
* @return ESP_OK on success.
|
||||
*/
|
||||
esp_err_t sys_uart_init(uint32_t baud_rate);
|
||||
|
||||
/**
|
||||
* @brief Change the UART baud rate dynamically.
|
||||
* @param baud_rate New baud rate.
|
||||
* @return ESP_OK on success.
|
||||
*/
|
||||
esp_err_t sys_uart_set_baud_rate(uint32_t baud_rate);
|
||||
|
||||
/**
|
||||
* @brief Get the currently active baud rate.
|
||||
*/
|
||||
uint32_t sys_uart_get_baud_rate(void);
|
||||
|
||||
/**
|
||||
* @brief Transmit data over UART TX pin.
|
||||
* @param data Pointer to buffer.
|
||||
* @param len Number of bytes to send.
|
||||
* @return ESP_OK on success.
|
||||
*/
|
||||
esp_err_t sys_uart_write(const uint8_t *data, size_t len);
|
||||
|
||||
/**
|
||||
* @brief Transmit a null-terminated string over UART TX.
|
||||
* @param str Null-terminated string.
|
||||
* @return ESP_OK on success.
|
||||
*/
|
||||
esp_err_t sys_uart_write_str(const char *str);
|
||||
|
||||
/**
|
||||
* @brief Read new incoming data since a given monotonic sequence index.
|
||||
* @param from_seq Sequence number previously returned to the caller.
|
||||
* @param out_buf Buffer to store newly received bytes.
|
||||
* @param max_len Size of out_buf.
|
||||
* @param[out] new_seq Pointer to store the updated sequence counter.
|
||||
* @return Number of bytes copied to out_buf.
|
||||
*/
|
||||
size_t sys_uart_read_delta(uint32_t from_seq, uint8_t *out_buf, size_t max_len, uint32_t *new_seq);
|
||||
|
||||
/**
|
||||
* @brief Get total transmitted and received byte counts.
|
||||
*/
|
||||
void sys_uart_get_stats(uint32_t *rx_count, uint32_t *tx_count);
|
||||
|
||||
/**
|
||||
* @brief Clear the RX circular buffer and reset sequence.
|
||||
*/
|
||||
void sys_uart_clear_rx_buffer(void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SYS_UART_H
|
||||
Reference in New Issue
Block a user