Hello,
As of the new 1.9.0 release, attachInterrupt callback's API of the HardwareTimer class is now std::function(void). HardwareTimer *htim is no longer passed as argument. As the callback must be a C function pointer, it must be a static function or a static member. So "this" operateur isn't usable.
So now, how to handle the HardwareTimer instance caller in the timer interrupt callback ?
HardwareTimer : How to handle HardwareTimer instance caller in the timer callback
-
- Posts: 5
- Joined: Mon May 18, 2020 11:42 am
Re: HardwareTimer : How to handle HardwareTimer instance caller in the timer callback
Answer from @ABOSTM
With the new implementation done in the 1.9.0, it is always possible to give an argument to the callback at execution time. Thanks to the magical C++ binding and templates.
But the parameter is no longer restricted to the HardwareTimer object, it can be anything.
It is therefore always possible to pass the object ... but more if necessary.
An example is available here:
https://github.com/stm32duino/STM32Exam ... _parameter

With the new implementation done in the 1.9.0, it is always possible to give an argument to the callback at execution time. Thanks to the magical C++ binding and templates.
But the parameter is no longer restricted to the HardwareTimer object, it can be anything.
It is therefore always possible to pass the object ... but more if necessary.
An example is available here:
https://github.com/stm32duino/STM32Exam ... _parameter
-
- Posts: 5
- Joined: Mon May 18, 2020 11:42 am
Re: HardwareTimer : How to handle HardwareTimer instance caller in the timer callback
that's clear now, thank you for all ! 

-
- Posts: 633
- Joined: Thu Dec 19, 2019 1:23 am
Re: HardwareTimer : How to handle HardwareTimer instance caller in the timer callback
Code: Select all
// Instantiate HardwareTimer object. Thanks to 'new' instanciation, HardwareTimer is not destructed when setup() function is finished.
Ray