diff options
| author | yulei <yuleiz@gmail.com> | 2021-11-05 10:54:40 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-05 13:54:40 +1100 |
| commit | 3f62b46939dbd2dd04d5d8c7b7ad53323f832332 (patch) | |
| tree | 50e2c93b3951401b395c6ba19aabf1c162f91195 /keyboards/matrix/abelx/abelx.c | |
| parent | 2ac2695cb5fac5402e9a9834c55dce9d34ed0da5 (diff) | |
| download | qmk_firmware-3f62b46939dbd2dd04d5d8c7b7ad53323f832332.tar.gz qmk_firmware-3f62b46939dbd2dd04d5d8c7b7ad53323f832332.zip | |
add matrix abelx keyboard (#10968)
* add matrix abelx keyboard
* Update keyboards/matrix/abelx/abelx.c
Co-authored-by: Drashna Jaelre <drashna@live.com>
* fixed rgb led pin issue
* Apply suggestions from code review
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
* Update keyboards/matrix/abelx/aw9523b.h
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
* Update keyboards/matrix/abelx/aw9523b.c
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
* Update keyboards/matrix/abelx/abelx.h
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
* Update keyboards/matrix/abelx/abelx.c
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
* fixed board name
* Apply suggestions from code review
Co-authored-by: Nick Brassel <nick@tzarc.org>
* move led update from scan_kb to hoursekeeping_kb
* move led update from scan_kb to housekeeping_kb
Co-authored-by: Drashna Jaelre <drashna@live.com>
Co-authored-by: James Young <18669334+noroadsleft@users.noreply.github.com>
Co-authored-by: Nick Brassel <nick@tzarc.org>
Diffstat (limited to 'keyboards/matrix/abelx/abelx.c')
| -rw-r--r-- | keyboards/matrix/abelx/abelx.c | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/keyboards/matrix/abelx/abelx.c b/keyboards/matrix/abelx/abelx.c new file mode 100644 index 000000000..77e749ee4 --- /dev/null +++ b/keyboards/matrix/abelx/abelx.c | |||
| @@ -0,0 +1,99 @@ | |||
| 1 | /** | ||
| 2 | * abelx.c | ||
| 3 | * | ||
| 4 | * Copyright 2020 astro <yuleiz@gmail.com> | ||
| 5 | * | ||
| 6 | * This program is free software: you can redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation, either version 2 of the License, or | ||
| 9 | * (at your option) any later version. | ||
| 10 | * | ||
| 11 | * This program is distributed in the hope that it will be useful, | ||
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 14 | * GNU General Public License for more details. | ||
| 15 | * | ||
| 16 | * You should have received a copy of the GNU General Public License | ||
| 17 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 18 | */ | ||
| 19 | |||
| 20 | #include "abelx.h" | ||
| 21 | #include "tca6424.h" | ||
| 22 | #include "aw9523b.h" | ||
| 23 | |||
| 24 | void set_pin(uint16_t pin) | ||
| 25 | { | ||
| 26 | uint8_t data = tca6424_read_port(GET_PORT(pin)); | ||
| 27 | data |= ( 1 << GET_PIN(pin)); | ||
| 28 | tca6424_write_port(GET_PORT(pin), data); | ||
| 29 | } | ||
| 30 | |||
| 31 | void clear_pin(uint16_t pin) | ||
| 32 | { | ||
| 33 | uint8_t data = tca6424_read_port(GET_PORT(pin)); | ||
| 34 | data &= ~( 1 << GET_PIN(pin)); | ||
| 35 | tca6424_write_port(GET_PORT(pin), data); | ||
| 36 | } | ||
| 37 | |||
| 38 | uint8_t read_pin(uint16_t pin) | ||
| 39 | { | ||
| 40 | uint8_t data = tca6424_read_port(GET_PORT(pin)); | ||
| 41 | return (data & (1<<GET_PIN(pin))) ? 1 : 0; | ||
| 42 | } | ||
| 43 | |||
| 44 | void matrix_init_kb(void) { | ||
| 45 | #ifdef RGBLIGHT_ENABLE | ||
| 46 | aw9523b_init(AW9523B_ADDR); | ||
| 47 | #endif | ||
| 48 | matrix_init_user(); | ||
| 49 | } | ||
| 50 | |||
| 51 | |||
| 52 | void housekeeping_task_kb(void) { | ||
| 53 | #ifdef RGBLIGHT_ENABLE | ||
| 54 | aw9523b_update_pwm_buffers(AW9523B_ADDR); | ||
| 55 | #endif | ||
| 56 | } | ||
| 57 | |||
| 58 | #ifdef RGBLIGHT_ENABLE | ||
| 59 | #include "rgblight.h" | ||
| 60 | #include "i2c_master.h" | ||
| 61 | |||
| 62 | const aw9523b_led g_aw9523b_leds[AW9523B_RGB_NUM] = { | ||
| 63 | {AW9523B_P12_PWM, AW9523B_P11_PWM, AW9523B_P10_PWM}, | ||
| 64 | {AW9523B_P01_PWM, AW9523B_P00_PWM, AW9523B_P13_PWM}, | ||
| 65 | {AW9523B_P04_PWM, AW9523B_P03_PWM, AW9523B_P02_PWM}, | ||
| 66 | {AW9523B_P07_PWM, AW9523B_P06_PWM, AW9523B_P05_PWM}, | ||
| 67 | }; | ||
| 68 | |||
| 69 | void rgblight_call_driver(LED_TYPE *start_led, uint8_t num_leds) | ||
| 70 | { | ||
| 71 | uint8_t num = num_leds < AW9523B_RGB_NUM ? num_leds : AW9523B_RGB_NUM; | ||
| 72 | |||
| 73 | ws2812_setleds(start_led, num); | ||
| 74 | |||
| 75 | for (int i = 0; i < num; i++) { | ||
| 76 | aw9523b_set_color(i, start_led[i].r, start_led[i].g, start_led[i].b); | ||
| 77 | } | ||
| 78 | } | ||
| 79 | |||
| 80 | #endif | ||
| 81 | |||
| 82 | static uint16_t caps_lock_pin = DEF_PIN(TCA6424_PORT2, 3); | ||
| 83 | static uint16_t scroll_lock_pin = DEF_PIN(TCA6424_PORT0, 0); | ||
| 84 | |||
| 85 | bool led_update_kb(led_t led_state) { | ||
| 86 | bool res = led_update_user(led_state); | ||
| 87 | if (res) { | ||
| 88 | led_state.caps_lock ? set_pin(caps_lock_pin) : clear_pin(caps_lock_pin); | ||
| 89 | led_state.scroll_lock ? set_pin(scroll_lock_pin) : clear_pin(scroll_lock_pin); | ||
| 90 | } | ||
| 91 | return res; | ||
| 92 | } | ||
| 93 | |||
| 94 | #define REBOOT_MAGIC 0x41544B42 | ||
| 95 | void shutdown_user(void) | ||
| 96 | { | ||
| 97 | // set the magic number for resetting to the bootloader | ||
| 98 | *(uint32_t *)(&(RTCD1.rtc->BKP0R)) = REBOOT_MAGIC; | ||
| 99 | } | ||
