Skip to content

Commit

Permalink
nuphy-air60 back to a working state
Browse files Browse the repository at this point in the history
  • Loading branch information
carlossless committed Apr 7, 2024
1 parent 7514386 commit c41dc19
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 10 deletions.
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
6 changes: 6 additions & 0 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions src/smk/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions src/smk/matrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 1 addition & 2 deletions src/smk/report.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand All @@ -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));
Expand Down

0 comments on commit c41dc19

Please sign in to comment.