Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Machine 063 validate #100

Merged
merged 4 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ports/psoc6/modules/machine/machine_pin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) },
Expand Down
Empty file.
43 changes: 43 additions & 0 deletions tests/psoc6/dut/pin.py
Original file line number Diff line number Diff line change
@@ -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)

jaenrig-ifx marked this conversation as resolved.
Show resolved Hide resolved
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)
8 changes: 8 additions & 0 deletions tests/psoc6/dut/pin.py.exp
Original file line number Diff line number Diff line change
@@ -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
5 changes: 2 additions & 3 deletions tests/psoc6/i2c_hard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
1 change: 0 additions & 1 deletion tests/psoc6/i2c_hard.py.exp
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
I2C(0, freq=400000, scl=48, sda=49)
[]
5 changes: 2 additions & 3 deletions tests/psoc6/i2c_soft.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
1 change: 0 additions & 1 deletion tests/psoc6/i2c_soft.py.exp
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
SoftI2C(scl=48, sda=49, freq=500000)
[]
6 changes: 2 additions & 4 deletions tests/psoc6/pin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
2 changes: 0 additions & 2 deletions tests/psoc6/pin.py.exp
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions tests/psoc6/pwm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 3 additions & 2 deletions tests/psoc6/spi_soft.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading