Progmem sounds like the right solution, maybe. Here's some more details (not including entire file, since it's three thousand lines of code):
First, here's the struct definition:
typedef struct
{
CHAR* name; /* Setting/bitfield name */
UINT8 read_only; /* 1 for read only setting/regs or 0 for read/write */
UINT8 self_clearing; /* 1 for self-clearing setting/registers or 0 otherwise */
UINT8 nvm_type; /* See above */
UINT8 bit_length; /* Number of bits in setting */
UINT8 start_bit; /* Least significant bit of the setting */
UINT8 reg_length; /* Number of registers that the setting is stored in */
UINT16 addr[SI5351B_REVB_MAX_NUM_REGS]; /* Addresses the setting is contained in */
UINT8 mask[SI5351B_REVB_MAX_NUM_REGS]; /* Bitmask for each register containing the setting */
} si5351b_revb_regmap_t;
Then, here's a piece of the array:
si5351b_revb_regmap_t const si5351b_revb_settings[SI5351B_REVB_NUM_SETTINGS] =
{
/* REVID */
{
"REVID",
1, /* 1 = IS Read Only */
0, /* 0 = NOT Self Clearing */
SLAB_NVMT_NO, /* Not stored in NVM */
2, /* 2 bits in this setting */
0, /* setting starts at b0 in first register */
1, /* contained in 1 registers(s) */
{
0x0000, /* Register address 0 b7:0 */
},
{
0x03, /* Register mask 0 */
}
},
.
.
.
/* CLK7_DIS_STATE */
{
"CLK7_DIS_STATE",
0, /* 0 = NOT Read Only */
0, /* 0 = NOT Self Clearing */
SLAB_NVMT_NO, /* Not stored in NVM */
2, /* 2 bits in this setting */
6, /* setting starts at b6 in first register */
1, /* contained in 1 registers(s) */
{
0x0019, /* Register address 0 b7:0 */
},
{
0xC0, /* Register mask 0 */
}
},
.
.
.
}
Finally, here are few of the #DEFINEs:
#define SI5351B_REVB_REVID 0
.
.
.
#define SI5351B_REVB_CLK7_DIS_STATE 91
So if I wanted, for example, to get the address of the register which disables CLK7, I would do something like:
temp = si5351b_revb_settings[SI5351B_REVB_CLK7_DIS_STATE].addr;
I don't know if progmem can handle this, but it sounds like a nice fix.
Again, I don't _need_ this to work - of the 161 register elements defined in this file, I need, like, 3. I can program those manually. I was just surprised that while I included this header file in my project, but never actually referenced the array in any way, the compiler didn't just ignore it.
Edit to add: Can I tell you how annoying it is that they stuck "revb" everywhere? Probably to make it explictly not backward compatible, but still really annoying to have in every freaking variable name.