From e59f647d832a32a783e00a3096724c2d69ace03b Mon Sep 17 00:00:00 2001 From: Ondrej Jirman Date: Tue, 15 Jun 2021 09:21:31 +0200 Subject: [PATCH] Allow to switch to bootloader mode via FN+PINE+F --- firmware/main.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-) diff --git a/firmware/main.c b/firmware/main.c index 806f38b..6a86900 100644 --- a/firmware/main.c +++ b/firmware/main.c @@ -214,7 +214,6 @@ static uint8_t i2c_addr = 0; static uint8_t i2c_regs[I2C_N_REGS] = {0xaa, 0x55}; static uint8_t i2c_cmd[I2C_N_REGS]; static uint8_t i2c_cmd_len = 0; -static uint8_t go_boot = 0; void i2c_b_interupt(void) __interrupt(IRQ_I2CB) { @@ -239,15 +238,6 @@ void i2c_b_interupt(void) __interrupt(IRQ_I2CB) if (i2c_cmd_len < 16) i2c_cmd[i2c_cmd_len++] = tmp; - if (i2c_cmd_len) { - if (i2c_cmd[0] == 0xa0) - ext_int_assert(); - else if (i2c_cmd[0] == 0xa1) - ext_int_deassert(); - else if (i2c_cmd[0] == 0xa2) - go_boot = 1; - } - PAGESW = 0; P0_I2CBCR1 &= ~BIT(7); // clear data pending @@ -359,13 +349,6 @@ void main(void) keyscan_idle(); while (1) { - if (go_boot) { - EA = 0; - __asm__("mov r6,#0x5a"); - __asm__("mov r7,#0xe7"); - __asm__("ljmp 0x0118"); - } - if (scan_active) { uint8_t active_rows = keyscan_scan(i2c_regs + 4); if (!active_rows) { @@ -376,6 +359,13 @@ void main(void) //PCON |= BIT(1); //__asm__("nop"); } + + if (i2c_regs[4 + 0] & BIT(2) && i2c_regs[4 + 2] & BIT(5) && i2c_regs[4 + 4] & BIT(2)) { + EA = 0; + __asm__("mov r6,#0x5a"); + __asm__("mov r7,#0xe7"); + __asm__("ljmp 0x0118"); + } continue; }