This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

C++ Interrupt

I would like design a c++ class where an interrupt function b.e. EXTI0_IRQHandler is a member. How does it work ?

Parents
  • With a Cortex-M3 and a static method, it will work without magic needed.

    With a dynamic method, it will not work because of the lacking 'this' pointer. Possible to encapsulate with an assembler routine or by first calling a static member, and pick up a singleton reference for the "this" pointer.

    With a "normal" processor, it will not work since most processors requires the ISR to use a special keyword to get correct prologue/epologue for an ISR. Possible to manually hide with an assembler routine that encapsulates the call.

    But a static method is basically a function within a namespace, so no need to involve a C++ class.

    The biggest danger with C++ is that operator overloading or hidden constructors/destructors can introduce very big penalties even when the code looks very efficient. And an ISR don't want/need excess fat since it both represents CPU load and response latencies.

Reply
  • With a Cortex-M3 and a static method, it will work without magic needed.

    With a dynamic method, it will not work because of the lacking 'this' pointer. Possible to encapsulate with an assembler routine or by first calling a static member, and pick up a singleton reference for the "this" pointer.

    With a "normal" processor, it will not work since most processors requires the ISR to use a special keyword to get correct prologue/epologue for an ISR. Possible to manually hide with an assembler routine that encapsulates the call.

    But a static method is basically a function within a namespace, so no need to involve a C++ class.

    The biggest danger with C++ is that operator overloading or hidden constructors/destructors can introduce very big penalties even when the code looks very efficient. And an ISR don't want/need excess fat since it both represents CPU load and response latencies.

Children
No data