forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ports/psoc6: Finishing ADC and ADCBlock module.
Signed-off-by: NikhitaR-IFX <Nikhita.Rajasekhar@infineon.com>
- Loading branch information
1 parent
c558a19
commit 9ac12c2
Showing
6 changed files
with
59 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
""" | ||
ADC test for the PSoC6 port. | ||
""" | ||
|
||
from machine import ADC, Pin | ||
|
||
adc_pin = Pin("P10_0") | ||
adc_wrong_pin = Pin("P13_7") | ||
|
||
adc = ADC(adc_pin) | ||
print(adc) | ||
|
||
adc = ADC(adc_pin, sample_ns=1200) | ||
print(adc) | ||
|
||
print(adc.read_uv() > 0) | ||
print(adc.read_u16() > 0) | ||
|
||
# Exceptions should be raised | ||
try: | ||
adc = ADC(adc_wrong_pin) | ||
except: | ||
print("Invalid ADC Pin") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
""" | ||
ADCBlock test for the PSoC6 port. | ||
""" | ||
from machine import ADCBlock, Pin | ||
|
||
pin = Pin("P10_0") | ||
|
||
# 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, bits=12) | ||
|
||
try: | ||
adcPin = adcBlock.connect(1, pin) | ||
except: | ||
print("TypeError: Wrong pin specified for the mentioned channel") | ||
|
||
|
||
adcPin = adcBlock.connect(0, pin) | ||
|
||
print(adcPin.read_uv() > 0) |