summaryrefslogtreecommitdiffstats
path: root/sw/z80/tests/pio/main.c
blob: 7ac64bcf4672262abd77ab937b5ba4efda95ce32 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
// #include "pio.h"

#include <stdint.h>

#define PIO_A_DATA  0x10
#define PIO_B_DATA  0x11
#define PIO_A_CMD   0x12
#define PIO_B_CMD   0x13

void main(void)
{
    __asm
    ;; output variable
    ld h, #0x00

    ;; set bit mode
    ld c, #PIO_B_CMD

    ld a, #0xCF
    out (c), a

    ;; set all pins to output
    ld a, #0x00
    out (c), a

    ;; disable interrupts
    ld a, #0x0C
    out (c), a

    ;; load data addr
    ld c, #PIO_B_DATA
loop:
    out (c), h
    ld a, h

    cpl
    ld h, a
    jr loop
    __endasm; 

    // uint8_t i = 0;

    // pio_set_mode(PIO_A, PIO_MODE_BIT_IO, 0x00);
    // pio_set_interrupts(PIO_A, PIO_INT_DISABLE);

    // while (1) {
    //     pio_write(PIO_A, i);
    //     i = ~i;
    // }
}