Hi, I am trying to write an "event dispatcher" so it's possible to listen to types of event and send events. You pass a function pointer and it will be called when that event is sent. Though I am having issues with unaligned memory access and I am unsure what is the cause.
Here is the code for the event dispatcher. I have removed some checks to simplify the code but essentially it's a 2d array of "listener". Each listener has a callback associated with it.
And the .h with the types definitions
Here is where the code is used.
The event is trigger three to four times and after a hard fault stops the application. Here is the message displayed by the hard fault handler.
I tried aligned my struct using
__attribute__ ((aligned (4)))
on the typedef but it didn't fix the issue since I though this was the issue.
I am using Segger Embedded Studio 4.5 on Windows 10
SDK 15.3.0 on the nrf52840
I know this is a lot of information at once, but since don't know where the alignment issue can come from and no stack trace is available, I've tried to provide all the necessary info.
I don't know if it's caused by the static freertos stack allocation or when the even triggers.
Any help is appreciated and I am more than happy to provide more info if necessary
UPDATE: It seems even when not listening to an event, the issue is present. Thus the issue is necessarily in `eventDispatcher_task`, `EventDispatcher_dispatch` (though not much is done here) or `main_freertos` and the callbacks are not a problem