added serial port settings
This commit is contained in:
parent
147c2b9cdd
commit
dcd659e5ea
|
|
@ -204,6 +204,9 @@ typedef struct
|
|||
{
|
||||
int Serialmode;
|
||||
int BaudRate;
|
||||
int DataBits;
|
||||
int Parity;
|
||||
int StopBits;
|
||||
int InputBrake;
|
||||
struct
|
||||
{
|
||||
|
|
|
|||
|
|
@ -551,6 +551,11 @@ const rest_var_t SystemVariables[] =
|
|||
{ 0, "serial_bridge", &SysConfig.serialSettings.Flags.IsBridgeEnabled, VAR_BOOL, RW, 0, 1 },
|
||||
{ 0, "serial_mode", &funct_serial_mode, VAR_FUNCT, R, 1, 2 },
|
||||
{ 0, "serial_baud", &SysConfig.serialSettings.BaudRate, VAR_INT, RW, 1200, 4096000 },
|
||||
|
||||
{ 0, "serial_bits", &SysConfig.serialSettings.DataBits, VAR_INT, RW, 0, 3 },
|
||||
{ 0, "serial_parity", &SysConfig.serialSettings.Parity, VAR_INT, RW, 0, 3 },
|
||||
{ 0, "serial_stop", &SysConfig.serialSettings.StopBits, VAR_INT, RW, 1, 3 },
|
||||
|
||||
{ 0, "serial_break", &SysConfig.serialSettings.InputBrake, VAR_INT, RW, 1, 50 },
|
||||
{ 0, "serial_visible", (bool*) (&VAR_TRUE), VAR_BOOL, R, 0, 1 },
|
||||
#else
|
||||
|
|
|
|||
|
|
@ -231,13 +231,22 @@ void InitSerialPort(void)
|
|||
{
|
||||
uart_config_t uart_config = {
|
||||
.baud_rate = GetSysConf()->serialSettings.BaudRate,
|
||||
.data_bits = UART_DATA_8_BITS,
|
||||
.parity = UART_PARITY_DISABLE,
|
||||
.data_bits = UART_DATA_7_BITS,
|
||||
.parity = UART_PARITY_EVEN,
|
||||
.stop_bits = UART_STOP_BITS_1,
|
||||
.flow_ctrl = UART_HW_FLOWCTRL_DISABLE,
|
||||
.source_clk = UART_SCLK_APB,
|
||||
};
|
||||
|
||||
//uart_config.data_bits = (uint8_t) GetSysConf()->serialSettings.DataBits;
|
||||
//uart_config.parity = (uint8_t) GetSysConf()->serialSettings.Parity;
|
||||
//uart_config.stop_bits = (uint8_t) GetSysConf()->serialSettings.StopBits;
|
||||
|
||||
ESP_LOGI(TAG, "UART data_bits:%d parity:%d stop_bits:%d",
|
||||
GetSysConf()->serialSettings.DataBits,
|
||||
GetSysConf()->serialSettings.Parity,
|
||||
GetSysConf()->serialSettings.StopBits);
|
||||
|
||||
ESP_ERROR_CHECK(
|
||||
uart_driver_install(CONFIG_WEBGUIAPP_UART_PORT_NUM, CONFIG_WEBGUIAPP_UART_BUF_SIZE * 2, 0, 20, &uart_event_queue, 0));
|
||||
ESP_ERROR_CHECK(uart_param_config(CONFIG_WEBGUIAPP_UART_PORT_NUM, &uart_config));
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include "driver/gpio.h"
|
||||
#include "driver/adc.h"
|
||||
#include "driver/i2c.h"
|
||||
#include <driver/uart.h>
|
||||
|
||||
#include "romfs.h"
|
||||
#include "spifs.h"
|
||||
|
|
@ -425,6 +426,9 @@ esp_netif_str_to_ip4(CONFIG_WEBGUIAPP_DNS3_ADDRESS_DEFAULT, (esp_ip4_addr_t*) &C
|
|||
#endif
|
||||
Conf->serialSettings.Serialmode = 1;
|
||||
Conf->serialSettings.BaudRate = CONFIG_WEBGUIAPP_UART_BAUD_RATE;
|
||||
Conf->serialSettings.DataBits = UART_DATA_8_BITS;
|
||||
Conf->serialSettings.Parity = UART_PARITY_DISABLE;
|
||||
Conf->serialSettings.StopBits = UART_STOP_BITS_1;
|
||||
Conf->serialSettings.InputBrake = 50;
|
||||
#endif
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user