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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [orpmon/] [cmds/] [touch.c] - Blame information for rev 1768

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

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

powered by: WebSVN 2.1.0

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