mirror of https://github.com/rusefi/wideband.git
hardware index selection works
This commit is contained in:
parent
475d7b8936
commit
48dbdb842e
|
@ -88,37 +88,34 @@ Configuration GetConfiguration()
|
|||
{
|
||||
const auto& cfg = __configflash__start__;
|
||||
|
||||
// If config has been written before, return the stored configuration
|
||||
Configuration c;
|
||||
|
||||
// If config has been written before, use the stored configuration
|
||||
if (cfg.IsValid())
|
||||
{
|
||||
auto c = cfg;
|
||||
c = cfg;
|
||||
}
|
||||
|
||||
// TODO: test me!
|
||||
// auto sel1 = readSelPin(GPIOB, 1);
|
||||
// auto sel2 = readSelPin(GPIOA, 8);
|
||||
// Now, override the index with a hardware-strapped option (if present)
|
||||
auto sel1 = readSelPin(GPIOB, 1);
|
||||
auto sel2 = readSelPin(GPIOA, 8);
|
||||
|
||||
// See https://github.com/mck1117/wideband/issues/11
|
||||
// switch (3 * sel1 + sel2) {
|
||||
// case 0: c.CanIndexOffset = 0; break;
|
||||
// case 1: c.CanIndexOffset = 2; break;
|
||||
// case 2: c.CanIndexOffset = 3; break;
|
||||
// case 3: c.CanIndexOffset = 4; break;
|
||||
// case 4: /* both floating, do nothing */ break;
|
||||
// case 5: c.CanIndexOffset = 1; break;
|
||||
// case 6: c.CanIndexOffset = 5; break;
|
||||
// case 7: c.CanIndexOffset = 6; break;
|
||||
// case 8: c.CanIndexOffset = 7; break;
|
||||
// default: break;
|
||||
// }
|
||||
switch (3 * sel1 + sel2) {
|
||||
case 0: c.CanIndexOffset = 2; break;
|
||||
case 1: c.CanIndexOffset = 0; break;
|
||||
case 2: c.CanIndexOffset = 3; break;
|
||||
case 3: c.CanIndexOffset = 4; break;
|
||||
case 4: /* both floating, do nothing */ break;
|
||||
case 5: c.CanIndexOffset = 1; break;
|
||||
case 6: c.CanIndexOffset = 5; break;
|
||||
case 7: c.CanIndexOffset = 6; break;
|
||||
case 8: c.CanIndexOffset = 7; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Otherwise return a default config
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
void SetConfiguration(const Configuration& newConfig)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue