F256k keyboard now interrupt driven

This commit is contained in:
Peter Weingartner 2024-07-03 22:08:32 -04:00
parent 1f1c9c7364
commit 437ba285bf
4 changed files with 24 additions and 11 deletions

View file

@ -29,7 +29,7 @@
// INT_VICKY_B_DAC 0x0F
// INT_KBD_PS2 0x10 --> 0x00, 0x04 (PS/2 Keyboard)
// INT_KBD_A2560K 0x11 --> 0x01, 0x40 (F256K Keyboard)
// INT_KBD_A2560K 0x11
// INT_MOUSE 0x12 --> 0x00, 0x08 (PS/2 Mouse)
// INT_COM1 0x13 --> 0x01, 0x01 (Serial port 1)
// INT_COM2 0x14
@ -41,8 +41,8 @@
// INT_TIMER2 0x1A
// INT_TIMER3 0x1B
// INT_TIMER4 0x1C
// INT_RESERVED_3 0x1D
// INT_RESERVED_4 0x1E
// INT_VIA0 0x1D --> 0x01, 0x20 (VIA #0)
// INT_VIA1 0x1E --> 0x01, 0x40 (VIA #1, F256K only)
// INT_RTC 0x1F --> 0x01, 0x10 (Real time clock)
// INT_PATA 0x20
@ -99,7 +99,7 @@ p_int_handler int_handle_27;
*/
static unsigned short g_int_group[] = {
0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x00, 0x01, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01,
0x00, 0xff, 0x00, 0x01, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0xff, 0xff, 0xff, 0x01, 0x01, 0x01,
0xff, 0x02, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
@ -109,7 +109,7 @@ static unsigned short g_int_group[] = {
*/
static unsigned short g_int_mask[] = {
0x01, 0x02, 0xff, 0xff, 0xff, 0xff, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0x04, 0x40, 0x08, 0x01, 0xff, 0xff, 0xff, 0xff, 0x10, 0x20, 0xff, 0xff, 0xff, 0xff, 0xff, 0x10,
0x04, 0xff, 0x08, 0x01, 0xff, 0xff, 0xff, 0xff, 0x10, 0x20, 0xff, 0xff, 0xff, 0x20, 0x40, 0x10,
0xff, 0x80, 0x80, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};

View file

@ -14,6 +14,7 @@
#include <stdint.h>
#include <stdio.h>
#include "interrupt.h"
#include "log.h"
#include "ring_buffer.h"
#include "dev/kbd_f256k.h"
@ -21,6 +22,7 @@
#include "uart.h"
#include "gabe_reg.h"
#include "simpleio.h"
#include "vicky_general.h"
//
// Constants
@ -396,6 +398,9 @@ unsigned short kbd_get_scancode() {
*
*/
void kbd_handle_irq() {
uint8_t ifr = via0->ifr;
uint8_t counter_low = via0->t1c_l;
for (uint8_t row = 0; row < 8; row++) {
// Check each column to see if any key is pressed
uint16_t columns_stat = kbd_get_columns(row);
@ -650,5 +655,14 @@ short kbd_init() {
// Set up the layout of the F256k keyboard
kbd_layout(kbd_256k_layout);
int_register(INT_VIA0, kbd_handle_irq);
via0->acr = 0x40; // Timer #0 in free running mode
via0->ier = VIA_INT_TIMER1 | VIA_INT_IRQ; // Allow timer #0 interrupts
via0->t1c_l = 0xff; // Set timer count
via0->t1c_h = 0xff;
int_enable(INT_VIA0);
return 1;
}

View file

@ -206,8 +206,8 @@
#define INT_TIMER2 0x1A /* Timer 2, Clocked with the CPU Clock */
#define INT_TIMER3 0x1B /* Timer 3, Clocked with the SOF Channel A */
#define INT_TIMER4 0x1C /* Timer 4, Clocked with the SOF Channel B */
#define INT_RESERVED_3 0x1D /* Reserved */
#define INT_RESERVED_4 0x1E /* Reserved */
#define INT_VIA0 0x1D /* VIA #0 for machines that have them (F256s) */
#define INT_VIA1 0x1E /* VIA #1 for F256k, F256k2e */
#define INT_RTC 0x1F /* Real Time Clock */
#define INT_PATA 0x20 /* IDE/PATA Hard drive interrupt */

View file

@ -199,9 +199,9 @@ void initialize() {
// target_jiffies = sys_time_jiffies() + 300; /* 5 seconds minimum */
// DEBUG1("target_jiffies assigned: %d", target_jiffies);
// /* Enable all interrupts */
// int_enable_all();
// TRACE("Interrupts enabled");
/* Enable all interrupts */
int_enable_all();
TRACE("Interrupts enabled");
// // /* Play the SID test bong on the Gideon SID implementation */
// // sid_test_internal();
@ -292,7 +292,6 @@ int main(int argc, char * argv[]) {
kbd_init();
printf("\n> ");
while (!kbd_break()) {
kbd_handle_irq();
char c = kbd_getc();
if (c != 0) {
txt_put(0, c);