mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
tests/periph/selftest_shield: re-enable ADC test
The R-2R resistor ladder dac --> ADC test was disabled due to a bug in the v0.1 version of the shield. Since this has been fixed in v0.2 and v0.3 of the shield, it can be re-enabled. The comment regarding the high accuracy of the resistor is dropped, as v0.3 has been ordered with cost efficient resistors rather than with accurate ones. As a result, the tolerance for error has been increased to 10%. This quite a bit more lax than I have hoped for, but false positives would be something to avoid.
This commit is contained in:
parent
47d81ffbe1
commit
f51ca593ba
@ -93,10 +93,9 @@
|
||||
* - periph_adc support (so that we have something to test)
|
||||
* - Arduino I/O mapping for ADC (so that we know which line to test)
|
||||
* - The PCF857x driver (so that we can control the R-2R resistor ladder
|
||||
* connected to the GPIO expander.
|
||||
* connected to the GPIO expander).
|
||||
*/
|
||||
#if defined(MODULE_PERIPH_ADC) && defined(ARDUINO_A0) && defined(MODULE_PCF857X) && 0
|
||||
// TODO: Re-anble when PCB is fixed
|
||||
#if defined(MODULE_PERIPH_ADC) && defined(ARDUINO_A0) && defined(MODULE_PCF857X)
|
||||
# define ENABLE_ADC_TEST 1
|
||||
#else
|
||||
# define ENABLE_ADC_TEST 0
|
||||
@ -979,9 +978,9 @@ static bool periph_adc_test(void)
|
||||
uint16_t sample = adc_sample(ARDUINO_A0, ADC_RES_10BIT);
|
||||
uint16_t expected = i << 6;
|
||||
|
||||
/* the resistors are said to be rather accurate, so lets be a bit
|
||||
* more strict here */
|
||||
const uint16_t delta = 16;
|
||||
/* The resistors on board v0.3 are not that accurate, so allow for 10%
|
||||
* error margin */
|
||||
const uint16_t delta = 1024 / 10;
|
||||
uint16_t lower = expected <= delta ? 0 : expected - delta;
|
||||
uint16_t upper = MIN(1023, expected + delta);
|
||||
bool test_failed = TEST((lower <= sample) && (upper >= sample));
|
||||
|
Loading…
Reference in New Issue
Block a user