Skip to content

Commit 30cac1d

Browse files
committed
Merge remote-tracking branch 'flabbergast-tmk_keyboard/chibios'
Merge flabbergast's chibios protocol into master https://github.com/flabbergast/tmk_keyboard/tree/chibios
2 parents f218a38 + 3e68807 commit 30cac1d

29 files changed

+3410
-24
lines changed

common.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
COMMON_DIR = common
1+
COMMON_DIR = $(TMK_DIR)/common
22
SRC += $(COMMON_DIR)/host.c \
33
$(COMMON_DIR)/keyboard.c \
44
$(COMMON_DIR)/action.c \
@@ -58,7 +58,7 @@ ifdef KEYBOARD_LOCK_ENABLE
5858
endif
5959

6060
ifdef SLEEP_LED_ENABLE
61-
SRC += $(COMMON_DIR)/sleep_led.c
61+
SRC += $(COMMON_DIR)/avr/sleep_led.c
6262
OPT_DEFS += -DSLEEP_LED_ENABLE
6363
OPT_DEFS += -DNO_SUSPEND_POWER_DOWN
6464
endif

common/action_tapping.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ bool process_tapping(keyrecord_t *keyp)
256256
return true;
257257
}
258258
} else {
259-
if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n");
259+
if (!IS_NOEVENT(event)) debug("Tapping: other key just after tap.\n") {};
260260
process_action(keyp);
261261
return true;
262262
}
File renamed without changes.

common/bootmagic.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include <stdint.h>
22
#include <stdbool.h>
3-
#include <util/delay.h>
3+
#include "wait.h"
44
#include "matrix.h"
55
#include "bootloader.h"
66
#include "debug.h"
@@ -10,6 +10,7 @@
1010
#include "eeconfig.h"
1111
#include "bootmagic.h"
1212

13+
keymap_config_t keymap_config;
1314

1415
void bootmagic(void)
1516
{
@@ -21,7 +22,7 @@ void bootmagic(void)
2122
/* do scans in case of bounce */
2223
print("bootmagic scan: ... ");
2324
uint8_t scan = 100;
24-
while (scan--) { matrix_scan(); _delay_ms(10); }
25+
while (scan--) { matrix_scan(); wait_ms(10); }
2526
print("done.\n");
2627

2728
/* bootmagic skip */

common/chibios/bootloader.c

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#include "bootloader.h"
2+
3+
#include "ch.h"
4+
#include "hal.h"
5+
6+
#ifdef STM32_BOOTLOADER_ADDRESS
7+
/* STM32 */
8+
9+
#if defined(STM32F0XX)
10+
/* This code should be checked whether it runs correctly on platforms */
11+
#define SYMVAL(sym) (uint32_t)(((uint8_t *)&(sym)) - ((uint8_t *)0))
12+
extern uint32_t __ram0_end__;
13+
14+
void bootloader_jump(void) {
15+
*((unsigned long *)(SYMVAL(__ram0_end__) - 4)) = 0xDEADBEEF; // set magic flag => reset handler will jump into boot loader
16+
NVIC_SystemReset();
17+
}
18+
19+
#else /* defined(STM32F0XX) */
20+
#error Check that the bootloader code works on your platform and add it to bootloader.c!
21+
#endif /* defined(STM32F0XX) */
22+
23+
#elif defined(KL2x) || defined(K20x) /* STM32_BOOTLOADER_ADDRESS */
24+
/* Kinetis */
25+
26+
#if defined(KIIBOHD_BOOTLOADER)
27+
/* Kiibohd Bootloader (MCHCK and Infinity KB) */
28+
#define SCB_AIRCR_VECTKEY_WRITEMAGIC 0x05FA0000
29+
const uint8_t sys_reset_to_loader_magic[] = "\xff\x00\x7fRESET TO LOADER\x7f\x00\xff";
30+
void bootloader_jump(void) {
31+
__builtin_memcpy((void *)VBAT, (const void *)sys_reset_to_loader_magic, sizeof(sys_reset_to_loader_magic));
32+
// request reset
33+
SCB->AIRCR = SCB_AIRCR_VECTKEY_WRITEMAGIC | SCB_AIRCR_SYSRESETREQ_Msk;
34+
}
35+
36+
#else /* defined(KIIBOHD_BOOTLOADER) */
37+
/* Default for Kinetis - expecting an ARM Teensy */
38+
void bootloader_jump(void) {
39+
chThdSleepMilliseconds(100);
40+
__BKPT(0);
41+
}
42+
#endif /* defined(KIIBOHD_BOOTLOADER) */
43+
44+
#else /* neither STM32 nor KINETIS */
45+
void bootloader_jump(void) {}
46+
#endif

0 commit comments

Comments
 (0)