aboutsummaryrefslogtreecommitdiffstats
path: root/src/uart_rx.pio
diff options
context:
space:
mode:
authorLouis Burda <quent.burda@gmail.com>2022-12-02 16:06:32 +0100
committerLouis Burda <quent.burda@gmail.com>2022-12-02 17:18:16 +0100
commit0392766bc379448c907de2bce45d6b57621d95b5 (patch)
treeb87705bfb60a6569769b3c0125a910144c784436 /src/uart_rx.pio
parent6defee37f9939991bbf3152e2cd4e18593baa541 (diff)
downloadsxkbd-0392766bc379448c907de2bce45d6b57621d95b5.tar.gz
sxkbd-0392766bc379448c907de2bce45d6b57621d95b5.zip
Added split uart support based on chibios impl
Diffstat (limited to 'src/uart_rx.pio')
-rw-r--r--src/uart_rx.pio22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/uart_rx.pio b/src/uart_rx.pio
new file mode 100644
index 0000000..a903176
--- /dev/null
+++ b/src/uart_rx.pio
@@ -0,0 +1,22 @@
+.program uart_rx
+
+.wrap_target
+start:
+ wait 0 pin, 0 [6] ; wait for START bit
+
+ set x, 7 [4] ; read 8 DATA bits and offset
+ ; clock for better readings
+bitloop:
+ in pins, 1
+ jmp x--, bitloop [6]
+
+ jmp pin, outb ; got STOP bit, output byte
+
+error:
+ irq wait 0 ; no STOP bit,
+ wait 1 pin, 0 ; set err IRQ and await reset
+ jmp start
+
+outb:
+ push block
+.wrap