mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-09-02 02:22:57 +00:00
Zephyr UART drivers offer very low-level functionality. Oftentimes, it would be useful to provide higher-level wrappers around UART device which would offer additional functionality. However, UART driver irq callback routine receives just a pointer to (low-level) UART device, and it's not possible to get to a wrapper structure (without introducing expensive external mapping structures). This is an indirect reason why the current UARt wrappers - uart_pipe, console - are instantiated statically just for one underlying UART device and cannot be reused for multiple devices. Solve this by allowing to pass an arbitrary user data to irq callback, set by new uart_irq_callback_user_data_set() function. Existing uart_irq_callback_set() keeps setting a callback which will receive pointer to the device. While public API maintains compatibility, drivers themselves need to be updated to support arbitrary user data storage/passing (as legacy uart_irq_callback_set() functionality is now implemented in terms of it). Signed-off-by: Paul Sokolovsky <paul.sokolovsky@linaro.org>
35 lines
624 B
C
35 lines
624 B
C
/*
|
|
* Copyright (c) 2016 Open-RnD Sp. z o.o.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
*/
|
|
|
|
/**
|
|
* @brief Driver for UART port on STM32 family processor.
|
|
*
|
|
*/
|
|
|
|
#ifndef _STM32_UART_H_
|
|
#define _STM32_UART_H_
|
|
|
|
/* device config */
|
|
struct uart_stm32_config {
|
|
struct uart_device_config uconf;
|
|
/* clock subsystem driving this peripheral */
|
|
struct stm32_pclken pclken;
|
|
/* Baud rate */
|
|
u32_t baud_rate;
|
|
};
|
|
|
|
/* driver data */
|
|
struct uart_stm32_data {
|
|
/* clock device */
|
|
struct device *clock;
|
|
#ifdef CONFIG_UART_INTERRUPT_DRIVEN
|
|
uart_irq_callback_user_data_t user_cb;
|
|
void *user_data;
|
|
#endif
|
|
};
|
|
|
|
#endif /* _STM32_UART_H_ */
|