Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
56ae14d
tests/ports/psoc6: Add tests for machine.time_pulse_us().
NikhitaR-IFX Jul 11, 2025
ba81e79
tests/ports/psoc6: Adding tests for machine.time_pulse_us().
NikhitaR-IFX Jul 11, 2025
0eed55f
tests/ports/psoc6: Update pins and exp file.
NikhitaR-IFX Jul 14, 2025
5f1d67a
tests/ports/psoc6: Update pins and exp file.
NikhitaR-IFX Jul 14, 2025
4e718fe
tests/ports/psoc6: Remove multi tests.
NikhitaR-IFX Jul 14, 2025
f6e7e0e
tests/ports/psoc6: Copilot review fixes.
NikhitaR-IFX Jul 14, 2025
5c2a9ec
tests/ports/psoc6: Minor fixes as given by copilot.
NikhitaR-IFX Jul 14, 2025
88e7fa2
tests/ports/psoc6: Check modtime error case.
NikhitaR-IFX Jul 14, 2025
e2a0d08
psoc6/modtime: Try fix overflow error.
NikhitaR-IFX Jul 14, 2025
f75ac79
psoc6/modtime: Try fix overflow error.
NikhitaR-IFX Jul 14, 2025
c914ea1
psoc6/mpconfigport: Allow date range extension.
NikhitaR-IFX Jul 15, 2025
ce16f1b
tests/psoc6/board_ext_hw/single/time_pulse: Correct pins numbers.
NikhitaR-IFX Jul 15, 2025
aa779ce
tests/ports/psoc6/board_Ext_hw/single: Fix .exp naming.
NikhitaR-IFX Jul 15, 2025
b425f2d
tests/ports/psoc6: Add small delay to avoid sig gen issues.
NikhitaR-IFX Jul 15, 2025
0529b19
tests/ports/psoc6: Remove delay.
NikhitaR-IFX Jul 15, 2025
9b9130d
tests/ports/psoc6: Stabilize time_pulse_us tests.
NikhitaR-IFX Jul 21, 2025
294d5b0
tests/ports/psoc6: Add test setup diag.
NikhitaR-IFX Jul 21, 2025
a7c2017
tests/ports/psoc6: Refactor time_pulse_us test.
NikhitaR-IFX Jul 23, 2025
8340aa2
test/ports/psoc6/../time_pulse_us.py: Fixed HIL pin.
jaenrig-ifx Jul 23, 2025
ca3d0c5
tests/ports/psoc6/run_psoc6_test.sh: Set time_pulse_test boards.
jaenrig-ifx Jul 23, 2025
6921e99
tests/ports/psoc6/run_psoc6_test.sh: Disable time_pulse momentarily.
jaenrig-ifx Jul 23, 2025
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
2 changes: 1 addition & 1 deletion ports/psoc6/modtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,6 @@ static mp_obj_t mp_time_time_get(void) {
mp_raise_ValueError(MP_ERROR_TEXT("cyhal_rtc_read failed !"));
}

