summaryrefslogtreecommitdiffstats
path: root/sw/z80/tests/pio/main.c
blob: 3687f504c25a4de3f362c5e2c4a1640539aee926 (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
// #include "pio.h"

#include <stdint.h>

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

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

    ;; set bit mode
    ld a, #0xCF
    ;; load cmd addr 
    ld c, #PIO_B_CMD
    out (c), a
    ;; set 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;
    // }
}