Skip to content

Commit

Permalink
Implement QMK's IAP default keybind (qmk#29)
Browse files Browse the repository at this point in the history
* Add keymap for going into IAP

* switch to default QMK keybind for IAP mode

* implement bluetooth IAP mode
  • Loading branch information
jmarmstrong1207 authored Jan 31, 2021
1 parent 4e28740 commit 5233d3a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 1 deletion.
21 changes: 21 additions & 0 deletions keyboards/annepro2/annepro2.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,26 @@ uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS] = {
0,0,0,0,0,0,0,0,0,0,0,0,0,0,
};

void OVERRIDE bootloader_jump(void) {

// Send msg to shine to boot into IAP
sdPut(&SD0, CMD_LED_IAP);

// wait for shine to boot into IAP
wait_ms(15);

// Load ble into IAP
annepro2_ble_bootload();
wait_ms(15);

// Magic key to set keyboard to IAP
*((uint32_t*)0x20001ffc) = 0x0000fab2;

// Load the main MCU into IAP
__disable_irq();
NVIC_SystemReset();
}

void OVERRIDE keyboard_pre_init_kb(void) {
#if HAL_USE_SPI == TRUE
spi_init();
Expand Down Expand Up @@ -146,6 +166,7 @@ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) {
case KC_AP_LED_SPEED:
annepro2LedNextAnimationSpeed();
return false;

default:
break;
}
Expand Down
8 changes: 8 additions & 0 deletions keyboards/annepro2/annepro2_ble.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,21 @@ static uint8_t bleMcuUnpair[10] = {
0x7b, 0x10, 0x53, 0x10, 0x02, 0x00, 0x00, 0x7d, 0x40, 0x05,
};

static uint8_t bleMcuBootload[11] = {
0x7b, 0x10, 0x51, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x01
};

static host_driver_t *lastHostDriver = NULL;
#ifdef NKRO_ENABLE
static bool lastNkroStatus = false;
#endif // NKRO_ENABLE

/* -------------------- Public Function Implementation ---------------------- */

void annepro2_ble_bootload(void) {
sdWrite(&SD1, bleMcuBootload, 11);
}

void annepro2_ble_startup(void) {
sdWrite(&SD1, bleMcuWakeup, 11);
}
Expand Down
1 change: 1 addition & 0 deletions keyboards/annepro2/annepro2_ble.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "annepro2.h"
#include "quantum.h"

void annepro2_ble_bootload(void);
void annepro2_ble_startup(void);
void annepro2_ble_broadcast(uint8_t port);
void annepro2_ble_connect(uint8_t port);
Expand Down
2 changes: 1 addition & 1 deletion keyboards/annepro2/c18/rules.mk
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ EXTRAKEY_ENABLE = yes
KEY_LOCK_ENABLE = no

# Other featues
BOOTMAGIC_ENABLE = no
BOOTMAGIC_ENABLE = yes
CONSOLE_ENABLE = no
COMMAND_ENABLE = yes
RAW_ENABLE = yes
Expand Down
2 changes: 2 additions & 0 deletions keyboards/annepro2/qmk_ap2_led.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
#define CMD_LED_NEXT_ANIMATION_SPEED 0xD
#define CMD_LED_SET_FOREGROUND_COLOR 0xE
#define CMD_LED_KEYPRESS 0xF
#define CMD_LED_IAP 0x10

void annepro2SetIAP(void);
void annepro2LedDisable(void);
void annepro2LedEnable(void);
void annepro2LedUpdate(uint8_t row, uint8_t col);
Expand Down

0 comments on commit 5233d3a

Please sign in to comment.