File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 55# Allocate pin based on board
66board = os .uname ().machine
77if "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 "
1010elif "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 "
1313elif "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
1717ack_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 )
3232ack_in = Pin (ack_in_pin , Pin .IN )
3333ack_in .irq (trigger = Pin .IRQ_RISING , handler = cback )
3434
3535# Starting condition always low pulse
3636pulse_out .low ()
37- blocking_delay_ms (500 )
3837
3938while 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
4544pulse_out .high ()
46- while not ack_recvd :
47- pass # Wait for high received ACK signal
4845
4946# Wait for 1sec to time the pulse
5047blocking_delay_ms (1000 )
5148
5249pulse_out .low ()
5350
54- pulse_out .deinit () # Deinitialize the pulse output pin
51+ # Deinitialize the pins
52+ pulse_out .deinit ()
5553ack_in .deinit ()
Original file line number Diff line number Diff line change 55# Allocate pin based on board
66board = os .uname ().machine
77if "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 "
1010elif "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 "
1313elif "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
2518def blocking_delay_ms (delay_ms ):
@@ -34,18 +27,10 @@ def blocking_delay_ms(delay_ms):
3427
3528width = 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
4131blocking_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
4934ack_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
5844pulse_in .deinit ()
5945ack_out .deinit ()
Original file line number Diff line number Diff 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-
214210pin_tests () {
215211 run_tests " pin" ${dev_test} " ${tests_psoc6_dir} /board_ext_hw/single/pin.py"
216212}
You can’t perform that action at this time.
0 commit comments