forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: IFX-Anusha <Anusha.TR@infineon.com>
- Loading branch information
1 parent
af80dec
commit ba939cf
Showing
5 changed files
with
146 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import os | ||
import time | ||
from machine import Pin | ||
from machine import bitstream | ||
|
||
# Allocate pin based on board | ||
machine = os.uname().machine | ||
if "CY8CPROTO-062-4343W" in machine: | ||
pin_in = 'P12_0' | ||
pin_out = 'P13_7' | ||
|
||
elif "CY8CPROTO-063-BLE" in machine: | ||
pin_in = 'P5_3' | ||
pin_out = 'P12_6' | ||
|
||
expected_values = [8000, 5000, 8000, 5000, 8000, 50000, 8000, 5000, 3000, 1000, 3000, 10000, 3000, 1000, 3000, 1000] | ||
tolerance = 100 | ||
|
||
print("bitstream capture") | ||
input_pin = Pin(pin_in, Pin.IN) | ||
periods = [] | ||
last_value = 0 | ||
p0 = Pin(pin_out, Pin.OUT, value=0) | ||
start_time = time.ticks_us() | ||
current_value =0 | ||
for i in range(17): | ||
while (current_value == last_value): | ||
current_value=input_pin.value() | ||
current_time = time.ticks_us() | ||
time_period = time.ticks_diff(current_time, start_time) | ||
last_value=current_value | ||
start_time=current_time | ||
periods.append(time_period) | ||
|
||
for i in range(len(periods)-1): | ||
if abs((periods[i+1] - expected_values[i]) <= tolerance): | ||
print("true") | ||
else: | ||
print("false") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
bitstream capture | ||
true | ||
true | ||
true | ||
true | ||
true | ||
true | ||
true | ||
true | ||
true | ||
true | ||
true | ||
true | ||
true | ||
true | ||
true | ||
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import sys | ||
import time | ||
import os | ||
from machine import Pin | ||
from machine import bitstream | ||
|
||
|
||
# Allocate pin based on board | ||
machine = os.uname().machine | ||
if "CY8CPROTO-062-4343W" in machine: | ||
gpio_pin = 'P12_1' | ||
input_pin = 'P13_6' | ||
elif "CY8CPROTO-063-BLE" in machine: | ||
gpio_pin = 'P5_2' | ||
input_pin = 'P12_7' | ||
|
||
print("bitstream execution") | ||
timing = [3000000, 1000000, 8000000, 5000000] | ||
buf = bytearray([0xF0]) | ||
p0 = Pin(gpio_pin, Pin.OUT, value=0) | ||
input_pin = Pin(input_pin, Pin.IN) | ||
while(input_pin.value()==1): | ||
pass | ||
for i in range(2): | ||
bitstream(p0, 0, timing, buf) | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import sys | ||
import time | ||
import os | ||
import subprocess | ||
|
||
device = sys.argv[1] | ||
file_location = "./psoc6/test_inputs/main.py" | ||
remote_directory_path = "/" | ||
mpr_connect = f"../tools/mpremote/mpremote.py connect {device}" | ||
mpr_file_cp = f"{mpr_connect} cp {file_location} :{remote_directory_path}" | ||
mpr_ls = f"{mpr_connect} fs ls /" | ||
mpr_rm = f"{mpr_connect} fs rm " | ||
mpr_reset =f"../tools/mpremote/mpremote.py reset" | ||
|
||
def exec(cmd, op_file_path="null"): | ||
if cmd == mpr_rm: | ||
# Check if file is present already | ||
output = subprocess.run(f"{mpr_ls} | grep {op_file_path}", shell=True, capture_output=True) | ||
# If the file is present, remove it | ||
if output.returncode == 0: | ||
subprocess.run(f"{cmd} {op_file_path}", shell=True, capture_output=False) | ||
else: | ||
with open(op_file_path, "a") as file: | ||
subprocess.check_call(cmd, shell=True, stdout=file) | ||
|
||
#bistream generation | ||
|
||
print("copying file to remote device") | ||
exec(mpr_rm, "main.py") | ||
exec(mpr_file_cp) | ||
print("Resest board") | ||
subprocess.run(mpr_reset, shell=True) | ||
|
||
|
||
|
||
|