diff options
Diffstat (limited to 'quantum')
| -rw-r--r-- | quantum/audio/driver_chibios_pwm_hardware.c | 4 | ||||
| -rw-r--r-- | quantum/backlight/backlight_chibios.c | 10 | ||||
| -rw-r--r-- | quantum/quantum.c | 96 |
3 files changed, 105 insertions, 5 deletions
diff --git a/quantum/audio/driver_chibios_pwm_hardware.c b/quantum/audio/driver_chibios_pwm_hardware.c index 3c7d89b29..cd40019ee 100644 --- a/quantum/audio/driver_chibios_pwm_hardware.c +++ b/quantum/audio/driver_chibios_pwm_hardware.c | |||
| @@ -109,9 +109,9 @@ void audio_driver_initialize(void) { | |||
| 109 | 109 | ||
| 110 | // connect the AUDIO_PIN to the PWM hardware | 110 | // connect the AUDIO_PIN to the PWM hardware |
| 111 | #if defined(USE_GPIOV1) // STM32F103C8 | 111 | #if defined(USE_GPIOV1) // STM32F103C8 |
| 112 | palSetLineMode(AUDIO_PIN, PAL_MODE_STM32_ALTERNATE_PUSHPULL); | 112 | palSetLineMode(AUDIO_PIN, PAL_MODE_ALTERNATE_PUSHPULL); |
| 113 | #else // GPIOv2 (or GPIOv3 for f4xx, which is the same/compatible at this command) | 113 | #else // GPIOv2 (or GPIOv3 for f4xx, which is the same/compatible at this command) |
| 114 | palSetLineMode(AUDIO_PIN, PAL_STM32_MODE_ALTERNATE | PAL_STM32_ALTERNATE(AUDIO_PWM_PAL_MODE)); | 114 | palSetLineMode(AUDIO_PIN, PAL_MODE_ALTERNATE(AUDIO_PWM_PAL_MODE)); |
| 115 | #endif | 115 | #endif |
| 116 | 116 | ||
| 117 | gptStart(&AUDIO_STATE_TIMER, &gptCFG); | 117 | gptStart(&AUDIO_STATE_TIMER, &gptCFG); |
diff --git a/quantum/backlight/backlight_chibios.c b/quantum/backlight/backlight_chibios.c index 4d5a69e14..7c6edd10d 100644 --- a/quantum/backlight/backlight_chibios.c +++ b/quantum/backlight/backlight_chibios.c | |||
| @@ -8,9 +8,13 @@ | |||
| 8 | # define BACKLIGHT_LIMIT_VAL 255 | 8 | # define BACKLIGHT_LIMIT_VAL 255 |
| 9 | #endif | 9 | #endif |
| 10 | 10 | ||
| 11 | // GPIOV2 && GPIOV3 | ||
| 12 | #ifndef BACKLIGHT_PAL_MODE | 11 | #ifndef BACKLIGHT_PAL_MODE |
| 13 | # define BACKLIGHT_PAL_MODE 2 | 12 | # if defined(USE_GPIOV1) |
| 13 | # define BACKLIGHT_PAL_MODE PAL_MODE_ALTERNATE_PUSHPULL | ||
| 14 | # else | ||
| 15 | // GPIOV2 && GPIOV3 | ||
| 16 | # define BACKLIGHT_PAL_MODE 5 | ||
| 17 | # endif | ||
| 14 | #endif | 18 | #endif |
| 15 | 19 | ||
| 16 | // GENERIC | 20 | // GENERIC |
| @@ -70,7 +74,7 @@ static uint32_t rescale_limit_val(uint32_t val) { | |||
| 70 | 74 | ||
| 71 | void backlight_init_ports(void) { | 75 | void backlight_init_ports(void) { |
| 72 | #ifdef USE_GPIOV1 | 76 | #ifdef USE_GPIOV1 |
| 73 | palSetPadMode(PAL_PORT(BACKLIGHT_PIN), PAL_PAD(BACKLIGHT_PIN), PAL_MODE_STM32_ALTERNATE_PUSHPULL); | 77 | palSetPadMode(PAL_PORT(BACKLIGHT_PIN), PAL_PAD(BACKLIGHT_PIN), BACKLIGHT_PAL_MODE); |
| 74 | #else | 78 | #else |
| 75 | palSetPadMode(PAL_PORT(BACKLIGHT_PIN), PAL_PAD(BACKLIGHT_PIN), PAL_MODE_ALTERNATE(BACKLIGHT_PAL_MODE)); | 79 | palSetPadMode(PAL_PORT(BACKLIGHT_PIN), PAL_PAD(BACKLIGHT_PIN), PAL_MODE_ALTERNATE(BACKLIGHT_PAL_MODE)); |
| 76 | #endif | 80 | #endif |
diff --git a/quantum/quantum.c b/quantum/quantum.c index e60378afe..9d77fa438 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c | |||
| @@ -480,3 +480,99 @@ void api_send_unicode(uint32_t unicode) { | |||
| 480 | __attribute__((weak)) void startup_user() {} | 480 | __attribute__((weak)) void startup_user() {} |
| 481 | 481 | ||
| 482 | __attribute__((weak)) void shutdown_user() {} | 482 | __attribute__((weak)) void shutdown_user() {} |
| 483 | |||
| 484 | /** \brief Run keyboard level Power down | ||
| 485 | * | ||
| 486 | * FIXME: needs doc | ||
| 487 | */ | ||
| 488 | __attribute__((weak)) void suspend_power_down_user(void) {} | ||
| 489 | /** \brief Run keyboard level Power down | ||
| 490 | * | ||
| 491 | * FIXME: needs doc | ||
| 492 | */ | ||
| 493 | __attribute__((weak)) void suspend_power_down_kb(void) { suspend_power_down_user(); } | ||
| 494 | |||
| 495 | void suspend_power_down_quantum(void) { | ||
| 496 | #ifndef NO_SUSPEND_POWER_DOWN | ||
| 497 | // Turn off backlight | ||
| 498 | # ifdef BACKLIGHT_ENABLE | ||
| 499 | backlight_set(0); | ||
| 500 | # endif | ||
| 501 | |||
| 502 | # ifdef LED_MATRIX_ENABLE | ||
| 503 | led_matrix_task(); | ||
| 504 | # endif | ||
| 505 | # ifdef RGB_MATRIX_ENABLE | ||
| 506 | rgb_matrix_task(); | ||
| 507 | # endif | ||
| 508 | |||
| 509 | // Turn off LED indicators | ||
| 510 | uint8_t leds_off = 0; | ||
| 511 | # if defined(BACKLIGHT_CAPS_LOCK) && defined(BACKLIGHT_ENABLE) | ||
| 512 | if (is_backlight_enabled()) { | ||
| 513 | // Don't try to turn off Caps Lock indicator as it is backlight and backlight is already off | ||
| 514 | leds_off |= (1 << USB_LED_CAPS_LOCK); | ||
| 515 | } | ||
| 516 | # endif | ||
| 517 | led_set(leds_off); | ||
| 518 | |||
| 519 | // Turn off audio | ||
| 520 | # ifdef AUDIO_ENABLE | ||
| 521 | stop_all_notes(); | ||
| 522 | # endif | ||
| 523 | |||
| 524 | // Turn off underglow | ||
| 525 | # if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 526 | rgblight_suspend(); | ||
| 527 | # endif | ||
| 528 | |||
| 529 | # if defined(LED_MATRIX_ENABLE) | ||
| 530 | led_matrix_set_suspend_state(true); | ||
| 531 | # endif | ||
| 532 | # if defined(RGB_MATRIX_ENABLE) | ||
| 533 | rgb_matrix_set_suspend_state(true); | ||
| 534 | # endif | ||
| 535 | |||
| 536 | # ifdef OLED_ENABLE | ||
| 537 | oled_off(); | ||
| 538 | # endif | ||
| 539 | # ifdef ST7565_ENABLE | ||
| 540 | st7565_off(); | ||
| 541 | # endif | ||
| 542 | #endif | ||
| 543 | } | ||
| 544 | |||
| 545 | /** \brief run user level code immediately after wakeup | ||
| 546 | * | ||
| 547 | * FIXME: needs doc | ||
| 548 | */ | ||
| 549 | __attribute__((weak)) void suspend_wakeup_init_user(void) {} | ||
| 550 | |||
| 551 | /** \brief run keyboard level code immediately after wakeup | ||
| 552 | * | ||
| 553 | * FIXME: needs doc | ||
| 554 | */ | ||
| 555 | __attribute__((weak)) void suspend_wakeup_init_kb(void) { suspend_wakeup_init_user(); } | ||
| 556 | |||
| 557 | __attribute__((weak)) void suspend_wakeup_init_quantum(void) { | ||
| 558 | // Turn on backlight | ||
| 559 | #ifdef BACKLIGHT_ENABLE | ||
| 560 | backlight_init(); | ||
| 561 | #endif | ||
| 562 | |||
| 563 | // Restore LED indicators | ||
| 564 | led_set(host_keyboard_leds()); | ||
| 565 | |||
| 566 | // Wake up underglow | ||
| 567 | #if defined(RGBLIGHT_SLEEP) && defined(RGBLIGHT_ENABLE) | ||
| 568 | rgblight_wakeup(); | ||
| 569 | #endif | ||
| 570 | |||
| 571 | #if defined(LED_MATRIX_ENABLE) | ||
| 572 | led_matrix_set_suspend_state(false); | ||
| 573 | #endif | ||
| 574 | #if defined(RGB_MATRIX_ENABLE) | ||
| 575 | rgb_matrix_set_suspend_state(false); | ||
| 576 | #endif | ||
| 577 | suspend_wakeup_init_kb(); | ||
| 578 | } | ||
