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

Subversion Repositories or1k

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

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

powered by: WebSVN 2.1.0

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