I have a maple mini application I have been working on for the past year. it works well as it is. I just decided that it would be good to add the code to make the sd card reader that I have on the board work.
The application has migrated to a class oriented project with 90% of the software in a set of classes. I implement this through libraries. The basic structure is
Device[Can be several]
Manager[one per Device]
Sampler[one per device]
Duty[one per device]
I have started implementing the sd card as a Logger class with the Device creating the instance. The logger has an instance of the HardwareSPI class, with two devices there are two HardwareSPI instances. This works and each Device can write to the card successfully. Each device completes its writing task before it gives up control.
The problem is that I also need the Manager and the Sampler to be able to write to the sd card. This brings up all kinds of memory allocation issues if I just pass the logger instance to the Sampler or Manager.
I am heading to the model where each class that needs to write to the sd card inherits from a logger base class. The issue is there will be potentially many instances of the HardwareSPI class instantiated and don''t understand it well enough to know if this causes an issue.
I can post as much code as is needed, I didn''t think it would help.
Any advise would be appreciated.