From 625105d830c95c6dfaf1eca2c7ea959397951c8f Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Wed, 18 Oct 2023 16:15:47 +0200 Subject: [PATCH 1/4] ports/psoc6/machine_pin.c: Fixed on(), off() polarity. Signed-off-by: enriquezgarc --- ports/psoc6/modules/machine/machine_pin.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ports/psoc6/modules/machine/machine_pin.c b/ports/psoc6/modules/machine/machine_pin.c index 8b1f8b08557b..3482d6f090cd 100644 --- a/ports/psoc6/modules/machine/machine_pin.c +++ b/ports/psoc6/modules/machine/machine_pin.c @@ -330,8 +330,8 @@ STATIC const mp_rom_map_elem_t machine_pin_locals_dict_table[] = { { MP_ROM_QSTR(MP_QSTR_value), MP_ROM_PTR(&machine_pin_value_obj) }, { MP_ROM_QSTR(MP_QSTR_low), MP_ROM_PTR(&machine_pin_low_obj) }, { MP_ROM_QSTR(MP_QSTR_high), MP_ROM_PTR(&machine_pin_high_obj) }, - { MP_ROM_QSTR(MP_QSTR_off), MP_ROM_PTR(&machine_pin_high_obj) }, - { MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&machine_pin_low_obj) }, + { MP_ROM_QSTR(MP_QSTR_off), MP_ROM_PTR(&machine_pin_low_obj) }, + { MP_ROM_QSTR(MP_QSTR_on), MP_ROM_PTR(&machine_pin_high_obj) }, // Const { MP_ROM_QSTR(MP_QSTR_IN), MP_ROM_INT(GPIO_MODE_IN) }, From 68e3aa90a82f23766f6b4a20e4a380e8b5563a84 Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Wed, 18 Oct 2023 16:18:19 +0200 Subject: [PATCH 2/4] ports/psoc6/pin.py: Modified for new board support. Signed-off-by: enriquezgarc --- tests/psoc6/pin.py | 6 ++---- tests/psoc6/pin.py.exp | 2 -- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/tests/psoc6/pin.py b/tests/psoc6/pin.py index 0f03c6ac3706..8c7ba1574ef9 100644 --- a/tests/psoc6/pin.py +++ b/tests/psoc6/pin.py @@ -9,15 +9,14 @@ pin1_name = "P13_7" pin2_name = "P0_4" elif "CY8CPROTO-063-BLE" in machine: - print("SKIP") - raise SystemExit + pin1_name = "P6_3" + pin2_name = "P0_4" # Tests for Output pin # Instantiate output pin for led operation # Constr p1 = Pin(pin1_name) p1.init(Pin.OUT) -print(p1) # Pin:111 or P13_7, Mode=OUT, Pull=None, Value=1 p1.value(0) # Led glows print(p1.value()) # None @@ -31,6 +30,5 @@ # Tests for Input pin # Instantiate input pin for button operation 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/pin.py.exp b/tests/psoc6/pin.py.exp index 99572fff665c..37df6a5b2f32 100644 --- a/tests/psoc6/pin.py.exp +++ b/tests/psoc6/pin.py.exp @@ -1,6 +1,4 @@ -Pin:111 or P13_7, Mode=OUT, Pull=None None None None -Pin:4 or P0_4, Mode=IN, Pull=None 1 From ae0a65b1785b0ced5bffba7cae999e17e42b4513 Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Wed, 18 Oct 2023 16:19:57 +0200 Subject: [PATCH 3/4] tests/psoc6/dut: Added pin test requiring hw dut connections. Signed-off-by: enriquezgarc --- tests/psoc6/dut/i2c_master_slave.py | 0 tests/psoc6/dut/pin.py | 43 +++++++++++++++++++++++++++++ tests/psoc6/dut/pin.py.exp | 8 ++++++ 3 files changed, 51 insertions(+) delete mode 100644 tests/psoc6/dut/i2c_master_slave.py create mode 100644 tests/psoc6/dut/pin.py create mode 100644 tests/psoc6/dut/pin.py.exp diff --git a/tests/psoc6/dut/i2c_master_slave.py b/tests/psoc6/dut/i2c_master_slave.py deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/tests/psoc6/dut/pin.py b/tests/psoc6/dut/pin.py new file mode 100644 index 000000000000..298fb4406d65 --- /dev/null +++ b/tests/psoc6/dut/pin.py @@ -0,0 +1,43 @@ +import os +from machine import Pin +import machine + +# Allocate pin based on board +machine = os.uname().machine +if "CY8CPROTO-062-4343W" in machine: + pin1_name = "P13_7" + pin2_name = "P13_6" +elif "CY8CPROTO-063-BLE" in machine: + pin1_name = "P6_3" + pin2_name = "P6_2" + +# Pin out and pin in must be connected +# together in the board + +pin_out = Pin(pin1_name) +pin_out.init(Pin.OUT) +pin_in = Pin(pin2_name, Pin.IN) + +pin_out.value(1) +print("pin out value 1: ", pin_in.value() == 1) + +pin_out.value(0) +print("pin out value 0: ", pin_in.value() == 0) + +pin_out.value(True) +print("pin out value True: ", pin_in.value() == True) + +pin_out.value(False) +print("pin out value False: ", pin_in.value() == False) + +pin_out.high() +print("pin out value high: ", pin_in.value() == 1) + +pin_out.low() +print("pin out value low: ", pin_in.value() == 0) + +pin_out.on() +print("pin out value on: ", pin_in.value() == 1) + +pin_out.off() +print("pin out value off: ", pin_in.value() == 0) diff --git a/tests/psoc6/dut/pin.py.exp b/tests/psoc6/dut/pin.py.exp new file mode 100644 index 000000000000..98817fc78542 --- /dev/null +++ b/tests/psoc6/dut/pin.py.exp @@ -0,0 +1,8 @@ +pin out value 1: True +pin out value 0: True +pin out value True: True +pin out value False: True +pin out value high: True +pin out value low: True +pin out value on: True +pin out value off: True From 7ada12bcd47db6ecb5e65968e2b142bddae8741e Mon Sep 17 00:00:00 2001 From: enriquezgarc Date: Wed, 18 Oct 2023 17:23:15 +0200 Subject: [PATCH 4/4] tests/psoc6: Modification in test to accept new board. Signed-off-by: enriquezgarc --- tests/psoc6/i2c_hard.py | 5 ++--- tests/psoc6/i2c_hard.py.exp | 1 - tests/psoc6/i2c_soft.py | 5 ++--- tests/psoc6/i2c_soft.py.exp | 1 - tests/psoc6/pwm.py | 3 +-- tests/psoc6/spi_soft.py | 5 +++-- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/tests/psoc6/i2c_hard.py b/tests/psoc6/i2c_hard.py index 4ddeee167b4a..af5ac5987051 100644 --- a/tests/psoc6/i2c_hard.py +++ b/tests/psoc6/i2c_hard.py @@ -8,10 +8,9 @@ scl_pin = "P6_0" sda_pin = "P6_1" elif "CY8CPROTO-063-BLE" in machine: - print("SKIP") - raise SystemExit + scl_pin = "P6_4" + sda_pin = "P6_5" i2c = I2C(id=0, scl=scl_pin, sda=sda_pin, freq=400000) -print(i2c) print(i2c.scan()) diff --git a/tests/psoc6/i2c_hard.py.exp b/tests/psoc6/i2c_hard.py.exp index 8d60f88ee685..fe51488c7066 100644 --- a/tests/psoc6/i2c_hard.py.exp +++ b/tests/psoc6/i2c_hard.py.exp @@ -1,2 +1 @@ -I2C(0, freq=400000, scl=48, sda=49) [] diff --git a/tests/psoc6/i2c_soft.py b/tests/psoc6/i2c_soft.py index da1b8c55a9ad..4178f19363a9 100644 --- a/tests/psoc6/i2c_soft.py +++ b/tests/psoc6/i2c_soft.py @@ -8,10 +8,9 @@ scl_pin = "P6_0" sda_pin = "P6_1" elif "CY8CPROTO-063-BLE" in machine: - print("SKIP") - raise SystemExit + scl_pin = "P6_4" + sda_pin = "P6_5" si2c = SoftI2C(scl=scl_pin, sda=sda_pin, freq=400000) -print(si2c) print(si2c.scan()) diff --git a/tests/psoc6/i2c_soft.py.exp b/tests/psoc6/i2c_soft.py.exp index 49bfede5efe0..fe51488c7066 100644 --- a/tests/psoc6/i2c_soft.py.exp +++ b/tests/psoc6/i2c_soft.py.exp @@ -1,2 +1 @@ -SoftI2C(scl=48, sda=49, freq=500000) [] diff --git a/tests/psoc6/pwm.py b/tests/psoc6/pwm.py index f1c42ad39fcc..5ed63e403e35 100644 --- a/tests/psoc6/pwm.py +++ b/tests/psoc6/pwm.py @@ -7,8 +7,7 @@ if "CY8CPROTO-062-4343W" in machine: pin_name = "P12_0" elif "CY8CPROTO-063-BLE" in machine: - print("SKIP") - raise SystemExit + pin_name = "P6_3" pwm = PWM(pin_name, freq=50, duty_u16=8192, invert=0) print(pwm) diff --git a/tests/psoc6/spi_soft.py b/tests/psoc6/spi_soft.py index 947c7aceece4..fe94eadb4e52 100644 --- a/tests/psoc6/spi_soft.py +++ b/tests/psoc6/spi_soft.py @@ -9,8 +9,9 @@ mosi_pin = "P9_0" miso_pin = "P9_1" elif "CY8CPROTO-063-BLE" in machine: - print("SKIP") - raise SystemExit + sck_pin = "P9_2" + mosi_pin = "P9_0" + miso_pin = "P9_1" spi = SoftSPI(baudrate=100000, polarity=1, phase=0, sck=sck_pin, mosi=mosi_pin, miso=miso_pin) print(spi)