aboutsummaryrefslogtreecommitdiffstats
path: root/src/uart_rx.pio
blob: a9031764bedbf3e3add970666d2bca89ec2d69c7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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