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

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [sw/] [dev/] [kptest.c] - Blame information for rev 48

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

Line No. Rev Author Line
1 29 dgisselq
////////////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    kptest.c
4
//
5
// Project:     CMod S6 System on a Chip, ZipCPU demonstration project
6
//
7
// Purpose:     To test and demonstrate that the keypad works.
8
//
9
// Creator:     Dan Gisselquist, Ph.D.
10
//              Gisselquist Technology, LLC
11
//
12
////////////////////////////////////////////////////////////////////////////////
13
//
14 45 dgisselq
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
15 29 dgisselq
//
16
// This program is free software (firmware): you can redistribute it and/or
17
// modify it under the terms of  the GNU General Public License as published
18
// by the Free Software Foundation, either version 3 of the License, or (at
19
// your option) any later version.
20
//
21
// This program is distributed in the hope that it will be useful, but WITHOUT
22
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
23
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
24
// for more details.
25
//
26
// You should have received a copy of the GNU General Public License along
27
// with this program.  (It's in the $(ROOT)/doc directory, run make with no
28
// target there if the PDF file isn't present.)  If not, see
29
// <http://www.gnu.org/licenses/> for a copy.
30
//
31
// License:     GPL, v3, as defined and found on www.gnu.org,
32
//              http://www.gnu.org/licenses/gpl.html
33
//
34
//
35
////////////////////////////////////////////////////////////////////////////////
36
//
37
//
38
#include "asmstartup.h"
39
#include "board.h"
40
#include "keypad.h"
41 45 dgisselq
#include "txfns.h"
42 29 dgisselq
 
43
void entry(void) {
44 45 dgisselq
        register volatile IOSPACE *const sys = _sys;
45 29 dgisselq
 
46
        sys->io_pic = 0x07fffffff; // Acknowledge and turn off all interrupts
47
        sys->io_spio = 0x0f0;
48 45 dgisselq
        sys->io_timer = 100000 | TM_REPEAT;
49 29 dgisselq
 
50
        txstr("Press any keypad button for test.\r\n");
51
 
52
        while(1) {
53
                int     ch;
54
                while(0 == (sys->io_pic & INT_KEYPAD))
55
                        ;
56 45 dgisselq
                sys->io_pic = INT_KEYPAD | INT_TIMER;
57 29 dgisselq
                // Wait 5 ms
58
                for(int i=0; i<5; i++) {
59 45 dgisselq
                        while(0 == (sys->io_pic & INT_TIMER))
60 29 dgisselq
                                ;
61
                }
62
                sys->io_spio = 0x011;
63
                ch = keypadread();
64 45 dgisselq
                if ((ch < 0)||(ch == -1))
65 29 dgisselq
                        ; // txstr("Unknown key pressed or error\n");
66
                else if (ch < 10)
67
                        txchr(ch+'0');
68
                else if (ch == 15)
69
                        txstr("F\r\n");
70
                else if (ch < 15)
71
                        txchr(ch+'A'-10);
72 45 dgisselq
                else {
73
                        txstr("Unknown key pressed\r\n");
74
                }
75 29 dgisselq
                keypad_wait_for_release();
76
                sys->io_spio = 0x010;
77
        }
78
}

powered by: WebSVN 2.1.0

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