Skip to content

Disable USART IRQ in uart_write and uart_debug_write #496

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

Closed
wants to merge 3 commits into from

Conversation

benwaffle
Copy link
Contributor

@benwaffle benwaffle commented Apr 9, 2019

This PR fixes issues #494 and #467 for printf();

I want to be able to use printf() with Serial.write() and Serial.read(). See discussion in both issues mentioned above.

Validation

See the example code in #494


I'm not sure how to:

  • Get IRQn_Type values from a UART_TypeDef
  • Determine which UARTs are defined for a given device
  • Whether I need to set the priority when enabling the interrupt

@benwaffle benwaffle force-pushed the printf-fix branch 2 times, most recently from d4498e7 to 03a7b82 Compare April 10, 2019 19:40
@benwaffle benwaffle changed the title Disable uart interrupt in uart_debug_write Disable USART IRQ in uart_write and uart_debug_write Apr 10, 2019
@fpistm
Copy link
Member

fpistm commented Apr 11, 2019

Hi @benwaffle
Thanks for the PR.
Could you squash some commits to clean the PR?

Those can be merged in one:

Disable uart interrupt in uart_debug_write
redundant
remove broken/unneeded code

And those one:

Fix UART error callback (clear flags and restart receive IT)
fix astyle

Then the PR should contains only 3 commits:

Disable uart interrupt in uart_debug_write
Fix serial port full-duplex bug
Fix UART error callback (clear flags and restart receive IT)

Thanks in advance

@fpistm fpistm self-requested a review April 11, 2019 06:09
benwaffle and others added 3 commits April 11, 2019 15:41
When a receive IT fires while the HAL handle is locked, the receive callback fails to re-enable the IT and the serial port stops receiving anymore. This can happen when transmit IT is enabled outside the IRQ in HardwareSerial::write(), following a buffer full condition that disables transmit IT in HAL_UART_TxCpltCallback().
Solution is to temporarily disable the IRQ while the interrupt enable flags are modified.
@benwaffle
Copy link
Contributor Author

@fpistm squashed

@fpistm
Copy link
Member

fpistm commented Apr 11, 2019

Thanks a lot @benwaffle. I will rview and test it as soon as possible.

@fpistm
Copy link
Member

fpistm commented Apr 15, 2019

@benwaffle
using your code example, I only receive and print one time?
Is this really fix your issue ?

@benwaffle
Copy link
Contributor Author

yes, it worked for me. make sure that you have the Disable uart interrupt in uart_debug_write patch applied

@fpistm
Copy link
Member

fpistm commented Apr 16, 2019

I got it but it is not functional on my side.

@benwaffle
Copy link
Contributor Author

I can test it again today.

@fpistm
Copy link
Member

fpistm commented Apr 16, 2019

Ok, in fact it fails with Arduino Serial monitor.
Using Putty terminal, it works.
Anyway, I need deeper review/tests.

@fpistm
Copy link
Member

fpistm commented Apr 17, 2019

@benwaffle, @ppescher ,
I've made some test and dig into the code.
The result is the #502 .
Please could you review and test it?

@fpistm fpistm added enhancement New feature or request fix 🩹 Bug fix abandoned No more work on this labels Apr 19, 2019
@fpistm
Copy link
Member

fpistm commented Apr 19, 2019

This one is superseded by #502

@fpistm fpistm closed this Apr 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
abandoned No more work on this enhancement New feature or request fix 🩹 Bug fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants