Skip to main content
13 events
when toggle format what by license comment
Apr 3, 2019 at 20:03 vote accept 19172281
Apr 3, 2019 at 19:45 comment added 19172281 This would only be an issue though if I included the systickTimer header file more than once (directly)?
Apr 3, 2019 at 19:26 comment added Colin It's best not to, see stackoverflow.com/questions/38942013/…
Apr 3, 2019 at 19:22 comment added 19172281 And finally, is there any reason why I couldn't place the pointer to systickTimer in the header file?
Apr 3, 2019 at 19:11 comment added Colin It's not necessary, stackoverflow.com/questions/357404/… answers it better than I could here.
Apr 3, 2019 at 19:10 comment added 19172281 Seems like an interesting way of doing things. What is the purpose of the namespace? Is it needed?
Apr 3, 2019 at 19:04 comment added Colin @19172281 gist.github.com/csowter/73ce695d1c304c064f9a746d580f39e1 I have uploaded a systick handler from one of my projects there, when you create an instance of it, it initialises the pointer in the unnamed namespace which can then be used by the IRQ handler. It should probably be a singleton, but I just don't create two of them.
Apr 3, 2019 at 19:01 comment added DKNguyen I don't know of a way to make the handler a class member. I would not be surprised if you could not. I write public member functions if my interrupt handler needs to access them. You could try declaring the handler as a friend to your class rather than declaring it as a class member. That might work but I've never tried it. Let me know if it works. It could be convenient if it does.
Apr 3, 2019 at 19:00 comment added 19172281 @Colin, that's what I wanted to do originally, but what's the best way to get the instance to the handler in the first place?
Apr 3, 2019 at 18:57 comment added Colin @19172281 Not easily, no. A member function has an inherent this pointer passed to it as the first argument, which can't happen if it's called from elsewhere. The easiest thing to do is have your SysTick_Handler call a function on an instance of your class.
Apr 3, 2019 at 18:55 comment added 19172281 @Toor Can Systick_Handler() be made a member of a class? If so, does it need to be static? Ideally I'd like it to have access to context data, without needing a "load" function in the same file, which initialises variables in an included header file.
Apr 3, 2019 at 18:48 comment added DKNguyen That extern "C" part is really important. I was hung up on that for quite a while when I first started out. You don't need it if you are in C since the compiler was specified the interrupt handler names in C. But if you are in C++, function name mangling will occur if you do not use those keywords causing the compiler to be unable to not recognize the function's name as the interrupt handler. You'll get no warnings if you don't. Your interrupt will just inexplicably not work since the compiler just treats it as a regular function and use the default interrupt dummy handler.
Apr 3, 2019 at 18:31 history answered Colin CC BY-SA 4.0