Skip to content

Commit 9f9ed50

Browse files
NikhitaR-IFXjaenrig-ifx
authored andcommitted
tests/ports/psoc6: Refactor time_pulse_us test.
Signed-off-by: NikhitaR-IFX <nikhita.rajasekhar@infineon.com>
1 parent f1e59e7 commit 9f9ed50

3 files changed

Lines changed: 19 additions & 39 deletions

File tree

tests/ports/psoc6/board_ext_hw/multi/time_pulse_sig_gen.py

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
# Allocate pin based on board
66
board = os.uname().machine
77
if "CY8CPROTO-062-4343W" in board:
8-
pulse_out_pin = "P9_7"
9-
ack_in_pin = "P9_6"
8+
pulse_out_pin = "P12_1"
9+
ack_in_pin = "P12_3"
1010
elif "CY8CPROTO-063-BLE" in board:
11-
pulse_out_pin = "P9_4"
12-
ack_in_pin = "P9_6"
11+
pulse_out_pin = "P5_2"
12+
ack_in_pin = "P6_2"
1313
elif "CY8CKIT-062S2-AI" in board:
14-
pulse_out_pin = "P9_7"
15-
ack_in_pin = "P9_6"
14+
pulse_out_pin = "P9_5"
15+
ack_in_pin = "P9_7"
1616

1717
ack_recvd = False
1818

@@ -28,28 +28,26 @@ def blocking_delay_ms(delay_ms):
2828
pass
2929

3030

31-
pulse_out = Pin(pulse_out_pin, Pin.OUT, value=False)
31+
pulse_out = Pin(pulse_out_pin, Pin.OUT)
3232
ack_in = Pin(ack_in_pin, Pin.IN)
3333
ack_in.irq(trigger=Pin.IRQ_RISING, handler=cback)
3434

3535
# Starting condition always low pulse
3636
pulse_out.low()
37-
blocking_delay_ms(500)
3837

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

42-
ack_recvd = False
41+
blocking_delay_ms(100)
4342

4443
# Generate high pulse
4544
pulse_out.high()
46-
while not ack_recvd:
47-
pass # Wait for high received ACK signal
4845

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

5249
pulse_out.low()
5350

54-
pulse_out.deinit() # Deinitialize the pulse output pin
51+
# Deinitialize the pins
52+
pulse_out.deinit()
5553
ack_in.deinit()

tests/ports/psoc6/board_ext_hw/multi/time_pulse_us.py

Lines changed: 9 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,14 @@
55
# Allocate pin based on board
66
board = os.uname().machine
77
if "CY8CPROTO-062-4343W" in board:
8-
pulse_in_pin = "P9_7"
9-
ack_out_pin = "P9_6"
8+
pulse_in_pin = "P12_1"
9+
ack_out_pin = "P12_3"
1010
elif "CY8CPROTO-063-BLE" in board:
11-
pulse_in_pin = "P9_4"
12-
ack_out_pin = "P9_6"
11+
pulse_in_pin = "P5_2"
12+
ack_out_pin = "P6_2"
1313
elif "CY8CKIT-062S2-AI" in board:
14-
pulse_in_pin = "P9_7"
15-
ack_out_pin = "P9_6"
16-
17-
pin_high_received = False
18-
19-
20-
def cback(pin):
21-
global pin_high_received
22-
pin_high_received = True
14+
pulse_in_pin = "P9_5"
15+
ack_out_pin = "P9_7"
2316

2417

2518
def blocking_delay_ms(delay_ms):
@@ -34,18 +27,10 @@ def blocking_delay_ms(delay_ms):
3427

3528
width = 0
3629

37-
pulse_in.irq(trigger=Pin.IRQ_RISING, handler=cback)
38-
39-
# Send begin ack to start generating pulse
40-
ack_out.high()
30+
# Wait initially for a brief period
4131
blocking_delay_ms(1000)
42-
ack_out.low()
4332

44-
# Wait to receive pulse high signal
45-
while not pin_high_received:
46-
pass
47-
48-
# Send pulse high recvd ack
33+
# Send begin ack to start generating pulse
4934
ack_out.high()
5035

5136
# Measure the pulse width
@@ -55,5 +40,6 @@ def blocking_delay_ms(delay_ms):
5540
f"Pulse timing verified: {True if (0.98 < (width / 1000000) < 1.2) else 'False, width=' + str(width / 1000000)}"
5641
)
5742

43+
# Deinitialize the pins
5844
pulse_in.deinit()
5945
ack_out.deinit()

tests/ports/psoc6/run_psoc6_tests.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -207,10 +207,6 @@ pwm_tests() {
207207
run_tests "pwm" ${dev_test} "${tests_psoc6_dir}/board_ext_hw/single/pwm.py"
208208
}
209209

210-
#time_pulse_tests() {
211-
# run_tests "time_pulse" ${dev_test} "${tests_psoc6_dir}/board_ext_hw/single/time_pulse_us.py"
212-
#}
213-
214210
pin_tests() {
215211
run_tests "pin" ${dev_test} "${tests_psoc6_dir}/board_ext_hw/single/pin.py"
216212
}

0 commit comments

Comments
 (0)