A single memory read at address swt reads 32 bits of which 16 bits are active. the variable swtchs is stored for detection of changes to the state.
unsigned int swtchs;
unsigned int program;
unsigned int i;
// Read the switch bank at memory bank
swtchs = (*(&swt) & 0x0000FFFF);
program = swtchs & 0x3;
// load pre-emphasis parameters
switch (program)
{
case PRE_EMPHASIS50US:
for(i=0;i<10;i++)fintXus[i] = fint50uS[i];
break;
case PRE_EMPHASIS75US:
for(i=0;i<10;i++)fintXuS[i]=fint75uS[i];
break;
case PRE_EMPHASIS125US:
for(i=0;i<10;i++)fintXuS[i]=fint125uS[i];
break;
default:
// 0uS pre-emphasis
for(i=0;i<10;i++)fintXuS[i]=fint0uS[
break;
}
Bit mapping is used to extract the bits of each parameter. Here bits 0, 1 are extracted to determine the pre-emphasis to be used. A case comparision is used to select the correct set of pre-emphasis parameters. The parameters are loaded into the array fintXuS that is used by the processing loop.
All the other parameters are extracted in the same way.