None
frac32.positive o00
frac32.positive o01
frac32.positive o02
frac32.positive o03
frac32.positive o04
frac32.positive o05
frac32.positive o06
frac32.positive o07
frac32.positive o08
frac32.positive o09
frac32.positive o10
frac32.positive o11
frac32.positive o12
frac32.positive o13
frac32.positive o14
frac32.positive o15
frac32.positive o16
frac32.positive o17
frac32.positive o18
frac32.positive o19
frac32.positive o20
frac32.positive o21
frac32.positive o22
frac32.positive o23
combo Z0
combo Z1
combo Z2
combo S0
combo S1
combo S2
int32_t a_inF0[24], a_inF1[24], a_inF2[24], a_inF3[24];
uint8_t multiplex_cpt;
uint8_t kcycle2_cpt, kcycle24_cpt;
multiplex_cpt = kcycle2_cpt = kcycle24_cpt = 0;
for (int i = 0; i < 24; i++) {
a_inF3[i] = a_inF2[i] = a_inF1[i] = a_inF0[i] = 0;
}
// init gpios
// outputs for the 4051 select lines S0 S1 S2
palSetPadMode(attr_S0, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(attr_S1, PAL_MODE_OUTPUT_PUSHPULL);
palSetPadMode(attr_S2, PAL_MODE_OUTPUT_PUSHPULL);
// the inputs are sampled 1/2 kcycle so that the multiplexed signals (4051) are
// stable
kcycle2_cpt++;
if (kcycle2_cpt == 2) {
kcycle2_cpt = 0;
int32_t *a_in = a_inF0 + multiplex_cpt;
// LP with 0.25 coefficient
*a_in = ___SMMLA(0x40000000, (adcvalues[attr_Z0] << 15) - *a_in, *a_in);
a_in += 8;
*a_in = ___SMMLA(0x40000000, (adcvalues[attr_Z1] << 15) - *a_in, *a_in);
a_in += 8;
*a_in = ___SMMLA(0x40000000, (adcvalues[attr_Z2] << 15) - *a_in, *a_in);
// prepare next
multiplex_cpt++;
multiplex_cpt &= 7;
}
// set gpio outputs
palWritePad(attr_S0, (multiplex_cpt & 1) != 0);
palWritePad(attr_S1, (multiplex_cpt & 2) != 0);
palWritePad(attr_S2, (multiplex_cpt & 4) != 0);
// Repartition des filtrages 'intelligent' des 24 entrees analogiques
{
kcycle24_cpt++;
if (kcycle24_cpt == 24) {
kcycle24_cpt = 0;
}
int i = kcycle24_cpt;
// extends to [0 64[ even if there is some noise
a_inF0[i] = __USAT(___SMMLA(a_inF0[i], 0x40800000, -1 << 17) << 2, 27);
if (abs(a_inF0[i] - a_inF1[i]) > (1 << 21)) { // jump
a_inF1[i] = a_inF0[i];
} else { // smooth 0.25
a_inF1[i] = ___SMMLA(0x40000000, a_inF0[i] - a_inF1[i], a_inF1[i]);
}
int32_t dist = abs(a_inF1[i] - a_inF2[i]);
if (dist > (1 << 20)) { // jump
a_inF2[i] = a_inF1[i];
} else {
// the closer, the smoother
int32_t coef;
if (dist > (1 << 19))
coef = 0x2A000000;
else
coef = (dist << 10) + 0x0A000000;
a_inF2[i] = ___SMMLA(coef, a_inF1[i] - a_inF2[i], a_inF2[i]);
}
dist = abs(a_inF2[i] - a_inF3[i]);
if (dist > (1 << 18)) { // jump
a_inF3[i] = a_inF2[i];
} else {
// the closer, the smoother
int32_t coef;
if (dist > (1 << 19))
coef = 0x20600000;
else
coef = (dist << 10) + 0x00600000;
a_inF3[i] = ___SMMLA(coef, a_inF2[i] - a_inF3[i], a_inF3[i]);
}
}
// set outlets
outlet_o00 = a_inF3[0];
outlet_o01 = a_inF3[1];
outlet_o02 = a_inF3[2];
outlet_o03 = a_inF3[3];
outlet_o04 = a_inF3[4];
outlet_o05 = a_inF3[5];
outlet_o06 = a_inF3[6];
outlet_o07 = a_inF3[7];
outlet_o08 = a_inF3[8];
outlet_o09 = a_inF3[9];
outlet_o10 = a_inF3[10];
outlet_o11 = a_inF3[11];
outlet_o12 = a_inF3[12];
outlet_o13 = a_inF3[13];
outlet_o14 = a_inF3[14];
outlet_o15 = a_inF3[15];
outlet_o16 = a_inF3[16];
outlet_o17 = a_inF3[17];
outlet_o18 = a_inF3[18];
outlet_o19 = a_inF3[19];
outlet_o20 = a_inF3[20];
outlet_o21 = a_inF3[21];
outlet_o22 = a_inF3[22];
outlet_o23 = a_inF3[23];