Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for stm32 serial driver not returning -ENOTSUP. #31798

Conversation

zisisadamos
Copy link
Contributor

Signed-off-by: Zisis Adamos [email protected]

@github-actions github-actions bot added the platform: STM32 ST Micro STM32 label Jan 29, 2021
@zephyrbot zephyrbot added the area: UART Universal Asynchronous Receiver-Transmitter label Jan 30, 2021
@@ -336,10 +336,10 @@ static int uart_stm32_configure(const struct device *dev,
/* Driver doesn't support 5 or 6 databits and potentially 7 or 9 */
if ((UART_CFG_DATA_BITS_5 == cfg->data_bits) ||
(UART_CFG_DATA_BITS_6 == cfg->data_bits)
#ifndef LL_USART_DATAWIDTH_7B
#ifdef LL_USART_DATAWIDTH_7B
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code returns -ENOTSUP when LL_USART_DATAWIDTH_7B/9B is not defined (which is the case on some parts). So, from this point of view, this code is correct.
You're modifying in "return -ENOTSUP when LL_USART_DATAWIDTH_7B/9B is defined", which doens't seem correct.
There might be things to fix, but I don't think this is the correct fix.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right I havent taken mcu that dont support 9bit mode into account. I can just do a check on configuration and then return -ENOTSUP. I can have a change ready on the afternoon.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to purely remove this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tthis change was removed and requested changes have been made.

@@ -336,10 +336,10 @@ static int uart_stm32_configure(const struct device *dev,
/* Driver doesn't support 5 or 6 databits and potentially 7 or 9 */
if ((UART_CFG_DATA_BITS_5 == cfg->data_bits) ||
(UART_CFG_DATA_BITS_6 == cfg->data_bits)
#ifndef LL_USART_DATAWIDTH_7B
#ifdef LL_USART_DATAWIDTH_7B
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I propose to purely remove this change.

drivers/serial/uart_stm32.c Outdated Show resolved Hide resolved
@zisisadamos zisisadamos force-pushed the stm32_uart9bit_init_fix branch 6 times, most recently from 4f5fa6b to 271893d Compare February 6, 2021 22:24
…TSUP.

Fixes driver incorrectly indicating that drive
r supports 7 and 9 bit modes.

Fixes zephyrproject-rtos#31799

Signed-off-by: Zisis Adamos <[email protected]>
) {
if ((cfg->data_bits == UART_CFG_DATA_BITS_5) ||
(cfg->data_bits == UART_CFG_DATA_BITS_6) ||
(cfg->data_bits == UART_CFG_DATA_BITS_7) ||
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some devices support UART_CFG_DATA_BITS_7, and depending on application, 7B transaction could work.
So I'm not sure what it the right thing to do here.
If dedicated functions are required to support transaction different from 8B, then I guess the problem is that API has to be reviewed. Otherwise, I don't see why we should prevent 7B trasactions.

if ((cfg->data_bits == UART_CFG_DATA_BITS_5) ||
(cfg->data_bits == UART_CFG_DATA_BITS_6) ||
(cfg->data_bits == UART_CFG_DATA_BITS_7) ||
(cfg->data_bits == UART_CFG_DATA_BITS_9)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be clear I think we should limit the change to the following for now

	if ((UART_CFG_DATA_BITS_5 == cfg->data_bits) ||
	    (UART_CFG_DATA_BITS_6 == cfg->data_bits)
#ifndef LL_USART_DATAWIDTH_7B
	    || (UART_CFG_DATA_BITS_7 == cfg->data_bits)
#endif /* LL_USART_DATAWIDTH_7B */
	    || (UART_CFG_DATA_BITS_9 == cfg->data_bits)
		) {

@erwango
Copy link
Member

erwango commented Feb 15, 2021

Fixed by #32204

@erwango erwango closed this Feb 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: UART Universal Asynchronous Receiver-Transmitter platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants