1
0
Fork 0

qmk cformat

This commit is contained in:
Nick Brassel 2021-01-18 05:12:15 +11:00 committed by Zach White
parent e702c7f1b4
commit 31c57aab35
9 changed files with 136 additions and 113 deletions

View file

@ -248,9 +248,9 @@ typedef ioline_t pin_t;
*/ */
# if !defined(GPIO_INPUT_PIN_DELAY) # if !defined(GPIO_INPUT_PIN_DELAY)
# if defined(STM32_SYSCLK) # if defined(STM32_SYSCLK)
# define GPIO_INPUT_PIN_DELAY (STM32_SYSCLK/1000000L / 4) # define GPIO_INPUT_PIN_DELAY (STM32_SYSCLK / 1000000L / 4)
# elif defined(KINETIS_SYSCLK_FREQUENCY) # elif defined(KINETIS_SYSCLK_FREQUENCY)
# define GPIO_INPUT_PIN_DELAY (KINETIS_SYSCLK_FREQUENCY/1000000L / 4) # define GPIO_INPUT_PIN_DELAY (KINETIS_SYSCLK_FREQUENCY / 1000000L / 4)
# endif # endif
# endif # endif
# define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY) # define waitInputPinDelay() wait_cpuclock(GPIO_INPUT_PIN_DELAY)

View file

@ -237,13 +237,13 @@ __attribute__((weak)) void bootloader_jump(void) {
"bootloader_startup_loop%=: \n\t" "bootloader_startup_loop%=: \n\t"
"rjmp bootloader_startup_loop%= \n\t" "rjmp bootloader_startup_loop%= \n\t"
: :
: [mcucsrio] "I"(_SFR_IO_ADDR(MCUCSR)), : [ mcucsrio ] "I"(_SFR_IO_ADDR(MCUCSR)),
# if (FLASHEND > 131071) # if (FLASHEND > 131071)
[ramendhi] "M"(((RAMEND - 2) >> 8) & 0xff), [ramendlo] "M"(((RAMEND - 2) >> 0) & 0xff), [bootaddrhi] "M"((((FLASH_SIZE - BOOTLOADER_SIZE) >> 1) >> 16) & 0xff), [ ramendhi ] "M"(((RAMEND - 2) >> 8) & 0xff), [ ramendlo ] "M"(((RAMEND - 2) >> 0) & 0xff), [ bootaddrhi ] "M"((((FLASH_SIZE - BOOTLOADER_SIZE) >> 1) >> 16) & 0xff),
# else # else
[ramendhi] "M"(((RAMEND - 1) >> 8) & 0xff), [ramendlo] "M"(((RAMEND - 1) >> 0) & 0xff), [ ramendhi ] "M"(((RAMEND - 1) >> 8) & 0xff), [ ramendlo ] "M"(((RAMEND - 1) >> 0) & 0xff),
# endif # endif
[bootaddrme] "M"((((FLASH_SIZE - BOOTLOADER_SIZE) >> 1) >> 8) & 0xff), [bootaddrlo] "M"((((FLASH_SIZE - BOOTLOADER_SIZE) >> 1) >> 0) & 0xff)); [ bootaddrme ] "M"((((FLASH_SIZE - BOOTLOADER_SIZE) >> 1) >> 8) & 0xff), [ bootaddrlo ] "M"((((FLASH_SIZE - BOOTLOADER_SIZE) >> 1) >> 0) & 0xff));
#else // Assume remaining boards are DFU, even if the flag isn't set #else // Assume remaining boards are DFU, even if the flag isn't set

View file

