From 42dbe380ff74dd55e652c4882a62f2f96763f689 Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Tue, 19 Sep 2023 15:22:36 +0200 Subject: [PATCH 1/3] .github/workflows/ports_psoc6.yml: Added dev selection to tests stages. Signed-off-by: enriquezgarc --- .github/workflows/ports_psoc6.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ports_psoc6.yml b/.github/workflows/ports_psoc6.yml index 6ee0f4846a42..d36e4203b7ae 100644 --- a/.github/workflows/ports_psoc6.yml +++ b/.github/workflows/ports_psoc6.yml @@ -66,12 +66,14 @@ jobs: source tools/ci.sh && ci_psoc6_flash_multiple_devices ${{ matrix.board }} firmware.hex tools/psoc6/${{ runner.name }}-devs.yml - name: Run psoc6 multi test run: | + devs=($(python tools/psoc6/get-devs.py port -b ${{ matrix.board }} -y tools/psoc6/${{ runner.name }}-devs.yml)) cd tests - ./psoc6/run_psoc6_tests.sh --psoc6-multi + ./psoc6/run_psoc6_tests.sh --psoc6-multi --dev0 ${devs[0]} --dev1 ${devs[1]} - name: Run psoc6 tests run: | + devs=($(python tools/psoc6/get-devs.py port -b ${{ matrix.board }} -y tools/psoc6/${{ runner.name }}-devs.yml)) cd tests - ./psoc6/run_psoc6_tests.sh --psoc6 + ./psoc6/run_psoc6_tests.sh --psoc6 --dev0 ${devs[0]} # TODO: Enable when HIL is updgraded # - name: Run all implemented tests # if: github.event_name == 'pull_request' From b3f1cf9e429b3dbe67513f057b4f1bfafbaabbee Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Tue, 19 Sep 2023 17:27:34 +0200 Subject: [PATCH 2/3] tests/psoc6: Added board pin allocation and skip if module unavailable. Signed-off-by: enriquezgarc --- tests/psoc6/adc.py | 14 ++++++++++++-- tests/psoc6/adcblock.py | 11 ++++++++++- tests/psoc6/i2c_hard.py | 12 +++++++++++- tests/psoc6/i2c_soft.py | 12 +++++++++++- tests/psoc6/multi/network.py | 8 +++++++- tests/psoc6/multi/network_config.py | 8 +++++++- tests/psoc6/pin.py | 14 ++++++++++++-- tests/psoc6/pwm.py | 11 ++++++++++- tests/psoc6/spi_soft.py | 13 ++++++++++++- 9 files changed, 92 insertions(+), 11 deletions(-) diff --git a/tests/psoc6/adc.py b/tests/psoc6/adc.py index 46e4c5ab7c4a..c0483a6fb575 100644 --- a/tests/psoc6/adc.py +++ b/tests/psoc6/adc.py @@ -2,10 +2,20 @@ ADC test for the PSoC6 port. """ +import os from machine import ADC, Pin -adc_pin = Pin("P10_0") -adc_wrong_pin = Pin("P13_7") +# Allocate pin based on board +machine = os.uname().machine +if "CY8CPROTO-062-4343W" in machine: + adc_pin_name = "P10_0" + adc_wrong_pin_name = "P13_7" +elif "CY8CPROTO-063-BLE" in machine: + print("SKIP") + raise SystemExit + +adc_pin = Pin(adc_pin_name) +adc_wrong_pin = Pin(adc_wrong_pin_name) # Exceptions should be raised try: diff --git a/tests/psoc6/adcblock.py b/tests/psoc6/adcblock.py index c31eee20f8c3..08c672d64ab0 100644 --- a/tests/psoc6/adcblock.py +++ b/tests/psoc6/adcblock.py @@ -1,9 +1,18 @@ """ ADCBlock test for the PSoC6 port. """ +import os from machine import Pin, ADCBlock -pin = Pin("P10_3") +# Allocate pin based on board +machine = os.uname().machine +if "CY8CPROTO-062-4343W" in machine: + pin_name = "P10_3" +elif "CY8CPROTO-063-BLE" in machine: + print("SKIP") + raise SystemExit + +pin = Pin(pin_name) # Negative tests try: diff --git a/tests/psoc6/i2c_hard.py b/tests/psoc6/i2c_hard.py index 07219fbb7bda..4ddeee167b4a 100644 --- a/tests/psoc6/i2c_hard.py +++ b/tests/psoc6/i2c_hard.py @@ -1,7 +1,17 @@ ### I2C +import os from machine import I2C -i2c = I2C(id=0, scl="P6_0", sda="P6_1", freq=400000) +# Allocate pin based on board +machine = os.uname().machine +if "CY8CPROTO-062-4343W" in machine: + scl_pin = "P6_0" + sda_pin = "P6_1" +elif "CY8CPROTO-063-BLE" in machine: + print("SKIP") + raise SystemExit + +i2c = I2C(id=0, scl=scl_pin, sda=sda_pin, freq=400000) print(i2c) print(i2c.scan()) diff --git a/tests/psoc6/i2c_soft.py b/tests/psoc6/i2c_soft.py index d36fb499458e..da1b8c55a9ad 100644 --- a/tests/psoc6/i2c_soft.py +++ b/tests/psoc6/i2c_soft.py @@ -1,7 +1,17 @@ #### SoftI2C +import os from machine import SoftI2C -si2c = SoftI2C(scl="P6_0", sda="P6_1", freq=400000) +# Allocate pin based on board +machine = os.uname().machine +if "CY8CPROTO-062-4343W" in machine: + scl_pin = "P6_0" + sda_pin = "P6_1" +elif "CY8CPROTO-063-BLE" in machine: + print("SKIP") + raise SystemExit + +si2c = SoftI2C(scl=scl_pin, sda=sda_pin, freq=400000) print(si2c) print(si2c.scan()) diff --git a/tests/psoc6/multi/network.py b/tests/psoc6/multi/network.py index e55743906a25..ed78d24b6faf 100644 --- a/tests/psoc6/multi/network.py +++ b/tests/psoc6/multi/network.py @@ -1,4 +1,10 @@ -import binascii, network, time +import binascii, time + +try: + import network +except ImportError: + print("SKIP") + raise SystemExit channel_default = 9 channel_new = 5 diff --git a/tests/psoc6/multi/network_config.py b/tests/psoc6/multi/network_config.py index ca162ced7ae5..0aa28ad83e0a 100644 --- a/tests/psoc6/multi/network_config.py +++ b/tests/psoc6/multi/network_config.py @@ -1,4 +1,10 @@ -import binascii, network, time +import binascii, time + +try: + import network +except ImportError: + print("SKIP") + raise SystemExit channel_new = 5 ssid_new = "mpy-test-conf-wlan" diff --git a/tests/psoc6/pin.py b/tests/psoc6/pin.py index 3e1812d80645..0f03c6ac3706 100644 --- a/tests/psoc6/pin.py +++ b/tests/psoc6/pin.py @@ -1,11 +1,21 @@ +import os from machine import Pin import time import machine +# Allocate pin based on board +machine = os.uname().machine +if "CY8CPROTO-062-4343W" in machine: + pin1_name = "P13_7" + pin2_name = "P0_4" +elif "CY8CPROTO-063-BLE" in machine: + print("SKIP") + raise SystemExit + # Tests for Output pin # Instantiate output pin for led operation # Constr -p1 = Pin("P13_7") +p1 = Pin(pin1_name) p1.init(Pin.OUT) print(p1) # Pin:111 or P13_7, Mode=OUT, Pull=None, Value=1 @@ -20,7 +30,7 @@ # Tests for Input pin # Instantiate input pin for button operation -p2 = Pin("P0_4", Pin.IN) +p2 = Pin(pin2_name, Pin.IN) print(p2) # Pin:4 or P0_4, Mode=IN, Pull=None, Value=1 p2.value() print(p2.value()) # 1 - button is released diff --git a/tests/psoc6/pwm.py b/tests/psoc6/pwm.py index 57a0b97d2924..f1c42ad39fcc 100644 --- a/tests/psoc6/pwm.py +++ b/tests/psoc6/pwm.py @@ -1,7 +1,16 @@ ### PWM +import os from machine import PWM -pwm = PWM("P12_0", freq=50, duty_u16=8192, invert=0) +# Allocate pin based on board +machine = os.uname().machine +if "CY8CPROTO-062-4343W" in machine: + pin_name = "P12_0" +elif "CY8CPROTO-063-BLE" in machine: + print("SKIP") + raise SystemExit + +pwm = PWM(pin_name, freq=50, duty_u16=8192, invert=0) print(pwm) print(pwm.freq()) print(pwm.duty_u16()) diff --git a/tests/psoc6/spi_soft.py b/tests/psoc6/spi_soft.py index e1ed73c966d4..947c7aceece4 100644 --- a/tests/psoc6/spi_soft.py +++ b/tests/psoc6/spi_soft.py @@ -1,7 +1,18 @@ #### SoftSPI +import os from machine import SoftSPI -spi = SoftSPI(baudrate=100000, polarity=1, phase=0, sck="P9_2", mosi="P9_0", miso="P9_1") +# Allocate pin based on board +machine = os.uname().machine +if "CY8CPROTO-062-4343W" in machine: + sck_pin = "P9_2" + mosi_pin = "P9_0" + miso_pin = "P9_1" +elif "CY8CPROTO-063-BLE" in machine: + print("SKIP") + raise SystemExit + +spi = SoftSPI(baudrate=100000, polarity=1, phase=0, sck=sck_pin, mosi=mosi_pin, miso=miso_pin) print(spi) spi.init(baudrate=200000) print(spi) From 4e214ab5a0b09cd3900b985a61bfd6bcee93dfbd Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Wed, 20 Sep 2023 09:05:29 +0200 Subject: [PATCH 3/3] tools/psoc6/get-devs.py: Removal unused main section. Signed-off-by: enriquezgarc --- tools/psoc6/get-devs.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/tools/psoc6/get-devs.py b/tools/psoc6/get-devs.py index 8ea99b6434a1..4e612d0dd480 100644 --- a/tools/psoc6/get-devs.py +++ b/tools/psoc6/get-devs.py @@ -129,10 +129,6 @@ def get_devices_port(board=None, devs_yml=None): return port_list -if __name__ == "__main__": - pass - - def parser(): def main_parser_func(args): parser.print_help()