diff --git a/src/dev/kbd_f256k.c b/src/dev/kbd_f256k.c index 7547439..e4ad17a 100644 --- a/src/dev/kbd_f256k.c +++ b/src/dev/kbd_f256k.c @@ -14,6 +14,7 @@ #include #include +#include "features.h" #include "interrupt.h" #include "log.h" #include "ring_buffer.h" @@ -330,11 +331,20 @@ bool kbd_break() { * */ short kbd_sc_init() { + // NOTE: Reading from the new optical keyboard IO registers on non-F256K2 + // devices causes odd and sometimes intermittent issues not limited to + // the keyboard not working at all right after a cold bootup from flash. + // Possibly this can be addressed with future FPGA updates for + // non-F256K2 devices, but for now we want to avoid this situation. +#if HAS_OPTICAL_KBD_SUPPORT if (KBD_OPTICAL->status & KBD_OPT_STAT_MECH) { is_optical = false; } else { is_optical = true; } +#else + is_optical = false; +#endif // Initialize VIA0 -- we'll just read from PB7 via0->ddra = 0x00; diff --git a/src/include/features.h b/src/include/features.h index ee92b5e..630e2f5 100644 --- a/src/include/features.h +++ b/src/include/features.h @@ -46,6 +46,10 @@ #define HAS_IEC 1 #endif +#if MODEL == MODEL_FOENIX_F256K2 || MODEL == MODEL_FOENIX_F256K2E + #define HAS_OPTICAL_KBD_SUPPORT 1 +#endif + /* Defaults -----------------------------------------------------------------*/ @@ -93,4 +97,8 @@ #define HAS_IEC 0 #endif -#endif \ No newline at end of file +#ifndef HAS_OPTICAL_KBD_SUPPORT + #define HAS_OPTICAL_KBD_SUPPORT 0 +#endif + +#endif