return mp_obj_new_int_from_ull(timeutils_seconds_since_epoch(current_date_time.tm_year, current_date_time.tm_mon, current_date_time.tm_mday,
return timeutils_obj_from_timestamp(timeutils_seconds_since_epoch(current_date_time.tm_year, current_date_time.tm_mon, current_date_time.tm_mday,
current_date_time.tm_hour, current_date_time.tm_min, current_date_time.tm_sec));
}
3 changes: 3 additions & 0 deletions ports/psoc6/mpconfigport.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@
#define MICROPY_PY_MACHINE_PDM_PCM (1)
#define MICROPY_PY_MACHINE_PDM_PCM_RING_BUF (1)

#define MICROPY_TIME_SUPPORT_Y1969_AND_BEFORE (1)

#define MICROPY_PY_MACHINE_PULSE (1)
// VFS
#define MICROPY_VFS (1)
#define MICROPY_READER_VFS (1)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
53 changes: 53 additions & 0 deletions tests/ports/psoc6/board_ext_hw/multi/time_pulse_sig_gen.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
from machine import Pin
import os
import time

# Allocate pin based on board
board = os.uname().machine
if "CY8CPROTO-062-4343W" in board:
pulse_out_pin = "P12_1"
ack_in_pin = "P12_3"
elif "CY8CPROTO-063-BLE" in board:
pulse_out_pin = "P5_2"
ack_in_pin = "P6_2"
elif "CY8CKIT-062S2-AI" in board:
pulse_out_pin = "P9_5"
ack_in_pin = "P9_7"

ack_recvd = False


def cback(pin):
global ack_recvd
ack_recvd = True


def blocking_delay_ms(delay_ms):
start = time.ticks_ms()
while time.ticks_diff(time.ticks_ms(), start) < delay_ms:
pass


pulse_out = Pin(pulse_out_pin, Pin.OUT)
ack_in = Pin(ack_in_pin, Pin.IN)
ack_in.irq(trigger=Pin.IRQ_RISING, handler=cback)

# Starting condition always low pulse
pulse_out.low()

while not ack_recvd:
pass # Wait for the Begin ACK signal

blocking_delay_ms(100)

# Generate high pulse
pulse_out.high()

# Wait for 1sec to time the pulse
blocking_delay_ms(1000)

pulse_out.low()

# Deinitialize the pins
pulse_out.deinit()
ack_in.deinit()
42 changes: 42 additions & 0 deletions tests/ports/psoc6/board_ext_hw/multi/time_pulse_us.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
from machine import Pin, time_pulse_us
import os
import time

# Allocate pin based on board
board = os.uname().machine
if "CY8CPROTO-062-4343W" in board:
pulse_in_pin = "P12_1"
ack_out_pin = "P12_3"
elif "CY8CPROTO-063-BLE" in board:
pulse_in_pin = "P5_2"
ack_out_pin = "P6_2"
elif "CY8CKIT-062S2-AI" in board:
pulse_in_pin = "P9_2"
ack_out_pin = "P9_7"


def blocking_delay_ms(delay_ms):
start = time.ticks_ms()
while time.ticks_diff(time.ticks_ms(), start) < delay_ms:
pass


pulse_in = Pin(pulse_in_pin, Pin.IN, Pin.PULL_DOWN)
ack_out = Pin(ack_out_pin, Pin.OUT)
ack_out.low()

width = 0

# Send begin ack to start generating pulse
ack_out.high()

# Measure the pulse width
width = time_pulse_us(pulse_in, 1, 10000000)

print(
f"Pulse timing verified: {True if (0.98 < (width / 1000000) < 1.2) else 'False, width=' + str(width / 1000000)}"
)

# Deinitialize the pins
pulse_in.deinit()
ack_out.deinit()
1 change: 1 addition & 0 deletions tests/ports/psoc6/board_ext_hw/multi/time_pulse_us.py.exp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Pulse timing verified: True
27 changes: 20 additions & 7 deletions tests/ports/psoc6/run_psoc6_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ usage() {
echo " pdm_pcm run pdm_pcm tests"
echo " bitstream run bitstream tests"
echo " watchdog run watchdog tests"
echo " time_pulse run time_pulse test"
echo " multi-instance run multiple board instances tests"
echo " help display this help"
echo
Expand Down Expand Up @@ -218,6 +219,7 @@ i2c_tests() {
run_tests "i2c" ${dev_test} "${tests_psoc6_dir}/board_ext_hw/single/i2c.py"
}


uart_tests() {
run_tests "uart" ${dev_test} "${tests_psoc6_dir}/board_ext_hw/single/uart.py"
}
Expand All @@ -237,6 +239,11 @@ i2s_tests() {
"" "i2s_tx" ${dev_stub} "${tests_psoc6_dir}/board_ext_hw/multi/i2s_tx.py"
}

time_pulse_tests() {
run_tests "time_pulse" ${dev_test} "${tests_psoc6_dir}/board_ext_hw/multi/time_pulse_us.py" \
"" "time_pulse_sig_gen" ${dev_stub} "${tests_psoc6_dir}/board_ext_hw/multi/time_pulse_sig_gen.py"
}

pdm_pcm_tests() {
run_tests "pdm_pcm" ${dev_test} "${tests_psoc6_dir}/board_ext_hw/multi/pdm_pcm_rx.py" \
"" "pdm_pcm_tx" ${dev_stub} "${tests_psoc6_dir}/board_ext_hw/multi/pdm_pcm_tx.py"
Expand Down Expand Up @@ -301,7 +308,7 @@ run_ci_tests() {

dev_test=${devs_a[0]}
pwm_tests

if [ "${board}" == "CY8CPROTO-062-4343W" ] || [ "${board}" == "CY8CPROTO-063-BLE" ]; then
dev_test=${devs_a[0]}
else
Expand Down Expand Up @@ -351,6 +358,7 @@ run_ci_tests() {
fi
i2s_tests


if [ "${board}" == "CY8CPROTO-062-4343W" ] || [ "${board}" == "CY8CPROTO-063-BLE" ]; then
dev_test=${devs_b[0]}
dev_stub=${devs_a[0]}
Expand All @@ -366,13 +374,15 @@ run_ci_tests() {
dev_test=${devs_a[0]}
dev_stub=${devs_b[0]}
bitstream_tests
#else
# if [ "${board}" == "CY8CKIT-062S2-AI" ]; then
# dev_test=${devs_c[0]}
# dev_stub=${devs_b[0]}
# fi
else
if [ "${board}" == "CY8CKIT-062S2-AI" ]; then
dev_test=${devs_b[0]}
dev_stub=${devs_c[0]}
fi
fi
# bitstream_tests
# TODO:Enable this 2 test properly in the HIL!
# bitstream_tests
#time_pulse_tests

dev_test=${devs[0]}
wdt_tests
Expand Down Expand Up @@ -419,6 +429,9 @@ case ${test_suite} in
"i2s")
i2s_tests
;;
"time_pulse")
time_pulse_tests
;;
"pdm_pcm")
pdm_pcm_tests
;;
Expand Down
Loading