enforce following lf config

This commit is contained in:
iceman1001 2020-01-16 10:42:39 +01:00
commit 958754edf4
3 changed files with 8 additions and 4 deletions

View file

@ -61,7 +61,7 @@ size_t lf_count_edge_periods_ex(size_t max, bool wait, bool detect_gap) {
adc_val = AT91C_BASE_SSC->SSC_RHR; adc_val = AT91C_BASE_SSC->SSC_RHR;
periods++; periods++;
if (logging) logSample(adc_val, 1, 8, 0); if (logging) logSampleSimple(adc_val);
// Only test field changes if state of adc values matter // Only test field changes if state of adc values matter
if (!wait) { if (!wait) {
@ -91,7 +91,7 @@ size_t lf_count_edge_periods_ex(size_t max, bool wait, bool detect_gap) {
if (periods == max) return 0; if (periods == max) return 0;
} }
} }
if (logging) logSample(255, 1, 8, 0); if (logging) logSampleSimple(0xFF);
return 0; return 0;
} }
@ -206,14 +206,13 @@ size_t lf_detect_field_drop(size_t max) {
} }
++checked; ++checked;
// Watchdog hit
WDT_HIT(); WDT_HIT();
if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) { if (AT91C_BASE_SSC->SSC_SR & (AT91C_SSC_RXRDY)) {
periods++; periods++;
adc_val = AT91C_BASE_SSC->SSC_RHR; adc_val = AT91C_BASE_SSC->SSC_RHR;
if (logging) logSample(adc_val, 1, 8, 0); if (logging) logSampleSimple(adc_val);
if (adc_val == 0) { if (adc_val == 0) {
rising_edge = false; rising_edge = false;

View file

@ -138,6 +138,10 @@ uint32_t getSampleCounter() {
return samples.total_saved; return samples.total_saved;
} }
void logSampleSimple(uint8_t sample) {
logSample(sample, config.decimation, config.bits_per_sample, config.averaging);
}
void logSample(uint8_t sample, uint8_t decimation, uint8_t bits_per_sample, bool avg) { void logSample(uint8_t sample, uint8_t decimation, uint8_t bits_per_sample, bool avg) {
if (!data.buffer) return; if (!data.buffer) return;

View file

@ -70,6 +70,7 @@ uint32_t DoAcquisition_config(bool verbose, uint32_t sample_size);
* Refactoring of lf sampling buffer * Refactoring of lf sampling buffer
*/ */
void initSampleBuffer(uint32_t *sample_size); void initSampleBuffer(uint32_t *sample_size);
void logSampleSimple(uint8_t sample);
void logSample(uint8_t sample, uint8_t decimation, uint8_t bits_per_sample, bool avg); void logSample(uint8_t sample, uint8_t decimation, uint8_t bits_per_sample, bool avg);
uint32_t getSampleCounter(); uint32_t getSampleCounter();