I’m in the process of designing a embedded C data storage module. It will be included by files/modules who want access to this “shared” system-wide data. Multiple tasks aggregate dozens of inputs (GPIO, CAN, I2C/SPI/SSP data, etc) and stores those values off using the API. Then, other tasks can access the data safely through the API. The system is an embedded app with an RTOS, so mutexes are used to protect the data. These ideas will be used regardless of the implementation
I’ve designed something like this in the past, and I’m trying to improve upon it. I’m currently halfway through a new implementation and I’m running into a few hiccups and would really benefit from a fresh perspective.
Quick rundown of the requirements of this module:
The question is how would you go about designing something like this? Enumerations, structures, accessors, macros, etc? I’m not looking for code here, just discussing general overall design ideas. If there’s a solution on the internet that addresses these sorts of things, perhaps even just a link is sufficient.
Figured I’d update one of my only unaccepted questions. Here’s my final implementation. Been using this for over a year and it works fantastic. Very easy to add variables to and very little overhead for the benefit it gives us.
lib_data.h:
lib_data.c: