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

Subversion Repositories s6soc

[/] [s6soc/] [trunk/] [sw/] [dev/] [keypad.c] - Diff between revs 29 and 45

Show entire file | Details | Blame | View Log

Rev 29 Rev 45
Line 9... Line 9...
// Creator:     Dan Gisselquist, Ph.D.
// Creator:     Dan Gisselquist, Ph.D.
//              Gisselquist Technology, LLC
//              Gisselquist Technology, LLC
//
//
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
//
// Copyright (C) 2015-2016, Gisselquist Technology, LLC
// Copyright (C) 2015-2017, Gisselquist Technology, LLC
//
//
// This program is free software (firmware): you can redistribute it and/or
// This program is free software (firmware): you can redistribute it and/or
// modify it under the terms of  the GNU General Public License as published
// modify it under the terms of  the GNU General Public License as published
// by the Free Software Foundation, either version 3 of the License, or (at
// by the Free Software Foundation, either version 3 of the License, or (at
// your option) any later version.
// your option) any later version.
Line 39... Line 39...
#ifdef ZIPOS
#ifdef ZIPOS
#include "../zipos/ktraps.h"
#include "../zipos/ktraps.h"
#include "../zipos/kfildes.h"
#include "../zipos/kfildes.h"
#endif
#endif
 
 
static const int keymap[] = {
static const char keymap[] = {
        0x01,0x02,0x03,0x0a,
        0x01,0x02,0x03,0x0a,
        0x04,0x05,0x06,0x0b,
        0x04,0x05,0x06,0x0b,
        0x07,0x08,0x09,0x0c,
        0x07,0x08,0x09,0x0c,
        0x00,0x0f,0x0e,0x0d
        0x00,0x0f,0x0e,0x0d
};
};
 
 
int     keypadread(void) {
int     keypadread(void) {
        int     row, col, key;
        int     row, col, key;
        IOSPACE *sys = (IOSPACE *)IOADDR;
        volatile IOSPACE *const sys = _sys;
 
 
        row = sys->io_spio & 0x0f00;
        row = sys->io_spio & 0x0f00;
        if (row != 0x0f00) {
        if (row != 0x0f00) {
                // If a button is still pressed .. 
                // If a button is still pressed .. 
                //
                //
Line 111... Line 111...
 
 
        return key;
        return key;
}
}
 
 
void    keypad_wait_for_release(void) {
void    keypad_wait_for_release(void) {
        IOSPACE *sys = (IOSPACE *)IOADDR;
        volatile IOSPACE * const sys = _sys;
        sys->io_spio = 0x0f00;
        sys->io_spio = 0x0f00;
        while((sys->io_spio & 0x0f00)!=0x0f00)
        while((sys->io_spio & 0x0f00)!=0x0f00)
#ifdef  ZIPOS
#ifdef  ZIPOS
                wait(0,2);
                wait(0,2);
#else
#else
Line 123... Line 123...
#endif
#endif
}
}
 
 
#ifdef ZIPOS
#ifdef ZIPOS
void keypad_task(void) {
void keypad_task(void) {
        clear(INT_KEYPAD);
        clear(INT_KEYPAD, 0);
        while(1) {
        while(1) {
                int     key;
                int     key;    char ch;
                wait(INT_KEYPAD,-1); // Automatically clears
                wait(INT_KEYPAD,-1); // Automatically clears
                key = keypadread();
                key = keypadread();
                write(FILENO_STDOUT, &key, 1);
                if (key >= 0) {
 
                        ch = key;
 
                        write(FILENO_STDOUT, &ch, 1);
 
                }
                // Prepare for the next key
                // Prepare for the next key
                clear(INT_KEYPAD);
                clear(INT_KEYPAD, 0);
        }
        }
}
}
#endif
#endif
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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