Commit 0df6736b authored by Yishai Jaffe's avatar Yishai Jaffe Committed by Benjamin Cabé
Browse files

drivers: serial: define default values for basic options

Defined default values for baudrate, parity, stop bits, and data bits.
This removes complexity and obfuscation from the code.

Signed-off-by: default avatarYishai Jaffe <yishai1999@gmail.com>
parent 64585b74
Loading
Loading
Loading
Loading
+3 −6
Changes for drivers/serial/uart_altera.c: 3 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -960,12 +960,9 @@ static struct uart_altera_device_data uart_altera_dev_data_##n = { \
	.uart_cfg =                                                           \
	{                                                                     \
			.baudrate = DT_INST_PROP(n, current_speed),                   \
			.parity = DT_INST_ENUM_IDX_OR(n, parity,                      \
						 UART_CFG_PARITY_NONE),                           \
			.stop_bits = DT_INST_ENUM_IDX_OR(n, stop_bits,                \
						 UART_CFG_STOP_BITS_1),                           \
			.data_bits = DT_INST_ENUM_IDX_OR(n, data_bits,                \
						 UART_CFG_DATA_BITS_8),                           \
			.parity = DT_INST_ENUM_IDX(n, parity),                        \
			.stop_bits = DT_INST_ENUM_IDX(n, stop_bits),                  \
			.data_bits = DT_INST_ENUM_IDX(n, data_bits),                  \
			.flow_ctrl = DT_INST_PROP(n, hw_flow_control) ?               \
				UART_CFG_FLOW_CTRL_RTS_CTS :                              \
				UART_CFG_FLOW_CTRL_NONE,                                  \
+3 −3
Changes for drivers/serial/uart_cc13xx_cc26xx.c: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -617,9 +617,9 @@ static DEVICE_API(uart, uart_cc13xx_cc26xx_driver_api) = {
		uart_cc13xx_cc26xx_data_##n = {			     \
		.uart_config = {				     \
			.baudrate = DT_INST_PROP(n, current_speed),  \
			.parity = UART_CFG_PARITY_NONE,		     \
			.stop_bits = UART_CFG_STOP_BITS_1,	     \
			.data_bits = UART_CFG_DATA_BITS_8,	     \
			.parity = DT_INST_ENUM_IDX(n, parity),	     \
			.stop_bits = DT_INST_ENUM_IDX(n, stop_bits), \
			.data_bits = DT_INST_ENUM_IDX(n, data_bits), \
			.flow_ctrl = UART_CFG_FLOW_CTRL_NONE,	     \
		},						     \
		.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n), \
+3 −5
Changes for drivers/serial/uart_esp32.c: 3 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -1055,11 +1055,9 @@ static DEVICE_API(uart, uart_esp32_api) = {
                                                                                                   \
	static struct uart_esp32_data uart_esp32_data_##idx = {                                    \
		.uart_config = {.baudrate = DT_INST_PROP(idx, current_speed),                      \
				.parity = DT_INST_ENUM_IDX_OR(idx, parity, UART_CFG_PARITY_NONE),  \
				.stop_bits = DT_INST_ENUM_IDX_OR(idx, stop_bits,                   \
								 UART_CFG_STOP_BITS_1),            \
				.data_bits = DT_INST_ENUM_IDX_OR(idx, data_bits,                   \
								 UART_CFG_DATA_BITS_8),            \
				.parity = DT_INST_ENUM_IDX(idx, parity),                           \
				.stop_bits = DT_INST_ENUM_IDX(idx, stop_bits),                     \
				.data_bits = DT_INST_ENUM_IDX(idx, data_bits),                     \
				.flow_ctrl = MAX(COND_CODE_1(DT_INST_PROP(idx, hw_rs485_hd_mode),  \
							     (UART_CFG_FLOW_CTRL_RS485),           \
							     (UART_CFG_FLOW_CTRL_NONE)),           \
+3 −3
Changes for drivers/serial/uart_ifx_cat1.c: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -519,9 +519,9 @@ static DEVICE_API(uart, ifx_cat1_uart_driver_api) = {
											     \
	static struct ifx_cat1_uart_config ifx_cat1_uart##n##_cfg = {			     \
		.dt_cfg.baudrate = DT_INST_PROP(n, current_speed),			     \
		.dt_cfg.parity = DT_INST_ENUM_IDX_OR(n, parity, UART_CFG_PARITY_NONE),	     \
		.dt_cfg.stop_bits = DT_INST_ENUM_IDX_OR(n, stop_bits, UART_CFG_STOP_BITS_1), \
		.dt_cfg.data_bits = DT_INST_ENUM_IDX_OR(n, data_bits, UART_CFG_DATA_BITS_8), \
		.dt_cfg.parity = DT_INST_ENUM_IDX(n, parity),				     \
		.dt_cfg.stop_bits = DT_INST_ENUM_IDX(n, stop_bits),			     \
		.dt_cfg.data_bits = DT_INST_ENUM_IDX(n, data_bits),			     \
		.dt_cfg.flow_ctrl = DT_INST_PROP(n, hw_flow_control),			     \
		.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(n),				     \
		.reg_addr = (CySCB_Type *)DT_INST_REG_ADDR(n),				     \
+3 −6
Changes for drivers/serial/uart_intel_lw.c: 3 added lines, 6 removed lines.
Original line number Diff line number Diff line
@@ -994,12 +994,9 @@ static struct uart_intel_lw_device_data uart_intel_lw_dev_data_##n = { \
	.uart_cfg =                                                         \
	{                                                                   \
			.baudrate = DT_INST_PROP(n, current_speed),         \
			.parity = DT_INST_ENUM_IDX_OR(n, parity,            \
						 UART_CFG_PARITY_NONE),     \
			.stop_bits = DT_INST_ENUM_IDX_OR(n, stop_bits,      \
						 UART_CFG_STOP_BITS_1),     \
			.data_bits = DT_INST_ENUM_IDX_OR(n, data_bits,      \
						 UART_CFG_DATA_BITS_8),     \
			.parity = DT_INST_ENUM_IDX(n, parity),              \
			.stop_bits = DT_INST_ENUM_IDX(n, stop_bits),        \
			.data_bits = DT_INST_ENUM_IDX(n, data_bits),        \
			.flow_ctrl = DT_INST_PROP(n, hw_flow_control) ?     \
				UART_CFG_FLOW_CTRL_RTS_CTS :                \
				UART_CFG_FLOW_CTRL_NONE,                    \
Loading