Ch-6 clean
This commit is contained in:
@@ -34,7 +34,7 @@ sm = rp2pio.StateMachine(
|
||||
frequency=2000,
|
||||
)
|
||||
|
||||
buffer = array.array('I', [0])
|
||||
buffer = array.array("I", [0])
|
||||
|
||||
# read the data
|
||||
sm.readinto(buffer)
|
||||
|
||||
@@ -30,14 +30,12 @@ sm = rp2pio.StateMachine(
|
||||
)
|
||||
|
||||
|
||||
buffer = array.array('I', [0])
|
||||
buffer = array.array("I", [0])
|
||||
|
||||
sm.write(array.array('I', [0b01101000_00000000_00000000_00000000]))
|
||||
sm.write(array.array("I", [0b01101000_00000000_00000000_00000000]))
|
||||
# read the data
|
||||
sm.readinto(buffer)
|
||||
print("Initial Y: {0} 0b{0:032b} 0x{0:x}".format(buffer[0]))
|
||||
|
||||
sm.readinto(buffer)
|
||||
print("Y bit extracted: {0} 0b{0:032b} 0x{0:x}".format(buffer[0]))
|
||||
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import rp2pio
|
||||
import adafruit_pioasm
|
||||
import array
|
||||
|
||||
|
||||
def scenario(test_data, bit_to_extract, expected):
|
||||
program = f"""
|
||||
.program extract_bit
|
||||
@@ -41,7 +42,7 @@ def scenario(test_data, bit_to_extract, expected):
|
||||
assembled,
|
||||
frequency=2000,
|
||||
) as sm:
|
||||
buffer = array.array('I', [0])
|
||||
buffer = array.array("I", [0])
|
||||
|
||||
print("source bits: {0} 0b{0:032b} 0x{0:x}".format(test_data))
|
||||
sm.readinto(buffer)
|
||||
@@ -55,6 +56,7 @@ def scenario(test_data, bit_to_extract, expected):
|
||||
print("Y bit expected: {0} 0b{0:032b} 0x{0:x}".format(expected))
|
||||
print("")
|
||||
|
||||
|
||||
def pull_scenario(test_data, bit_to_extract, expected):
|
||||
program = f"""
|
||||
.program extract_bit_pull
|
||||
@@ -92,8 +94,8 @@ def pull_scenario(test_data, bit_to_extract, expected):
|
||||
assembled,
|
||||
frequency=2000,
|
||||
) as sm:
|
||||
sm.write(array.array('I', [test_data]))
|
||||
buffer = array.array('I', [0])
|
||||
sm.write(array.array("I", [test_data]))
|
||||
buffer = array.array("I", [0])
|
||||
|
||||
print("source bits: {0} 0b{0:032b} 0x{0:x}".format(test_data))
|
||||
sm.readinto(buffer)
|
||||
@@ -105,7 +107,8 @@ def pull_scenario(test_data, bit_to_extract, expected):
|
||||
if buffer[0] != expected:
|
||||
print("Didn't get what I expected")
|
||||
print("Y bit expected: {0} 0b{0:032b} 0x{0:x}".format(expected))
|
||||
print("")
|
||||
print("")
|
||||
|
||||
|
||||
scenario(0b101, 1, 0)
|
||||
scenario(0b110, 1, 1)
|
||||
@@ -126,4 +129,3 @@ pull_scenario(0b10111000_00000000_00000000_00000000, 30, 0)
|
||||
# v
|
||||
pull_scenario(0b10111000_00000000_00000000_00000000, 31, 1)
|
||||
pull_scenario(0b01111000_00000000_00000000_00000000, 31, 0)
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ sm = rp2pio.StateMachine(
|
||||
frequency=2000,
|
||||
)
|
||||
|
||||
buffer = array.array('i', [0])
|
||||
buffer = array.array("i", [0])
|
||||
|
||||
# read the data
|
||||
sm.readinto(buffer)
|
||||
|
||||
@@ -26,7 +26,7 @@ sm = rp2pio.StateMachine(
|
||||
frequency=2000,
|
||||
)
|
||||
|
||||
buffer = array.array('I', [0])
|
||||
buffer = array.array("I", [0])
|
||||
|
||||
# read the data
|
||||
sm.readinto(buffer)
|
||||
|
||||
@@ -28,7 +28,7 @@ sm = rp2pio.StateMachine(
|
||||
frequency=2000,
|
||||
)
|
||||
|
||||
buffer = array.array('I', [0])
|
||||
buffer = array.array("I", [0])
|
||||
|
||||
# read the data
|
||||
sm.readinto(buffer)
|
||||
|
||||
@@ -19,7 +19,7 @@ assembled = adafruit_pioasm.assemble(program)
|
||||
## set up a statemachine
|
||||
sm = rp2pio.StateMachine(assembled, frequency=2000)
|
||||
|
||||
buffer = array.array('I', [0])
|
||||
buffer = array.array("I", [0])
|
||||
|
||||
# read the data
|
||||
sm.readinto(buffer)
|
||||
|
||||
@@ -26,7 +26,7 @@ sm = rp2pio.StateMachine(
|
||||
frequency=2000,
|
||||
)
|
||||
|
||||
buffer = array.array('I', [0])
|
||||
buffer = array.array("I", [0])
|
||||
|
||||
# read the data
|
||||
sm.readinto(buffer)
|
||||
|
||||
@@ -29,7 +29,7 @@ sm = rp2pio.StateMachine(
|
||||
frequency=2000,
|
||||
)
|
||||
|
||||
buffer = array.array('I', [0])
|
||||
buffer = array.array("I", [0])
|
||||
|
||||
# read the data
|
||||
sm.readinto(buffer)
|
||||
|
||||
@@ -36,7 +36,7 @@ sm = rp2pio.StateMachine(
|
||||
frequency=2000,
|
||||
)
|
||||
|
||||
buffer = array.array('I', [0])
|
||||
buffer = array.array("I", [0])
|
||||
|
||||
# read the data
|
||||
sm.readinto(buffer)
|
||||
|
||||
Reference in New Issue
Block a user