samd: PDMIn: Reduce code unrolling on samd21 only

Instead of unrolling the code 16 times, unroll it 4 times and loop
over it 4 times.  This gives the same 16 iterations, but at an expense
of less flash space.
This commit is contained in:
Jeff Epler 2020-11-19 16:19:37 -06:00
parent b2b8520880
commit aaca3eccf1

View File

@ -337,7 +337,11 @@ const uint16_t sinc_filter [OVERSAMPLING] = {
94, 63, 39, 21, 9, 2, 0, 0
};
#define REPEAT_16_TIMES(X) X X X X X X X X X X X X X X X X
#ifdef SAMD21
#define REPEAT_16_TIMES(X) do { for(uint8_t j=0; j<4; j++) { X X X X } } while (0)
#else
#define REPEAT_16_TIMES(X) do { X X X X X X X X X X X X X X X X } while(0)
#endif
static uint16_t filter_sample(uint32_t pdm_samples[4]) {
uint16_t running_sum = 0;
@ -354,7 +358,7 @@ static uint16_t filter_sample(uint32_t pdm_samples[4]) {
filter_ptr++;
pdm_sample <<= 1;
}
)
);
}
return running_sum;
}