LowPowerLab / SPIFlash

Arduino library for read/write access to SPI flash memory chips
GNU General Public License v3.0
173 stars 91 forks source link

Late Initialization #11

Open EtherFidelity opened 9 years ago

EtherFidelity commented 9 years ago

This change allows the class to be instantiated globally but configured in the setup() section.

LowPowerLab commented 9 years ago

Thanks for the pull, can you give an example of how this mod would be useful over using the initialization of the vars in the constructor?

EtherFidelity commented 9 years ago

This is part of a system I'm working on. I haven't released any code yet because it's far from finished.

Basically, I have a small circuit configuration program that you, the manufacturer, could run on your board prior to shipping. It uses a section of the EEPROM to store pin configuration details for that specific board model. The idea is that with this program being used to define the circuit configuration, it could be used with yours and the variety of other boards out there with additional hardware soldered on such that a user's final program can read this and use it to initialize the hardware on any board without the use of build flags or separate code bases.

What do you think? I realize that compiler flags to identify various boards are easy enough, but this method would eliminate those. This could be nice because to use a new board design one would need no additional code modifications.

The EEPROM could just have a simple struct in it that says what each pin is connected to, if anything. An easy lookup in the setup phase and the late initialization patch together would make it possible, since that struct can't be read before the setup phase.

What do you think?

Charles

On Mon, Jun 8, 2015 at 7:44 AM, Felix Rusu notifications@github.com wrote:

Thanks for the pull, can you give an example of how this mod would be useful over using the initialization of the vars in the constructor?

— Reply to this email directly or view it on GitHub https://github.com/LowPowerLab/SPIFlash/pull/11#issuecomment-110020426.