@ -130,13 +130,11 @@ const uint16_t mk_initial_speed = MOUSEKEY_INITIAL_SPEED;
static uint8_t move_unit(void) { static uint8_t move_unit(void) {
float speed = mk_initial_speed; float speed = mk_initial_speed;
if (mousekey_accel & ((1<<0) | (1<<2))) { if (mousekey_accel & ((1 << 0) | (1 << 2))) {
speed = mousekey_accel & (1<<2) ? mk_accelerated_speed : mk_decelerated_speed; speed = mousekey_accel & (1 << 2) ? mk_accelerated_speed : mk_decelerated_speed;
} else if (mousekey_repeat && mouse_timer) { } else if (mousekey_repeat && mouse_timer) {
const float time_elapsed = timer_elapsed(mouse_timer) / 50; const float time_elapsed = timer_elapsed(mouse_timer) / 50;
speed = mk_initial_speed + speed = mk_initial_speed + MOUSEKEY_MOVE_DELTA * time_elapsed + MOUSEKEY_MOVE_DELTA * 0.5 * time_elapsed * time_elapsed;
MOUSEKEY_MOVE_DELTA * time_elapsed +
MOUSEKEY_MOVE_DELTA * 0.5 * time_elapsed * time_elapsed;
speed = speed > mk_base_speed ? mk_base_speed : speed; speed = speed > mk_base_speed ? mk_base_speed : speed;
} }
@ -153,14 +151,12 @@ float mk_wheel_interval = 1000.0f / MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;
static uint8_t wheel_unit(void) { static uint8_t wheel_unit(void) {
float speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS; float speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS;
if (mousekey_accel & ((1<<0) | (1<<2))) { if (mousekey_accel & ((1 << 0) | (1 << 2))) {
speed = mousekey_accel & (1<<2) ? MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS : MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS; speed = mousekey_accel & (1 << 2) ? MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS : MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS;
} else if (mousekey_repeat && mouse_timer) { } else if (mousekey_repeat && mouse_timer) {
if (mk_wheel_interval != MOUSEKEY_WHEEL_BASE_MOVEMENTS) { if (mk_wheel_interval != MOUSEKEY_WHEEL_BASE_MOVEMENTS) {
const float time_elapsed = timer_elapsed(mouse_timer) / 50; const float time_elapsed = timer_elapsed(mouse_timer) / 50;
speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS + speed = MOUSEKEY_WHEEL_INITIAL_MOVEMENTS + 1 * time_elapsed + 1 * 0.5 * time_elapsed * time_elapsed;
1 * time_elapsed +
1 * 0.5 * time_elapsed * time_elapsed;
} }
speed = speed > MOUSEKEY_WHEEL_BASE_MOVEMENTS ? MOUSEKEY_WHEEL_BASE_MOVEMENTS : speed; speed = speed > MOUSEKEY_WHEEL_BASE_MOVEMENTS ? MOUSEKEY_WHEEL_BASE_MOVEMENTS : speed;
} }
@ -260,11 +256,11 @@ void mousekey_task(void) {
} }
void mousekey_on(uint8_t code) { void mousekey_on(uint8_t code) {
#ifdef MK_KINETIC_SPEED # ifdef MK_KINETIC_SPEED
if (mouse_timer == 0) { if (mouse_timer == 0) {
mouse_timer = timer_read(); mouse_timer = timer_read();
} }
#endif /* #ifdef MK_KINETIC_SPEED */ # endif /* #ifdef MK_KINETIC_SPEED */
if (code == KC_MS_UP) if (code == KC_MS_UP)
mouse_report.y = move_unit() * -1; mouse_report.y = move_unit() * -1;
@ -335,9 +331,9 @@ void mousekey_off(uint8_t code) {
mousekey_accel &= ~(1 << 2); mousekey_accel &= ~(1 << 2);
if (mouse_report.x == 0 && mouse_report.y == 0) { if (mouse_report.x == 0 && mouse_report.y == 0) {
mousekey_repeat = 0; mousekey_repeat = 0;
#ifdef MK_KINETIC_SPEED # ifdef MK_KINETIC_SPEED
mouse_timer = 0; mouse_timer = 0;
#endif /* #ifdef MK_KINETIC_SPEED */ # endif /* #ifdef MK_KINETIC_SPEED */
} }
if (mouse_report.v == 0 && mouse_report.h == 0) mousekey_wheel_repeat = 0; if (mouse_report.v == 0 && mouse_report.h == 0) mousekey_wheel_repeat = 0;
} }

View file

@ -36,28 +36,28 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# endif # endif
# ifndef MOUSEKEY_MOVE_DELTA # ifndef MOUSEKEY_MOVE_DELTA
#ifndef MK_KINETIC_SPEED # ifndef MK_KINETIC_SPEED
# define MOUSEKEY_MOVE_DELTA 5 # define MOUSEKEY_MOVE_DELTA 5
#else # else
# define MOUSEKEY_MOVE_DELTA 25 # define MOUSEKEY_MOVE_DELTA 25
#endif # endif
# endif # endif
# ifndef MOUSEKEY_WHEEL_DELTA # ifndef MOUSEKEY_WHEEL_DELTA
# define MOUSEKEY_WHEEL_DELTA 1 # define MOUSEKEY_WHEEL_DELTA 1
# endif # endif
# ifndef MOUSEKEY_DELAY # ifndef MOUSEKEY_DELAY
#ifndef MK_KINETIC_SPEED # ifndef MK_KINETIC_SPEED
# define MOUSEKEY_DELAY 300 # define MOUSEKEY_DELAY 300
#else # else
# define MOUSEKEY_DELAY 8 # define MOUSEKEY_DELAY 8
#endif # endif
# endif # endif
# ifndef MOUSEKEY_INTERVAL # ifndef MOUSEKEY_INTERVAL
#ifndef MK_KINETIC_SPEED # ifndef MK_KINETIC_SPEED
# define MOUSEKEY_INTERVAL 50 # define MOUSEKEY_INTERVAL 50
#else # else
# define MOUSEKEY_INTERVAL 8 # define MOUSEKEY_INTERVAL 8
#endif # endif
# endif # endif
# ifndef MOUSEKEY_MAX_SPEED # ifndef MOUSEKEY_MAX_SPEED
# define MOUSEKEY_MAX_SPEED 10 # define MOUSEKEY_MAX_SPEED 10
@ -78,30 +78,30 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
# define MOUSEKEY_WHEEL_TIME_TO_MAX 40 # define MOUSEKEY_WHEEL_TIME_TO_MAX 40
# endif # endif
#ifndef MOUSEKEY_INITIAL_SPEED # ifndef MOUSEKEY_INITIAL_SPEED
#define MOUSEKEY_INITIAL_SPEED 100 # define MOUSEKEY_INITIAL_SPEED 100
#endif # endif
#ifndef MOUSEKEY_BASE_SPEED # ifndef MOUSEKEY_BASE_SPEED
#define MOUSEKEY_BASE_SPEED 1000 # define MOUSEKEY_BASE_SPEED 1000
#endif # endif
#ifndef MOUSEKEY_DECELERATED_SPEED # ifndef MOUSEKEY_DECELERATED_SPEED
#define MOUSEKEY_DECELERATED_SPEED 400 # define MOUSEKEY_DECELERATED_SPEED 400
#endif # endif
#ifndef MOUSEKEY_ACCELERATED_SPEED # ifndef MOUSEKEY_ACCELERATED_SPEED
#define MOUSEKEY_ACCELERATED_SPEED 3000 # define MOUSEKEY_ACCELERATED_SPEED 3000
#endif # endif
#ifndef MOUSEKEY_WHEEL_INITIAL_MOVEMENTS # ifndef MOUSEKEY_WHEEL_INITIAL_MOVEMENTS
#define MOUSEKEY_WHEEL_INITIAL_MOVEMENTS 16 # define MOUSEKEY_WHEEL_INITIAL_MOVEMENTS 16
#endif # endif
#ifndef MOUSEKEY_WHEEL_BASE_MOVEMENTS # ifndef MOUSEKEY_WHEEL_BASE_MOVEMENTS
#define MOUSEKEY_WHEEL_BASE_MOVEMENTS 32 # define MOUSEKEY_WHEEL_BASE_MOVEMENTS 32
#endif # endif
#ifndef MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS # ifndef MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS
#define MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS 48 # define MOUSEKEY_WHEEL_ACCELERATED_MOVEMENTS 48
#endif # endif
#ifndef MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS # ifndef MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS
#define MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS 8 # define MOUSEKEY_WHEEL_DECELERATED_MOVEMENTS 8
#endif # endif
#else /* #ifndef MK_3_SPEED */ #else /* #ifndef MK_3_SPEED */

View file

@ -15,44 +15,71 @@ extern "C" {
# define CLOCK_DELAY_NOP8 "nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t" # define CLOCK_DELAY_NOP8 "nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t nop\n\t"
__attribute__((always_inline)) __attribute__((always_inline)) static inline void wait_cpuclock_allnop(unsigned int n) { /* n: 1..135 */
static inline void wait_cpuclock_allnop(unsigned int n) { /* n: 1..135 */
/* The argument n must be a constant expression. /* The argument n must be a constant expression.
* That way, compiler optimization will remove unnecessary code. */ * That way, compiler optimization will remove unnecessary code. */
if (n < 1) { return; } if (n < 1) {
return;
}
if (n > 8) { if (n > 8) {
unsigned int n8 = n/8; unsigned int n8 = n / 8;
n = n - n8*8; n = n - n8 * 8;
switch (n8) { switch (n8) {
case 16: asm volatile (CLOCK_DELAY_NOP8::: "memory"); case 16:
case 15: asm volatile (CLOCK_DELAY_NOP8::: "memory"); asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 14: asm volatile (CLOCK_DELAY_NOP8::: "memory"); case 15:
case 13: asm volatile (CLOCK_DELAY_NOP8::: "memory"); asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 12: asm volatile (CLOCK_DELAY_NOP8::: "memory"); case 14:
case 11: asm volatile (CLOCK_DELAY_NOP8::: "memory"); asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 10: asm volatile (CLOCK_DELAY_NOP8::: "memory"); case 13:
case 9: asm volatile (CLOCK_DELAY_NOP8::: "memory"); asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 8: asm volatile (CLOCK_DELAY_NOP8::: "memory"); case 12:
case 7: asm volatile (CLOCK_DELAY_NOP8::: "memory"); asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 6: asm volatile (CLOCK_DELAY_NOP8::: "memory"); case 11:
case 5: asm volatile (CLOCK_DELAY_NOP8::: "memory"); asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 4: asm volatile (CLOCK_DELAY_NOP8::: "memory"); case 10:
case 3: asm volatile (CLOCK_DELAY_NOP8::: "memory"); asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 2: asm volatile (CLOCK_DELAY_NOP8::: "memory"); case 9:
case 1: asm volatile (CLOCK_DELAY_NOP8::: "memory"); asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 0: break; case 8:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 7:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 6:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 5:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 4:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 3:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 2:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 1:
asm volatile(CLOCK_DELAY_NOP8::: "memory");
case 0:
break;
} }
} }
switch (n) { switch (n) {
case 8: asm volatile ("nop"::: "memory"); case 8:
case 7: asm volatile ("nop"::: "memory"); asm volatile("nop" ::: "memory");
case 6: asm volatile ("nop"::: "memory"); case 7:
case 5: asm volatile ("nop"::: "memory"); asm volatile("nop" ::: "memory");
case 4: asm volatile ("nop"::: "memory"); case 6:
case 3: asm volatile ("nop"::: "memory"); asm volatile("nop" ::: "memory");
case 2: asm volatile ("nop"::: "memory"); case 5:
case 1: asm volatile ("nop"::: "memory"); asm volatile("nop" ::: "memory");
case 0: break; case 4:
asm volatile("nop" ::: "memory");
case 3:
asm volatile("nop" ::: "memory");
case 2:
asm volatile("nop" ::: "memory");
case 1:
asm volatile("nop" ::: "memory");
case 0:
break;
} }
} }
#endif #endif