Skip to content

Add Support for uart_line_ctrl_set() for UART RTS Line in NXP MCUX LPUART Driver #86710

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

Merged

Conversation

nirav-agrawal
Copy link
Contributor

  • For MCUX LPUART driver, added support to control RTS line High/Low from other driver/app code.
  • This control is required to wakeup other device which is in sleep and configured its wakeup-source as UART-CTS line.

@dleach02, @DerekSnell, please review this PR. Thank you.

Regards,
Nirav

@zephyrbot zephyrbot added area: UART Universal Asynchronous Receiver-Transmitter platform: NXP Drivers NXP Semiconductors, drivers labels Mar 6, 2025
@nirav-agrawal nirav-agrawal force-pushed the rts_control_support_mcux_lpuart branch from 4abd6d8 to 1757607 Compare March 6, 2025 10:56
@dcpleung dcpleung assigned dleach02 and mmahadevan108 and unassigned dcpleung Mar 6, 2025
DerekSnell
DerekSnell previously approved these changes Mar 11, 2025
Copy link
Member

@decsny decsny left a comment

Choose a reason for hiding this comment

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

blocking over return value but please consider the other comments

Comment on lines 1182 to 1183
#if CONFIG_UART_LINE_CTRL && \
defined(FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT) && FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT
Copy link
Member

Choose a reason for hiding this comment

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

nit you can make a macro for this expression since it is used in two places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, thank you

Comment on lines 1191 to 1216
case UART_LINE_CTRL_RTS:
/* Disable Transmitter and Receiver */
config->base->CTRL &= ~(LPUART_CTRL_TE_MASK | LPUART_CTRL_RE_MASK);

if (val >= 1U) {
/* Reset TXRTS to set RXRTSE bit, this provides high-level on RTS line */
config->base->MODIR &= ~(LPUART_MODIR_TXRTSPOL_MASK |
LPUART_MODIR_TXRTSE_MASK);
config->base->MODIR |= LPUART_MODIR_RXRTSE_MASK;
} else {
/* Set TXRTSE to reset RXRTSE bit,this provide low-level on RTS line*/
config->base->MODIR &= ~(LPUART_MODIR_RXRTSE_MASK);
config->base->MODIR |= (LPUART_MODIR_TXRTSPOL_MASK |
LPUART_MODIR_TXRTSE_MASK);
}
break;
Copy link
Member

Choose a reason for hiding this comment

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

nit is to always make helper function if indent gets greater than 2 levels

Copy link
Contributor Author

Choose a reason for hiding this comment

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

sure, I will update this. thank you.

break;

default:
ret = -ENODEV;
Copy link
Member

Choose a reason for hiding this comment

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

should be -ENOTSUP according to API if some control option is not enabled I think

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will update return value.

Comment on lines 1294 to 1295
#if CONFIG_UART_LINE_CTRL && \
defined(FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT) && FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT
Copy link
Member

Choose a reason for hiding this comment

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

large expression used in multiple places should make macro for this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, I will take a macro and use that. thank you.

@nirav-agrawal
Copy link
Contributor Author

Hi @decsny, I updated this PR as per your given comments. please review. thank you.

@nirav-agrawal nirav-agrawal requested a review from decsny March 12, 2025 07:52
@nirav-agrawal nirav-agrawal force-pushed the rts_control_support_mcux_lpuart branch from 969a378 to dfd9018 Compare March 12, 2025 08:20
#if defined(CONFIG_UART_LINE_CTRL) && \
defined(FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT) && \
(FSL_FEATURE_LPUART_HAS_MODEM_SUPPORT)
#define CONFIG_UART_LINE_CTRL_ENABLE
Copy link
Member

Choose a reason for hiding this comment

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

I think the compliance check will fail because CONFIG_ is reserved for kconfigs

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @decsny, yes it gets failed. I updated that macro and updated this PR. thank you.

- For MCUX LPUART driver, added support to control RTS line
  High/Low from other driver/app code.

- This control is required to wakeup other device which is
  in sleep and configured its wakeup-source as UART-CTS line.

Signed-off-by: Nirav Agrawal <[email protected]>
@nirav-agrawal nirav-agrawal force-pushed the rts_control_support_mcux_lpuart branch from dfd9018 to 86dfa00 Compare March 12, 2025 15:55
@fabiobaltieri fabiobaltieri added the Trivial Changes that can be reviewed by anyone, i.e. doc changes, minor build system tweaks, etc. label Mar 12, 2025
@fabiobaltieri fabiobaltieri removed the Trivial Changes that can be reviewed by anyone, i.e. doc changes, minor build system tweaks, etc. label Mar 12, 2025
@kartben kartben merged commit fbf3353 into zephyrproject-rtos:main Mar 13, 2025
24 checks passed
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: NXP Drivers NXP Semiconductors, drivers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants