diff --git a/tests/psoc6/adc.py b/tests/psoc6/adc.py new file mode 100644 index 000000000000..46e4c5ab7c4a --- /dev/null +++ b/tests/psoc6/adc.py @@ -0,0 +1,20 @@ +""" +ADC test for the PSoC6 port. +""" + +from machine import ADC, Pin + +adc_pin = Pin("P10_0") +adc_wrong_pin = Pin("P13_7") + +# Exceptions should be raised +try: + adc = ADC(adc_wrong_pin) +except: + print("Invalid ADC Pin") + +adc = ADC(adc_pin, sample_ns=1000) +print(adc) + +print(adc.read_u16() > 0) +print(adc.read_uv() > 0) diff --git a/tests/psoc6/adc.py.exp b/tests/psoc6/adc.py.exp new file mode 100644 index 000000000000..acf3080c7150 --- /dev/null +++ b/tests/psoc6/adc.py.exp @@ -0,0 +1,4 @@ +Invalid ADC Pin + +True +True diff --git a/tests/psoc6/adcblock.py b/tests/psoc6/adcblock.py new file mode 100644 index 000000000000..c31eee20f8c3 --- /dev/null +++ b/tests/psoc6/adcblock.py @@ -0,0 +1,29 @@ +""" +ADCBlock test for the PSoC6 port. +""" +from machine import Pin, ADCBlock + +pin = Pin("P10_3") + +# Negative tests +try: + adcBlock = ADCBlock(1) +except: + print("TypeError: Specified ADC id not supported. Currently only block 0 is configured!") + +try: + adcBlock = ADCBlock(0, bits=10) +except: + print("TypeError: Invalid bits. Current ADC configuration supports only 12 bits resolution!") + +adcBlock = ADCBlock(0) + +try: + adcPin = adcBlock.connect(0, pin) +except: + print("TypeError: Wrong pin specified for the mentioned channel") + + +adcPin = adcBlock.connect(3, pin) + +print(adcPin.read_uv() > 0) diff --git a/tests/psoc6/adcblock.py.exp b/tests/psoc6/adcblock.py.exp new file mode 100644 index 000000000000..dcb8531e876d --- /dev/null +++ b/tests/psoc6/adcblock.py.exp @@ -0,0 +1,4 @@ +TypeError: Specified ADC id not supported. Currently only block 0 is configured! +TypeError: Invalid bits. Current ADC configuration supports only 12 bits resolution! +TypeError: Wrong pin specified for the mentioned channel +True