From c41dc1916fc2882a17cbaccb947cba4fcddb2079 Mon Sep 17 00:00:00 2001 From: Karolis Stasaitis Date: Sun, 7 Apr 2024 20:33:05 +0200 Subject: [PATCH] nuphy-air60 back to a working state --- Makefile | 8 +++++--- src/main.c | 6 ++++++ src/smk/matrix.c | 6 +++--- src/smk/matrix.h | 4 ++-- src/smk/report.c | 3 +-- 5 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index c76830b..9834c42 100644 --- a/Makefile +++ b/Makefile @@ -30,6 +30,7 @@ CFLAGS := -V -mmcs51 --model-small \ --xram-size $(XRAM_SIZE) --xram-loc $(XRAM_LOC) \ --code-size $(CODE_SIZE) \ --std-c2x \ + --opt-code-speed \ -I$(ROOT_DIR)../include \ -DDEBUG=$(DEBUG) \ -DFREQ_SYS=$(FREQ_SYS) \ @@ -69,9 +70,9 @@ all: $(KEYBOARDS_LAYOUTS:%=$(BINDIR)/%.hex) clean: rm -rf $(BINDIR) $(OBJDIR) -.PHONY: %_flash -%_flash: $(BINDIR)/%.hex - $(FLASHER) $(BINDIR)/%.hex +.PHONY: flash +flash: $(BINDIR)/nuphy-air60_default.hex + $(FLASHER) $< $(OBJDIR)/%.rel: $(SRCDIR)/%.c @mkdir -p $(@D) @@ -85,6 +86,7 @@ $(BINDIR)/platform.lib: $(PLATFORM_OBJECTS) @mkdir -p $(@D) $(SDAR) $@ $^ +.PRECIOUS: $(BINDIR)/%.ihx $(BINDIR)/%.ihx: $(MAIN_OBJECTS) $(BINDIR)/$(PLATFORM_LIB).lib $(BINDIR)/$(USER_LIB).lib @mkdir -p $(@D) $(CC) -m$(FAMILY) -l$(PROC) $(LFLAGS) -o $@ $(MAIN_OBJECTS) -L$(BINDIR) -l$(USER_LIB) -l$(PLATFORM_LIB) diff --git a/src/main.c b/src/main.c index 9ca7d01..2bfead6 100644 --- a/src/main.c +++ b/src/main.c @@ -44,9 +44,15 @@ void main() dprintf("DEVICE vId:" TOSTRING(USB_VID) " pId:" TOSTRING(USB_PID) "\n\r"); dprintf("OS: 0x%x, CONN: 0x%x\n\r", keyboard_state.os_mode, keyboard_state.conn_mode); + if (keyboard_state.os_mode == KEYBOARD_OS_MODE_WIN) { + isp_jump(); + } + // enable pwm and interrupt (driving matrix scan) pwm_enable(); + delay_ms(1000); + while (1) { CLR_WDT(); diff --git a/src/smk/matrix.c b/src/smk/matrix.c index c580c63..ed85c6f 100644 --- a/src/smk/matrix.c +++ b/src/smk/matrix.c @@ -44,7 +44,7 @@ inline matrix_col_t matrix_can_read() return matrix_updated; } -void process_key_state(uint8_t row, uint8_t col, bool pressed) +inline void process_key_state(uint8_t row, uint8_t col, bool pressed) { uint16_t qcode = keymaps[0][row][col]; @@ -97,7 +97,7 @@ void process_key_state(uint8_t row, uint8_t col, bool pressed) dprintf("UNRECOGNIZED KEY: 0x%04x\r\n", qcode); } -uint8_t matrix_task() +inline uint8_t matrix_task() { if (!matrix_can_read()) { return false; @@ -148,7 +148,7 @@ inline void matrix_scan_step() if (!matrix_updated) { matrix_pre_scan(current_step); - uint8_t column_state = matrix_get_col(current_step); + uint8_t column_state = matrix_scan_col(current_step); matrix_post_scan(); diff --git a/src/smk/matrix.h b/src/smk/matrix.h index 4b22c31..06d2694 100644 --- a/src/smk/matrix.h +++ b/src/smk/matrix.h @@ -6,8 +6,8 @@ #define MATRIX_COLS 16 #define MATRIX_ROWS 5 -void matrix_init(); -uint8_t matrix_task(); +inline void matrix_init(); +inline uint8_t matrix_task(); inline void matrix_scan_step(); #endif diff --git a/src/smk/report.c b/src/smk/report.c index 41a3b08..9c8ddf7 100644 --- a/src/smk/report.c +++ b/src/smk/report.c @@ -7,6 +7,7 @@ static uint8_t real_mods = 0; static uint8_t weak_mods = 0; __xdata report_keyboard_t keyboard_report; +__xdata report_keyboard_t last_report; /** \brief Send keyboard report * @@ -16,8 +17,6 @@ void send_keyboard_report() keyboard_report.mods = real_mods; keyboard_report.mods |= weak_mods; - static report_keyboard_t last_report; - /* Only send the report if there are changes to propagate to the host. */ if (memcmp(&keyboard_report, &last_report, sizeof(report_keyboard_t)) != 0) { memcpy(&last_report, &keyboard_report, sizeof(report_keyboard_t));