Callback fuzziness???
Posted: Fri Feb 11, 2022 6:56 pm
I am trying to understand the meaning of the following 'tip' for the building of interrupt handling code. The following tip can be found at:
https://docs.micropython.org/en/latest/ ... rules.html
What I do not understand is how does a callback (interrupt handler) like mycallback(t) above return anything, much less a pre-allocated buffer?
Did the hint mean to say something other than return'? Did the hint mean to say that the ISR should update a pre-allocated memory buffer like a pre-allocated bytearray or a pre-allocated array.array? If this is not the case, how does one construct an ISR that 'returns' a pre-allocated buffer with the 'return' reserved word, and how does it get passed back via the callback function return?
https://docs.micropython.org/en/latest/ ... rules.html
- Where an ISR returns multiple bytes use a pre-allocated bytearray. If multiple integers are to be shared between an ISR and the main program consider an array (array.array).
Code: Select all
# -----------------------------------------
def mycallback(t):
pass.
tim = machine.Timer()
tim.init(mode = Timer.PERIODIC, period = 1000, callback = mycallback)
# -----------------------------------------------
Did the hint mean to say something other than return'? Did the hint mean to say that the ISR should update a pre-allocated memory buffer like a pre-allocated bytearray or a pre-allocated array.array? If this is not the case, how does one construct an ISR that 'returns' a pre-allocated buffer with the 'return' reserved word, and how does it get passed back via the callback function return?