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

Add support for LPC USART TX IDLE IRQ + TX IDLE status flag #128

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

laurensmiers
Copy link

This adds support for the LPC USART TX IDLE IRQ and TX IDLE status flag which enables the support for the USART non-blocking API which is part of the standard LPC SDK.

More info is available in the raised github issue:
renode/renode#761

Reproduction using the renode-template

It is based on the lpcxpresso55s16 board which is running some zephyr examples using renode:
https://designer.antmicro.com/hardware/devices/lpcxpresso55s16?software=zephyr|lpcxpresso55s16|
the repo has a binary compiled from the LPC SDK for the usart_interrupt_transfer driver example.
It's basically a echo-example using the non-blocking usart API. Whatever we write to the uart, should be printed back to us.

Failing

A failing example with the current LPC_USART C# peripheral can be found here:
https://github.com/laurensmiers/renode-issue-reproduction-template/tree/761-lpc-usart-txidle-irq-not-firing

Passing

The passing example uses the updated LPC_USART driver of this PR (copied into the other repo and dynamically included):
https://github.com/laurensmiers/renode-issue-reproduction-template/tree/761-lpc-usart-txidle-irq

If more info or changes are required, let me know.

Store the TXIDLE interrupt status and check if we need to generate an
interrupt in UpdateInterrupts().

We generate an interrupt if both conditions are true:
- The TXIDLE interrupt is enabled
- AND the TX queue is empty

This is part 1/2 of enabling the non-blocking API in the standard LPC
SDK fsl_usart.c driver.
Next we need to implement the TXIDLE status flag.

Signed-off-by: Laurens Miers <[email protected]>
The TXIDLE register-flag is a status flag indicating if the USART TX
is idle/done.
This means whenever the queue is empty, we should report idle.

This is part 2/2 of enabling the non-blocking API in the standard LPC
SDK fsl_usart.c driver.

Signed-off-by: Laurens Miers <[email protected]>
@CLAassistant
Copy link

CLAassistant commented Mar 2, 2025

CLA assistant check
All committers have signed the CLA.

@PiotrZierhoffer
Copy link
Member

Hi @laurensmiers , thanks for the contribution.

One thing I'm wondering about - should the STATUS.TXIDLE flag also follow the same logic you added to the interrupt status register?

@laurensmiers
Copy link
Author

Hi @PiotrZierhoffer ,

Good question, I find the explanation of that register a bit ambiguous.
From my understanding from the explanation of the STAT register in the user manual, page 583, table 609:

The STAT register primarily provides a set of USART status flags (not including FIFO
status) for software to read.
...
Transmitter Idle. When 0, indicates that the transmitter is currently in the
process of sending data.When 1, indicate that the transmitter is not currently in
the process of sending data.

If I understand correctly, this register does NOT include FIFO status but is a 'general' status register.

My guess is that this is for the case where the FIFO (or possible DMA) operation is completed, so FIFO is empty, but the actual UART HW is still sending data.
If this is true, than it would be '0' for a (very?) small period of time before the UART operation is actually done. I'm unsure how long this period is.
On the other hand, since the sending is instant in the emulator, it should be fine to always return 'true' since the operation is technically done.
But I'm not sure how this is handled in other peripherals?

…is written

F.e. the TXIDLE interrupt might have been cleared.
@laurensmiers
Copy link
Author

I pushed one fix for an issue in a proprietary app which popped up, sometimes the firmware disables the TXIDLE interrupt and just looks at the TXLVL register like the SDK examples.
However, sometimes it leaves the TXIDLE interrupt enabled and it wasn't de-asserted properly by the C# peripheral.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants