stm32f0xx-hal icon indicating copy to clipboard operation
stm32f0xx-hal copied to clipboard

New Interrupt Driven Serial Echo Example

Open AdinAck opened this issue 1 year ago • 6 comments

Motivation

  • The provided serial_echo example seemed lacking imho
  • Would be really nice if it used interrupts

Change(s)

  • Added serial_echo_irq.rs to /examples

AdinAck avatar Aug 19 '23 02:08 AdinAck

This compiles and runs on my end... looking into it.

AdinAck avatar Aug 19 '23 02:08 AdinAck

that first error makes no sense, still compiles in my deployment repo but not in this repo... 🤷‍♂️

AdinAck avatar Aug 19 '23 03:08 AdinAck

Adding an example seems fine to me, though this is unnecessarily complex and convoluted:

  • The macros (just to deal with the global variables) seem a bit over the top and make it even harder to follow for the uninitiated.
  • Since you're toggling the LED in the main loop, there's no need for all that extra global complexity, a local variable will do.

PS: If you want to use a resource only in a single place (like an interrupt handler), you can also move it into a variable in the interrupt handler once and then safely use it without a critical section.

therealprof avatar Aug 20 '23 02:08 therealprof

  • The macros (just to deal with the global variables) seem a bit over the top and make it even harder to follow for the uninitiated.

Yes those were left over from my main project where I have many global variables and want it to be easy to use them later, I will remove this.

  • Since you're toggling the LED in the main loop, there's no need for all that extra global complexity, a local variable will do.

Haha another remnant from my main project, I will fix this as well.

PS: If you want to use a resource only in a single place (like an interrupt handler), you can also move it into a variable in the interrupt handler once and then safely use it without a critical section.

I have no idea what this means, and if you are able to explain to me further at your convenience, I would greatly appreciate it.

AdinAck avatar Aug 20 '23 04:08 AdinAck

I believe I have correctly converted the example over to the proper way of using the global serial port. I have also rebased this PR.

AdinAck avatar Oct 01 '23 16:10 AdinAck

#170 will fix this PR.

AdinAck avatar Nov 25 '23 16:11 AdinAck