aboutsummaryrefslogtreecommitdiff
path: root/nicla
diff options
context:
space:
mode:
authorlonkaars <loek@pipeframe.xyz>2023-05-24 21:56:32 +0200
committerlonkaars <loek@pipeframe.xyz>2023-05-24 21:56:32 +0200
commitf6cf3917fc7982e1bfe0aef295c5b228199d78d4 (patch)
tree782ab03a99a558efb24d385420acdf748286fb88 /nicla
parentd0a1cc366e1657b4d65bd5c3bef35f4173ef2b15 (diff)
WIP nicla<->zumo integration
Diffstat (limited to 'nicla')
-rw-r--r--nicla/serial_test.py36
1 files changed, 30 insertions, 6 deletions
diff --git a/nicla/serial_test.py b/nicla/serial_test.py
index c8b84e5..276f6d1 100644
--- a/nicla/serial_test.py
+++ b/nicla/serial_test.py
@@ -13,10 +13,34 @@ def uart_send(byte):
udelay(1000)
zumo_rx.value(1)
-while True:
- # uart_send("a")
- for x in range(8):
- n = 1 << x
- uart_send(n)
- print(f"0x{n:02x}")
+__uart_buffer = bytearray()
+def uart_flush():
+ global __uart_buffer
+ print("UART FLUSH START")
+ for byte in __uart_buffer:
+ print(f"BYTE 0x{byte:02X}")
+ uart_send(byte) # dit is de oplossing
+ udelay(2000)
+ uart_send(byte)
+ udelay(2000)
+ uart_send(byte)
+ __uart_buffer = bytearray()
+
+def tx_irq_handler(pin):
+ if pin is zumo_tx:
+ uart_flush()
+
+zumo_tx.irq(trigger = Pin.IRQ_RISING, handler = tx_irq_handler)
+
+def uart_buffer(i):
+ global __uart_buffer
+ __uart_buffer.append(i)
+
+if __name__ == "__main__":
+ while True: # test commands
+ uart_buffer(0x29)
+ uart_buffer(0x70)
+ delay(1000)
+ uart_buffer(0xff)
+ uart_buffer(0x20)
delay(1000)