Skip to content

Commit

Permalink
tests/psoc6: Added board pin allocation and skip if module unavailable.
Browse files Browse the repository at this point in the history
Signed-off-by: enriquezgarc <enriquezgarcia.external@infineon.com>
  • Loading branch information
jaenrig-ifx committed Sep 19, 2023
1 parent 86c1f65 commit 006fa12
Show file tree
Hide file tree
Showing 9 changed files with 92 additions and 11 deletions.
14 changes: 12 additions & 2 deletions tests/psoc6/adc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 10 additions & 1 deletion tests/psoc6/adcblock.py
Original file line number Diff line number Diff line change
@@ -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:
Expand Down
12 changes: 11 additions & 1 deletion tests/psoc6/i2c_hard.py
Original file line number Diff line number Diff line change
@@ -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())
12 changes: 11 additions & 1 deletion tests/psoc6/i2c_soft.py
Original file line number Diff line number Diff line change
@@ -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())
8 changes: 7 additions & 1 deletion tests/psoc6/multi/network.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 7 additions & 1 deletion tests/psoc6/multi/network_config.py
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
14 changes: 12 additions & 2 deletions tests/psoc6/pin.py
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
11 changes: 10 additions & 1 deletion tests/psoc6/pwm.py
Original file line number Diff line number Diff line change
@@ -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())
Expand Down
13 changes: 12 additions & 1 deletion tests/psoc6/spi_soft.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 006fa12

Please sign in to comment.