Skip to content

Commit

Permalink
tests/psoc6/hw_ext/adc.py: Generalized without pin info.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
  • Loading branch information
jaenrig-ifx committed Apr 12, 2024
1 parent 0604f14 commit 0baeda1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 50 deletions.
37 changes: 12 additions & 25 deletions tests/psoc6/hw_ext/adc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@
adc_pin_max = "P10_0"
adc_wrong_pin_name = "P13_7"
# Enable after DUT setup
print("SKIP")
raise SystemExit
# print("SKIP")
# raise SystemExit
elif "CY8CPROTO-063-BLE" in machine:
adc_pin_gnd = "P10_1"
adc_pin_gnd = "P10_2"
adc_pin_mid = "P10_3"
adc_pin_max = "P10_0"
adc_pin_max = "P10_4"
adc_wrong_pin_name = "P13_7"
print("SKIP")
raise SystemExit
# print("SKIP")
# raise SystemExit

# 0.35V
tolerance_uv = 350000
Expand All @@ -41,22 +41,18 @@

def validate_adc_uv_value(adc_pin, exp_volt, act_volt):
print(
"\nExpected voltage - ",
"Expected voltage - ",
exp_volt,
"(uV) on pin ",
adc_pin,
"is approx same as obtained voltage(uV): ",
"(uV) is approx same as obtained voltage(uV): ",
(exp_volt - tolerance_uv) < act_volt < (exp_volt + tolerance_uv),
)


def validate_adc_raw_value(adc_pin, exp_volt, act_volt):
print(
"\nExpected voltage - ",
"Expected voltage - ",
exp_volt,
"(raw) on pin ",
adc_pin,
"is approx same as obtained voltage(raw): ",
"(raw) is approx same as obtained voltage(raw): ",
(exp_volt - tolerance_raw) < act_volt < (exp_volt + tolerance_raw),
)

Expand All @@ -67,30 +63,24 @@ def validate_adc_raw_value(adc_pin, exp_volt, act_volt):
except:
print("Invalid ADC Pin\n")

adc0 = ADC(adc_pin_gnd, sample_ns=1000)
print(adc0)

block = ADCBlock(0, bits=12)
# ADCBlock.connect(channel)
adc1 = block.connect(3)
print("\nADCBlock.connect(channel): ", adc1)
block.deinit()
print("ADCBlock.deinit(): ", block)

# ADCBlock.connect(source)
block = ADCBlock(0, bits=12)
adc1 = block.connect(adc_pin_mid)
print("ADCBlock.connect(source): ", adc1)
block.deinit()
print("ADCBlock.deinit(): ", block)

adc0 = ADC(adc_pin_gnd, sample_ns=1000)

# ADCBlock.connect(channel,source)
block = ADCBlock(0, bits=12)
adc1 = block.connect(3, adc_pin_mid)
print("ADCBlock.connect(channel,source)", adc1)

adc2 = ADC(adc_pin_max, sample_ns=1000)
print("\n", adc2)

adc0_value_uv = adc0.read_uv()
validate_adc_uv_value(adc_pin_gnd, 0, adc0_value_uv)
Expand All @@ -108,8 +98,5 @@ def validate_adc_raw_value(adc_pin, exp_volt, act_volt):
validate_adc_raw_value(adc_pin_max, 32767, adc2_value_raw)

adc0.deinit()
print("\n", adc0)
adc1.deinit()
print(adc1)
adc2.deinit()
print(adc2)
31 changes: 6 additions & 25 deletions tests/psoc6/hw_ext/adc.py.exp
Original file line number Diff line number Diff line change
@@ -1,27 +1,8 @@
Invalid ADC Pin

<ADC Pin=81, ADCBlock_id=0, sampling_time_ns=1000>

ADCBlock.connect(channel): <ADC Pin=83, ADCBlock_id=0, sampling_time_ns=1000>
ADCBlock.deinit(): ADCBlock(0, bits=12)
ADCBlock.connect(source): <ADC Pin=83, ADCBlock_id=0, sampling_time_ns=1000>
ADCBlock.deinit(): ADCBlock(0, bits=12)
ADCBlock.connect(channel,source) <ADC Pin=83, ADCBlock_id=0, sampling_time_ns=1000>

<ADC Pin=80, ADCBlock_id=0, sampling_time_ns=1000>

Expected voltage - 0 (uV) on pin P10_1 is approx same as obtained voltage(uV): True

Expected voltage - 0 (raw) on pin P10_1 is approx same as obtained voltage(raw): True

Expected voltage - 1650000 (uV) on pin P10_3 is approx same as obtained voltage(uV): True

Expected voltage - 16385 (raw) on pin P10_3 is approx same as obtained voltage(raw): True

Expected voltage - 3300000 (uV) on pin P10_0 is approx same as obtained voltage(uV): True

Expected voltage - 32767 (raw) on pin P10_0 is approx same as obtained voltage(raw): True

<ADC Pin=81, ADCBlock_id=0, sampling_time_ns=1000>
<ADC Pin=83, ADCBlock_id=0, sampling_time_ns=1000>
<ADC Pin=80, ADCBlock_id=0, sampling_time_ns=1000>
Expected voltage - 0 (uV) is approx same as obtained voltage(uV): True
Expected voltage - 0 (raw) is approx same as obtained voltage(raw): True
Expected voltage - 1650000 (uV) is approx same as obtained voltage(uV): True
Expected voltage - 16385 (raw) is approx same as obtained voltage(raw): True
Expected voltage - 3300000 (uV) is approx same as obtained voltage(uV): True
Expected voltage - 32767 (raw) is approx same as obtained voltage(raw): True

0 comments on commit 0baeda1

Please sign in to comment.