drivers: serial: xmc4xxx: drop usage of uart_device_config

Create a driver specific configuration structure, containing the
required fields only.

Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
This commit is contained in:
Gerard Marull-Paretas 2022-01-25 20:25:48 +01:00 committed by Anas Nashif
commit f8423a1b45

View file

@ -11,42 +11,44 @@
#include <xmc_uart.h> #include <xmc_uart.h>
#include <drivers/uart.h> #include <drivers/uart.h>
struct uart_xmc4xx_config {
XMC_USIC_CH_t *uart;
};
struct uart_xmc4xxx_data { struct uart_xmc4xxx_data {
XMC_UART_CH_CONFIG_t config; XMC_UART_CH_CONFIG_t config;
}; };
static int uart_xmc4xxx_poll_in(const struct device *dev, unsigned char *c) static int uart_xmc4xxx_poll_in(const struct device *dev, unsigned char *c)
{ {
const struct uart_device_config *config = dev->config; const struct uart_xmc4xx_config *config = dev->config;
*(uint16_t *)c = *(uint16_t *)c = XMC_UART_CH_GetReceivedData(config->uart);
XMC_UART_CH_GetReceivedData((XMC_USIC_CH_t *)config->base);
return 0; return 0;
} }
static void uart_xmc4xxx_poll_out(const struct device *dev, unsigned char c) static void uart_xmc4xxx_poll_out(const struct device *dev, unsigned char c)
{ {
const struct uart_device_config *config = dev->config; const struct uart_xmc4xx_config *config = dev->config;
XMC_UART_CH_Transmit((XMC_USIC_CH_t *)config->base, (uint16_t)c); XMC_UART_CH_Transmit(config->uart, (uint16_t)c);
} }
static int uart_xmc4xxx_init(const struct device *dev) static int uart_xmc4xxx_init(const struct device *dev)
{ {
const struct uart_device_config *config = dev->config; const struct uart_xmc4xx_config *config = dev->config;
struct uart_xmc4xxx_data *data = dev->data; struct uart_xmc4xxx_data *data = dev->data;
XMC_USIC_CH_t *uart = (XMC_USIC_CH_t *)config->base;
data->config.data_bits = 8U; data->config.data_bits = 8U;
data->config.stop_bits = 1U; data->config.stop_bits = 1U;
/* configure PIN 0.0 and 0.1 as UART */ /* configure PIN 0.0 and 0.1 as UART */
XMC_UART_CH_Init(uart, &(data->config)); XMC_UART_CH_Init(config->uart, &(data->config));
XMC_GPIO_SetMode(P0_0, XMC_GPIO_MODE_INPUT_TRISTATE); XMC_GPIO_SetMode(P0_0, XMC_GPIO_MODE_INPUT_TRISTATE);
XMC_UART_CH_SetInputSource(uart, XMC_UART_CH_INPUT_RXD, XMC_UART_CH_SetInputSource(config->uart, XMC_UART_CH_INPUT_RXD,
USIC1_C1_DX0_P0_0); USIC1_C1_DX0_P0_0);
XMC_UART_CH_Start(uart); XMC_UART_CH_Start(config->uart);
XMC_GPIO_SetMode(P0_1, XMC_GPIO_SetMode(P0_1,
XMC_GPIO_MODE_OUTPUT_PUSH_PULL | P0_1_AF_U1C1_DOUT0); XMC_GPIO_MODE_OUTPUT_PUSH_PULL | P0_1_AF_U1C1_DOUT0);
@ -64,8 +66,8 @@ static struct uart_xmc4xxx_data xmc4xxx_data_##index = { \
.config.baudrate = DT_INST_PROP(index, current_speed) \ .config.baudrate = DT_INST_PROP(index, current_speed) \
}; \ }; \
\ \
static const struct uart_device_config xmc4xxx_config_##index = { \ static const struct uart_xmc4xx_config xmc4xxx_config_##index = { \
.base = (void *)DT_INST_REG_ADDR(index), \ .uart = (XMC_USIC_CH_t *)DT_INST_REG_ADDR(index), \
}; \ }; \
\ \
DEVICE_DT_INST_DEFINE(index, &uart_xmc4xxx_init, \ DEVICE_DT_INST_DEFINE(index, &uart_xmc4xxx_init, \