Is there an easy way, through code, to determine what type of CPU the code is running on?
My project calls for modular CPU boards depending on need or scale out. So a client can start with a G30 for a small setup but swap out the board for a G80, 120, or 400 when the need arises (for RAM, speed, etc).
I would like the framework I am building to work regardless of what it is deployed to.
But I’m having trouble trying to figure out what MCU the code is running on to handle pin reconfiguration.
I’m faced with the proposition of either having a separate program version for each CPU, or incorporating a flash memory module to store configuration data, or using an SD card with a config file, etc… All of those solutions adds to cost and complexity. And I haven’t tested whether I can even late-bind pin declarations like that. When I try to execute code with bad pin declarations it breaks immediately (e.g. swapping from a G400 to a G30) when that program loads.
So is there a way to do this?
If there’s no way through code, maybe I could use an unused analog port and use a different voltage divider resistor setup on each type of board? Have all of my pin declarations be an abstract class that depending on that initialization read of what the analog port is picking up for voltage, it swaps in the appropriate pin values for what I’m using?
Also this is for NETMF 4.3.
It was a head scratcher over the weekend and I threw in the towel and decided to ask this morning. Friday I swapped over a test program from a G400 dev board to a G30 and it failed to deploy because of some interrupt pins I’d set didn’t exist on the G30. I looked at the screen and went … “oh boy.”
I mean it’s easy to change the code and hit F5 again, but when it comes time to do production if I have 4 different compute modules that can all plug in to the same slot, I don’t want to have to do 4 different builds every time something changes…
GPIO.Pin / CPU.Pin are just ints so I can abstract it all but need to know what module the code is running on to do it.
if (SystemInfo.SystemID.Model == 0x08) // G120