OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [bootloaders/] [orpmon/] [cmds/] [touch.c] - Blame information for rev 628

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 marcus.erl
#include "common.h"
2
#include "support.h"
3
#include "spi.h"
4
 
5 406 julius
int touch_cmd(int argc, char *argv[])
6 2 marcus.erl
{
7 406 julius
        unsigned long x, y, z1, z2;
8
        float res;
9 2 marcus.erl
 
10 406 julius
        if (argc == 0) {
11
                printf("usage:  -r  read coordinates\n");
12
                printf
13
                    ("        -c  read coordinates in a loop (press any key to exit)\n");
14
        } else if (argc == 1) {
15
                if (!strcmp(argv[0], "-r")) {
16
                        spi_init(0, 1000000, 21, 0, 1, 0);
17
                        printf("X = %.3lx\n", spi_xmit(0xd3l << 13) & 0xfff);
18
                        printf("Y = %.3lx\n", spi_xmit(0x93l << 13) & 0xfff);
19
                } else if (!strcmp(argv[0], "-c")) {
20
                        spi_init(0, 1000000, 21, 0, 1, 0);
21
                        while (1) {
22
                                x = spi_xmit(0xd3l << 13) & 0xfff;
23
                                z1 = spi_xmit(0xb3l << 13) & 0xfff;
24
                                z2 = spi_xmit(0xc3l << 13) & 0xfff;
25
                                res = (z2 / z1) - 1;
26
                                res = ((float)x * res) / 4096;
27
                                if ((int)res < 20) {
28
                                        y = spi_xmit(0x93l << 13) & 0xfff;
29
                                        printf("X = %.3lx\n", x);
30
                                        printf("Y = %.3lx\n\n", y);
31
                                }
32
                                if (testc())
33
                                        break;
34
                        }
35
                }
36
        } else {
37
                printf("usage:  -r  read coordinates\n");
38
                printf
39
                    ("        -c  read coordinates in a loop (press any key to exit)\n");
40
        }
41 2 marcus.erl
 
42 406 julius
        return 0;
43 2 marcus.erl
}
44 406 julius
 
45
void module_touch_init(void)
46 2 marcus.erl
{
47 406 julius
        register_command("touch", "", "touch screen utility", touch_cmd);
48 2 marcus.erl
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.