Skip to content

DMA Support - IRQ Handlers in Core? #821

Closed
@xC0000005

Description

@xC0000005

While trying to get some LEDs working with the ST Arduino core, I ran into a problem that's likely a missing feature. Libraries probably shouldn't be implementing the weak IRQ handlers, because you can't have them defined everywhere. In my own fork, I added, similar to timers, handlers with registration/deregistration. For things like ADC and SD Support, this would be handy, but I'm not sure if there's a plan for this. I could create a PR, but I'd rather see what the consensus is.

Link to a branch with some test DMA support (ignore the library - I'm not sure how I want it to work, so it's not even remotely usable).

https://github.com/xC0000005/Arduino_Core_STM32/tree/DMASupport

Activity

fpistm

fpistm commented on Dec 9, 2019

@fpistm
Member

Hi @xC0000005
DMA support would be fine.
Currently, I have no plan about that. Any contribution are welcome.
Do not hesitate to proposal a PR (you can set it as Draft) to open discussion about your proposal.

4ndreas

4ndreas commented on Dec 9, 2019

@4ndreas

I had the same problem, that you can not add IRQ functions in the arduino code (Also for DMA). My work around was to add a new board variant with the IRW functions. This is not perfect but at least I don't have to fork the hole core.
Adding IRW functions to the variant.c works for me.

fpistm

fpistm commented on Dec 9, 2019

@fpistm
Member

Hi @4ndreas

I had the same problem, that you can not add IRQ functions in the arduino code (Also for DMA).

I guess you talk about adding an IRD handler in the sketch ? Did you define it with extern "c" ?

4ndreas

4ndreas commented on Dec 9, 2019

@4ndreas

No In my case I needed the

 void DMA2_Stream2_IRQHandler(void)
 {
   /* USER CODE BEGIN DMA2_Stream2_IRQn 0 */

   /* USER CODE END DMA2_Stream2_IRQn 0 */
   HAL_DMA_IRQHandler(&hdma_tim8_ch1);
   /* USER CODE BEGIN DMA2_Stream2_IRQn 1 */

   /* USER CODE END DMA2_Stream2_IRQn 1 */
 }

Function, adding this in the *.ino files won't work, but in the variant.c does. Took me a while to figure out why the interrupt jumped to a wired position.

The complet project is here: https://github.com/4ndreas/HyperLight_DMA
It uses DMA to GPIO to drive WS2812 leds

fpistm

fpistm commented on Dec 9, 2019

@fpistm
Member

At sketch level it should be:
extern "C" void DMA2_Stream2_IRQHandler(void)

Note:
In your case, I guess a library would be a best choice.
the Adafruit Neopixel library is now compatible with the STM32 core.

4ndreas

4ndreas commented on Dec 9, 2019

@4ndreas

At sketch level it should be:
extern "C" void DMA2_Stream2_IRQHandler(void)

Note:
In your case, I guess a library would be a best choice.
the Adafruit Neopixel library is now compatible with the STM32 core.

That is something for the Wiki I gues, thank you.
My driver drives 16 strips up top 1000 leds in parallel. The DMA controller is perfect for this.

xC0000005

xC0000005 commented on Dec 9, 2019

@xC0000005
ContributorAuthor

I'll open a PR this week. The goal is simple - have sketches not defining handlers for events that are global to the core, so libraries can register for different DMA events without having conflicting handlers. Thanks for the input, all.

xC0000005

xC0000005 commented on Dec 10, 2019

@xC0000005
ContributorAuthor

Opened #825 since a suggested change is better than a dozen posts about what we could do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wanted 🙏Extra attention is neededquestion ❓Usually converted as a discussion

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      DMA Support - IRQ Handlers in Core? · Issue #821 · stm32duino/Arduino_Core_STM32