2016-03-03 15:33:20 +01:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Open-RnD Sp. z o.o.
|
|
|
|
*
|
2017-01-18 17:01:01 -08:00
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
2016-03-03 15:33:20 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2016-11-17 10:00:49 -06:00
|
|
|
* @brief Driver for UART port on STM32 family processor.
|
2016-03-03 15:33:20 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2018-09-14 10:43:44 -07:00
|
|
|
#ifndef ZEPHYR_DRIVERS_SERIAL_UART_STM32_H_
|
|
|
|
#define ZEPHYR_DRIVERS_SERIAL_UART_STM32_H_
|
2016-03-03 15:33:20 +01:00
|
|
|
|
2020-06-05 10:57:52 +02:00
|
|
|
#include <drivers/pinmux.h>
|
|
|
|
|
2016-03-03 15:33:20 +01:00
|
|
|
/* device config */
|
|
|
|
struct uart_stm32_config {
|
|
|
|
struct uart_device_config uconf;
|
|
|
|
/* clock subsystem driving this peripheral */
|
2017-01-23 17:55:57 +01:00
|
|
|
struct stm32_pclken pclken;
|
2019-02-08 18:39:35 +01:00
|
|
|
/* initial hardware flow control, 1 for RTS/CTS */
|
|
|
|
bool hw_flow_control;
|
2020-03-18 13:40:21 +02:00
|
|
|
/* initial parity, 0 for none, 1 for odd, 2 for even */
|
|
|
|
int parity;
|
2020-06-05 10:57:52 +02:00
|
|
|
const struct soc_gpio_pinctrl *pinctrl_list;
|
|
|
|
size_t pinctrl_list_size;
|
2016-03-03 15:33:20 +01:00
|
|
|
};
|
|
|
|
|
2021-01-16 18:44:24 +02:00
|
|
|
#ifdef CONFIG_UART_ASYNC_API
|
|
|
|
struct uart_dma_stream {
|
2021-03-01 11:59:57 +01:00
|
|
|
const struct device *dma_dev;
|
2021-01-16 18:44:24 +02:00
|
|
|
uint32_t dma_channel;
|
|
|
|
struct dma_config dma_cfg;
|
|
|
|
uint8_t priority;
|
|
|
|
bool src_addr_increment;
|
|
|
|
bool dst_addr_increment;
|
|
|
|
int fifo_threshold;
|
|
|
|
struct dma_block_config blk_cfg;
|
|
|
|
uint8_t *buffer;
|
|
|
|
size_t buffer_length;
|
|
|
|
size_t offset;
|
|
|
|
volatile size_t counter;
|
|
|
|
int32_t timeout;
|
2021-04-08 12:09:58 +02:00
|
|
|
struct k_work_delayable timeout_work;
|
2021-01-16 18:44:24 +02:00
|
|
|
bool enabled;
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2016-03-03 15:33:20 +01:00
|
|
|
/* driver data */
|
|
|
|
struct uart_stm32_data {
|
2019-01-07 13:52:24 -08:00
|
|
|
/* Baud rate */
|
2020-05-27 11:26:57 -05:00
|
|
|
uint32_t baud_rate;
|
2016-03-03 15:33:20 +01:00
|
|
|
/* clock device */
|
2020-04-30 20:33:38 +02:00
|
|
|
const struct device *clock;
|
2016-03-13 19:37:25 +01:00
|
|
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
2018-07-16 21:12:26 +03:00
|
|
|
uart_irq_callback_user_data_t user_cb;
|
|
|
|
void *user_data;
|
2016-03-13 19:37:25 +01:00
|
|
|
#endif
|
2021-01-16 18:44:24 +02:00
|
|
|
|
|
|
|
#ifdef CONFIG_UART_ASYNC_API
|
|
|
|
const struct device *uart_dev;
|
|
|
|
uart_callback_t async_cb;
|
|
|
|
void *async_user_data;
|
|
|
|
struct uart_dma_stream dma_rx;
|
|
|
|
struct uart_dma_stream dma_tx;
|
|
|
|
uint8_t *rx_next_buffer;
|
|
|
|
size_t rx_next_buffer_len;
|
|
|
|
#endif
|
2016-03-03 15:33:20 +01:00
|
|
|
};
|
|
|
|
|
2018-09-14 10:43:44 -07:00
|
|
|
#endif /* ZEPHYR_DRIVERS_SERIAL_UART_STM32_H_ */
|