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 36... |
Line 36... |
//
|
//
|
//
|
//
|
#include "asmstartup.h"
|
#include "asmstartup.h"
|
#include "board.h"
|
#include "board.h"
|
#include "keypad.h"
|
#include "keypad.h"
|
|
#include "txfns.h"
|
void txchr(char v) {
|
|
volatile IOSPACE *sys = (IOSPACE *)IOADDR;
|
|
if (v < 10)
|
|
return;
|
|
v &= 0x07f;
|
|
sys->io_pic = INT_UARTTX;
|
|
while((sys->io_pic&INT_UARTTX)==0)
|
|
;
|
|
sys->io_uart = v;
|
|
}
|
|
|
|
void txstr(const char *str) {
|
|
const char *ptr = str;
|
|
while(*ptr) {
|
|
txchr(*ptr++);
|
|
}
|
|
}
|
|
|
|
void entry(void) {
|
void entry(void) {
|
register IOSPACE *sys = (IOSPACE *)0x0100;
|
register volatile IOSPACE *const sys = _sys;
|
|
|
sys->io_pic = 0x07fffffff; // Acknowledge and turn off all interrupts
|
sys->io_pic = 0x07fffffff; // Acknowledge and turn off all interrupts
|
sys->io_spio = 0x0f0;
|
sys->io_spio = 0x0f0;
|
sys->io_tima = 100000 | TM_REPEAT;
|
sys->io_timer = 100000 | TM_REPEAT;
|
|
|
txstr("Press any keypad button for test.\r\n");
|
txstr("Press any keypad button for test.\r\n");
|
|
|
while(1) {
|
while(1) {
|
int ch;
|
int ch;
|
while(0 == (sys->io_pic & INT_KEYPAD))
|
while(0 == (sys->io_pic & INT_KEYPAD))
|
;
|
;
|
sys->io_pic = INT_KEYPAD | INT_TIMA;
|
sys->io_pic = INT_KEYPAD | INT_TIMER;
|
// Wait 5 ms
|
// Wait 5 ms
|
for(int i=0; i<5; i++) {
|
for(int i=0; i<5; i++) {
|
while(0 == (sys->io_pic & INT_TIMA))
|
while(0 == (sys->io_pic & INT_TIMER))
|
;
|
;
|
}
|
}
|
sys->io_spio = 0x011;
|
sys->io_spio = 0x011;
|
ch = keypadread();
|
ch = keypadread();
|
if (ch < 0)
|
if ((ch < 0)||(ch == -1))
|
; // txstr("Unknown key pressed or error\n");
|
; // txstr("Unknown key pressed or error\n");
|
else if (ch < 10)
|
else if (ch < 10)
|
txchr(ch+'0');
|
txchr(ch+'0');
|
else if (ch == 15)
|
else if (ch == 15)
|
txstr("F\r\n");
|
txstr("F\r\n");
|
else if (ch < 15)
|
else if (ch < 15)
|
txchr(ch+'A'-10);
|
txchr(ch+'A'-10);
|
else txstr("Unknown key pressed\n");
|
else {
|
|
txstr("Unknown key pressed\r\n");
|
|
}
|
keypad_wait_for_release();
|
keypad_wait_for_release();
|
sys->io_spio = 0x010;
|
sys->io_spio = 0x010;
|
}
|
}
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|