diff options
author | lonkaars <loek@pipeframe.xyz> | 2023-05-24 18:03:05 +0200 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2023-05-24 18:03:05 +0200 |
commit | cef95354c69745f782a95d37f4b0e7bbf02e106a (patch) | |
tree | ff3a2ce26b1785dc88eb272f41e24ee997c6b4ed /nicla/serial_test.py | |
parent | 4568db72dc3f9694ecae3506fc3de6ffc948b24f (diff) |
uart working
Diffstat (limited to 'nicla/serial_test.py')
-rw-r--r-- | nicla/serial_test.py | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/nicla/serial_test.py b/nicla/serial_test.py index bef43a2..c8b84e5 100644 --- a/nicla/serial_test.py +++ b/nicla/serial_test.py @@ -1,21 +1,22 @@ -from pyb import Pin, delay +from pyb import Pin, delay, udelay zumo_tx = Pin("PA10", Pin.IN) zumo_rx = Pin("PA9", Pin.OUT_PP) -def uart_send(s): +def uart_send(byte): zumo_rx.value(0) - byte = ord(s) - print("START BIT") - delay(2) + udelay(1000) for x in range(8): bit = (byte & (1 << 7)) >> 7 byte <<= 1 zumo_rx.value(bit) - print(f"BIT[{x}] = {bit}") - delay(2) - print("STOP BIT") + udelay(1000) zumo_rx.value(1) while True: - uart_send("a") + # uart_send("a") + for x in range(8): + n = 1 << x + uart_send(n) + print(f"0x{n:02x}") + delay(1000) |