سؤال

I am wondering whether it is safe to call a function via a function pointer while inside a event handler on a STM32. The event handler is for I2C and has the highest priority. The function to be called can be assumed to be fast (just some byte reordering).

Thanks for any hints or comments.

Arne

هل كانت مفيدة؟

المحلول

If the function pointer is initialized, should work fine. The only issue I can think of the usual one with interrupt-handlers - if the 'byte reordering' involves removing/adding bytes from tx/rx buffers, the buffer-management has to be safely interruptable.

نصائح أخرى

Yes.

Having said that, there is one potential risk. You have to ensure that the function pointer is initialized when the event handler is activated.

Normally, global variables are initialized before main is called, but if the event handler is active before that you could run into trouble.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top