From 4a549dad82049f656c7a87a7e2600731817ebcc2 Mon Sep 17 00:00:00 2001 From: codetector Date: Mon, 29 Jun 2020 23:32:19 -0400 Subject: [PATCH 01/88] [keyboard] Initial support for Anne Pro 2 --- keyboards/annepro2/annepro2.c | 9 + keyboards/annepro2/annepro2.h | 22 + keyboards/annepro2/boards/ANNEPRO2/board.c | 207 ++++++ keyboards/annepro2/boards/ANNEPRO2/board.h | 70 ++ keyboards/annepro2/boards/ANNEPRO2/board.mk | 5 + keyboards/annepro2/chconf.h | 691 +++++++++++++++++++ keyboards/annepro2/config.h | 169 +++++ keyboards/annepro2/halconf.h | 376 ++++++++++ keyboards/annepro2/hardfault_handler.c | 41 ++ keyboards/annepro2/keymaps/default/keymap.c | 34 + keyboards/annepro2/ld/HT32F52342_ANNEPRO2.ld | 91 +++ keyboards/annepro2/matrix.c | 116 ++++ keyboards/annepro2/mcuconf.h | 72 ++ keyboards/annepro2/rules.mk | 37 + 14 files changed, 1940 insertions(+) create mode 100644 keyboards/annepro2/annepro2.c create mode 100644 keyboards/annepro2/annepro2.h create mode 100644 keyboards/annepro2/boards/ANNEPRO2/board.c create mode 100644 keyboards/annepro2/boards/ANNEPRO2/board.h create mode 100644 keyboards/annepro2/boards/ANNEPRO2/board.mk create mode 100644 keyboards/annepro2/chconf.h create mode 100644 keyboards/annepro2/config.h create mode 100644 keyboards/annepro2/halconf.h create mode 100644 keyboards/annepro2/hardfault_handler.c create mode 100644 keyboards/annepro2/keymaps/default/keymap.c create mode 100644 keyboards/annepro2/ld/HT32F52342_ANNEPRO2.ld create mode 100644 keyboards/annepro2/matrix.c create mode 100644 keyboards/annepro2/mcuconf.h create mode 100644 keyboards/annepro2/rules.mk diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c new file mode 100644 index 000000000000..c770163bedbb --- /dev/null +++ b/keyboards/annepro2/annepro2.c @@ -0,0 +1,9 @@ +#include "annepro2.h" + +void OVERRIDE matrix_init_kb(void) { + matrix_init_user(); +} + +bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { + return process_record_user(keycode, record); +} diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h new file mode 100644 index 000000000000..f8acc896b421 --- /dev/null +++ b/keyboards/annepro2/annepro2.h @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018 Charlie Waters + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +#include "quantum.h" + +#define OVERRIDE __attribute__ ((noinline)) diff --git a/keyboards/annepro2/boards/ANNEPRO2/board.c b/keyboards/annepro2/boards/ANNEPRO2/board.c new file mode 100644 index 000000000000..d95f3fb3859b --- /dev/null +++ b/keyboards/annepro2/boards/ANNEPRO2/board.c @@ -0,0 +1,207 @@ +/* + ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio + (C) 2018 Charlie Waters + (C) 2020 Yaotian Feng, Codetector + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include +#include "ch.h" +#include "hal.h" +#include "wait.h" +#include "led.h" +#include "annepro2.h" + +/* ============ Private Defines ===================== */ + +/* ============ Function Prototypes ================== */ + + +#define PBIT(PORT, LINE) ((PAL_PORT(LINE) == PORT) ? (1 << PAL_PAD(LINE)) : 0) +#define PAFIO_L(PORT, LINE, AF) (((PAL_PORT(LINE) == PORT) && (PAL_PAD(LINE) < 8)) ? (AF << (PAL_PAD(LINE) << 2)) : 0) +#define PAFIO_H(PORT, LINE, AF) (((PAL_PORT(LINE) == PORT) && (PAL_PAD(LINE) >= 8)) ? (AF << ((PAL_PAD(LINE) - 8) << 2)) : 0) +#define PAFIO(PORT, N, LINE, AF) ((N) ? PAFIO_H(PORT, LINE, AF) : PAFIO_L(PORT, LINE, AF)) + +#define OUT_BITS(PORT) (\ + PBIT(PORT, LINE_ROW1 ) | \ + PBIT(PORT, LINE_ROW2 ) | \ + PBIT(PORT, LINE_ROW3 ) | \ + PBIT(PORT, LINE_ROW4 ) | \ + PBIT(PORT, LINE_ROW5 ) | \ +0) + +#define IN_BITS(PORT) (\ + PBIT(PORT, LINE_COL1) | \ + PBIT(PORT, LINE_COL2) | \ + PBIT(PORT, LINE_COL3) | \ + PBIT(PORT, LINE_COL4) | \ + PBIT(PORT, LINE_COL5) | \ + PBIT(PORT, LINE_COL6) | \ + PBIT(PORT, LINE_COL7) | \ + PBIT(PORT, LINE_COL8) | \ + PBIT(PORT, LINE_COL9) | \ + PBIT(PORT, LINE_COL10)| \ + PBIT(PORT, LINE_COL11)| \ + PBIT(PORT, LINE_COL12)| \ + PBIT(PORT, LINE_COL13)| \ + PBIT(PORT, LINE_COL14)| \ +0) + +// Alternate Functions +#define AF_BITS(PORT, N) (\ + PAFIO(PORT, N, LINE_ROW1, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_ROW2, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_ROW3, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_ROW4, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_ROW5, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_COL1, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_COL2, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_COL3, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_COL4, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_COL5, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_COL6, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_COL7, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_COL8, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_COL9, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_COL10, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_COL11, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_COL12, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_COL13, AFIO_GPIO) | \ + PAFIO(PORT, N, LINE_COL14, AFIO_GPIO) | \ +0) + + + +/** + * @brief PAL setup. + * @details Digital I/O ports static configuration as defined in @p board.h. + * This variable is used by the HAL when initializing the PAL driver. + */ +const PALConfig pal_default_config = { + // GPIO A + .setup[0] = { + .DIR = OUT_BITS(IOPORTA), + .INE = IN_BITS(IOPORTA), + .PU = IN_BITS(IOPORTA), + .PD = 0x0000, + .OD = 0x0000, + .DRV = 0x0000, + .LOCK = 0x0000, + .OUT = 0x0000, + .CFG[0] = AF_BITS(IOPORTA, 0), + .CFG[1] = AF_BITS(IOPORTA, 1), + }, + // GPIO B + .setup[1] = { + .DIR = OUT_BITS(IOPORTB), + .INE = IN_BITS(IOPORTB), + .PU = IN_BITS(IOPORTB), + .PD = 0x0000, + .OD = 0x0000, + .DRV = 0x0000, + .LOCK = 0x0000, + .OUT = 0x0000, + .CFG[0] = AF_BITS(IOPORTB, 0), + .CFG[1] = AF_BITS(IOPORTB, 1), + }, + // GPIO C + .setup[2] = { + .DIR = OUT_BITS(IOPORTC), + .INE = IN_BITS(IOPORTC), + .PU = IN_BITS(IOPORTC), + .PD = 0x0000, + .OD = 0x0000, + .DRV = 0x0000, + .LOCK = 0x0000, + .OUT = 0x0000, + .CFG[0] = AF_BITS(IOPORTC, 0), + .CFG[1] = AF_BITS(IOPORTC, 1), + }, + // GPIO D + .setup[3] = { + .DIR = OUT_BITS(IOPORTD), + .INE = IN_BITS(IOPORTD), + .PU = IN_BITS(IOPORTD), + .PD = 0x0000, + .OD = 0x0000, + .DRV = 0x0000, + .LOCK = 0x0000, + .OUT = 0x0000, + .CFG[0] = AF_BITS(IOPORTD, 0), + .CFG[1] = AF_BITS(IOPORTD, 1), + }, + .ESSR[0] = 0x00000000, + .ESSR[1] = 0x00000000, +}; + +const ioline_t row_list[MATRIX_ROWS] = { + LINE_ROW1, + LINE_ROW2, + LINE_ROW3, + LINE_ROW4, + LINE_ROW5, +}; + +const ioline_t col_list[MATRIX_COLS] = { + LINE_COL1, + LINE_COL2, + LINE_COL3, + LINE_COL4, + LINE_COL5, + LINE_COL6, + LINE_COL7, + LINE_COL8, + LINE_COL9, + LINE_COL10, + LINE_COL11, + LINE_COL12, + LINE_COL13, + LINE_COL14, +}; + +void __early_init(void) { + ht32_clock_init(); +} + +void matrix_scan_kb() { + matrix_scan_user(); +} + + + +// SPI Initialization + +// static const SPIConfig spi1_config = { +// .end_cb = NULL, +// .cr0 = SPI_CR0_SELOEN, +// .cr1 = 8 | SPI_CR1_FORMAT_MODE0 | SPI_CR1_MODE, +// .cpr = 1, +// .fcr = 0, +// }; + +// void spi_init(void) { +// spiStart(&SPID1, &spi1_config); +// palSetLine(LINE_SPI_CS); +// } + +/** + * @brief Board-specific initialization code. + * @todo Add your board-specific code, if any. + */ +void boardInit(void) { +#if HAL_USE_GPT == TRUE + gpt_init(); +#endif + // spi_init(); +} diff --git a/keyboards/annepro2/boards/ANNEPRO2/board.h b/keyboards/annepro2/boards/ANNEPRO2/board.h new file mode 100644 index 000000000000..d9dcd3e3bb32 --- /dev/null +++ b/keyboards/annepro2/boards/ANNEPRO2/board.h @@ -0,0 +1,70 @@ +/* + ChibiOS - Copyright (C) 2020 Codetector + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef BOARD_H +#define BOARD_H +/* + * Setup for Anne Pro 2 board. + */ + +/* + * Board identifier. + */ +#define ANNEPRO2 +#define BOARD_NAME "Anne Pro 2" + +#define HT32F52342 + +#define FLASH_SIZE (0x10000 - 0x4000) // 64kB - 16kB + +/* + * I/O + */ + +// outputs (rows are pulled low) +#define LINE_ROW1 PAL_LINE(IOPORTC, 2) +#define LINE_ROW2 PAL_LINE(IOPORTC, 1) +#define LINE_ROW3 PAL_LINE(IOPORTB, 5) +#define LINE_ROW4 PAL_LINE(IOPORTB, 4) +#define LINE_ROW5 PAL_LINE(IOPORTC, 3) + +// inputs (columns are sampled) +#define LINE_COL1 PAL_LINE(IOPORTC, 4) +#define LINE_COL2 PAL_LINE(IOPORTC, 5) +#define LINE_COL3 PAL_LINE(IOPORTB, 10) +#define LINE_COL4 PAL_LINE(IOPORTB, 11) +#define LINE_COL5 PAL_LINE(IOPORTC, 0) +#define LINE_COL6 PAL_LINE(IOPORTA, 15) +#define LINE_COL7 PAL_LINE(IOPORTA, 8) +#define LINE_COL8 PAL_LINE(IOPORTA, 10) +#define LINE_COL9 PAL_LINE(IOPORTA, 11) +#define LINE_COL10 PAL_LINE(IOPORTA, 12) +#define LINE_COL11 PAL_LINE(IOPORTA, 13) +#define LINE_COL12 PAL_LINE(IOPORTA, 14) +#define LINE_COL13 PAL_LINE(IOPORTB, 2) +#define LINE_COL14 PAL_LINE(IOPORTB, 3) + +#if !defined(_FROM_ASM_) +#ifdef __cplusplus +extern "C" { +#endif + void boardInit(void); +#ifdef __cplusplus +} +#endif +#endif /* _FROM_ASM_ */ + +#endif /* BOARD_H */ diff --git a/keyboards/annepro2/boards/ANNEPRO2/board.mk b/keyboards/annepro2/boards/ANNEPRO2/board.mk new file mode 100644 index 000000000000..0464919caf22 --- /dev/null +++ b/keyboards/annepro2/boards/ANNEPRO2/board.mk @@ -0,0 +1,5 @@ +# List of all the board related files. +BOARDSRC = $(BOARD_PATH)/boards/ANNEPRO2/board.c + +# Required include directories +BOARDINC = $(BOARD_PATH)/boards/ANNEPRO2 diff --git a/keyboards/annepro2/chconf.h b/keyboards/annepro2/chconf.h new file mode 100644 index 000000000000..f5c09246d67c --- /dev/null +++ b/keyboards/annepro2/chconf.h @@ -0,0 +1,691 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file templates/chconf.h + * @brief Configuration file template. + * @details A copy of this file must be placed in each project directory, it + * contains the application specific kernel settings. + * + * @addtogroup config + * @details Kernel related settings and hooks. + * @{ + */ + +#ifndef CHCONF_H +#define CHCONF_H + +#define _CHIBIOS_RT_CONF_ +#define _CHIBIOS_RT_CONF_VER_6_0_ + + +/*===========================================================================*/ +/** + * @name System timers settings + * @{ + */ +/*===========================================================================*/ + +/** + * @brief System time counter resolution. + * @note Allowed values are 16 or 32 bits. + */ +#if !defined(CH_CFG_ST_RESOLUTION) +#define CH_CFG_ST_RESOLUTION 32 +#endif +/** + * @brief System tick frequency. + * @details Frequency of the system timer that drives the system ticks. This + * setting also defines the system tick time unit. + */ +#if !defined(CH_CFG_ST_FREQUENCY) +#define CH_CFG_ST_FREQUENCY 1000 +#endif + +/** + * @brief Time intervals data size. + * @note Allowed values are 16, 32 or 64 bits. + */ +#if !defined(CH_CFG_INTERVALS_SIZE) +#define CH_CFG_INTERVALS_SIZE 32 +#endif + +/** + * @brief Time types data size. + * @note Allowed values are 16 or 32 bits. + */ +#if !defined(CH_CFG_TIME_TYPES_SIZE) +#define CH_CFG_TIME_TYPES_SIZE 32 +#endif + +/** + * @brief Time delta constant for the tick-less mode. + * @note If this value is zero then the system uses the classic + * periodic tick. This value represents the minimum number + * of ticks that is safe to specify in a timeout directive. + * The value one is not valid, timeouts are rounded up to + * this value. + */ +#if !defined(CH_CFG_ST_TIMEDELTA) +#define CH_CFG_ST_TIMEDELTA 0 +#endif +/** @} */ + +/*===========================================================================*/ +/** + * @name Kernel parameters and options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Round robin interval. + * @details This constant is the number of system ticks allowed for the + * threads before preemption occurs. Setting this value to zero + * disables the preemption for threads with equal priority and the + * round robin becomes cooperative. Note that higher priority + * threads can still preempt, the kernel is always preemptive. + * @note Disabling the round robin preemption makes the kernel more compact + * and generally faster. + * @note The round robin preemption is not supported in tickless mode and + * must be set to zero in that case. + */ +#if !defined(CH_CFG_TIME_QUANTUM) +#define CH_CFG_TIME_QUANTUM 20 +#endif + +/** + * @brief Managed RAM size. + * @details Size of the RAM area to be managed by the OS. If set to zero + * then the whole available RAM is used. The core memory is made + * available to the heap allocator and/or can be used directly through + * the simplified core memory allocator. + * + * @note In order to let the OS manage the whole RAM the linker script must + * provide the @p __heap_base__ and @p __heap_end__ symbols. + * @note Requires @p CH_CFG_USE_MEMCORE. + */ +#if !defined(CH_CFG_MEMCORE_SIZE) +#define CH_CFG_MEMCORE_SIZE 0 +#endif + +/** + * @brief Idle thread automatic spawn suppression. + * @details When this option is activated the function @p chSysInit() + * does not spawn the idle thread. The application @p main() + * function becomes the idle thread and must implement an + * infinite loop. + */ +#if !defined(CH_CFG_NO_IDLE_THREAD) +#define CH_CFG_NO_IDLE_THREAD FALSE +#endif + + +/** @} */ + +/*===========================================================================*/ +/** + * @name Performance options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief OS optimization. + * @details If enabled then time efficient rather than space efficient code + * is used when two possible implementations exist. + * + * @note This is not related to the compiler optimization options. + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_OPTIMIZE_SPEED) +#define CH_CFG_OPTIMIZE_SPEED TRUE +#endif +/** @} */ + +/** + * @brief Time Measurement APIs. + * @details If enabled then the time measurement APIs are included in + * the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_TM) +#define CH_CFG_USE_TM FALSE +#endif + +/** + * @brief Threads registry APIs. + * @details If enabled then the registry APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_REGISTRY) +#define CH_CFG_USE_REGISTRY TRUE +#endif + +/** + * @brief Threads synchronization APIs. + * @details If enabled then the @p chThdWait() function is included in + * the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_WAITEXIT) +#define CH_CFG_USE_WAITEXIT TRUE +#endif + +/** + * @brief Semaphores APIs. + * @details If enabled then the Semaphores APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_SEMAPHORES) +#define CH_CFG_USE_SEMAPHORES TRUE +#endif + +/** + * @brief Semaphores queuing mode. + * @details If enabled then the threads are enqueued on semaphores by + * priority rather than in FIFO order. + * + * @note The default is @p FALSE. Enable this if you have special + * requirements. + * @note Requires @p CH_CFG_USE_SEMAPHORES. + */ +#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY) +#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE +#endif + +/** + * @brief Mutexes APIs. + * @details If enabled then the mutexes APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_MUTEXES) +#define CH_CFG_USE_MUTEXES TRUE +#endif + +/** + * @brief Enables recursive behavior on mutexes. + * @note Recursive mutexes are heavier and have an increased + * memory footprint. + * + * @note The default is @p FALSE. + * @note Requires @p CH_CFG_USE_MUTEXES. + */ +#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE) +#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE +#endif + +/** + * @brief Conditional Variables APIs. + * @details If enabled then the conditional variables APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_MUTEXES. + */ +#if !defined(CH_CFG_USE_CONDVARS) +#define CH_CFG_USE_CONDVARS TRUE +#endif + +/** + * @brief Conditional Variables APIs with timeout. + * @details If enabled then the conditional variables APIs with timeout + * specification are included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_CONDVARS. + */ +#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT) +#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE +#endif + +/** + * @brief Events Flags APIs. + * @details If enabled then the event flags APIs are included in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_EVENTS) +#define CH_CFG_USE_EVENTS TRUE +#endif + +/** + * @brief Events Flags APIs with timeout. + * @details If enabled then the events APIs with timeout specification + * are included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_EVENTS. + */ +#if !defined(CH_CFG_USE_EVENTS_TIMEOUT) +#define CH_CFG_USE_EVENTS_TIMEOUT TRUE +#endif + +/** + * @brief Synchronous Messages APIs. + * @details If enabled then the synchronous messages APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_MESSAGES) +#define CH_CFG_USE_MESSAGES TRUE +#endif + +/** + * @brief Synchronous Messages queuing mode. + * @details If enabled then messages are served by priority rather than in + * FIFO order. + * + * @note The default is @p FALSE. Enable this if you have special + * requirements. + * @note Requires @p CH_CFG_USE_MESSAGES. + */ +#if !defined(CH_CFG_USE_MESSAGES_PRIORITY) +#define CH_CFG_USE_MESSAGES_PRIORITY FALSE +#endif + +/** + * @brief Mailboxes APIs. + * @details If enabled then the asynchronous messages (mailboxes) APIs are + * included in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_SEMAPHORES. + */ +#if !defined(CH_CFG_USE_MAILBOXES) +#define CH_CFG_USE_MAILBOXES TRUE +#endif + +/** + * @brief Core Memory Manager APIs. + * @details If enabled then the core memory manager APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_MEMCORE) +#define CH_CFG_USE_MEMCORE TRUE +#endif + +/** + * @brief Heap Allocator APIs. + * @details If enabled then the memory heap allocator APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or + * @p CH_CFG_USE_SEMAPHORES. + * @note Mutexes are recommended. + */ +#if !defined(CH_CFG_USE_HEAP) +#define CH_CFG_USE_HEAP TRUE +#endif + +/** + * @brief Memory Pools Allocator APIs. + * @details If enabled then the memory pools allocator APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_MEMPOOLS) +#define CH_CFG_USE_MEMPOOLS TRUE +#endif + +/** + * @brief Objects FIFOs APIs. + * @details If enabled then the objects FIFOs APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_OBJ_FIFOS) +#define CH_CFG_USE_OBJ_FIFOS TRUE +#endif + +/** + * @brief Pipes APIs. + * @details If enabled then the pipes APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + */ +#if !defined(CH_CFG_USE_PIPES) +#define CH_CFG_USE_PIPES TRUE +#endif + +/** + * @brief Dynamic Threads APIs. + * @details If enabled then the dynamic threads creation APIs are included + * in the kernel. + * + * @note The default is @p TRUE. + * @note Requires @p CH_CFG_USE_WAITEXIT. + * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS. + */ +#if !defined(CH_CFG_USE_DYNAMIC) +#define CH_CFG_USE_DYNAMIC TRUE +#endif + +/** @} */ + + +/*===========================================================================*/ +/** + * @name Objects factory options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Objects Factory APIs. + * @details If enabled then the objects factory APIs are included in the + * kernel. + * + * @note The default is @p FALSE. + */ +#if !defined(CH_CFG_USE_FACTORY) +#define CH_CFG_USE_FACTORY TRUE +#endif + +/** + * @brief Maximum length for object names. + * @details If the specified length is zero then the name is stored by + * pointer but this could have unintended side effects. + */ +#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH) +#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8 +#endif + +/** + * @brief Enables the registry of generic objects. + */ +#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY) +#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE +#endif + +/** + * @brief Enables factory for generic buffers. + */ +#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS) +#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE +#endif + +/** + * @brief Enables factory for semaphores. + */ +#if !defined(CH_CFG_FACTORY_SEMAPHORES) +#define CH_CFG_FACTORY_SEMAPHORES TRUE +#endif + +/** + * @brief Enables factory for mailboxes. + */ +#if !defined(CH_CFG_FACTORY_MAILBOXES) +#define CH_CFG_FACTORY_MAILBOXES TRUE +#endif + +/** + * @brief Enables factory for objects FIFOs. + */ +#if !defined(CH_CFG_FACTORY_OBJ_FIFOS) +#define CH_CFG_FACTORY_OBJ_FIFOS TRUE +#endif + +/** + * @brief Enables factory for Pipes. + */ +#if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__) +#define CH_CFG_FACTORY_PIPES TRUE +#endif + +/** @} */ + +/*===========================================================================*/ +/** + * @name Debug options + * @{ + */ +/*===========================================================================*/ + +/** + * @brief Debug option, kernel statistics. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_STATISTICS FALSE + +/** + * @brief Debug option, system state check. + * @details If enabled the correct call protocol for system APIs is checked + * at runtime. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_SYSTEM_STATE_CHECK FALSE // adds about 1K code + +/** + * @brief Debug option, parameters checks. + * @details If enabled then the checks on the API functions input + * parameters are activated. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_ENABLE_CHECKS FALSE // adds < 1K code + +/** + * @brief Debug option, consistency checks. + * @details If enabled then all the assertions in the kernel code are + * activated. This includes consistency checks inside the kernel, + * runtime anomalies and port-defined checks. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_ENABLE_ASSERTS FALSE // adds about 3K code + +/** + * @brief Debug option, trace buffer. + * @details If enabled then the trace buffer is activated. + * + * @note The default is @p CH_DBG_TRACE_MASK_DISABLED. + */ +#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED + +/** + * @brief Trace buffer entries. + * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is + * different from @p CH_DBG_TRACE_MASK_DISABLED. + */ +#define CH_DBG_TRACE_BUFFER_SIZE 128 + +/** + * @brief Debug option, stack checks. + * @details If enabled then a runtime stack check is performed. + * + * @note The default is @p FALSE. + * @note The stack check is performed in a architecture/port dependent way. + * It may not be implemented or some ports. + * @note The default failure mode is to halt the system with the global + * @p panic_msg variable set to @p NULL. + */ +#define CH_DBG_ENABLE_STACK_CHECK FALSE + +/** + * @brief Debug option, stacks initialization. + * @details If enabled then the threads working area is filled with a byte + * value when a thread is created. This can be useful for the + * runtime measurement of the used stack. + * + * @note The default is @p FALSE. + */ +#define CH_DBG_FILL_THREADS FALSE + +/** + * @brief Debug option, threads profiling. + * @details If enabled then a field is added to the @p thread_t structure that + * counts the system ticks occurred while executing the thread. + * + * @note The default is @p FALSE. + * @note This debug option is not currently compatible with the + * tickless mode. + */ +#define CH_DBG_THREADS_PROFILING FALSE + +/** @} */ + +/*===========================================================================*/ +/** + * @name Kernel hooks + * @{ + */ +/*===========================================================================*/ + +/** + * @brief System structure extension. + * @details User fields added to the end of the @p ch_system_t structure. + */ +#define CH_CFG_SYSTEM_EXTRA_FIELDS \ + /* Add threads custom fields here.*/ + +/** + * @brief System initialization hook. + * @details User initialization code added to the @p chSysInit() function + * just before interrupts are enabled globally. + */ +#define CH_CFG_SYSTEM_INIT_HOOK() { \ + /* Add threads initialization code here.*/ \ +} + +/** + * @brief Threads descriptor structure extension. + * @details User fields added to the end of the @p thread_t structure. + */ +#define CH_CFG_THREAD_EXTRA_FIELDS \ + /* Add threads custom fields here.*/ + +/** + * @brief Threads initialization hook. + * @details User initialization code added to the @p _thread_init() function. + * + * @note It is invoked from within @p _thread_init() and implicitly from all + * the threads creation APIs. + */ +#define CH_CFG_THREAD_INIT_HOOK(tp) { \ + /* Add threads initialization code here.*/ \ +} + +/** + * @brief Threads finalization hook. + * @details User finalization code added to the @p chThdExit() API. + */ +#define CH_CFG_THREAD_EXIT_HOOK(tp) { \ + /* Add threads finalization code here.*/ \ +} + +/** + * @brief Context switch hook. + * @details This hook is invoked just before switching between threads. + */ +#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \ + /* Context switch code here.*/ \ +} + +/** + * @brief ISR enter hook. + */ +#define CH_CFG_IRQ_PROLOGUE_HOOK() { \ + /* IRQ prologue code here.*/ \ +} + +/** + * @brief ISR exit hook. + */ +#define CH_CFG_IRQ_EPILOGUE_HOOK() { \ + /* IRQ epilogue code here.*/ \ +} + +/** + * @brief Idle thread enter hook. + * @note This hook is invoked within a critical zone, no OS functions + * should be invoked from here. + * @note This macro can be used to activate a power saving mode. + */ +#define CH_CFG_IDLE_ENTER_HOOK() { \ + /* Idle-enter code here.*/ \ +} + +/** + * @brief Idle thread leave hook. + * @note This hook is invoked within a critical zone, no OS functions + * should be invoked from here. + * @note This macro can be used to deactivate a power saving mode. + */ +#define CH_CFG_IDLE_LEAVE_HOOK() { \ + /* Idle-leave code here.*/ \ +} + +/** + * @brief Idle Loop hook. + * @details This hook is continuously invoked by the idle thread loop. + */ +#define CH_CFG_IDLE_LOOP_HOOK() { \ + /* Idle loop code here.*/ \ +} + +/** + * @brief System tick event hook. + * @details This hook is invoked in the system tick handler immediately + * after processing the virtual timers queue. + */ +#define CH_CFG_SYSTEM_TICK_HOOK() { \ + /* System tick event code here.*/ \ +} + +/** + * @brief System halt hook. + * @details This hook is invoked in case to a system halting error before + * the system is halted. + */ +#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \ + /* System halt code here.*/ \ +} + +/** + * @brief Trace hook. + * @details This hook is invoked each time a new record is written in the + * trace buffer. + */ +#define CH_CFG_TRACE_HOOK(tep) { \ + /* Trace code here.*/ \ +} + +/** @} */ + +/*===========================================================================*/ +/* Port-specific settings (override port settings defaulted in chcore.h). */ +/*===========================================================================*/ + +#define CH_HT32_WAIT_US_POLL TRUE + +#endif /* CHCONF_H */ + +/** @} */ diff --git a/keyboards/annepro2/config.h b/keyboards/annepro2/config.h new file mode 100644 index 000000000000..111efbf86abb --- /dev/null +++ b/keyboards/annepro2/config.h @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2018 Charlie Waters + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0x04d9 +#define PRODUCT_ID 0xa290 +#define DEVICE_VER 0x1337 +#define MANUFACTURER Holtek +#define PRODUCT Anne Pro 2 QMK +#define DESCRIPTION Anne Pro 2 with QMK +#define NAME_SLUG "annepro2" + + +// key matrix size +#define MATRIX_ROWS 5 +#define MATRIX_COLS 14 +// layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 144 bytes + +// Max available layers +#define MAX_LAYERS 8 +// keymaps size: layer size * MAX_LAYERS = 1152 bytes + +#define KEYMAP_60_ANSI +// Number of supported layouts +#define NUM_LAYOUTS 4 + +// Matrix keymap + +#define KEYMAP( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \ + K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, \ + K40, K42, K43, K46, K49, K4A, K4B, K4C \ +) { \ + /* COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14*/ \ + /* ROW1 */ { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \ + /* ROW2 */ { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D }, \ + /* ROW3 */ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, KC_NO}, \ + /* ROW4 */ { K30, KC_NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, KC_NO}, \ + /* ROW5 */ { K40, KC_NO, K42, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, K49, K4A, K4B, K4C, KC_NO}, \ +} + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCE 5 + +/* number of backlight levels */ +// #define BACKLIGHT_LEVELS 10 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +//#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +//#define LOCKING_RESYNC_ENABLE + +/* If defined, GRAVE_ESC will always act as ESC when CTRL is held. + * This is userful for the Windows task manager shortcut (ctrl+shift+esc). + */ +// #define GRAVE_ESC_CTRL_OVERRIDE + +/* + * Force NKRO + * + * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved + * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the + * makefile for this to work.) + * + * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) + * until the next keyboard reset. + * + * NKRO may prevent your keystrokes from being detected in the BIOS, but it is + * fully operational during normal computer usage. + * + * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) + * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by + * bootmagic, NKRO mode will always be enabled until it is toggled again during a + * power-up. + * + */ +#define FORCE_NKRO + +/* + * Magic Key Options + * + * Magic keys are hotkey commands that allow control over firmware functions of + * the keyboard. They are best used in combination with the HID Listen program, + * found here: https://www.pjrc.com/teensy/hid_listen.html + * + * The options below allow the magic key functionality to be changed. This is + * useful if your keyboard/keypad is missing keys and you want magic key support. + * + */ + +/* key combination for magic key command */ +/* +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) +*/ + +/* control how magic key switches layers */ +//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true +//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true +//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false + +/* override magic key keymap */ +//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS +//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS +//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM +//#define MAGIC_KEY_HELP1 H +//#define MAGIC_KEY_HELP2 SLASH +//#define MAGIC_KEY_DEBUG D +//#define MAGIC_KEY_DEBUG_MATRIX X +//#define MAGIC_KEY_DEBUG_KBD K +//#define MAGIC_KEY_DEBUG_MOUSE M +//#define MAGIC_KEY_VERSION V +//#define MAGIC_KEY_STATUS S +//#define MAGIC_KEY_CONSOLE C +//#define MAGIC_KEY_LAYER0_ALT1 ESC +//#define MAGIC_KEY_LAYER0_ALT2 GRAVE +//#define MAGIC_KEY_LAYER0 0 +//#define MAGIC_KEY_LAYER1 1 +//#define MAGIC_KEY_LAYER2 2 +//#define MAGIC_KEY_LAYER3 3 +//#define MAGIC_KEY_LAYER4 4 +//#define MAGIC_KEY_LAYER5 5 +//#define MAGIC_KEY_LAYER6 6 +//#define MAGIC_KEY_LAYER7 7 +//#define MAGIC_KEY_LAYER8 8 +//#define MAGIC_KEY_LAYER9 9 +//#define MAGIC_KEY_BOOTLOADER R +//#define MAGIC_KEY_LOCK CAPS +//#define MAGIC_KEY_EEPROM E +//#define MAGIC_KEY_NKRO N +//#define MAGIC_KEY_SLEEP_LED Z + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +// #define NO_DEBUG + +/* disable print */ +// #define NO_PRINTg + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + diff --git a/keyboards/annepro2/halconf.h b/keyboards/annepro2/halconf.h new file mode 100644 index 000000000000..05fe1c4e531a --- /dev/null +++ b/keyboards/annepro2/halconf.h @@ -0,0 +1,376 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +/** + * @file templates/halconf.h + * @brief HAL configuration header. + * @details HAL configuration file, this file allows to enable or disable the + * various device drivers from your application. You may also use + * this file in order to override the device drivers default settings. + * + * @addtogroup HAL_CONF + * @{ + */ + +#ifndef _HALCONF_H_ +#define _HALCONF_H_ + +#define _CHIBIOS_HAL_CONF_ +#define _CHIBIOS_HAL_CONF_VER_7_0_ + +#include "mcuconf.h" + +/** + * @brief Enables the PAL subsystem. + */ +#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) +#define HAL_USE_PAL TRUE +#endif + +/** + * @brief Enables the ADC subsystem. + */ +#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) +#define HAL_USE_ADC FALSE +#endif + +/** + * @brief Enables the CAN subsystem. + */ +#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) +#define HAL_USE_CAN FALSE +#endif + +/** + * @brief Enables the DAC subsystem. + */ +#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) +#define HAL_USE_DAC FALSE +#endif + +/** + * @brief Enables the EXT subsystem. + */ +#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__) +#define HAL_USE_EXT FALSE +#endif + +/** + * @brief Enables the GPT subsystem. + */ +#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) +#define HAL_USE_GPT FALSE +#endif + +/** + * @brief Enables the I2C subsystem. + */ +#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) +#define HAL_USE_I2C FALSE +#endif + +/** + * @brief Enables the I2S subsystem. + */ +#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) +#define HAL_USE_I2S FALSE +#endif + +/** + * @brief Enables the ICU subsystem. + */ +#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) +#define HAL_USE_ICU FALSE +#endif + +/** + * @brief Enables the MAC subsystem. + */ +#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) +#define HAL_USE_MAC FALSE +#endif + +/** + * @brief Enables the MMC_SPI subsystem. + */ +#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) +#define HAL_USE_MMC_SPI FALSE +#endif + +/** + * @brief Enables the PWM subsystem. + */ +#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) +#define HAL_USE_PWM FALSE +#endif + +/** + * @brief Enables the RTC subsystem. + */ +#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) +#define HAL_USE_RTC FALSE +#endif + +/** + * @brief Enables the SDC subsystem. + */ +#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) +#define HAL_USE_SDC FALSE +#endif + +/** + * @brief Enables the SERIAL subsystem. + */ +#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL FALSE +#endif + +/** + * @brief Enables the SERIAL over USB subsystem. + */ +#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) +#define HAL_USE_SERIAL_USB FALSE +#endif + +/** + * @brief Enables the SPI subsystem. + */ +#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) +#define HAL_USE_SPI FALSE +#endif + +/** + * @brief Enables the UART subsystem. + */ +#if !defined(HAL_USE_UART) || defined(__DOXYGEN__) +#define HAL_USE_UART FALSE +#endif + +/** + * @brief Enables the USB subsystem. + */ +#if !defined(HAL_USE_USB) || defined(__DOXYGEN__) +#define HAL_USE_USB TRUE +#endif + +/** + * @brief Enables the WDG subsystem. + */ +#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) +#define HAL_USE_WDG FALSE +#endif + +/*===========================================================================*/ +/* PAL driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__) +#define PAL_USE_CALLBACKS FALSE +#endif + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__) +#define PAL_USE_WAIT FALSE +#endif + +/*===========================================================================*/ +/* ADC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) +#define ADC_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define ADC_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* CAN driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Sleep mode related APIs inclusion switch. + */ +#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) +#define CAN_USE_SLEEP_MODE TRUE +#endif + +/*===========================================================================*/ +/* I2C driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables the mutual exclusion APIs on the I2C bus. + */ +#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define I2C_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* MAC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables an event sources for incoming packets. + */ +#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) +#define MAC_USE_ZERO_COPY FALSE +#endif + +/** + * @brief Enables an event sources for incoming packets. + */ +#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) +#define MAC_USE_EVENTS TRUE +#endif + +/*===========================================================================*/ +/* MMC_SPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + * This option is recommended also if the SPI driver does not + * use a DMA channel and heavily loads the CPU. + */ +#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) +#define MMC_NICE_WAITING TRUE +#endif + +/*===========================================================================*/ +/* SDC driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Number of initialization attempts before rejecting the card. + * @note Attempts are performed at 10mS intervals. + */ +#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) +#define SDC_INIT_RETRY 100 +#endif + +/** + * @brief Include support for MMC cards. + * @note MMC support is not yet implemented so this option must be kept + * at @p FALSE. + */ +#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) +#define SDC_MMC_SUPPORT FALSE +#endif + +/** + * @brief Delays insertions. + * @details If enabled this options inserts delays into the MMC waiting + * routines releasing some extra CPU time for the threads with + * lower priority, this may slow down the driver a bit however. + */ +#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) +#define SDC_NICE_WAITING TRUE +#endif + +/*===========================================================================*/ +/* SERIAL driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Default bit rate. + * @details Configuration parameter, this is the baud rate selected for the + * default configuration. + */ +#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) +#define SERIAL_DEFAULT_BITRATE 38400 +#endif + +/** + * @brief Serial buffers size. + * @details Configuration parameter, you can change the depth of the queue + * buffers depending on the requirements of your application. + * @note The default is 64 bytes for both the transmission and receive + * buffers. + */ +#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_BUFFERS_SIZE 16 +#endif + +/*===========================================================================*/ +/* SERIAL_USB driver related setting. */ +/*===========================================================================*/ + +/** + * @brief Serial over USB buffers size. + * @details Configuration parameter, the buffer size must be a multiple of + * the USB data endpoint maximum packet size. + * @note The default is 64 bytes for both the transmission and receive + * buffers. + */ +#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) +#define SERIAL_USB_BUFFERS_SIZE 256 +#endif + +/*===========================================================================*/ +/* SPI driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) +#define SPI_USE_WAIT TRUE +#endif + +/** + * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) +#define SPI_USE_MUTUAL_EXCLUSION TRUE +#endif + +/*===========================================================================*/ +/* USB driver related settings. */ +/*===========================================================================*/ + +/** + * @brief Enables synchronous APIs. + * @note Disabling this option saves both code and data space. + */ +#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) +#define USB_USE_WAIT TRUE +#endif + +#endif /* _HALCONF_H_ */ + +/** @} */ diff --git a/keyboards/annepro2/hardfault_handler.c b/keyboards/annepro2/hardfault_handler.c new file mode 100644 index 000000000000..dd65535feff2 --- /dev/null +++ b/keyboards/annepro2/hardfault_handler.c @@ -0,0 +1,41 @@ +#include "ch.h" +#include +#include "hal.h" + +#define bkpt() __asm volatile("BKPT #0\n") +OSAL_IRQ_HANDLER(HardFault_Handler) { +//Copy to local variables (not pointers) to allow GDB "i loc" to directly show the info + struct port_extctx ctx; + volatile unsigned long _CFSR ; + volatile unsigned long _HFSR ; + volatile unsigned long _DFSR ; + volatile unsigned long _AFSR ; + volatile unsigned long _BFAR ; + volatile unsigned long _MMAR ; + //Get thread context. Contains main registers including PC and LR + memcpy(&ctx, (void*)__get_PSP(), sizeof(struct port_extctx)); + (void)ctx; + + // Configurable Fault Status Register + // Consists of MMSR, BFSR and UFSR + _CFSR = (*((volatile unsigned long *)(0xE000ED28))); (void)(_CFSR); + + // Hard Fault Status Register + _HFSR = (*((volatile unsigned long *)(0xE000ED2C))); (void)(_HFSR); + + // Debug Fault Status Register + _DFSR = (*((volatile unsigned long *)(0xE000ED30))); (void)(_DFSR); + + // Auxiliary Fault Status Register + _AFSR = (*((volatile unsigned long *)(0xE000ED3C))); (void)(_AFSR); + + // Read the Fault Address Registers. These may not contain valid values. + // Check BFARVALID/MMARVALID to see if they are valid values + // MemManage Fault Address Register + _MMAR = (*((volatile unsigned long *)(0xE000ED34))) ; (void)(_MMAR); + // Bus Fault Address Register + _BFAR = (*((volatile unsigned long *)(0xE000ED38))); (void)(_BFAR); + //Cause debugger to stop. Ignored if no debugger is attached + bkpt(); + NVIC_SystemReset(); // If no debugger connected, just reset the board +} diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c new file mode 100644 index 000000000000..b1ed9d86c141 --- /dev/null +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -0,0 +1,34 @@ +#include +#include "annepro2.h" + +enum anne_pro_layers { + _BASE_LAYER, +}; + +const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE_LAYER] = KEYMAP( /* Base */ + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, + KC_LCTL,KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_RGUI, KC_RCTL + ) +}; + +const uint16_t keymaps_size = sizeof(keymaps); + + +void matrix_init_user(void) { + +} + +void matrix_scan_user(void) { +} + +layer_state_t layer_state_set_user(layer_state_t layer) { + return layer; +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + return true; +} diff --git a/keyboards/annepro2/ld/HT32F52342_ANNEPRO2.ld b/keyboards/annepro2/ld/HT32F52342_ANNEPRO2.ld new file mode 100644 index 000000000000..544400b94839 --- /dev/null +++ b/keyboards/annepro2/ld/HT32F52342_ANNEPRO2.ld @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2013-2016 Fabio UJonathan A. Kollaschtzig, http://fabioutzig.com + * (c) 2020 Yaotian Feng (Codetector) + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +/* + * HT32F52342 w/ Anne Pro 2 bootloader memory setup. + */ +MEMORY { + flash0 : org = 0x00004000, len = 64k - 16k /* firmware */ + flash1 : org = 0x00000000, len = 0 + flash2 : org = 0x00000000, len = 0 + flash3 : org = 0x00000000, len = 0 + flash4 : org = 0x00000000, len = 0 + flash5 : org = 0x00000000, len = 0 + flash6 : org = 0x00000000, len = 0 + flash7 : org = 0x00000000, len = 0 + ram0 : org = 0x20000000, len = 8k - 4 /* RAM */ + ram1 : org = 0x00000000, len = 0 + ram2 : org = 0x00000000, len = 0 + ram3 : org = 0x00000000, len = 0 + ram4 : org = 0x00000000, len = 0 + ram5 : org = 0x00000000, len = 0 + ram6 : org = 0x00000000, len = 0 + ram7 : org = 0x00000000, len = 0 +} + +/* For each data/text section two region are defined, a virtual region + and a load region (_LMA suffix).*/ + +/* Flash region to be used for exception vectors.*/ +REGION_ALIAS("VECTORS_FLASH", flash0); +REGION_ALIAS("VECTORS_FLASH_LMA", flash0); + +/* Flash region to be used for constructors and destructors.*/ +REGION_ALIAS("XTORS_FLASH", flash0); +REGION_ALIAS("XTORS_FLASH_LMA", flash0); + +/* Flash region to be used for code text.*/ +REGION_ALIAS("TEXT_FLASH", flash0); +REGION_ALIAS("TEXT_FLASH_LMA", flash0); + +/* Flash region to be used for read only data.*/ +REGION_ALIAS("RODATA_FLASH", flash0); +REGION_ALIAS("RODATA_FLASH_LMA", flash0); + +/* Flash region to be used for various.*/ +REGION_ALIAS("VARIOUS_FLASH", flash0); +REGION_ALIAS("VARIOUS_FLASH_LMA", flash0); + +/* Flash region to be used for RAM(n) initialization data.*/ +REGION_ALIAS("RAM_INIT_FLASH_LMA", flash0); + +/* RAM region to be used for Main stack. This stack accommodates the processing + of all exceptions and interrupts.*/ +REGION_ALIAS("MAIN_STACK_RAM", ram0); + +/* RAM region to be used for the process stack. This is the stack used by + the main() function.*/ +REGION_ALIAS("PROCESS_STACK_RAM", ram0); + +/* RAM region to be used for data segment.*/ +REGION_ALIAS("DATA_RAM", ram0); +REGION_ALIAS("DATA_RAM_LMA", flash0); + +/* RAM region to be used for BSS segment.*/ +REGION_ALIAS("BSS_RAM", ram0); + +/* RAM region to be used for the default heap.*/ +REGION_ALIAS("HEAP_RAM", ram0); + +/* Generic rules inclusion.*/ +INCLUDE rules.ld diff --git a/keyboards/annepro2/matrix.c b/keyboards/annepro2/matrix.c new file mode 100644 index 000000000000..5dbbae17992d --- /dev/null +++ b/keyboards/annepro2/matrix.c @@ -0,0 +1,116 @@ +/* + * Copyright (c) 2018 Charlie Waters + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include +#include +#include +#include "timer.h" +#include "wait.h" +#include "print.h" +#include "matrix.h" +#include "annepro2.h" + +static matrix_row_t matrix[MATRIX_ROWS]; +static matrix_row_t matrix_debouncing[MATRIX_ROWS]; +static uint32_t debounce_times[MATRIX_ROWS]; + +extern ioline_t row_list[MATRIX_ROWS]; +extern ioline_t col_list[MATRIX_COLS]; + +void matrix_init(void) { + memset(matrix, 0, MATRIX_ROWS * sizeof(matrix_row_t)); + memset(matrix_debouncing, 0, MATRIX_ROWS * sizeof(matrix_row_t)); + memset(debounce_times, 0, MATRIX_ROWS * sizeof(uint32_t)); + matrix_init_quantum(); +} + +uint8_t matrix_scan_key(uint32_t row_line, uint32_t col_line) { + uint8_t debouncing = 0; + uint8_t count = 0; + while (1) { + // pull row low + palClearLine(row_line); + wait_us(1); + // read column + uint8_t val = palReadLine(col_line); + // drive row high + palSetLine(row_line); + + // debounce + if (val != debouncing) { + // restart debouncing + debouncing = val; + count = 0; + } else if (count >= DEBOUNCE) { + // finished debouncing + return (~debouncing) & 1; + } + wait_ms(1); + count++; + } +} + +uint8_t matrix_scan(void) { + // cache of input ports for columns + static uint16_t port_cache[3]; + // scan each row + for (int row = 0; row < MATRIX_ROWS; row++) { + palClearLine(row_list[row]); + __NOP(); __NOP(); __NOP(); __NOP(); + // read i/o ports + port_cache[0] = palReadPort(IOPORTA); + port_cache[1] = palReadPort(IOPORTB); + port_cache[2] = palReadPort(IOPORTC); + palSetLine(row_list[row]); + + // get columns from ports + matrix_row_t data = 0; + for (int col = 0; col < MATRIX_COLS; ++col) { + ioline_t line = col_list[col]; + uint16_t port = port_cache[HT32_PAL_IDX(PAL_PORT(line))]; + data |= (((port & (1 << PAL_PAD(line))) ? 0 : 1) << col); + } + + // if a key event happens <5ms before the system time rolls over, + // the event will "never" debounce + // but any event on the same row will reset the debounce timer + if (matrix_debouncing[row] != data) { + // whenever row changes restart debouncing + matrix_debouncing[row] = data; + debounce_times[row] = timer_read32(); + } else if(debounce_times[row] && timer_elapsed32(debounce_times[row]) >= DEBOUNCE){ + // when debouncing complete, update matrix + matrix[row] = matrix_debouncing[row]; + debounce_times[row] = 0; + } + } + matrix_scan_quantum(); + + return 1; +} + +bool matrix_is_on(uint8_t row, uint8_t col) { + return (matrix[row] & (1 << col)); +} + +matrix_row_t matrix_get_row(uint8_t row) { + return matrix[row]; +} + +void matrix_print(void) { +} diff --git a/keyboards/annepro2/mcuconf.h b/keyboards/annepro2/mcuconf.h new file mode 100644 index 000000000000..130607533d16 --- /dev/null +++ b/keyboards/annepro2/mcuconf.h @@ -0,0 +1,72 @@ +/* + ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef _MCUCONF_H_ +#define _MCUCONF_H_ + +#include "nvic.h" + +#define HT32F52342_MCUCONF + +/* + * HAL driver system settings. + */ + +/* + * Clock configuration. + */ + +// This configuration: +// 8 MHz HSE crystal +// PLL multiplies HSE to 48 MHz core and peripheral clock +// 48 MHz to UART +// 48 MHz to USB + +#define HT32_CK_HSE_FREQUENCY 8000000UL // 8 MHz +#define HT32_CKCU_SW CKCU_GCCR_SW_PLL +#define HT32_PLL_USE_HSE FALSE +#define HT32_PLL_FBDIV 6 // 8 MHz -> 48 MHz +#define HT32_PLL_OTDIV 0 +#define HT32_AHB_PRESCALER 1 // 48 MHz -> 48 MHz +#define HT32_USART_PRESCALER 1 // 48 MHz +#define HT32_USB_PRESCALER 1 // 48 MHz -> 48 MHz +// SysTick uses processor clock at 72MHz +#define HT32_ST_USE_HCLK TRUE + +/* + * Peripheral driver settings + */ + +#define HT32_GPT_USE_BFTM0 TRUE +#define HT32_GPT_BFTM0_IRQ_PRIORITY 4 + +//#define HT32_SPI_USE_SPI1 TRUE +//#define HT32_SPI1_IRQ_PRIORITY 6 + +//#define HT32_UART_USE_USART0 TRUE +//#define HT32_USART0_IRQ_PRIORITY 6 + +/* + * USB driver settings + */ + +#define HT32_USB_USE_USB0 TRUE +#define HT32_USB_USB0_IRQ_PRIORITY 5 + +#define HT32_PWM_USE_GPTM1 TRUE +// #define HT32_GPT_BFTM1_IRQ_PRIORITY + +#endif /* _MCUCONF_H_ */ diff --git a/keyboards/annepro2/rules.mk b/keyboards/annepro2/rules.mk new file mode 100644 index 000000000000..d37b0437e1e8 --- /dev/null +++ b/keyboards/annepro2/rules.mk @@ -0,0 +1,37 @@ +# Anne Pro 2 +SRC = \ + matrix.c \ + hardfault_handler.c + +LAYOUTS += + +# MCU +MCU = cortex-m0plus +ARMV = 6 +USE_FPU = no +MCU_FAMILY = HT32 +MCU_SERIES = HT32F523x2 +MCU_LDSCRIPT = HT32F52342_ANNEPRO2 +MCU_STARTUP = ht32f523x2 + +BOARD = ANNEPRO2 + +OPT_DEFS = -Wno-unused-function -fdump-rtl-dfinish -fstack-usage +#EXTRALDFLAGS = -Wl,--print-memory-usage + +# Options + +# Keys +CUSTOM_MATRIX = yes +NKRO_ENABLE = no +MOUSEKEY_ENABLE = no +EXTRAKEY_ENABLE = yes +KEY_LOCK_ENABLE = no + +# Other featues +BOOTMAGIC_ENABLE = no +CONSOLE_ENABLE = no +COMMAND_ENABLE = yes +RAW_ENABLE = yes +MIDI_ENABLE = no +VIRTSER_ENABLE = no From 91ae4c7bff1676b5af003c67d9fb6f22379cae65 Mon Sep 17 00:00:00 2001 From: Codetector Date: Tue, 30 Jun 2020 10:46:48 -0400 Subject: [PATCH 02/88] [keyboard][AnnePro2] Keymap:update to a reasonable keymap with caps+hjkl => arrow --- keyboards/annepro2/keymaps/default/keymap.c | 24 +++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index b1ed9d86c141..7646e60b1af0 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -3,16 +3,32 @@ enum anne_pro_layers { _BASE_LAYER, + _ARROW_LAYER, + _FN_LAYER, }; const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_BASE_LAYER] = KEYMAP( /* Base */ - KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_GRAVE, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, - KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + LT(_ARROW_LAYER, KC_ESC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, - KC_LCTL,KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, KC_RGUI, KC_RCTL - ) + KC_LCTL,KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, MO(_FN_LAYER), KC_RCTL + ), + [_FN_LAYER] = KEYMAP( /* Base */ + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), + [_FN_LAYER] = KEYMAP( /* Base */ + KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), }; const uint16_t keymaps_size = sizeof(keymaps); From c323356edeac708abc59cc55d1265c8faf46a38d Mon Sep 17 00:00:00 2001 From: codetector Date: Tue, 30 Jun 2020 15:51:40 -0400 Subject: [PATCH 03/88] :( --- keyboards/annepro2/keymaps/default/keymap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 7646e60b1af0..6e9fcd1cf0ee 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -13,19 +13,19 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, LT(_ARROW_LAYER, KC_ESC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, - KC_LCTL,KC_LGUI, KC_LALT, KC_SPC, KC_RALT, KC_RGUI, MO(_FN_LAYER), KC_RCTL + KC_LCTL,KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN_LAYER), KC_RGUI, KC_RCTL ), - [_FN_LAYER] = KEYMAP( /* Base */ + [_ARROW_LAYER] = KEYMAP( /* Base */ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_END, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INSERT, KC_DELETE, KC_TRNS, KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), [_FN_LAYER] = KEYMAP( /* Base */ KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_TRNS, KC_TRNS, KC_TRNS, + KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_PGUP, KC_PGDN, KC_TRNS, KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), From bc1c56677c78f78fb78b39c57f2a8d962c82b93a Mon Sep 17 00:00:00 2001 From: codetector Date: Tue, 30 Jun 2020 18:05:50 -0400 Subject: [PATCH 04/88] changed to use HSI --- keyboards/annepro2/keymaps/default/keymap.c | 4 ++-- keyboards/annepro2/mcuconf.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 6e9fcd1cf0ee..9c8661e1aac3 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -24,9 +24,9 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), [_FN_LAYER] = KEYMAP( /* Base */ KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_END, KC_TRNS, KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_PGUP, KC_PGDN, KC_TRNS, - KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INSERT, KC_DELETE, KC_TRNS, KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), }; diff --git a/keyboards/annepro2/mcuconf.h b/keyboards/annepro2/mcuconf.h index 130607533d16..e98da37f45af 100644 --- a/keyboards/annepro2/mcuconf.h +++ b/keyboards/annepro2/mcuconf.h @@ -37,7 +37,7 @@ #define HT32_CK_HSE_FREQUENCY 8000000UL // 8 MHz #define HT32_CKCU_SW CKCU_GCCR_SW_PLL -#define HT32_PLL_USE_HSE FALSE +#define HT32_PLL_USE_HSE TRUE #define HT32_PLL_FBDIV 6 // 8 MHz -> 48 MHz #define HT32_PLL_OTDIV 0 #define HT32_AHB_PRESCALER 1 // 48 MHz -> 48 MHz From 7e4486187f2d18a3f4b0e1e295d21104e7e9be28 Mon Sep 17 00:00:00 2001 From: codetector Date: Tue, 30 Jun 2020 22:58:21 -0400 Subject: [PATCH 05/88] support for annepro2 c18 --- .../annepro2/boards/ANNEPRO2_C18/board.h | 70 ++++++++ .../annepro2/boards/ANNEPRO2_C18/board.mk | 5 + keyboards/annepro2/{ => c15}/config.h | 0 keyboards/annepro2/{ => c15}/rules.mk | 0 keyboards/annepro2/c18/config.h | 169 ++++++++++++++++++ keyboards/annepro2/c18/rules.mk | 37 ++++ 6 files changed, 281 insertions(+) create mode 100644 keyboards/annepro2/boards/ANNEPRO2_C18/board.h create mode 100644 keyboards/annepro2/boards/ANNEPRO2_C18/board.mk rename keyboards/annepro2/{ => c15}/config.h (100%) rename keyboards/annepro2/{ => c15}/rules.mk (100%) create mode 100644 keyboards/annepro2/c18/config.h create mode 100644 keyboards/annepro2/c18/rules.mk diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h new file mode 100644 index 000000000000..6b33268a9bca --- /dev/null +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h @@ -0,0 +1,70 @@ +/* + ChibiOS - Copyright (C) 2020 Codetector + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#ifndef BOARD_H +#define BOARD_H +/* + * Setup for Anne Pro 2 board. + */ + +/* + * Board identifier. + */ +#define ANNEPRO2 +#define BOARD_NAME "Anne Pro 2" + +#define HT32F52342 + +#define FLASH_SIZE (0x10000 - 0x4000) // 64kB - 16kB + +/* + * I/O + */ + +// outputs (rows are pulled low) +#define LINE_ROW1 PAL_LINE(IOPORTB, 5) +#define LINE_ROW2 PAL_LINE(IOPORTB, 4) +#define LINE_ROW3 PAL_LINE(IOPORTB, 3) +#define LINE_ROW4 PAL_LINE(IOPORTB, 2) +#define LINE_ROW5 PAL_LINE(IOPORTC, 14) + +// inputs (columns are sampled) +#define LINE_COL1 PAL_LINE(IOPORTC, 4) +#define LINE_COL2 PAL_LINE(IOPORTC, 5) +#define LINE_COL3 PAL_LINE(IOPORTB, 15) +#define LINE_COL4 PAL_LINE(IOPORTC, 0) +#define LINE_COL5 PAL_LINE(IOPORTC, 11) +#define LINE_COL6 PAL_LINE(IOPORTC, 10) +#define LINE_COL7 PAL_LINE(IOPORTC, 12) +#define LINE_COL8 PAL_LINE(IOPORTC, 13) +#define LINE_COL9 PAL_LINE(IOPORTA, 8) +#define LINE_COL10 PAL_LINE(IOPORTA, 9) +#define LINE_COL11 PAL_LINE(IOPORTA, 10) +#define LINE_COL12 PAL_LINE(IOPORTA, 11) +#define LINE_COL13 PAL_LINE(IOPORTD, 2) +#define LINE_COL14 PAL_LINE(IOPORTD, 3) + +#if !defined(_FROM_ASM_) +#ifdef __cplusplus +extern "C" { +#endif + void boardInit(void); +#ifdef __cplusplus +} +#endif +#endif /* _FROM_ASM_ */ + +#endif /* BOARD_H */ diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.mk b/keyboards/annepro2/boards/ANNEPRO2_C18/board.mk new file mode 100644 index 000000000000..d3ebf910b572 --- /dev/null +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.mk @@ -0,0 +1,5 @@ +# List of all the board related files. +BOARDSRC = $(BOARD_PATH)/boards/ANNEPRO2/board.c + +# Required include directories +BOARDINC = $(BOARD_PATH)/boards/ANNEPRO2_C18 diff --git a/keyboards/annepro2/config.h b/keyboards/annepro2/c15/config.h similarity index 100% rename from keyboards/annepro2/config.h rename to keyboards/annepro2/c15/config.h diff --git a/keyboards/annepro2/rules.mk b/keyboards/annepro2/c15/rules.mk similarity index 100% rename from keyboards/annepro2/rules.mk rename to keyboards/annepro2/c15/rules.mk diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h new file mode 100644 index 000000000000..ad6333889220 --- /dev/null +++ b/keyboards/annepro2/c18/config.h @@ -0,0 +1,169 @@ +/* + * Copyright (c) 2018 Charlie Waters + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +/* USB Device descriptor parameter */ +#define VENDOR_ID 0x04d9 +#define PRODUCT_ID 0xa291 +#define DEVICE_VER 0x1337 +#define MANUFACTURER Holtek +#define PRODUCT Anne Pro 2 (c18) QMK +#define DESCRIPTION Anne Pro 2 (c18) with QMK +#define NAME_SLUG "annepro2" + + +// key matrix size +#define MATRIX_ROWS 5 +#define MATRIX_COLS 14 +// layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 144 bytes + +// Max available layers +#define MAX_LAYERS 8 +// keymaps size: layer size * MAX_LAYERS = 1152 bytes + +#define KEYMAP_60_ANSI +// Number of supported layouts +#define NUM_LAYOUTS 4 + +// Matrix keymap + +#define KEYMAP( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \ + K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, \ + K40, K42, K43, K46, K49, K4A, K4B, K4C \ +) { \ + /* COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14*/ \ + /* ROW1 */ { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \ + /* ROW2 */ { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D }, \ + /* ROW3 */ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, KC_NO}, \ + /* ROW4 */ { K30, KC_NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, KC_NO}, \ + /* ROW5 */ { K40, KC_NO, K42, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, K49, K4A, K4B, K4C, KC_NO}, \ +} + +/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ +#define DEBOUNCE 5 + +/* number of backlight levels */ +// #define BACKLIGHT_LEVELS 10 + +/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ +//#define LOCKING_SUPPORT_ENABLE +/* Locking resynchronize hack */ +//#define LOCKING_RESYNC_ENABLE + +/* If defined, GRAVE_ESC will always act as ESC when CTRL is held. + * This is userful for the Windows task manager shortcut (ctrl+shift+esc). + */ +// #define GRAVE_ESC_CTRL_OVERRIDE + +/* + * Force NKRO + * + * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved + * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the + * makefile for this to work.) + * + * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) + * until the next keyboard reset. + * + * NKRO may prevent your keystrokes from being detected in the BIOS, but it is + * fully operational during normal computer usage. + * + * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) + * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by + * bootmagic, NKRO mode will always be enabled until it is toggled again during a + * power-up. + * + */ +#define FORCE_NKRO + +/* + * Magic Key Options + * + * Magic keys are hotkey commands that allow control over firmware functions of + * the keyboard. They are best used in combination with the HID Listen program, + * found here: https://www.pjrc.com/teensy/hid_listen.html + * + * The options below allow the magic key functionality to be changed. This is + * useful if your keyboard/keypad is missing keys and you want magic key support. + * + */ + +/* key combination for magic key command */ +/* +#define IS_COMMAND() ( \ + keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ +) +*/ + +/* control how magic key switches layers */ +//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true +//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true +//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false + +/* override magic key keymap */ +//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS +//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS +//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM +//#define MAGIC_KEY_HELP1 H +//#define MAGIC_KEY_HELP2 SLASH +//#define MAGIC_KEY_DEBUG D +//#define MAGIC_KEY_DEBUG_MATRIX X +//#define MAGIC_KEY_DEBUG_KBD K +//#define MAGIC_KEY_DEBUG_MOUSE M +//#define MAGIC_KEY_VERSION V +//#define MAGIC_KEY_STATUS S +//#define MAGIC_KEY_CONSOLE C +//#define MAGIC_KEY_LAYER0_ALT1 ESC +//#define MAGIC_KEY_LAYER0_ALT2 GRAVE +//#define MAGIC_KEY_LAYER0 0 +//#define MAGIC_KEY_LAYER1 1 +//#define MAGIC_KEY_LAYER2 2 +//#define MAGIC_KEY_LAYER3 3 +//#define MAGIC_KEY_LAYER4 4 +//#define MAGIC_KEY_LAYER5 5 +//#define MAGIC_KEY_LAYER6 6 +//#define MAGIC_KEY_LAYER7 7 +//#define MAGIC_KEY_LAYER8 8 +//#define MAGIC_KEY_LAYER9 9 +//#define MAGIC_KEY_BOOTLOADER R +//#define MAGIC_KEY_LOCK CAPS +//#define MAGIC_KEY_EEPROM E +//#define MAGIC_KEY_NKRO N +//#define MAGIC_KEY_SLEEP_LED Z + +/* + * Feature disable options + * These options are also useful to firmware size reduction. + */ + +/* disable debug print */ +// #define NO_DEBUG + +/* disable print */ +// #define NO_PRINTg + +/* disable action features */ +//#define NO_ACTION_LAYER +//#define NO_ACTION_TAPPING +//#define NO_ACTION_ONESHOT +//#define NO_ACTION_MACRO +//#define NO_ACTION_FUNCTION + diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk new file mode 100644 index 000000000000..963f115e27e9 --- /dev/null +++ b/keyboards/annepro2/c18/rules.mk @@ -0,0 +1,37 @@ +# Anne Pro 2 +SRC = \ + matrix.c \ + hardfault_handler.c + +LAYOUTS += + +# MCU +MCU = cortex-m0plus +ARMV = 6 +USE_FPU = no +MCU_FAMILY = HT32 +MCU_SERIES = HT32F523x2 +MCU_LDSCRIPT = HT32F52342_ANNEPRO2 +MCU_STARTUP = ht32f523x2 + +BOARD = ANNEPRO2_C18 + +OPT_DEFS = -Wno-unused-function -fdump-rtl-dfinish -fstack-usage +#EXTRALDFLAGS = -Wl,--print-memory-usage + +# Options + +# Keys +CUSTOM_MATRIX = yes +NKRO_ENABLE = no +MOUSEKEY_ENABLE = no +EXTRAKEY_ENABLE = yes +KEY_LOCK_ENABLE = no + +# Other featues +BOOTMAGIC_ENABLE = no +CONSOLE_ENABLE = no +COMMAND_ENABLE = yes +RAW_ENABLE = yes +MIDI_ENABLE = no +VIRTSER_ENABLE = no From 00509c8ad92164ad7c06ad764e1fc2b03bbbdedd Mon Sep 17 00:00:00 2001 From: codetector Date: Wed, 1 Jul 2020 17:29:43 -0400 Subject: [PATCH 06/88] keyboard/annepro2: Very stupid matrix scan bug fix. --- .../annepro2/boards/ANNEPRO2_C18/board.h | 18 ++++++------ keyboards/annepro2/matrix.c | 29 ++----------------- 2 files changed, 11 insertions(+), 36 deletions(-) diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h index 6b33268a9bca..f413595d11f8 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h @@ -39,23 +39,23 @@ #define LINE_ROW2 PAL_LINE(IOPORTB, 4) #define LINE_ROW3 PAL_LINE(IOPORTB, 3) #define LINE_ROW4 PAL_LINE(IOPORTB, 2) -#define LINE_ROW5 PAL_LINE(IOPORTC, 14) +#define LINE_ROW5 PAL_LINE(IOPORTD, 1) // inputs (columns are sampled) #define LINE_COL1 PAL_LINE(IOPORTC, 4) #define LINE_COL2 PAL_LINE(IOPORTC, 5) -#define LINE_COL3 PAL_LINE(IOPORTB, 15) -#define LINE_COL4 PAL_LINE(IOPORTC, 0) +#define LINE_COL3 PAL_LINE(IOPORTD, 0) +#define LINE_COL4 PAL_LINE(IOPORTB, 15) #define LINE_COL5 PAL_LINE(IOPORTC, 11) -#define LINE_COL6 PAL_LINE(IOPORTC, 10) +#define LINE_COL6 PAL_LINE(IOPORTA, 15) #define LINE_COL7 PAL_LINE(IOPORTC, 12) #define LINE_COL8 PAL_LINE(IOPORTC, 13) #define LINE_COL9 PAL_LINE(IOPORTA, 8) -#define LINE_COL10 PAL_LINE(IOPORTA, 9) -#define LINE_COL11 PAL_LINE(IOPORTA, 10) -#define LINE_COL12 PAL_LINE(IOPORTA, 11) -#define LINE_COL13 PAL_LINE(IOPORTD, 2) -#define LINE_COL14 PAL_LINE(IOPORTD, 3) +#define LINE_COL10 PAL_LINE(IOPORTA, 10) +#define LINE_COL11 PAL_LINE(IOPORTA, 11) +#define LINE_COL12 PAL_LINE(IOPORTA, 14) +#define LINE_COL13 PAL_LINE(IOPORTD, 3) +#define LINE_COL14 PAL_LINE(IOPORTD, 2) #if !defined(_FROM_ASM_) #ifdef __cplusplus diff --git a/keyboards/annepro2/matrix.c b/keyboards/annepro2/matrix.c index 5dbbae17992d..472b20ec729b 100644 --- a/keyboards/annepro2/matrix.c +++ b/keyboards/annepro2/matrix.c @@ -39,35 +39,9 @@ void matrix_init(void) { matrix_init_quantum(); } -uint8_t matrix_scan_key(uint32_t row_line, uint32_t col_line) { - uint8_t debouncing = 0; - uint8_t count = 0; - while (1) { - // pull row low - palClearLine(row_line); - wait_us(1); - // read column - uint8_t val = palReadLine(col_line); - // drive row high - palSetLine(row_line); - - // debounce - if (val != debouncing) { - // restart debouncing - debouncing = val; - count = 0; - } else if (count >= DEBOUNCE) { - // finished debouncing - return (~debouncing) & 1; - } - wait_ms(1); - count++; - } -} - uint8_t matrix_scan(void) { // cache of input ports for columns - static uint16_t port_cache[3]; + static uint16_t port_cache[4]; // scan each row for (int row = 0; row < MATRIX_ROWS; row++) { palClearLine(row_list[row]); @@ -76,6 +50,7 @@ uint8_t matrix_scan(void) { port_cache[0] = palReadPort(IOPORTA); port_cache[1] = palReadPort(IOPORTB); port_cache[2] = palReadPort(IOPORTC); + port_cache[2] = palReadPort(IOPORTD); palSetLine(row_list[row]); // get columns from ports From f4089ce96a08b09b587fd6f14907a9fe7b02a2ea Mon Sep 17 00:00:00 2001 From: codetector Date: Wed, 1 Jul 2020 17:30:35 -0400 Subject: [PATCH 07/88] typo --- keyboards/annepro2/matrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/annepro2/matrix.c b/keyboards/annepro2/matrix.c index 472b20ec729b..5e9f2895fbc8 100644 --- a/keyboards/annepro2/matrix.c +++ b/keyboards/annepro2/matrix.c @@ -50,7 +50,7 @@ uint8_t matrix_scan(void) { port_cache[0] = palReadPort(IOPORTA); port_cache[1] = palReadPort(IOPORTB); port_cache[2] = palReadPort(IOPORTC); - port_cache[2] = palReadPort(IOPORTD); + port_cache[3] = palReadPort(IOPORTD); palSetLine(row_list[row]); // get columns from ports From 648c4828ef8bcc60c59dd4134f1e310448e0885a Mon Sep 17 00:00:00 2001 From: codetector Date: Wed, 1 Jul 2020 18:03:05 -0400 Subject: [PATCH 08/88] swap COL14/13 --- keyboards/annepro2/boards/ANNEPRO2_C18/board.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h index f413595d11f8..77f15bae3587 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h @@ -54,8 +54,8 @@ #define LINE_COL10 PAL_LINE(IOPORTA, 10) #define LINE_COL11 PAL_LINE(IOPORTA, 11) #define LINE_COL12 PAL_LINE(IOPORTA, 14) -#define LINE_COL13 PAL_LINE(IOPORTD, 3) -#define LINE_COL14 PAL_LINE(IOPORTD, 2) +#define LINE_COL13 PAL_LINE(IOPORTD, 2) +#define LINE_COL14 PAL_LINE(IOPORTD, 3) #if !defined(_FROM_ASM_) #ifdef __cplusplus From 87b1e2c69a01443adc19fd4b30d6ffea60be9942 Mon Sep 17 00:00:00 2001 From: codetector Date: Sat, 4 Jul 2020 01:45:23 -0400 Subject: [PATCH 09/88] keyboard/annepro2: startup secondary LED MCU --- keyboards/annepro2/annepro2.c | 17 +++++++++++++++++ keyboards/annepro2/boards/ANNEPRO2/board.c | 19 ++----------------- keyboards/annepro2/boards/ANNEPRO2/board.h | 4 ++++ keyboards/annepro2/halconf.h | 2 +- keyboards/annepro2/mcuconf.h | 10 ++++------ 5 files changed, 28 insertions(+), 24 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index c770163bedbb..a128140de9e1 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -1,6 +1,23 @@ +#include "ch.h" +#include "hal.h" #include "annepro2.h" +/** + * @brief Driver default configuration. + */ +static const SerialConfig ledUartConfig = { + .speed = 115200, +}; + +static uint8_t ledMcuWakeup[11] = { +0x7b, 0x10, 0x43, 0x10, 0x03, 0, 0, 0x7d, 0x02, 0x01, 0x02 +}; + void OVERRIDE matrix_init_kb(void) { + // Start uart + sdStart(&SD0, &ledUartConfig); + sdWrite(&SD0, ledMcuWakeup, 11); + matrix_init_user(); } diff --git a/keyboards/annepro2/boards/ANNEPRO2/board.c b/keyboards/annepro2/boards/ANNEPRO2/board.c index d95f3fb3859b..92d597a9e1df 100644 --- a/keyboards/annepro2/boards/ANNEPRO2/board.c +++ b/keyboards/annepro2/boards/ANNEPRO2/board.c @@ -60,6 +60,8 @@ // Alternate Functions #define AF_BITS(PORT, N) (\ + PAFIO(PORT, N, LINE_UART_RX, AFIO_USART)| \ + PAFIO(PORT, N, LINE_UART_TX, AFIO_USART)| \ PAFIO(PORT, N, LINE_ROW1, AFIO_GPIO) | \ PAFIO(PORT, N, LINE_ROW2, AFIO_GPIO) | \ PAFIO(PORT, N, LINE_ROW3, AFIO_GPIO) | \ @@ -178,23 +180,6 @@ void matrix_scan_kb() { matrix_scan_user(); } - - -// SPI Initialization - -// static const SPIConfig spi1_config = { -// .end_cb = NULL, -// .cr0 = SPI_CR0_SELOEN, -// .cr1 = 8 | SPI_CR1_FORMAT_MODE0 | SPI_CR1_MODE, -// .cpr = 1, -// .fcr = 0, -// }; - -// void spi_init(void) { -// spiStart(&SPID1, &spi1_config); -// palSetLine(LINE_SPI_CS); -// } - /** * @brief Board-specific initialization code. * @todo Add your board-specific code, if any. diff --git a/keyboards/annepro2/boards/ANNEPRO2/board.h b/keyboards/annepro2/boards/ANNEPRO2/board.h index d9dcd3e3bb32..405dc63d967b 100644 --- a/keyboards/annepro2/boards/ANNEPRO2/board.h +++ b/keyboards/annepro2/boards/ANNEPRO2/board.h @@ -34,6 +34,9 @@ * I/O */ +#define LINE_UART_TX PAL_LINE(IOPORTB, 0) +#define LINE_UART_RX PAL_LINE(IOPORTB, 1) + // outputs (rows are pulled low) #define LINE_ROW1 PAL_LINE(IOPORTC, 2) #define LINE_ROW2 PAL_LINE(IOPORTC, 1) @@ -51,6 +54,7 @@ #define LINE_COL7 PAL_LINE(IOPORTA, 8) #define LINE_COL8 PAL_LINE(IOPORTA, 10) #define LINE_COL9 PAL_LINE(IOPORTA, 11) +// PORTA 12,13 conflict with SWD #define LINE_COL10 PAL_LINE(IOPORTA, 12) #define LINE_COL11 PAL_LINE(IOPORTA, 13) #define LINE_COL12 PAL_LINE(IOPORTA, 14) diff --git a/keyboards/annepro2/halconf.h b/keyboards/annepro2/halconf.h index 05fe1c4e531a..ea9c8da299aa 100644 --- a/keyboards/annepro2/halconf.h +++ b/keyboards/annepro2/halconf.h @@ -135,7 +135,7 @@ * @brief Enables the SERIAL subsystem. */ #if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL FALSE +#define HAL_USE_SERIAL TRUE #endif /** diff --git a/keyboards/annepro2/mcuconf.h b/keyboards/annepro2/mcuconf.h index e98da37f45af..a503bb7c884f 100644 --- a/keyboards/annepro2/mcuconf.h +++ b/keyboards/annepro2/mcuconf.h @@ -50,14 +50,14 @@ * Peripheral driver settings */ -#define HT32_GPT_USE_BFTM0 TRUE -#define HT32_GPT_BFTM0_IRQ_PRIORITY 4 +// #define HT32_GPT_USE_BFTM0 TRUE +// #define HT32_GPT_BFTM0_IRQ_PRIORITY 4 //#define HT32_SPI_USE_SPI1 TRUE //#define HT32_SPI1_IRQ_PRIORITY 6 -//#define HT32_UART_USE_USART0 TRUE -//#define HT32_USART0_IRQ_PRIORITY 6 +#define HT32_SERIAL_USE_USART0 TRUE +#define HT32_USART0_IRQ_PRIORITY 6 /* * USB driver settings @@ -66,7 +66,5 @@ #define HT32_USB_USE_USB0 TRUE #define HT32_USB_USB0_IRQ_PRIORITY 5 -#define HT32_PWM_USE_GPTM1 TRUE -// #define HT32_GPT_BFTM1_IRQ_PRIORITY #endif /* _MCUCONF_H_ */ From 5712e04ec24b8300fc8222aa98c0002df060a9dc Mon Sep 17 00:00:00 2001 From: codetector Date: Sun, 5 Jul 2020 20:24:02 -0400 Subject: [PATCH 10/88] keyboard/annepro2: typo fix --- keyboards/annepro2/annepro2.c | 40 +++++++++++++++++++++ keyboards/annepro2/annepro2.h | 7 ++++ keyboards/annepro2/c15/rules.mk | 1 + keyboards/annepro2/c18/rules.mk | 1 + keyboards/annepro2/keymaps/default/keymap.c | 24 +++++++++++-- keyboards/annepro2/qmk_ap2_led.h | 6 ++++ 6 files changed, 77 insertions(+), 2 deletions(-) create mode 100644 keyboards/annepro2/qmk_ap2_led.h diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index a128140de9e1..836dc31f09a3 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -1,6 +1,7 @@ #include "ch.h" #include "hal.h" #include "annepro2.h" +#include "qmk_ap2_led.h" /** * @brief Driver default configuration. @@ -13,6 +14,14 @@ static uint8_t ledMcuWakeup[11] = { 0x7b, 0x10, 0x43, 0x10, 0x03, 0, 0, 0x7d, 0x02, 0x01, 0x02 }; +uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS] = { + 0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0,0,0,0,0, +}; + void OVERRIDE matrix_init_kb(void) { // Start uart sdStart(&SD0, &ledUartConfig); @@ -21,6 +30,37 @@ void OVERRIDE matrix_init_kb(void) { matrix_init_user(); } +void annepro2LedDisable(void) +{ + sdPut(&SD0, CMD_LED_OFF); +} + +void annepro2LedEnable(void) +{ + sdPut(&SD0, CMD_LED_ON); +} + +void annepro2LedUpdate(uint8_t row, uint8_t col) +{ + sdPut(&SD0, CMD_LED_SET); + sdPut(&SD0, row); + sdPut(&SD0, col); + sdWrite(&SD0, (uint8_t *)&annepro2LedMatrix[row * MATRIX_COLS + col], sizeof(uint16_t)); +} + +void annepro2LedUpdateRow(uint8_t row) +{ + sdPut(&SD0, CMD_LED_SET_ROW); + sdPut(&SD0, row); + sdWrite(&SD0, (uint8_t *)&annepro2LedMatrix[row * MATRIX_COLS], sizeof(uint16_t) * MATRIX_COLS); +} + +bool OVERRIDE led_update_kb(led_t status) { + annepro2LedMatrix[2 * MATRIX_COLS] = status.caps_lock ? 0x4FF : 0; + annepro2LedUpdate(2, 0); + return led_update_user(status); +} + bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { return process_record_user(keycode, record); } diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index f8acc896b421..b7dbe3c5a792 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -20,3 +20,10 @@ #include "quantum.h" #define OVERRIDE __attribute__ ((noinline)) + +extern uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS]; + +void annepro2LedDisable(void); +void annepro2LedEnable(void); +void annepro2LedUpdate(uint8_t row, uint8_t col); +void annepro2LedUpdateRow(uint8_t row); diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index d37b0437e1e8..c358b7e5033d 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -35,3 +35,4 @@ COMMAND_ENABLE = yes RAW_ENABLE = yes MIDI_ENABLE = no VIRTSER_ENABLE = no +COMBO_ENABLE = no diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 963f115e27e9..18df7993ff3a 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -35,3 +35,4 @@ COMMAND_ENABLE = yes RAW_ENABLE = yes MIDI_ENABLE = no VIRTSER_ENABLE = no +COMBO_ENABLE = yes diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 9c8661e1aac3..7dbdfaf623e0 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -7,6 +7,11 @@ enum anne_pro_layers { _FN_LAYER, }; +enum custom_keys { + KC_AP_LED_ON = SAFE_RANGE, + KC_AP_LED_OFF, +}; + const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_BASE_LAYER] = KEYMAP( /* Base */ KC_GRAVE, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, @@ -24,8 +29,8 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { ), [_FN_LAYER] = KEYMAP( /* Base */ KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_END, KC_TRNS, - KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_END, KC_AP_LED_ON, + KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_PGUP, KC_PGDN, KC_AP_LED_OFF, KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INSERT, KC_DELETE, KC_TRNS, KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), @@ -45,6 +50,21 @@ layer_state_t layer_state_set_user(layer_state_t layer) { return layer; } +/*! + * @returns false processing for this keycode has been completed. + */ bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case KC_AP_LED_OFF: + if (record->event.pressed) + annepro2LedDisable(); + return false; + case KC_AP_LED_ON: + if (record->event.pressed) + annepro2LedEnable(); + return false; + default: + break; + } return true; } diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/qmk_ap2_led.h new file mode 100644 index 000000000000..681855b83999 --- /dev/null +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -0,0 +1,6 @@ +#pragma once + +#define CMD_LED_ON 0x1 +#define CMD_LED_OFF 0x2 +#define CMD_LED_SET 0x3 +#define CMD_LED_SET_ROW 0x4 From b2d2f00d916264e45a9b75353c4e4989a637f921 Mon Sep 17 00:00:00 2001 From: Fagl4 <18francisco18@gmail.com> Date: Tue, 7 Jul 2020 18:33:38 +0100 Subject: [PATCH 11/88] Add IO Values --- keyboards/annepro2/boards/ANNEPRO2_C18/board.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h index 77f15bae3587..0251a3a04116 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h @@ -33,6 +33,8 @@ /* * I/O */ +#define LINE_UART_TX PAL_LINE(IOPORTB, 0) +#define LINE_UART_RX PAL_LINE(IOPORTB, 1) // outputs (rows are pulled low) #define LINE_ROW1 PAL_LINE(IOPORTB, 5) From e240591628f17d6198878d081cf7c94881e03c4a Mon Sep 17 00:00:00 2001 From: Fagl4 <18francisco18@gmail.com> Date: Tue, 7 Jul 2020 18:34:36 +0100 Subject: [PATCH 12/88] Disable Combo feature --- keyboards/annepro2/c18/rules.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 18df7993ff3a..701307163d18 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -35,4 +35,4 @@ COMMAND_ENABLE = yes RAW_ENABLE = yes MIDI_ENABLE = no VIRTSER_ENABLE = no -COMBO_ENABLE = yes +COMBO_ENABLE = no From 77dbcc016f1246b092992ffaf14c665bd8cb2715 Mon Sep 17 00:00:00 2001 From: Codetector Date: Tue, 7 Jul 2020 21:25:37 -0400 Subject: [PATCH 13/88] Update default keymap to Anne Pro 2 Official Keymap --- keyboards/annepro2/keymaps/default/keymap.c | 103 +++++++++++++++----- 1 file changed, 78 insertions(+), 25 deletions(-) diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 7dbdfaf623e0..411b67601d4c 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -6,36 +6,89 @@ enum anne_pro_layers { _ARROW_LAYER, _FN_LAYER, }; - enum custom_keys { KC_AP_LED_ON = SAFE_RANGE, KC_AP_LED_OFF, }; - -const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [_BASE_LAYER] = KEYMAP( /* Base */ - KC_GRAVE, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, - KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, - LT(_ARROW_LAYER, KC_ESC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, - KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, - KC_LCTL,KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN_LAYER), KC_RGUI, KC_RCTL - ), - [_ARROW_LAYER] = KEYMAP( /* Base */ - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_END, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_PGUP, KC_PGDN, KC_TRNS, - KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INSERT, KC_DELETE, KC_TRNS, - KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS - ), - [_FN_LAYER] = KEYMAP( /* Base */ - KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_HOME, KC_END, KC_AP_LED_ON, - KC_CAPS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_PGUP, KC_PGDN, KC_AP_LED_OFF, - KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INSERT, KC_DELETE, KC_TRNS, - KC_TRNS,KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS - ), +/* +* Layer _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | +* |-----------------------------------------------------------------------------------------+ +* | Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | +* |-----------------------------------------------------------------------------------------+ +* | Caps | a | s | d | f | g | h | j | k | l | ; | ' | Enter | +* |-----------------------------------------------------------------------------------------+ +* | Shift | z | x | c | v | b | n | m | , | . | / | Shift | +* |-----------------------------------------------------------------------------------------+ +* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | +* \-----------------------------------------------------------------------------------------/ +* Layer TAP in _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | UP | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | LEFT | DOWN | RIGHT | +* \-----------------------------------------------------------------------------------------/ +*/ + const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE_LAYER] = KEYMAP( /* Base */ + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_ARROW_LAYER,KC_LEFT), LT(_FN_LAYER,KC_DOWN), RCTL_T(KC_RGHT) +), + /* + * Layer _ARROW_LAYER + * ,-----------------------------------------------------------------------------------------. + * | ~ | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | + * |-----------------------------------------------------------------------------------------+ + * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | + * |-----------------------------------------------------------------------------------------+ + * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift |V-UP |V-DWN|MUTE | v | b | n | m | , |INSRT| DEL | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_ARROW_LAYER] = KEYMAP( /* Base */ + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, + KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN_LAYER), KC_TRNS +), + /* + * Layer _FN_LAYER + * ,-----------------------------------------------------------------------------------------. + * | ~ | F1 | F2 | F3 | F4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp | + * |-----------------------------------------------------------------------------------------+ + * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | + * |-----------------------------------------------------------------------------------------+ + * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift | z | x | c | v | b | n | m | , |INSRT| DEL | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN_LAYER] = KEYMAP( /* Base */ + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + MO(_FN_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_ARROW_LAYER), MO(_FN_LAYER), KC_TRNS + ), }; - const uint16_t keymaps_size = sizeof(keymaps); From cb7e23a1c4acfaf751ff23168ea643015510d335 Mon Sep 17 00:00:00 2001 From: Codetector Date: Thu, 9 Jul 2020 18:14:30 -0400 Subject: [PATCH 14/88] keyboard/annepro2: keymap layer name changes --- keyboards/annepro2/keymaps/default/keymap.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 411b67601d4c..8582cf556d63 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -3,8 +3,8 @@ enum anne_pro_layers { _BASE_LAYER, - _ARROW_LAYER, - _FN_LAYER, + _FN1_LAYER, + _FN2_LAYER, }; enum custom_keys { KC_AP_LED_ON = SAFE_RANGE, @@ -42,10 +42,10 @@ enum custom_keys { KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), - KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_ARROW_LAYER,KC_LEFT), LT(_FN_LAYER,KC_DOWN), RCTL_T(KC_RGHT) + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LAYER,KC_LEFT), LT(_FN2_LAYER,KC_DOWN), RCTL_T(KC_RGHT) ), /* - * Layer _ARROW_LAYER + * Layer _FN1_LAYER * ,-----------------------------------------------------------------------------------------. * | ~ | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | * |-----------------------------------------------------------------------------------------+ @@ -59,12 +59,12 @@ enum custom_keys { * \-----------------------------------------------------------------------------------------/ * */ - [_ARROW_LAYER] = KEYMAP( /* Base */ + [_FN1_LAYER] = KEYMAP( /* Base */ KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN_LAYER), KC_TRNS + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS ), /* * Layer _FN_LAYER @@ -81,12 +81,12 @@ enum custom_keys { * \-----------------------------------------------------------------------------------------/ * */ - [_FN_LAYER] = KEYMAP( /* Base */ + [_FN2_LAYER] = KEYMAP( /* Base */ KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - MO(_FN_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_ARROW_LAYER), MO(_FN_LAYER), KC_TRNS + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_TRNS ), }; const uint16_t keymaps_size = sizeof(keymaps); From 7b3726e9170dcab73bc5b960170fed8f5985ef9b Mon Sep 17 00:00:00 2001 From: Codetector Date: Fri, 10 Jul 2020 11:04:07 -0400 Subject: [PATCH 15/88] keyboard/annepro2 BLE Support --- keyboards/annepro2/annepro2.c | 63 +++++++- keyboards/annepro2/annepro2.h | 16 +- keyboards/annepro2/annepro2_ble.c | 141 ++++++++++++++++++ keyboards/annepro2/annepro2_ble.h | 26 ++++ keyboards/annepro2/boards/ANNEPRO2/board.c | 6 +- keyboards/annepro2/boards/ANNEPRO2/board.h | 7 +- .../annepro2/boards/ANNEPRO2_C18/board.h | 3 + keyboards/annepro2/c15/rules.mk | 3 +- keyboards/annepro2/c18/rules.mk | 3 +- keyboards/annepro2/keymaps/default/keymap.c | 2 +- keyboards/annepro2/mcuconf.h | 11 +- 11 files changed, 259 insertions(+), 22 deletions(-) create mode 100644 keyboards/annepro2/annepro2_ble.c create mode 100644 keyboards/annepro2/annepro2_ble.h diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 836dc31f09a3..2ec26834cf1c 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -1,19 +1,22 @@ #include "ch.h" #include "hal.h" #include "annepro2.h" +#include "annepro2_ble.h" #include "qmk_ap2_led.h" -/** - * @brief Driver default configuration. - */ static const SerialConfig ledUartConfig = { .speed = 115200, }; +static const SerialConfig bleUartConfig = { + .speed = 115200, +}; + static uint8_t ledMcuWakeup[11] = { -0x7b, 0x10, 0x43, 0x10, 0x03, 0, 0, 0x7d, 0x02, 0x01, 0x02 + 0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02 }; + uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -22,11 +25,20 @@ uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0, }; -void OVERRIDE matrix_init_kb(void) { - // Start uart +void OVERRIDE keyboard_pre_init_kb(void) { +} + +void OVERRIDE keyboard_post_init_kb(void) { + // Start LED UART sdStart(&SD0, &ledUartConfig); sdWrite(&SD0, ledMcuWakeup, 11); + // Start BLE UART + sdStart(&SD1, &bleUartConfig); + annepro2_ble_startup(); +} + +void OVERRIDE matrix_init_kb(void) { matrix_init_user(); } @@ -61,6 +73,45 @@ bool OVERRIDE led_update_kb(led_t status) { return led_update_user(status); } +/*! + * @returns false processing for this keycode has been completed. + */ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { + if (record->event.pressed) { + switch (keycode) { + case KC_AP2_BT_SCAN1: + annepro2_ble_broadcast(0); + return false; + case KC_AP2_BT_SCAN2: + annepro2_ble_broadcast(1); + return false; + case KC_AP2_BT_SCAN3: + annepro2_ble_broadcast(2); + return false; + case KC_AP2_BT_SCAN4: + annepro2_ble_broadcast(3); + return false; + case KC_AP2_BT_CONN1: + annepro2_ble_connect(0); + return false; + case KC_AP2_BT_CONN2: + annepro2_ble_connect(1); + return false; + case KC_AP2_BT_CONN3: + annepro2_ble_connect(2); + return false; + case KC_AP2_BT_CONN4: + annepro2_ble_connect(3); + return false; + case KC_AP2_USB: + annepro2_ble_disconnect(); + return false; + case KC_AP2_BT_UNPAIR: + annepro2_ble_unpair(); + return false; + default: + break; + } + } return process_record_user(keycode, record); } diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index b7dbe3c5a792..4f6e3821f387 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018 Charlie Waters + * Copyright (c) 2018 Yaotian Feng * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,20 @@ extern uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS]; +enum AP2KeyCodes { + KC_AP2_BT_SCAN1 = SAFE_RANGE, + KC_AP2_BT_SCAN2, + KC_AP2_BT_SCAN3, + KC_AP2_BT_SCAN4, + KC_AP2_BT_CONN1, + KC_AP2_BT_CONN2, + KC_AP2_BT_CONN3, + KC_AP2_BT_CONN4, + KC_AP2_BT_UNPAIR, + KC_AP2_USB, + AP2_SAFE_RANGE, +}; + void annepro2LedDisable(void); void annepro2LedEnable(void); void annepro2LedUpdate(uint8_t row, uint8_t col); diff --git a/keyboards/annepro2/annepro2_ble.c b/keyboards/annepro2/annepro2_ble.c new file mode 100644 index 000000000000..57d38efc2f49 --- /dev/null +++ b/keyboards/annepro2/annepro2_ble.c @@ -0,0 +1,141 @@ +/* + Copyright (C) 2020 Yaotian Feng, Codetector + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "annepro2_ble.h" +#include "ch.h" +#include "hal.h" +#include "host.h" +#include "host_driver.h" + +/* -------------------- Static Function Prototypes -------------------------- */ +static uint8_t ap2_ble_leds(void); +static void ap2_ble_mouse(report_mouse_t *report); +static void ap2_ble_system(uint16_t data); +static void ap2_ble_consumer(uint16_t data); +static void ap2_ble_keyboard(report_keyboard_t *report); + +static void ap2_ble_swtich_ble_driver(void); + +/* -------------------- Static Local Variables ------------------------------ */ +static host_driver_t ap2_ble_driver = { + ap2_ble_leds, + ap2_ble_keyboard, + ap2_ble_mouse, + ap2_ble_system, + ap2_ble_consumer, +}; + +static uint8_t bleMcuWakeup[11] = { + 0x7b, 0x10, 0x53, 0x10, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02 +}; +static uint8_t bleMcuStartBroadcast[11] = { + 0x7b, 0x10, 0x53, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x01, 0x00 // Broadcast ID[0-3] +}; +static uint8_t bleMcuConnect[11] = { + 0x7b, 0x10, 0x53, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x04, 0x00 // Connect ID [0-3] +}; +static uint8_t bleMcuSendReport[10] = { + 0x7b, 0x10, 0x53, 0x10, 0x0A, 0x00, 0x00, 0x7d, 0x10, 0x04, +}; +static uint8_t bleMcuUnpair[10] = { + 0x7b, 0x10, 0x53, 0x10, 0x02, 0x00, 0x00, 0x7d, 0x40, 0x05, +}; + +static host_driver_t *lastHostDriver = NULL; +#ifdef NKRO_ENABLE +static bool lastNkroStatus = false; +#endif // NKRO_ENABLE + +/* -------------------- Public Function Implementation ---------------------- */ + +void annepro2_ble_startup(void) { + sdWrite(&SD1, bleMcuWakeup, 11); +} + +void annepro2_ble_broadcast(uint8_t port) { + if (port > 3) { + port = 3; + } + sdPut(&SD1, 0x00); + sdWrite(&SD1, bleMcuStartBroadcast, 10); + sdPut(&SD1, port); +} + +void annepro2_ble_connect(uint8_t port) { + if (port > 3) { + port = 3; + } + sdPut(&SD1, 0x00); + sdWrite(&SD1, bleMcuConnect, 10); + sdPut(&SD1, port); + ap2_ble_swtich_ble_driver(); +} + +void annepro2_ble_disconnect(void) { + /* Skip if the driver is already enabled */ + if (host_get_driver() != &ap2_ble_driver) { + return; + } + + clear_keyboard(); +#ifdef NKRO_ENABLE + keymap_config.nkro = lastNkroStatus; +#endif + host_set_driver(lastHostDriver); +} + +void annepro2_ble_unpair(void) { + sdPut(&SD1, 0x0); + sdWrite(&SD1, bleMcuUnpair, 11); +} + +/* ------------------- Static Function Implementation ----------------------- */ +static void ap2_ble_swtich_ble_driver(void) { + if (host_get_driver() == &ap2_ble_driver) { + return; + } + clear_keyboard(); + lastHostDriver = host_get_driver(); +#ifdef NKRO_ENABLE + lastNkroStatus = keymap_config.nkro; + keymap_config.nkro = false; +#endif + host_set_driver(&ap2_ble_driver); +} + +static uint8_t ap2_ble_leds(void) { + return 0; // TODO: Figure out how to obtain LED status +} + +static void ap2_ble_mouse(report_mouse_t *report){ +} + +static void ap2_ble_system(uint16_t data) { +} + +static void ap2_ble_consumer(uint16_t data) { + +} + +/*! + * @brief Send keyboard HID report for Bluetooth driver + */ +static void ap2_ble_keyboard(report_keyboard_t *report) { + sdPut(&SD1, 0x0); + sdWrite(&SD1, bleMcuSendReport, 10); + sdWrite(&SD1, &report->raw[0], 8); +} + diff --git a/keyboards/annepro2/annepro2_ble.h b/keyboards/annepro2/annepro2_ble.h new file mode 100644 index 000000000000..71498890fdee --- /dev/null +++ b/keyboards/annepro2/annepro2_ble.h @@ -0,0 +1,26 @@ +/* + Copyright (C) 2020 Yaotian Feng, Codetector + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#pragma once + +#include "annepro2.h" +#include "quantum.h" + +void annepro2_ble_startup(void); +void annepro2_ble_broadcast(uint8_t port); +void annepro2_ble_connect(uint8_t port); +void annepro2_ble_disconnect(void); +void annepro2_ble_unpair(void); diff --git a/keyboards/annepro2/boards/ANNEPRO2/board.c b/keyboards/annepro2/boards/ANNEPRO2/board.c index 92d597a9e1df..2514d96f9730 100644 --- a/keyboards/annepro2/boards/ANNEPRO2/board.c +++ b/keyboards/annepro2/boards/ANNEPRO2/board.c @@ -1,7 +1,5 @@ /* - ChibiOS - Copyright (C) 2006..2016 Giovanni Di Sirio - (C) 2018 Charlie Waters - (C) 2020 Yaotian Feng, Codetector + Copyright (C) 2020 Yaotian Feng, Codetector Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -62,6 +60,8 @@ #define AF_BITS(PORT, N) (\ PAFIO(PORT, N, LINE_UART_RX, AFIO_USART)| \ PAFIO(PORT, N, LINE_UART_TX, AFIO_USART)| \ + PAFIO(PORT, N, LINE_BT_UART_TX, AFIO_USART)| \ + PAFIO(PORT, N, LINE_BT_UART_RX, AFIO_USART)| \ PAFIO(PORT, N, LINE_ROW1, AFIO_GPIO) | \ PAFIO(PORT, N, LINE_ROW2, AFIO_GPIO) | \ PAFIO(PORT, N, LINE_ROW3, AFIO_GPIO) | \ diff --git a/keyboards/annepro2/boards/ANNEPRO2/board.h b/keyboards/annepro2/boards/ANNEPRO2/board.h index 405dc63d967b..695f1b7e96ac 100644 --- a/keyboards/annepro2/boards/ANNEPRO2/board.h +++ b/keyboards/annepro2/boards/ANNEPRO2/board.h @@ -34,8 +34,11 @@ * I/O */ -#define LINE_UART_TX PAL_LINE(IOPORTB, 0) -#define LINE_UART_RX PAL_LINE(IOPORTB, 1) +#define LINE_UART_TX PAL_LINE(IOPORTB, 0) // Master TX, LED RX +#define LINE_UART_RX PAL_LINE(IOPORTB, 1) // Master RX, LED TX + +#define LINE_BT_UART_TX PAL_LINE(IOPORTA, 4) // Master TX, BLE RX +#define LINE_BT_UART_RX PAL_LINE(IOPORTA, 5) // Master RX, BLE TX // outputs (rows are pulled low) #define LINE_ROW1 PAL_LINE(IOPORTC, 2) diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h index 0251a3a04116..ee75f310d666 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h @@ -36,6 +36,9 @@ #define LINE_UART_TX PAL_LINE(IOPORTB, 0) #define LINE_UART_RX PAL_LINE(IOPORTB, 1) +#define LINE_BT_UART_TX PAL_LINE(IOPORTA, 4) // Master TX, BLE RX +#define LINE_BT_UART_RX PAL_LINE(IOPORTA, 5) // Master RX, BLE TX + // outputs (rows are pulled low) #define LINE_ROW1 PAL_LINE(IOPORTB, 5) #define LINE_ROW2 PAL_LINE(IOPORTB, 4) diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index c358b7e5033d..0878c54cb36c 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -1,7 +1,8 @@ # Anne Pro 2 SRC = \ matrix.c \ - hardfault_handler.c + hardfault_handler.c \ + annepro2_ble.c LAYOUTS += diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 701307163d18..7df05caeb005 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -1,7 +1,8 @@ # Anne Pro 2 SRC = \ matrix.c \ - hardfault_handler.c + hardfault_handler.c \ + annepro2_ble.c LAYOUTS += diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 8582cf556d63..e576205969d2 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -7,7 +7,7 @@ enum anne_pro_layers { _FN2_LAYER, }; enum custom_keys { - KC_AP_LED_ON = SAFE_RANGE, + KC_AP_LED_ON = AP2_SAFE_RANGE, KC_AP_LED_OFF, }; /* diff --git a/keyboards/annepro2/mcuconf.h b/keyboards/annepro2/mcuconf.h index a503bb7c884f..d57afebd4a65 100644 --- a/keyboards/annepro2/mcuconf.h +++ b/keyboards/annepro2/mcuconf.h @@ -43,22 +43,19 @@ #define HT32_AHB_PRESCALER 1 // 48 MHz -> 48 MHz #define HT32_USART_PRESCALER 1 // 48 MHz #define HT32_USB_PRESCALER 1 // 48 MHz -> 48 MHz -// SysTick uses processor clock at 72MHz +// SysTick uses processor clock at 48MHz #define HT32_ST_USE_HCLK TRUE /* * Peripheral driver settings */ -// #define HT32_GPT_USE_BFTM0 TRUE -// #define HT32_GPT_BFTM0_IRQ_PRIORITY 4 - -//#define HT32_SPI_USE_SPI1 TRUE -//#define HT32_SPI1_IRQ_PRIORITY 6 - #define HT32_SERIAL_USE_USART0 TRUE #define HT32_USART0_IRQ_PRIORITY 6 +#define HT32_SERIAL_USE_USART1 TRUE +#define HT32_USART1_IRQ_PRIORITY 7 + /* * USB driver settings */ From db480da9aacee76e977e9f3cbb1b9c80a64edea9 Mon Sep 17 00:00:00 2001 From: Jakob Gillich Date: Fri, 10 Jul 2020 13:52:01 +0200 Subject: [PATCH 16/88] Fix keymap comment FN1 ESC was listed as ~ instead of ` --- keyboards/annepro2/keymaps/default/keymap.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index e576205969d2..1592bc23797b 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -47,7 +47,7 @@ enum custom_keys { /* * Layer _FN1_LAYER * ,-----------------------------------------------------------------------------------------. - * | ~ | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | + * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | * |-----------------------------------------------------------------------------------------+ * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | * |-----------------------------------------------------------------------------------------+ @@ -67,7 +67,7 @@ enum custom_keys { KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS ), /* - * Layer _FN_LAYER + * Layer _FN2_LAYER * ,-----------------------------------------------------------------------------------------. * | ~ | F1 | F2 | F3 | F4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp | * |-----------------------------------------------------------------------------------------+ From ac810bf18a2daf35b9246e408cbdee145a2fb0d8 Mon Sep 17 00:00:00 2001 From: Codetector Date: Mon, 13 Jul 2020 18:43:05 -0400 Subject: [PATCH 17/88] keyboard/annepro2: Bluetooth path --- keyboards/annepro2/annepro2.c | 20 ++++---------------- keyboards/annepro2/annepro2.h | 12 ++++-------- keyboards/annepro2/annepro2_ble.c | 4 ++-- keyboards/annepro2/keymaps/default/keymap.c | 4 ++-- 4 files changed, 12 insertions(+), 28 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 2ec26834cf1c..fe3819ae9dda 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -79,30 +79,18 @@ bool OVERRIDE led_update_kb(led_t status) { bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { switch (keycode) { - case KC_AP2_BT_SCAN1: + case KC_AP2_BT1: annepro2_ble_broadcast(0); return false; - case KC_AP2_BT_SCAN2: + case KC_AP2_BT2: annepro2_ble_broadcast(1); return false; - case KC_AP2_BT_SCAN3: + case KC_AP2_BT3: annepro2_ble_broadcast(2); return false; - case KC_AP2_BT_SCAN4: + case KC_AP2_BT4: annepro2_ble_broadcast(3); return false; - case KC_AP2_BT_CONN1: - annepro2_ble_connect(0); - return false; - case KC_AP2_BT_CONN2: - annepro2_ble_connect(1); - return false; - case KC_AP2_BT_CONN3: - annepro2_ble_connect(2); - return false; - case KC_AP2_BT_CONN4: - annepro2_ble_connect(3); - return false; case KC_AP2_USB: annepro2_ble_disconnect(); return false; diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index 4f6e3821f387..3e562d93af26 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -24,14 +24,10 @@ extern uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS]; enum AP2KeyCodes { - KC_AP2_BT_SCAN1 = SAFE_RANGE, - KC_AP2_BT_SCAN2, - KC_AP2_BT_SCAN3, - KC_AP2_BT_SCAN4, - KC_AP2_BT_CONN1, - KC_AP2_BT_CONN2, - KC_AP2_BT_CONN3, - KC_AP2_BT_CONN4, + KC_AP2_BT1 = SAFE_RANGE, + KC_AP2_BT2, + KC_AP2_BT3, + KC_AP2_BT4, KC_AP2_BT_UNPAIR, KC_AP2_USB, AP2_SAFE_RANGE, diff --git a/keyboards/annepro2/annepro2_ble.c b/keyboards/annepro2/annepro2_ble.c index 57d38efc2f49..fbd435370cab 100644 --- a/keyboards/annepro2/annepro2_ble.c +++ b/keyboards/annepro2/annepro2_ble.c @@ -72,13 +72,13 @@ void annepro2_ble_broadcast(uint8_t port) { sdPut(&SD1, 0x00); sdWrite(&SD1, bleMcuStartBroadcast, 10); sdPut(&SD1, port); + annepro2_ble_connect(port); } void annepro2_ble_connect(uint8_t port) { if (port > 3) { port = 3; } - sdPut(&SD1, 0x00); sdWrite(&SD1, bleMcuConnect, 10); sdPut(&SD1, port); ap2_ble_swtich_ble_driver(); @@ -111,8 +111,8 @@ static void ap2_ble_swtich_ble_driver(void) { lastHostDriver = host_get_driver(); #ifdef NKRO_ENABLE lastNkroStatus = keymap_config.nkro; - keymap_config.nkro = false; #endif + keymap_config.nkro = false; host_set_driver(&ap2_ble_driver); } diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 1592bc23797b..6a07a94584df 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -69,7 +69,7 @@ enum custom_keys { /* * Layer _FN2_LAYER * ,-----------------------------------------------------------------------------------------. - * | ~ | F1 | F2 | F3 | F4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp | + * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp | * |-----------------------------------------------------------------------------------------+ * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | * |-----------------------------------------------------------------------------------------+ @@ -82,7 +82,7 @@ enum custom_keys { * */ [_FN2_LAYER] = KEYMAP( /* Base */ - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, From 46c222143b0edafd84cdfe3bf5e83b9508045fae Mon Sep 17 00:00:00 2001 From: tech2077 Date: Fri, 21 Aug 2020 00:22:31 -0500 Subject: [PATCH 18/88] Keyboard annepro2 bidir led comms (#5) * Added bidirectional shine comms and moved led functionality to new file * Added bidirectional shine comms and moved led functionality to new file * Restore original functionality to existing keymaps using new shine commands * Fix dangling bracketless if statements * PR cleanup --- keyboards/annepro2/annepro2.c | 34 +----------- keyboards/annepro2/annepro2.h | 5 -- keyboards/annepro2/c15/rules.mk | 3 +- keyboards/annepro2/c18/rules.mk | 3 +- keyboards/annepro2/keymaps/default/keymap.c | 9 +++- keyboards/annepro2/qmk_ap2_led.c | 60 +++++++++++++++++++++ keyboards/annepro2/qmk_ap2_led.h | 15 ++++++ 7 files changed, 88 insertions(+), 41 deletions(-) create mode 100644 keyboards/annepro2/qmk_ap2_led.c diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index fe3819ae9dda..42523acae0df 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -2,7 +2,6 @@ #include "hal.h" #include "annepro2.h" #include "annepro2_ble.h" -#include "qmk_ap2_led.h" static const SerialConfig ledUartConfig = { .speed = 115200, @@ -36,43 +35,14 @@ void OVERRIDE keyboard_post_init_kb(void) { // Start BLE UART sdStart(&SD1, &bleUartConfig); annepro2_ble_startup(); + + keyboard_post_init_user(); } void OVERRIDE matrix_init_kb(void) { matrix_init_user(); } -void annepro2LedDisable(void) -{ - sdPut(&SD0, CMD_LED_OFF); -} - -void annepro2LedEnable(void) -{ - sdPut(&SD0, CMD_LED_ON); -} - -void annepro2LedUpdate(uint8_t row, uint8_t col) -{ - sdPut(&SD0, CMD_LED_SET); - sdPut(&SD0, row); - sdPut(&SD0, col); - sdWrite(&SD0, (uint8_t *)&annepro2LedMatrix[row * MATRIX_COLS + col], sizeof(uint16_t)); -} - -void annepro2LedUpdateRow(uint8_t row) -{ - sdPut(&SD0, CMD_LED_SET_ROW); - sdPut(&SD0, row); - sdWrite(&SD0, (uint8_t *)&annepro2LedMatrix[row * MATRIX_COLS], sizeof(uint16_t) * MATRIX_COLS); -} - -bool OVERRIDE led_update_kb(led_t status) { - annepro2LedMatrix[2 * MATRIX_COLS] = status.caps_lock ? 0x4FF : 0; - annepro2LedUpdate(2, 0); - return led_update_user(status); -} - /*! * @returns false processing for this keycode has been completed. */ diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index 3e562d93af26..8c6b58fcf403 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -32,8 +32,3 @@ enum AP2KeyCodes { KC_AP2_USB, AP2_SAFE_RANGE, }; - -void annepro2LedDisable(void); -void annepro2LedEnable(void); -void annepro2LedUpdate(uint8_t row, uint8_t col); -void annepro2LedUpdateRow(uint8_t row); diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index 0878c54cb36c..cbef25300e5c 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -2,7 +2,8 @@ SRC = \ matrix.c \ hardfault_handler.c \ - annepro2_ble.c + annepro2_ble.c \ + qmk_ap2_led.c LAYOUTS += diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 7df05caeb005..e042ff844a55 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -2,7 +2,8 @@ SRC = \ matrix.c \ hardfault_handler.c \ - annepro2_ble.c + annepro2_ble.c \ + qmk_ap2_led.c LAYOUTS += diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 6a07a94584df..27fa3f13f497 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -1,5 +1,6 @@ #include #include "annepro2.h" +#include "qmk_ap2_led.h" enum anne_pro_layers { _BASE_LAYER, @@ -109,12 +110,16 @@ layer_state_t layer_state_set_user(layer_state_t layer) { bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { case KC_AP_LED_OFF: - if (record->event.pressed) + if (record->event.pressed) { annepro2LedDisable(); + annepro2LedPrevProfile(); + } return false; case KC_AP_LED_ON: - if (record->event.pressed) + if (record->event.pressed) { annepro2LedEnable(); + annepro2LedNextProfile(); + } return false; default: break; diff --git a/keyboards/annepro2/qmk_ap2_led.c b/keyboards/annepro2/qmk_ap2_led.c new file mode 100644 index 000000000000..9ad89c465175 --- /dev/null +++ b/keyboards/annepro2/qmk_ap2_led.c @@ -0,0 +1,60 @@ +#include "hal.h" +#include "annepro2.h" +#include "qmk_ap2_led.h" + +void annepro2LedDisable(void) +{ + sdPut(&SD0, CMD_LED_OFF); +} + +void annepro2LedEnable(void) +{ + sdPut(&SD0, CMD_LED_ON); +} + +void annepro2LedUpdate(uint8_t row, uint8_t col) +{ + sdPut(&SD0, CMD_LED_SET); + sdPut(&SD0, row); + sdPut(&SD0, col); + sdWrite(&SD0, (uint8_t *)&annepro2LedMatrix[row * MATRIX_COLS + col], sizeof(uint16_t)); +} + +void annepro2LedUpdateRow(uint8_t row) +{ + sdPut(&SD0, CMD_LED_SET_ROW); + sdPut(&SD0, row); + sdWrite(&SD0, (uint8_t *)&annepro2LedMatrix[row * MATRIX_COLS], sizeof(uint16_t) * MATRIX_COLS); +} + +void annepro2LedSetProfile(uint8_t prof) +{ + sdPut(&SD0, CMD_LED_SET_PROFILE); + sdPut(&SD0, prof); +} + +uint8_t annepro2LedGetProfile() +{ + uint8_t buf = 0; + sdPut(&SD0, CMD_LED_GET_PROFILE); + buf = sdGet(&SD0); + return buf; +} + +uint8_t annepro2LedGetNumProfiles() +{ + uint8_t buf = 0; + sdPut(&SD0, CMD_LED_GET_NUM_PROFILES); + buf = sdGet(&SD0); + return buf; +} + +void annepro2LedNextProfile() +{ + sdPut(&SD0, CMD_LED_NEXT_PROFILE); +} + +void annepro2LedPrevProfile() +{ + sdPut(&SD0, CMD_LED_PREV_PROFILE); +} \ No newline at end of file diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/qmk_ap2_led.h index 681855b83999..44d94784c30e 100644 --- a/keyboards/annepro2/qmk_ap2_led.h +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -4,3 +4,18 @@ #define CMD_LED_OFF 0x2 #define CMD_LED_SET 0x3 #define CMD_LED_SET_ROW 0x4 +#define CMD_LED_SET_PROFILE 0x5 +#define CMD_LED_NEXT_PROFILE 0x6 +#define CMD_LED_PREV_PROFILE 0x7 +#define CMD_LED_GET_PROFILE 0x8 +#define CMD_LED_GET_NUM_PROFILES 0x9 + +void annepro2LedDisable(void); +void annepro2LedEnable(void); +void annepro2LedUpdate(uint8_t row, uint8_t col); +void annepro2LedUpdateRow(uint8_t row); +void annepro2LedSetProfile(uint8_t prof); +uint8_t annepro2LedGetProfile(void); +uint8_t annepro2LedGetNumProfiles(void); +void annepro2LedNextProfile(void); +void annepro2LedPrevProfile(void); From 266edcbc2f4fb19441ff94f02cfa05663b4a2263 Mon Sep 17 00:00:00 2001 From: jcdeA <31413538+JcdeA@users.noreply.github.com> Date: Fri, 21 Aug 2020 23:03:09 +0900 Subject: [PATCH 19/88] add custom keycodes to switch led profiles --- keyboards/annepro2/keymaps/default/keymap.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 27fa3f13f497..e4818e5d2561 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -10,6 +10,8 @@ enum anne_pro_layers { enum custom_keys { KC_AP_LED_ON = AP2_SAFE_RANGE, KC_AP_LED_OFF, + KC_AP_LED_NEXT_PROFILE, + KC_AP_LED_PREV_PROFILE }; /* * Layer _BASE_LAYER @@ -121,6 +123,14 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { annepro2LedNextProfile(); } return false; + case KC_AP_LED_NEXT_PROFILE: + if (record->event.pressed) + annepro2LedNextProfile(); + return false; + case KC_AP_LED_PREV_PROFILE: + if (record->event.pressed) + annepro2LedPrevProfile(); + return false; default: break; } From 39d5a42012b3879be6a41948df0f778fa7d84463 Mon Sep 17 00:00:00 2001 From: jcdeA <31413538+JcdeA@users.noreply.github.com> Date: Sat, 22 Aug 2020 08:43:16 +0900 Subject: [PATCH 20/88] Optimize code --- keyboards/annepro2/annepro2.c | 25 ++++++++++++++ keyboards/annepro2/annepro2.h | 9 ++++- keyboards/annepro2/keymaps/default/keymap.c | 38 +-------------------- 3 files changed, 34 insertions(+), 38 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 42523acae0df..87d78ff317bf 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -2,6 +2,7 @@ #include "hal.h" #include "annepro2.h" #include "annepro2_ble.h" +#include "qmk_ap2_led.h" static const SerialConfig ledUartConfig = { .speed = 115200, @@ -52,21 +53,45 @@ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { case KC_AP2_BT1: annepro2_ble_broadcast(0); return false; + case KC_AP2_BT2: annepro2_ble_broadcast(1); return false; + case KC_AP2_BT3: annepro2_ble_broadcast(2); return false; + case KC_AP2_BT4: annepro2_ble_broadcast(3); return false; + case KC_AP2_USB: annepro2_ble_disconnect(); return false; + case KC_AP2_BT_UNPAIR: annepro2_ble_unpair(); return false; + + case KC_AP_LED_OFF: + annepro2LedDisable(); + annepro2LedPrevProfile(); + return false; + + case KC_AP_LED_ON: + annepro2LedNextProfile(); + annepro2LedEnable(); + return false; + + case KC_AP_LED_NEXT_PROFILE: + annepro2LedNextProfile(); + return false; + + case KC_AP_LED_PREV_PROFILE: + annepro2LedPrevProfile(); + return false; + default: break; } diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index 8c6b58fcf403..1a81861147c2 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -16,7 +16,7 @@ */ #pragma once - +#include "annepro2.h" #include "quantum.h" #define OVERRIDE __attribute__ ((noinline)) @@ -32,3 +32,10 @@ enum AP2KeyCodes { KC_AP2_USB, AP2_SAFE_RANGE, }; + +enum custom_keys { + KC_AP_LED_ON = AP2_SAFE_RANGE, + KC_AP_LED_OFF, + KC_AP_LED_NEXT_PROFILE, + KC_AP_LED_PREV_PROFILE +}; diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index e4818e5d2561..a5053d6563e7 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -7,12 +7,7 @@ enum anne_pro_layers { _FN1_LAYER, _FN2_LAYER, }; -enum custom_keys { - KC_AP_LED_ON = AP2_SAFE_RANGE, - KC_AP_LED_OFF, - KC_AP_LED_NEXT_PROFILE, - KC_AP_LED_PREV_PROFILE -}; + /* * Layer _BASE_LAYER * ,-----------------------------------------------------------------------------------------. @@ -105,34 +100,3 @@ void matrix_scan_user(void) { layer_state_t layer_state_set_user(layer_state_t layer) { return layer; } - -/*! - * @returns false processing for this keycode has been completed. - */ -bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case KC_AP_LED_OFF: - if (record->event.pressed) { - annepro2LedDisable(); - annepro2LedPrevProfile(); - } - return false; - case KC_AP_LED_ON: - if (record->event.pressed) { - annepro2LedEnable(); - annepro2LedNextProfile(); - } - return false; - case KC_AP_LED_NEXT_PROFILE: - if (record->event.pressed) - annepro2LedNextProfile(); - return false; - case KC_AP_LED_PREV_PROFILE: - if (record->event.pressed) - annepro2LedPrevProfile(); - return false; - default: - break; - } - return true; -} From cab07723525960f4e913b91135bfec43141477fd Mon Sep 17 00:00:00 2001 From: jcdeA <31413538+JcdeA@users.noreply.github.com> Date: Sat, 22 Aug 2020 10:19:55 +0900 Subject: [PATCH 21/88] switch to prev profile before turning leds off --- keyboards/annepro2/annepro2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 87d78ff317bf..fd180695916b 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -75,8 +75,8 @@ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { return false; case KC_AP_LED_OFF: - annepro2LedDisable(); annepro2LedPrevProfile(); + annepro2LedDisable(); return false; case KC_AP_LED_ON: From 4bbc680a285012771dad8d99690cb900254f96b0 Mon Sep 17 00:00:00 2001 From: tech2077 Date: Sun, 23 Aug 2020 21:10:20 -0500 Subject: [PATCH 22/88] Add persistent led support with eeprom (#9) * adding HT32 support to chibios SPI master driver * add support for W25X20CL SPI eeprom * add makefile flag for eeprom feature * add spi support to keyboard startup and config * example keymap using eeprom profile loading --- keyboards/annepro2/annepro2.c | 24 ++- keyboards/annepro2/c18/config.h | 25 +++ keyboards/annepro2/c18/rules.mk | 5 + keyboards/annepro2/eeprom_w25x20cl.c | 203 ++++++++++++++++++ keyboards/annepro2/eeprom_w25x20cl.h | 84 ++++++++ keyboards/annepro2/keymaps/tech2077/keymap.c | 206 +++++++++++++++++++ keyboards/annepro2/keymaps/tech2077/rules.mk | 47 +++++ platforms/chibios/drivers/spi_master.c | 68 +++--- 8 files changed, 614 insertions(+), 48 deletions(-) create mode 100644 keyboards/annepro2/eeprom_w25x20cl.c create mode 100644 keyboards/annepro2/eeprom_w25x20cl.h create mode 100644 keyboards/annepro2/keymaps/tech2077/keymap.c create mode 100644 keyboards/annepro2/keymaps/tech2077/rules.mk diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index fd180695916b..a6bcf423bf37 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -2,6 +2,7 @@ #include "hal.h" #include "annepro2.h" #include "annepro2_ble.h" +#include "spi_master.h" #include "qmk_ap2_led.h" static const SerialConfig ledUartConfig = { @@ -26,6 +27,9 @@ uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS] = { }; void OVERRIDE keyboard_pre_init_kb(void) { +#if HAL_USE_SPI == TRUE + spi_init(); +#endif } void OVERRIDE keyboard_post_init_kb(void) { @@ -33,10 +37,21 @@ void OVERRIDE keyboard_post_init_kb(void) { sdStart(&SD0, &ledUartConfig); sdWrite(&SD0, ledMcuWakeup, 11); + // wait to receive response from wakeup + wait_ms(15); + + // loop to clear out receive buffer from shine wakeup + while(!sdGetWouldBlock(&SD0)) + sdGet(&SD0); + // Start BLE UART sdStart(&SD1, &bleUartConfig); annepro2_ble_startup(); + // Give the send uart thread some time to + // send out the queue before we read back + wait_ms(5); + keyboard_post_init_user(); } @@ -77,20 +92,21 @@ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { case KC_AP_LED_OFF: annepro2LedPrevProfile(); annepro2LedDisable(); - return false; + break; case KC_AP_LED_ON: annepro2LedNextProfile(); annepro2LedEnable(); - return false; + break; case KC_AP_LED_NEXT_PROFILE: annepro2LedNextProfile(); - return false; + break; case KC_AP_LED_PREV_PROFILE: annepro2LedPrevProfile(); - return false; + break; + default: break; diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h index ad6333889220..96b8c1f3e085 100644 --- a/keyboards/annepro2/c18/config.h +++ b/keyboards/annepro2/c18/config.h @@ -60,6 +60,31 @@ /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 +#if defined(ANNEPRO2_EEPROM) +// SPI Config +#define SPI_DRIVER SPID1 +#define SPI_SCK_PIN A0 +#define SPI_SCK_PAL_MODE 5 +#define SPI_MOSI_PIN A1 +#define SPI_MOSI_PAL_MODE 5 +#define SPI_MISO_PIN A2 +#define SPI_MISO_PAL_MODE 5 +// EEPROM Config for W25X20CL +#define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN A3 +#define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 16 +#define EXTERNAL_EEPROM_BYTE_COUNT 1024 // 262144 +#define EXTERNAL_EEPROM_PAGE_SIZE 256 +#define EXTERNAL_EEPROM_ADDRESS_SIZE 3 +#define EXTERNAL_EEPROM_SPI_LSBFIRST false +#define EXTERNAL_EEPROM_SPI_MODE 3 +// HAL Config +#define HAL_USE_SPI TRUE +#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD +// MCU Config +#define HT32_SPI_USE_SPI1 TRUE +#define HT32_SPI1_IRQ_PRIORITY 9 +#endif + /* number of backlight levels */ // #define BACKLIGHT_LEVELS 10 diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index e042ff844a55..11efab064870 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -5,6 +5,11 @@ SRC = \ annepro2_ble.c \ qmk_ap2_led.c +ifeq ($(strip $(ANNEPRO2_EEPROM)), yes) + OPT_DEFS += -DANNEPRO2_EEPROM + SRC += spi_master.c eeprom_w25x20cl.c +endif + LAYOUTS += # MCU diff --git a/keyboards/annepro2/eeprom_w25x20cl.c b/keyboards/annepro2/eeprom_w25x20cl.c new file mode 100644 index 000000000000..6f96e650fcbd --- /dev/null +++ b/keyboards/annepro2/eeprom_w25x20cl.c @@ -0,0 +1,203 @@ +/* Copyright 2020 Nick Brassel (tzarc) and tech2077 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include +#include + +/* + Note that the implementations of eeprom_XXXX_YYYY on AVR are normally + provided by avr-libc. The same functions are reimplemented below and are + rerouted to the external SPI equivalent. + + Seemingly, as this is compiled from within QMK, the object file generated + during the build overrides the avr-libc implementation during the linking + stage. + + On other platforms such as ARM, there are no provided implementations, so + there is nothing to override during linkage. +*/ + +#include "wait.h" +#include "spi_master.h" +#include "eeprom.h" +#include "eeprom_w25x20cl.h" + +#define CMD_WREN 0x06u +#define CMD_WRDI 0x04u +#define CMD_RDSR 0x05u +#define CMD_WRSR 0x01u +#define CMD_READ 0x03u +#define CMD_WRITE 0x02u +#define CMD_SECTOR_ERASE 0x20u + +#define SR_WIP 0x01u + +// #define DEBUG_EEPROM_OUTPUT + +#ifndef EXTERNAL_EEPROM_SPI_TIMEOUT +# define EXTERNAL_EEPROM_SPI_TIMEOUT 100 +#endif + +#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) +# include "timer.h" +# include "debug.h" +#endif // CONSOLE_ENABLE + +bool spi_eeprom_start(void) { + return spi_start(EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN, EXTERNAL_EEPROM_SPI_LSBFIRST, EXTERNAL_EEPROM_SPI_MODE, EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR); +} + +static spi_status_t spi_eeprom_wait_while_busy(int timeout) { + uint32_t deadline = timer_read32() + timeout; + spi_status_t response; + spi_write(CMD_RDSR); + do { + response = spi_read(); + if (timer_read32() >= deadline) { + return SPI_STATUS_TIMEOUT; + } + } while ((uint16_t)response & SR_WIP); + return SPI_STATUS_SUCCESS; +} +//---------------------------------------------------------------------------------------------------------------------- + +void eeprom_erase(uint32_t addr) { +#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) + uint32_t start = timer_read32(); +#endif + + spi_eeprom_start(); + spi_write(CMD_WREN); + spi_stop(); + + spi_eeprom_start(); + spi_write(CMD_SECTOR_ERASE); + spi_write((uint8_t)((addr & 0xFF0000u) >> 16u)); + spi_write((uint8_t)((addr & 0x00FF00u) >> 8u)); + spi_write((uint8_t)((addr & 0x0000FFu))); + spi_stop(); + + spi_eeprom_start(); + spi_status_t response = spi_eeprom_wait_while_busy(10000); + spi_stop(); + if (response == SPI_STATUS_TIMEOUT) { + dprint("SPI timeout for WIP check\n"); + return; + } + +#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) + dprintf("EEPROM erase took %ldms to complete\n", ((long)(timer_read32() - start))); +#endif +} + +void eeprom_read(void *buf, uint32_t addr, size_t len) { + //------------------------------------------------- + // Wait for the write-in-progress bit to be cleared + bool res = spi_eeprom_start(); + if (!res) { + dprint("failed to start SPI for WIP check\n"); + spi_stop(); + return; + } + + spi_status_t response = spi_eeprom_wait_while_busy(EXTERNAL_EEPROM_SPI_TIMEOUT); + spi_stop(); + if (response == SPI_STATUS_TIMEOUT) { + dprint("SPI timeout for WIP check\n"); + spi_stop(); + return; + } + + //------------------------------------------------- + // Perform read + res = spi_eeprom_start(); + if (!res) { + dprint("failed to start SPI for read\n"); + spi_stop(); + return; + } + + spi_write(CMD_READ); + spi_write((uint8_t)((addr & 0xFF0000u) >> 16u)); + spi_write((uint8_t)((addr & 0x00FF00u) >> 8u)); + spi_write((uint8_t)((addr & 0x0000FFu))); + spi_receive(buf, len); + spi_stop(); + +#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) + dprintf("[EEPROM R] 0x%08lX: ", (addr)); + for (size_t i = 0; i < len; ++i) { + dprintf(" %02X", (int)(((uint8_t *)buf)[i])); + } + dprintf("\n"); +#endif // DEBUG_EEPROM_OUTPUT + +} + +void eeprom_write(const void *buf, uint32_t addr, size_t len) { + eeprom_erase(addr); + + //------------------------------------------------- + // Enable writes + bool res = spi_eeprom_start(); + if (!res) { + dprint("failed to start SPI for write-enable\n"); + spi_stop(); + return; + } + + spi_write(CMD_WREN); + spi_stop(); + + wait_us(1); + + //------------------------------------------------- + // Perform the write + res = spi_eeprom_start(); + if (!res) { + dprint("failed to start SPI for write\n"); + spi_stop(); + return; + } + +#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) + dprintf("[EEPROM W] 0x%08lX: ", ((uint32_t)(uintptr_t)addr)); + for (size_t i = 0; i < len; i++) { + dprintf(" %02X", (int)(uint8_t)(buf[i])); + } + dprintf("\n"); +#endif // DEBUG_EEPROM_OUTPUT + + spi_write(CMD_WRITE); + spi_write((uint8_t)((addr & 0xFF0000u) >> 16u)); + spi_write((uint8_t)((addr & 0x00FF00u) >> 8u)); + spi_write((uint8_t)((addr & 0x0000FFu))); + spi_transmit(buf, len); + spi_stop(); + + res = spi_eeprom_start(); + if (!res) { + dprint("failed to start SPI for status\n"); + spi_stop(); + return; + } + spi_status_t response = spi_eeprom_wait_while_busy(EXTERNAL_EEPROM_SPI_TIMEOUT); + spi_stop(); + if (response == SPI_STATUS_TIMEOUT) { + dprint("SPI timeout for WIP check\n"); + return; + } +} diff --git a/keyboards/annepro2/eeprom_w25x20cl.h b/keyboards/annepro2/eeprom_w25x20cl.h new file mode 100644 index 000000000000..17021daded64 --- /dev/null +++ b/keyboards/annepro2/eeprom_w25x20cl.h @@ -0,0 +1,84 @@ +/* Copyright 2020 Nick Brassel (tzarc) and tech2077 + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + +void eeprom_erase(uint32_t addr); +void eeprom_read(void *buf, uint32_t addr, size_t len); +void eeprom_write(const void *buf, uint32_t addr, size_t len); + +/* + The slave select pin of the EEPROM. + This needs to be a normal GPIO pin_t value, such as A7. +*/ +#ifndef EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN +# error "No chip select pin defined -- missing EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN" +#endif + +/* + The clock divisor for SPI to ensure that the MCU is within the + specifications of the EEPROM chip. Generally this will be PCLK divided by + the intended divisor -- check your clock settings and the datasheet of + your EEPROM. +*/ +#ifndef EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR +# ifdef __AVR__ +# define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8 +# else +# define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 64 +# endif +#endif + +/* + The SPI mode to communicate with the EEPROM. +*/ +#ifndef EXTERNAL_EEPROM_SPI_MODE +# define EXTERNAL_EEPROM_SPI_MODE 0 +#endif + +/* + Whether or not the SPI communication between the MCU and EEPROM should be + LSB-first. +*/ +#ifndef EXTERNAL_EEPROM_SPI_LSBFIRST +# define EXTERNAL_EEPROM_SPI_LSBFIRST false +#endif + +/* + The total size of the EEPROM, in bytes. The EEPROM datasheet will usually + specify this value in kbits, and will require conversion to bytes. +*/ +#ifndef EXTERNAL_EEPROM_BYTE_COUNT +# define EXTERNAL_EEPROM_BYTE_COUNT 8192 +#endif + +/* + The page size in bytes of the EEPROM, as specified in the datasheet. +*/ +#ifndef EXTERNAL_EEPROM_PAGE_SIZE +# define EXTERNAL_EEPROM_PAGE_SIZE 32 +#endif + +/* + The address size in bytes of the EEPROM. For EEPROMs with <=256 bytes, this + will likely be 1. For EEPROMs >256 and <=65536, this will be 2. For EEPROMs + >65536, this will likely need to be 4. + + As expected, consult the datasheet for specifics of your EEPROM. +*/ +#ifndef EXTERNAL_EEPROM_ADDRESS_SIZE +# define EXTERNAL_EEPROM_ADDRESS_SIZE 2 +#endif \ No newline at end of file diff --git a/keyboards/annepro2/keymaps/tech2077/keymap.c b/keyboards/annepro2/keymaps/tech2077/keymap.c new file mode 100644 index 000000000000..a3f238dbd01f --- /dev/null +++ b/keyboards/annepro2/keymaps/tech2077/keymap.c @@ -0,0 +1,206 @@ +#include "annepro2.h" +#include +#include +#include +#include "qmk_ap2_led.h" +#include "eeprom_w25x20cl.h" + +// layout using eeprom and bidir-comms to keep user led settings persistent + +// eeprom memory layout +typedef union { + uint32_t raw; + struct { + uint8_t magic : 8; + bool leds_on : 1; + uint8_t leds_profile : 8; + }; +} user_config_t; + +// define out default user_config +user_config_t user_config = {.magic = 0xDE, .leds_on = 0, .leds_profile = 0}; + +// keep the number of profiles so we can track along with the shine proc +uint8_t numProfiles = 0; + +static uint8_t usb_buf[256]; +static uint8_t buf_fil = 0; + +enum anne_pro_layers { + _BASE_LAYER, + _FN1_LAYER, + _FN2_LAYER, +}; + +/* +* Layer _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | +* |-----------------------------------------------------------------------------------------+ +* | Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | +* |-----------------------------------------------------------------------------------------+ +* | Caps | a | s | d | f | g | h | j | k | l | ; | ' | Enter | +* |-----------------------------------------------------------------------------------------+ +* | Shift | z | x | c | v | b | n | m | , | . | / | Shift | +* |-----------------------------------------------------------------------------------------+ +* | Ctrl | GUI | Alt | space | GUI | ALT | FN1 | Ctrl | +* \-----------------------------------------------------------------------------------------/ +* Layer TAP in _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | UP | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | LEFT | DOWN | RIGHT | +* \-----------------------------------------------------------------------------------------/ +*/ +const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE_LAYER] = KEYMAP(/* Base */ + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), + KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, LT(KC_RALT, KC_LEFT), LT(_FN1_LAYER, KC_DOWN), RCTL_T(KC_RGHT)), + /* + * Layer _FN1_LAYER + * ,-----------------------------------------------------------------------------------------. + * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | + * |-----------------------------------------------------------------------------------------+ + * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | + * |-----------------------------------------------------------------------------------------+ + * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift |V-UP |V-DWN|MUTE | v | b | n | m | , |INSRT| DEL | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | space | Alt | FN2 | FN1 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN1_LAYER] = KEYMAP(/* Base */ + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, + KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + MO(_FN2_LAYER), KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS, KC_TRNS), + /* + * Layer _FN2_LAYER + * ,-----------------------------------------------------------------------------------------. + * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp | + * |-----------------------------------------------------------------------------------------+ + * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | + * |-----------------------------------------------------------------------------------------+ + * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift | z | x | c | v | b | n | m | , |INSRT| DEL | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | space | Alt | FN2 | FN1 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN2_LAYER] = KEYMAP(/* Base */ + KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_PROFILE, KC_TRNS, KC_TRNS, KC_TRNS, + MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), MO(_FN1_LAYER), KC_TRNS), +}; +const uint16_t keymaps_size = sizeof(keymaps); + +void matrix_init_user(void) +{ +} + +void matrix_scan_user(void) +{ +} + +layer_state_t layer_state_set_user(layer_state_t layer) +{ + return layer; +} + +void raw_hid_receive(uint8_t *data, uint8_t length) { + uprintf("raw_hid len: %u\n", length); + if (length == 1) + annepro2LedSetProfile(data[0]); + else { + for (uint8_t i = 0; i < length; i++){ + usb_buf[buf_fil + i] = data[i]; + } + buf_fil += length; + if (buf_fil >= 211) { + sdWrite(&SD0, usb_buf, 211); + buf_fil = 0; + } +// for (int i = 0; i < length; i++) { +// sdPut(&SD0, data[i]); +// sdGet(&SD0); +// } + } +} + +/*! + * @returns false processing for this keycode has been completed. + */ +bool process_record_user(uint16_t keycode, keyrecord_t* record) +{ + switch (keycode) { + case KC_AP_LED_OFF: + if (record->event.pressed) { + user_config.leds_on = false; + eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); + } + return false; + case KC_AP_LED_ON: + if (record->event.pressed) { + user_config.leds_on = true; + eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); + } + return false; + case KC_AP_LED_NEXT_PROFILE: + if (record->event.pressed) { + user_config.leds_profile = (user_config.leds_profile + 1) % numProfiles; + annepro2LedSetProfile(user_config.leds_profile); + eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); + } + return false; + default: + break; + } + return true; +} + +void keyboard_post_init_user(void) +{ + // Customize these values to desired behavior + debug_enable = true; + //debug_matrix = true; + //debug_keyboard=true; + //debug_mouse=true; + + // Read the user config from EEPROM + eeprom_read((void*)&user_config, 0, sizeof(user_config_t)); + + // initialize a new eeprom + if (user_config.magic != 0xDE) + { + user_config.magic = 0xDE; + user_config.leds_on = false; + user_config.leds_profile = 0; + eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); + } + + numProfiles = annepro2LedGetNumProfiles(); + + if (user_config.leds_on) { + // send profile before so that we don't get a flicker on startup + annepro2LedSetProfile(user_config.leds_profile); + annepro2LedEnable(); + } else { + annepro2LedDisable(); + } +} \ No newline at end of file diff --git a/keyboards/annepro2/keymaps/tech2077/rules.mk b/keyboards/annepro2/keymaps/tech2077/rules.mk new file mode 100644 index 000000000000..59a7f53b85cf --- /dev/null +++ b/keyboards/annepro2/keymaps/tech2077/rules.mk @@ -0,0 +1,47 @@ +# Anne Pro 2 +SRC = \ + matrix.c \ + hardfault_handler.c \ + annepro2_ble.c \ + qmk_ap2_led.c + +LAYOUTS += + +# MCU +MCU = cortex-m0plus +ARMV = 6 +USE_FPU = no +MCU_FAMILY = HT32 +MCU_SERIES = HT32F523x2 +MCU_LDSCRIPT = HT32F52342_ANNEPRO2 +MCU_STARTUP = ht32f523x2 + +BOARD = ANNEPRO2_C18 + +OPT_DEFS = -Wno-unused-function -fdump-rtl-dfinish -fstack-usage +#EXTRALDFLAGS = -Wl,--print-memory-usage + +# Options + +# Keys +CUSTOM_MATRIX = yes +NKRO_ENABLE = no +MOUSEKEY_ENABLE = no +EXTRAKEY_ENABLE = yes +KEY_LOCK_ENABLE = no + +# Other featues +BOOTMAGIC_ENABLE = no +CONSOLE_ENABLE = yes +COMMAND_ENABLE = yes +DEBUG_EEPROM = yes +RAW_ENABLE = no +MIDI_ENABLE = no +VIRTSER_ENABLE = no +COMBO_ENABLE = no +ANNEPRO2_EEPROM = yes + +ifeq ($(strip $(ANNEPRO2_EEPROM)), yes) + OPT_DEFS += -DANNEPRO2_EEPROM + SRC += spi_master.c eeprom_w25x20cl.c +endif \ No newline at end of file diff --git a/platforms/chibios/drivers/spi_master.c b/platforms/chibios/drivers/spi_master.c index 28ddcbb2ba67..78695369fb35 100644 --- a/platforms/chibios/drivers/spi_master.c +++ b/platforms/chibios/drivers/spi_master.c @@ -38,9 +38,13 @@ __attribute__((weak)) void spi_init(void) { chThdSleepMilliseconds(10); #if defined(USE_GPIOV1) - palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), SPI_SCK_PAL_MODE); - palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), SPI_MOSI_PAL_MODE); - palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), SPI_MISO_PAL_MODE); + palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_STM32_ALTERNATE_PUSHPULL); + palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_STM32_ALTERNATE_PUSHPULL); + palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), PAL_MODE_STM32_ALTERNATE_PUSHPULL); +#elif defined(HT32_SPI_USE_SPI1) || defined(HT32_SPI_USE_SPI2) + palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_HT32_MODE_AF(SPI_SCK_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_HT32_MODE_AF(SPI_MOSI_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), PAL_HT32_MODE_AF(SPI_MISO_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL); #else palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_ALTERNATE(SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); @@ -63,60 +67,36 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) { return false; } -#if defined(K20x) || defined(KL2x) - spiConfig.tar0 = SPIx_CTARn_FMSZ(7) | SPIx_CTARn_ASC(1); +#if defined(HT32_SPI_USE_SPI1) || defined(HT32_SPI_USE_SPI2) + spiConfig.cr0 = SPI_CR0_SELOEN; + spiConfig.cr1 = SPI_CR1_MODE | 8; // 8 bits and in master mode if (lsbFirst) { - spiConfig.tar0 |= SPIx_CTARn_LSBFE; + spiConfig.cr1 |= SPI_CR1_FIRSTBIT; } switch (mode) { - case 0: - break; - case 1: - spiConfig.tar0 |= SPIx_CTARn_CPHA; - break; - case 2: - spiConfig.tar0 |= SPIx_CTARn_CPOL; - break; - case 3: - spiConfig.tar0 |= SPIx_CTARn_CPHA | SPIx_CTARn_CPOL; - break; + case 0: + spiConfig.cr1 |= SPI_CR1_FORMAT_MODE0; + break; + case 1: + spiConfig.cr1 |= SPI_CR1_FORMAT_MODE1; + break; + case 2: + spiConfig.cr1 |= SPI_CR1_FORMAT_MODE2; + break; + case 3: + spiConfig.cr1 |= SPI_CR1_FORMAT_MODE3; + break; } - switch (roundedDivisor) { - case 2: - spiConfig.tar0 |= SPIx_CTARn_BR(0); - break; - case 4: - spiConfig.tar0 |= SPIx_CTARn_BR(1); - break; - case 8: - spiConfig.tar0 |= SPIx_CTARn_BR(3); - break; - case 16: - spiConfig.tar0 |= SPIx_CTARn_BR(4); - break; - case 32: - spiConfig.tar0 |= SPIx_CTARn_BR(5); - break; - case 64: - spiConfig.tar0 |= SPIx_CTARn_BR(6); - break; - case 128: - spiConfig.tar0 |= SPIx_CTARn_BR(7); - break; - case 256: - spiConfig.tar0 |= SPIx_CTARn_BR(8); - break; - } + spiConfig.cpr = (roundedDivisor - 1) >> 1; #else spiConfig.cr1 = 0; if (lsbFirst) { spiConfig.cr1 |= SPI_CR1_LSBFIRST; } - switch (mode) { case 0: break; From fffa641adffe0dccdc81f7c6d0e943e7b05cd0b5 Mon Sep 17 00:00:00 2001 From: tech2077 Date: Sat, 29 Aug 2020 16:19:42 -0500 Subject: [PATCH 23/88] Cleanup to fix C15 eeprom/spi build errors (#11) * Cleanup to fix C15 eeprom/spi build errors * add newline at eof --- keyboards/annepro2/c15/config.h | 1 + keyboards/annepro2/c18/config.h | 1 + keyboards/annepro2/keymaps/tech2077/keymap.c | 15 ++++--- keyboards/annepro2/keymaps/tech2077/rules.mk | 42 ++------------------ 4 files changed, 16 insertions(+), 43 deletions(-) diff --git a/keyboards/annepro2/c15/config.h b/keyboards/annepro2/c15/config.h index 111efbf86abb..76d0217cca7c 100644 --- a/keyboards/annepro2/c15/config.h +++ b/keyboards/annepro2/c15/config.h @@ -26,6 +26,7 @@ #define DESCRIPTION Anne Pro 2 with QMK #define NAME_SLUG "annepro2" +#define ANNEPRO2_C15 // key matrix size #define MATRIX_ROWS 5 diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h index 96b8c1f3e085..f47d622229bf 100644 --- a/keyboards/annepro2/c18/config.h +++ b/keyboards/annepro2/c18/config.h @@ -26,6 +26,7 @@ #define DESCRIPTION Anne Pro 2 (c18) with QMK #define NAME_SLUG "annepro2" +#define ANNEPRO2_C18 // key matrix size #define MATRIX_ROWS 5 diff --git a/keyboards/annepro2/keymaps/tech2077/keymap.c b/keyboards/annepro2/keymaps/tech2077/keymap.c index a3f238dbd01f..28d76edab02f 100644 --- a/keyboards/annepro2/keymaps/tech2077/keymap.c +++ b/keyboards/annepro2/keymaps/tech2077/keymap.c @@ -1,9 +1,10 @@ #include "annepro2.h" #include #include -#include #include "qmk_ap2_led.h" +#ifdef ANNEPRO2_C18 #include "eeprom_w25x20cl.h" +#endif // layout using eeprom and bidir-comms to keep user led settings persistent @@ -64,7 +65,7 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), - KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, LT(KC_RALT, KC_LEFT), LT(_FN1_LAYER, KC_DOWN), RCTL_T(KC_RGHT)), + KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, LT(_FN2_LAYER, KC_LEFT), LT(_FN1_LAYER, KC_DOWN), RCTL_T(KC_RGHT)), /* * Layer _FN1_LAYER * ,-----------------------------------------------------------------------------------------. @@ -148,6 +149,7 @@ void raw_hid_receive(uint8_t *data, uint8_t length) { */ bool process_record_user(uint16_t keycode, keyrecord_t* record) { +#ifdef ANNEPRO2_C18 switch (keycode) { case KC_AP_LED_OFF: if (record->event.pressed) { @@ -171,6 +173,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t* record) default: break; } +#endif return true; } @@ -182,6 +185,7 @@ void keyboard_post_init_user(void) //debug_keyboard=true; //debug_mouse=true; +#ifdef ANNEPRO2_C18 // Read the user config from EEPROM eeprom_read((void*)&user_config, 0, sizeof(user_config_t)); @@ -194,8 +198,6 @@ void keyboard_post_init_user(void) eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); } - numProfiles = annepro2LedGetNumProfiles(); - if (user_config.leds_on) { // send profile before so that we don't get a flicker on startup annepro2LedSetProfile(user_config.leds_profile); @@ -203,4 +205,7 @@ void keyboard_post_init_user(void) } else { annepro2LedDisable(); } -} \ No newline at end of file +#endif + + numProfiles = annepro2LedGetNumProfiles(); +} diff --git a/keyboards/annepro2/keymaps/tech2077/rules.mk b/keyboards/annepro2/keymaps/tech2077/rules.mk index 59a7f53b85cf..73e1375afc0a 100644 --- a/keyboards/annepro2/keymaps/tech2077/rules.mk +++ b/keyboards/annepro2/keymaps/tech2077/rules.mk @@ -1,47 +1,13 @@ -# Anne Pro 2 -SRC = \ - matrix.c \ - hardfault_handler.c \ - annepro2_ble.c \ - qmk_ap2_led.c - -LAYOUTS += - -# MCU -MCU = cortex-m0plus -ARMV = 6 -USE_FPU = no -MCU_FAMILY = HT32 -MCU_SERIES = HT32F523x2 -MCU_LDSCRIPT = HT32F52342_ANNEPRO2 -MCU_STARTUP = ht32f523x2 - -BOARD = ANNEPRO2_C18 - -OPT_DEFS = -Wno-unused-function -fdump-rtl-dfinish -fstack-usage -#EXTRALDFLAGS = -Wl,--print-memory-usage - -# Options - -# Keys -CUSTOM_MATRIX = yes -NKRO_ENABLE = no -MOUSEKEY_ENABLE = no -EXTRAKEY_ENABLE = yes -KEY_LOCK_ENABLE = no - # Other featues -BOOTMAGIC_ENABLE = no CONSOLE_ENABLE = yes COMMAND_ENABLE = yes DEBUG_EEPROM = yes -RAW_ENABLE = no -MIDI_ENABLE = no -VIRTSER_ENABLE = no -COMBO_ENABLE = no + +ifeq ($(strip $(BOARD)), ANNEPRO2_C18) ANNEPRO2_EEPROM = yes +endif ifeq ($(strip $(ANNEPRO2_EEPROM)), yes) OPT_DEFS += -DANNEPRO2_EEPROM SRC += spi_master.c eeprom_w25x20cl.c -endif \ No newline at end of file +endif From e60ea29c1644f2aad369415d24d16dc51a55e4c3 Mon Sep 17 00:00:00 2001 From: codetector Date: Sat, 29 Aug 2020 20:35:20 -0400 Subject: [PATCH 24/88] LED Masking support for Shine Introduce companion update to ledSetMask and ledClearMask. In keymap `codetector` there is example of how to map caps_lock to the caps_lock key light on the keyboard. --- keyboards/annepro2/qmk_ap2_led.c | 14 +++++++++++++- keyboards/annepro2/qmk_ap2_led.h | 4 ++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/keyboards/annepro2/qmk_ap2_led.c b/keyboards/annepro2/qmk_ap2_led.c index 9ad89c465175..8b626080355c 100644 --- a/keyboards/annepro2/qmk_ap2_led.c +++ b/keyboards/annepro2/qmk_ap2_led.c @@ -57,4 +57,16 @@ void annepro2LedNextProfile() void annepro2LedPrevProfile() { sdPut(&SD0, CMD_LED_PREV_PROFILE); -} \ No newline at end of file +} + +void annepro2LedSetMask(uint8_t key) +{ + sdPut(&SD0, CMD_LED_SET_MASK); + sdPut(&SD0, key); +} + +void annepro2LedClearMask(uint8_t key) +{ + sdPut(&SD0, CMD_LED_CLEAR_MASK); + sdPut(&SD0, key); +} diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/qmk_ap2_led.h index 44d94784c30e..684bcdf9f707 100644 --- a/keyboards/annepro2/qmk_ap2_led.h +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -9,6 +9,8 @@ #define CMD_LED_PREV_PROFILE 0x7 #define CMD_LED_GET_PROFILE 0x8 #define CMD_LED_GET_NUM_PROFILES 0x9 +#define CMD_LED_SET_MASK 0xA +#define CMD_LED_CLEAR_MASK 0xB void annepro2LedDisable(void); void annepro2LedEnable(void); @@ -19,3 +21,5 @@ uint8_t annepro2LedGetProfile(void); uint8_t annepro2LedGetNumProfiles(void); void annepro2LedNextProfile(void); void annepro2LedPrevProfile(void); +void annepro2LedSetMask(uint8_t key); +void annepro2LedClearMask(uint8_t key); From c179625ad3f640703bf42b688c1bf7348249991b Mon Sep 17 00:00:00 2001 From: codetector Date: Wed, 4 Nov 2020 14:41:36 -0500 Subject: [PATCH 25/88] [AnnePro2]: update bluetooth connection --- keyboards/annepro2/annepro2_ble.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/keyboards/annepro2/annepro2_ble.c b/keyboards/annepro2/annepro2_ble.c index fbd435370cab..5fce1716aa72 100644 --- a/keyboards/annepro2/annepro2_ble.c +++ b/keyboards/annepro2/annepro2_ble.c @@ -69,10 +69,14 @@ void annepro2_ble_broadcast(uint8_t port) { if (port > 3) { port = 3; } - sdPut(&SD1, 0x00); + // sdPut(&SD1, 0x00); sdWrite(&SD1, bleMcuStartBroadcast, 10); sdPut(&SD1, port); - annepro2_ble_connect(port); + static int lastBroadcast = -1; + if (lastBroadcast == port) { + annepro2_ble_connect(port); + } + lastBroadcast = port; } void annepro2_ble_connect(uint8_t port) { @@ -98,7 +102,7 @@ void annepro2_ble_disconnect(void) { } void annepro2_ble_unpair(void) { - sdPut(&SD1, 0x0); + // sdPut(&SD1, 0x0); sdWrite(&SD1, bleMcuUnpair, 11); } From cf4ca4682436cf0e810c31d2e70a69acb32c07e0 Mon Sep 17 00:00:00 2001 From: Thomaz Moura <5599621+thomazmoura@users.noreply.github.com> Date: Wed, 11 Nov 2020 23:57:52 -0300 Subject: [PATCH 26/88] Merge the custom keys enums on annepro2.h (#13) --- keyboards/annepro2/annepro2.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index 1a81861147c2..23184d510cbc 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -30,12 +30,9 @@ enum AP2KeyCodes { KC_AP2_BT4, KC_AP2_BT_UNPAIR, KC_AP2_USB, - AP2_SAFE_RANGE, -}; - -enum custom_keys { - KC_AP_LED_ON = AP2_SAFE_RANGE, + KC_AP_LED_ON, KC_AP_LED_OFF, KC_AP_LED_NEXT_PROFILE, - KC_AP_LED_PREV_PROFILE + KC_AP_LED_PREV_PROFILE, + AP2_SAFE_RANGE, }; From 758c541b13c7e00523d4a5592dcda20fe377ac19 Mon Sep 17 00:00:00 2001 From: tech2077 Date: Mon, 23 Nov 2020 23:28:36 -0600 Subject: [PATCH 27/88] Keyboard annepro2 ble caps lock (#12) * Move matrix_scan_kb out of board.c to annepro2.c * add buffer clear after init and caplock polling --- keyboards/annepro2/annepro2.c | 25 +++++++++++++++++++++- keyboards/annepro2/annepro2.h | 7 ++++++ keyboards/annepro2/boards/ANNEPRO2/board.c | 4 ---- 3 files changed, 31 insertions(+), 5 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index a6bcf423bf37..e9674649520d 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -17,6 +17,7 @@ static uint8_t ledMcuWakeup[11] = { 0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02 }; +ble_capslock_t BLECapsLock = {._dummy = {0}, .caps_lock = false}; uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS] = { 0,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -50,7 +51,11 @@ void OVERRIDE keyboard_post_init_kb(void) { // Give the send uart thread some time to // send out the queue before we read back - wait_ms(5); + wait_ms(15); + + // loop to clear out receive buffer from ble wakeup + while(!sdGetWouldBlock(&SD1)) + sdGet(&SD1); keyboard_post_init_user(); } @@ -59,6 +64,24 @@ void OVERRIDE matrix_init_kb(void) { matrix_init_user(); } +void matrix_scan_kb() { + // if there's stuff on the ble serial buffer + // read it into the capslock struct + while(!sdGetWouldBlock(&SD1)) { + sdReadTimeout(&SD1, (uint8_t *) &BLECapsLock, sizeof(ble_capslock_t), 10); + + // if it's capslock from ble, darken led + if (BLECapsLock.caps_lock) { + annepro2LedClearMask(MATRIX_COLS * 2); + } else { + annepro2LedSetMask(MATRIX_COLS * 2); + } + } + + + matrix_scan_user(); +} + /*! * @returns false processing for this keycode has been completed. */ diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index 23184d510cbc..a4aaf2ca9e01 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -21,8 +21,15 @@ #define OVERRIDE __attribute__ ((noinline)) +typedef struct __attribute__((__packed__)) { + uint8_t _dummy[10]; + bool caps_lock; +} ble_capslock_t; + extern uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS]; +extern ble_capslock_t BLECapsLock; + enum AP2KeyCodes { KC_AP2_BT1 = SAFE_RANGE, KC_AP2_BT2, diff --git a/keyboards/annepro2/boards/ANNEPRO2/board.c b/keyboards/annepro2/boards/ANNEPRO2/board.c index 2514d96f9730..98f9d9590185 100644 --- a/keyboards/annepro2/boards/ANNEPRO2/board.c +++ b/keyboards/annepro2/boards/ANNEPRO2/board.c @@ -176,10 +176,6 @@ void __early_init(void) { ht32_clock_init(); } -void matrix_scan_kb() { - matrix_scan_user(); -} - /** * @brief Board-specific initialization code. * @todo Add your board-specific code, if any. From 1a7732f489a309cde278958311253b0109dd63c4 Mon Sep 17 00:00:00 2001 From: Darkhan Date: Sat, 5 Dec 2020 11:06:37 +0600 Subject: [PATCH 28/88] Add support for LED intensity (#15) --- keyboards/annepro2/annepro2.c | 5 ++++- keyboards/annepro2/annepro2.h | 2 +- keyboards/annepro2/keymaps/default/keymap.c | 2 +- keyboards/annepro2/qmk_ap2_led.c | 5 +++++ keyboards/annepro2/qmk_ap2_led.h | 2 ++ 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index e9674649520d..8a1412b6bf1e 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -127,9 +127,12 @@ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { break; case KC_AP_LED_PREV_PROFILE: - annepro2LedPrevProfile(); + annepro2LedPrevProfile(); break; + case KC_AP_LED_NEXT_INTENSITY: + annepro2LedNextIntensity(); + return false; default: break; diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index a4aaf2ca9e01..0a08d045f123 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -16,7 +16,6 @@ */ #pragma once -#include "annepro2.h" #include "quantum.h" #define OVERRIDE __attribute__ ((noinline)) @@ -41,5 +40,6 @@ enum AP2KeyCodes { KC_AP_LED_OFF, KC_AP_LED_NEXT_PROFILE, KC_AP_LED_PREV_PROFILE, + KC_AP_LED_NEXT_INTENSITY, AP2_SAFE_RANGE, }; diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index a5053d6563e7..0cd4bc8f85af 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -80,7 +80,7 @@ enum anne_pro_layers { * */ [_FN2_LAYER] = KEYMAP( /* Base */ - KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, diff --git a/keyboards/annepro2/qmk_ap2_led.c b/keyboards/annepro2/qmk_ap2_led.c index 8b626080355c..5ee6f49aad93 100644 --- a/keyboards/annepro2/qmk_ap2_led.c +++ b/keyboards/annepro2/qmk_ap2_led.c @@ -54,6 +54,11 @@ void annepro2LedNextProfile() sdPut(&SD0, CMD_LED_NEXT_PROFILE); } +void annepro2LedNextIntensity() +{ + sdPut(&SD0, CMD_LED_NEXT_INTENSITY); +} + void annepro2LedPrevProfile() { sdPut(&SD0, CMD_LED_PREV_PROFILE); diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/qmk_ap2_led.h index 684bcdf9f707..30e1565e2e01 100644 --- a/keyboards/annepro2/qmk_ap2_led.h +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -11,6 +11,7 @@ #define CMD_LED_GET_NUM_PROFILES 0x9 #define CMD_LED_SET_MASK 0xA #define CMD_LED_CLEAR_MASK 0xB +#define CMD_LED_NEXT_INTENSITY 0xC void annepro2LedDisable(void); void annepro2LedEnable(void); @@ -23,3 +24,4 @@ void annepro2LedNextProfile(void); void annepro2LedPrevProfile(void); void annepro2LedSetMask(uint8_t key); void annepro2LedClearMask(uint8_t key); +void annepro2LedNextIntensity(void); From c16513602135178f2690c0e2afbb800d152ee3c1 Mon Sep 17 00:00:00 2001 From: Darkhan Date: Sat, 5 Dec 2020 11:10:35 +0600 Subject: [PATCH 29/88] Improve logic for switching off and on of LEDs (#16) --- keyboards/annepro2/annepro2.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 8a1412b6bf1e..82920e615118 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -17,6 +17,8 @@ static uint8_t ledMcuWakeup[11] = { 0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02 }; +static bool ledEnabled = false; + ble_capslock_t BLECapsLock = {._dummy = {0}, .caps_lock = false}; uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS] = { @@ -113,13 +115,17 @@ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { return false; case KC_AP_LED_OFF: - annepro2LedPrevProfile(); annepro2LedDisable(); + ledEnabled = false; break; case KC_AP_LED_ON: - annepro2LedNextProfile(); - annepro2LedEnable(); + if (ledEnabled) { + annepro2LedNextProfile(); + } else { + ledEnabled = true; + annepro2LedEnable(); + } break; case KC_AP_LED_NEXT_PROFILE: From ab17a1e3b6b5edf6a724efa63f085ac5335f7d69 Mon Sep 17 00:00:00 2001 From: Darkhan Date: Sat, 5 Dec 2020 11:27:36 +0600 Subject: [PATCH 30/88] Implement animation speed (#17) --- keyboards/annepro2/annepro2.c | 4 +++- keyboards/annepro2/annepro2.h | 1 + keyboards/annepro2/keymaps/default/keymap.c | 2 +- keyboards/annepro2/qmk_ap2_led.c | 5 +++++ keyboards/annepro2/qmk_ap2_led.h | 2 ++ 5 files changed, 12 insertions(+), 2 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 82920e615118..cdabe35fb457 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -139,7 +139,9 @@ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { case KC_AP_LED_NEXT_INTENSITY: annepro2LedNextIntensity(); return false; - + case KC_AP_LED_SPEED: + annepro2LedNextAnimationSpeed(); + return false; default: break; } diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index 0a08d045f123..a7383c759788 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -41,5 +41,6 @@ enum AP2KeyCodes { KC_AP_LED_NEXT_PROFILE, KC_AP_LED_PREV_PROFILE, KC_AP_LED_NEXT_INTENSITY, + KC_AP_LED_SPEED, AP2_SAFE_RANGE, }; diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 0cd4bc8f85af..33f81fc38fc0 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -80,7 +80,7 @@ enum anne_pro_layers { * */ [_FN2_LAYER] = KEYMAP( /* Base */ - KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, diff --git a/keyboards/annepro2/qmk_ap2_led.c b/keyboards/annepro2/qmk_ap2_led.c index 5ee6f49aad93..1a81e73f69a3 100644 --- a/keyboards/annepro2/qmk_ap2_led.c +++ b/keyboards/annepro2/qmk_ap2_led.c @@ -59,6 +59,11 @@ void annepro2LedNextIntensity() sdPut(&SD0, CMD_LED_NEXT_INTENSITY); } +void annepro2LedNextAnimationSpeed() +{ + sdPut(&SD0, CMD_LED_NEXT_ANIMATION_SPEED); +} + void annepro2LedPrevProfile() { sdPut(&SD0, CMD_LED_PREV_PROFILE); diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/qmk_ap2_led.h index 30e1565e2e01..4a501789dd4d 100644 --- a/keyboards/annepro2/qmk_ap2_led.h +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -12,6 +12,7 @@ #define CMD_LED_SET_MASK 0xA #define CMD_LED_CLEAR_MASK 0xB #define CMD_LED_NEXT_INTENSITY 0xC +#define CMD_LED_NEXT_ANIMATION_SPEED 0xD void annepro2LedDisable(void); void annepro2LedEnable(void); @@ -25,3 +26,4 @@ void annepro2LedPrevProfile(void); void annepro2LedSetMask(uint8_t key); void annepro2LedClearMask(uint8_t key); void annepro2LedNextIntensity(void); +void annepro2LedNextAnimationSpeed(void); From fb5829fa3127fef4501df1f49f389bc9d70d728f Mon Sep 17 00:00:00 2001 From: Thomaz Moura <5599621+thomazmoura@users.noreply.github.com> Date: Sat, 5 Dec 2020 16:54:44 -0300 Subject: [PATCH 31/88] Include logic to send solid colors as foreground to shine and add sample profiles (#14) Include the logic to send a solid color from qmk to shine. That solid color will act as a foreground (will override the current profile) until reset (witch will reactivate the current profile). This functionality depends on changes made for shine as well. Include 3 new profiles: default-full-caps -> same as default, but with the logic of using the red foreground color on caps lock. default-layer-indicators -> same as default, but with the logic of red foreground on caps lock, green foreground on FN1 and blue foreground on FN2. thomazmoura -> my own profile as a sample of an over-engineered advanced case scenario. --- .../keymaps/default-full-caps/keymap.c | 115 +++++ .../keymaps/default-layer-indicators/keymap.c | 132 ++++++ .../annepro2/keymaps/thomazmoura/config.h | 15 + .../annepro2/keymaps/thomazmoura/keymap.c | 419 ++++++++++++++++++ .../annepro2/keymaps/thomazmoura/rules.mk | 47 ++ keyboards/annepro2/qmk_ap2_led.c | 14 + keyboards/annepro2/qmk_ap2_led.h | 3 + 7 files changed, 745 insertions(+) create mode 100644 keyboards/annepro2/keymaps/default-full-caps/keymap.c create mode 100644 keyboards/annepro2/keymaps/default-layer-indicators/keymap.c create mode 100644 keyboards/annepro2/keymaps/thomazmoura/config.h create mode 100644 keyboards/annepro2/keymaps/thomazmoura/keymap.c create mode 100644 keyboards/annepro2/keymaps/thomazmoura/rules.mk diff --git a/keyboards/annepro2/keymaps/default-full-caps/keymap.c b/keyboards/annepro2/keymaps/default-full-caps/keymap.c new file mode 100644 index 000000000000..329c70dd4abc --- /dev/null +++ b/keyboards/annepro2/keymaps/default-full-caps/keymap.c @@ -0,0 +1,115 @@ +#include +#include "annepro2.h" +#include "qmk_ap2_led.h" + +enum anne_pro_layers { + _BASE_LAYER, + _FN1_LAYER, + _FN2_LAYER, +}; + +/* +* Layer _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | +* |-----------------------------------------------------------------------------------------+ +* | Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | +* |-----------------------------------------------------------------------------------------+ +* | Caps | a | s | d | f | g | h | j | k | l | ; | ' | Enter | +* |-----------------------------------------------------------------------------------------+ +* | Shift | z | x | c | v | b | n | m | , | . | / | Shift | +* |-----------------------------------------------------------------------------------------+ +* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | +* \-----------------------------------------------------------------------------------------/ +* Layer TAP in _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | UP | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | LEFT | DOWN | RIGHT | +* \-----------------------------------------------------------------------------------------/ +*/ + const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE_LAYER] = KEYMAP( /* Base */ + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LAYER,KC_LEFT), LT(_FN2_LAYER,KC_DOWN), RCTL_T(KC_RGHT) +), + /* + * Layer _FN1_LAYER + * ,-----------------------------------------------------------------------------------------. + * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | + * |-----------------------------------------------------------------------------------------+ + * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | + * |-----------------------------------------------------------------------------------------+ + * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift |V-UP |V-DWN|MUTE | v | b | n | m | , |INSRT| DEL | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN1_LAYER] = KEYMAP( /* Base */ + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, + KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS +), + /* + * Layer _FN2_LAYER + * ,-----------------------------------------------------------------------------------------. + * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp | + * |-----------------------------------------------------------------------------------------+ + * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | + * |-----------------------------------------------------------------------------------------+ + * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift | z | x | c | v | b | n | m | , |INSRT| DEL | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN2_LAYER] = KEYMAP( /* Base */ + KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_TRNS, + MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_TRNS + ), +}; +const uint16_t keymaps_size = sizeof(keymaps); + + +void matrix_init_user(void) { + +} + +void matrix_scan_user(void) { +} + +layer_state_t layer_state_set_user(layer_state_t layer) { + return layer; +} + +// The function to handle the caps lock logic +bool led_update_user(led_t leds) { + if (leds.caps_lock) { + // Set the leds to red + annepro2LedSetForegroundColor(0xFF, 0x00, 0x00); + } else { + annepro2LedResetForegroundColor(); + } + + return true; +} + diff --git a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c new file mode 100644 index 000000000000..b58f916b47c0 --- /dev/null +++ b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c @@ -0,0 +1,132 @@ +#include +#include "annepro2.h" +#include "qmk_ap2_led.h" + +enum anne_pro_layers { + _BASE_LAYER, + _FN1_LAYER, + _FN2_LAYER, +}; + +/* +* Layer _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | +* |-----------------------------------------------------------------------------------------+ +* | Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | +* |-----------------------------------------------------------------------------------------+ +* | Caps | a | s | d | f | g | h | j | k | l | ; | ' | Enter | +* |-----------------------------------------------------------------------------------------+ +* | Shift | z | x | c | v | b | n | m | , | . | / | Shift | +* |-----------------------------------------------------------------------------------------+ +* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | +* \-----------------------------------------------------------------------------------------/ +* Layer TAP in _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | UP | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | LEFT | DOWN | RIGHT | +* \-----------------------------------------------------------------------------------------/ +*/ + const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE_LAYER] = KEYMAP( /* Base */ + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LAYER,KC_LEFT), LT(_FN2_LAYER,KC_DOWN), RCTL_T(KC_RGHT) +), + /* + * Layer _FN1_LAYER + * ,-----------------------------------------------------------------------------------------. + * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | + * |-----------------------------------------------------------------------------------------+ + * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | + * |-----------------------------------------------------------------------------------------+ + * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift |V-UP |V-DWN|MUTE | v | b | n | m | , |INSRT| DEL | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN1_LAYER] = KEYMAP( /* Base */ + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, + KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS +), + /* + * Layer _FN2_LAYER + * ,-----------------------------------------------------------------------------------------. + * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp | + * |-----------------------------------------------------------------------------------------+ + * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | + * |-----------------------------------------------------------------------------------------+ + * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift | z | x | c | v | b | n | m | , |INSRT| DEL | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN2_LAYER] = KEYMAP( /* Base */ + KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_TRNS, + MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_TRNS + ), +}; +const uint16_t keymaps_size = sizeof(keymaps); + + +void matrix_init_user(void) { + +} + +void matrix_scan_user(void) { +} + +layer_state_t layer_state_set_user(layer_state_t layer) { + switch(get_highest_layer(layer)) { + case _FN1_LAYER: + // Set the leds to green + annepro2LedSetForegroundColor(0x00, 0xFF, 0x00); + break; + case _FN2_LAYER: + // Set the leds to blue + annepro2LedSetForegroundColor(0x00, 0x00, 0xFF); + break; + default: + // Reset back to the current profile + annepro2LedResetForegroundColor(); + break; + } + return layer; +} + +// The function to handle the caps lock logic +bool led_update_user(led_t leds) { + if (leds.caps_lock) { + // Set the leds to red + annepro2LedSetForegroundColor(0xFF, 0x00, 0x00); + } else { + // Reset back to the current profile if there is no layer active + if(!layer_state_is(_FN1_LAYER) && !layer_state_is(_FN2_LAYER)) { + annepro2LedResetForegroundColor(); + } + } + + return true; +} + diff --git a/keyboards/annepro2/keymaps/thomazmoura/config.h b/keyboards/annepro2/keymaps/thomazmoura/config.h new file mode 100644 index 000000000000..639124e1703f --- /dev/null +++ b/keyboards/annepro2/keymaps/thomazmoura/config.h @@ -0,0 +1,15 @@ +#pragma once + +#undef TAPPING_TERM +#define TAPPING_TERM 200 +#define RETRO_TAPPING + +#undef TAPPING_TOGGLE +#define TAPPING_TOGGLE 2 + +#define MK_3_SPEED +#define MK_MOMENTARY_ACCEL + +#define CAPS_LOCATION (MATRIX_COLS * 0 + 0) + +#define IDLE_PROFILE_INDEX 0 diff --git a/keyboards/annepro2/keymaps/thomazmoura/keymap.c b/keyboards/annepro2/keymaps/thomazmoura/keymap.c new file mode 100644 index 000000000000..6db81c6876bc --- /dev/null +++ b/keyboards/annepro2/keymaps/thomazmoura/keymap.c @@ -0,0 +1,419 @@ +#include +#include "annepro2.h" +#include "qmk_ap2_led.h" +#include "config.h" + +enum anne_pro_layers { + _BASE_LAYER, + _MOUSE_LAYER, + _FUNCTION_LAYER, + _MEDIA_AND_NAVIGATION_LAYER, + _NUMPAD_LAYER, +}; + +typedef struct { + bool is_press_action; + uint8_t state; +} tap; + +// Define a type for as many tap dance states as you need +enum { + SINGLE_TAP = 1, + SINGLE_HOLD, + DOUBLE_TAP, + DOUBLE_HOLD, + TRIPLE_TAP, + TRIPLE_HOLD +}; + +enum profile { + RED, + GREEN, + BLUE, + RAINBOWHORIZONTAL, + RAINBOWVERTICAL, + ANIMATEDRAINBOWVERTICAL, + ANIMATEDRAINBOWFLOW, + ANIMATEDRAINBOWWATERFALL, + ANIMATEDBREATHING, + ANIMATEDSPECTRUM +}; + +uint8_t cyclabe_profiles[] = { + IDLE_PROFILE_INDEX, + ANIMATEDRAINBOWFLOW, + ANIMATEDRAINBOWVERTICAL, + ANIMATEDRAINBOWWATERFALL, + ANIMATEDBREATHING, + ANIMATEDSPECTRUM +}; + +enum custom_codes { + NEXT_PROFILE = AP2_SAFE_RANGE, + ENABLE_OR_DISABLE_LEDS +}; + +enum { + ESC_TAP_DANCE, + GRV_TAP_DANCE, +}; + +/* +* Layer _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | +* |-----------------------------------------------------------------------------------------+ +* | Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | +* |-----------------------------------------------------------------------------------------+ +* |-----------------------------------------------------------------------------------------+ | Shift | z | x | c | v | b | n | m | , | . | / | Shift | +* |-----------------------------------------------------------------------------------------+ +* | Ctrl | FN2 | Alt | FN2 | Win | FN2 | FN1 | Ctrl | +* \-----------------------------------------------------------------------------------------/ +* Layer TAP in _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | ESC | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | Space | | | | | +* \-----------------------------------------------------------------------------------------/ +*/ + const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE_LAYER] = KEYMAP( /* Base */ + KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + TD(ESC_TAP_DANCE), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, + KC_LCTL, KC_LGUI, KC_LALT, LT(_MEDIA_AND_NAVIGATION_LAYER, KC_SPC), LALT_T(KC_APP), KC_RGUI, MO(_FUNCTION_LAYER), KC_RCTL +), + /* + * Layer _FUNCTION_LAYER + * ,-----------------------------------------------------------------------------------------. + * | Caps| F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | + * |-----------------------------------------------------------------------------------------+ + * | | | 7 | 8 | 9 | | | | | | | | | | + * |-----------------------------------------------------------------------------------------+ + * | | 0 | 4 | 5 | 6 | | LFT | DWN | UP | RGT | ; | ' | | + * |-----------------------------------------------------------------------------------------+ + * | | | 1 | 2 | 3 | | | | | | | | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | | | | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FUNCTION_LAYER] = KEYMAP( /* Base */ + KC_CAPS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, + KC_PSCR, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______ +), + /* + * Layer _MEDIA_AND_NAVIGATION_LAYER + * ,-----------------------------------------------------------------------------------------. + * | USB | BT1 | BT2 | BT3 | BT4 | | | |LEDCH|LEDON| | | | | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | | MUTE| PREV| PLAY| NEXT| | | | | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | | HOME|PGDWN| PGUP| END | | | | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | | | |VOLDN|VOLUP| | | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | | | | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_MEDIA_AND_NAVIGATION_LAYER] = KEYMAP( /* Base */ + KC_AP2_USB, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, _______, _______, _______, _______, NEXT_PROFILE, ENABLE_OR_DISABLE_LEDS, _______, _______, KC_AP2_BT_UNPAIR, + _______, _______, _______, KC_UP, _______, _______, KC_MUTE, KC_MPRV, KC_MPLY, KC_MNXT, _______, KC_BRID, KC_BRIU, _______, + _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END, _______, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLD, KC_VOLU, _______, _______, + _______, _______, _______, _______, _______, _______, _______, _______ + ), + /* + * Layer _NUMPAD_LAYER + * ,-----------------------------------------------------------------------------------------. +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | 7 | 8 | 9 | | + | 7 | 8 | 9 | . | | | | +* |-----------------------------------------------------------------------------------------+ +* | | 0 | 4 | 5 | 6 | | 0 | 4 | 5 | 6 | / | | | +* |-----------------------------------------------------------------------------------------+ +* | | | 1 | 2 | 3 | , | * | 1 | 2 | 3 | - | | +* |-----------------------------------------------------------------------------------------+ +* | | | | 0 | | | | | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_NUMPAD_LAYER] = KEYMAP( /* Base */ + _______, _______, _______, _______, _______, _______, _______, _______, KC_PAST, _______, KC_PSLS, KC_PMNS, KC_PPLS, _______, + _______, _______, _______, _______, _______, _______, _______, KC_7, KC_8, KC_9, KC_COMM, _______, _______, _______, + _______, _______, _______, _______, _______, _______, KC_0, KC_4, KC_5, KC_6, KC_PDOT, _______, _______, + _______, _______, _______, _______, _______, _______, _______, KC_1, KC_2, KC_3, _______, _______, + _______, _______, _______, KC_0, _______, _______, _______, _______ + ), + /* + * Layer _MOUSE_LAYER - Mouse Layer + * ,-----------------------------------------------------------------------------------------. + * | | | | | | | | | | | | | | | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | |ACL2 |WL-U |MS-U |WL-D |ACL1 |ACL0 | | | + * |-----------------------------------------------------------------------------------------+ + * | | | ACL0 | ACL1 | ACL2 | |BTN3 |MS-L |MS-D |MS-R |BTN2 | | | + * |-----------------------------------------------------------------------------------------+ + * | | | | | | |BTN4 |BTN5 |WL-L |WL-R | | | + * |-----------------------------------------------------------------------------------------+ + * | | | | BTN1 | | | | | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_MOUSE_LAYER] = KEYMAP( /* Base */ + _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, + _______, _______, _______, _______, _______, _______, KC_WH_L, KC_WH_D, KC_WH_U, KC_WH_R, _______, _______, _______, _______, + _______, _______, KC_ACL0, KC_ACL1, KC_ACL2, _______, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, KC_BTN2, _______, _______, + _______, _______, _______, _______, _______, _______, KC_BTN3, KC_BTN4, KC_BTN5, _______, _______, _______, + _______, _______, _______, KC_BTN1, _______, _______, _______, _______ + ), +}; +const uint16_t keymaps_size = sizeof(keymaps); + + +// Declare the functions to be used with your tap dance key(s) + +// Function associated with all tap dances +uint8_t cur_dance(qk_tap_dance_state_t *state); + +// Functions associated with individual tap dances +void enableProfileColor(uint8_t * profile); +void resetProfileColor(void); +void esc_layer_finished(qk_tap_dance_state_t *state, void *user_data); +void esc_layer_reset(qk_tap_dance_state_t *state, void *user_data); + +bool is_caps_set = false; +bool is_led_on = true; +uint8_t base_profile = IDLE_PROFILE_INDEX; + +uint8_t idle_profile[] = {0x00,0x00,0x00}; +uint8_t caps_profile[] = {0xFF,0x00,0x00}; +uint8_t function_profile[] = {0x00,0xFF,0x00}; +uint8_t navigation_profile[] = {0x44,0x00,0xFF}; +uint8_t numpad_profile[] = {0xFF,0xDD,0x00}; +uint8_t mouse_profile[] = {0x00,0x88,0xFF}; + +void matrix_init_user(void) { + +} + +void matrix_scan_user(void) { +} + +void keyboard_post_init_user(void) { + annepro2LedEnable(); + resetProfileColor(); +} + +// The function to handle the caps lock logic +bool led_update_user(led_t leds) { + if (leds.caps_lock) { + is_caps_set = true; + enableProfileColor(caps_profile); + return true; + } else if(is_caps_set) { + is_caps_set = false; + resetProfileColor(); + } + + return true; +} + +layer_state_t layer_state_set_user(layer_state_t state) { + switch(get_highest_layer(state)) { + case _FUNCTION_LAYER: + enableProfileColor(function_profile); + break; + case _NUMPAD_LAYER: + enableProfileColor(numpad_profile); + break; + case _MOUSE_LAYER: + enableProfileColor(mouse_profile); + break; + case _MEDIA_AND_NAVIGATION_LAYER: + enableProfileColor(navigation_profile); + break; + default: + resetProfileColor(); + break; + } + + return state; +} + +// Determine the current tap dance state +uint8_t cur_dance(qk_tap_dance_state_t *state) { + if (state->count == 1) { + if (!state->pressed) return SINGLE_TAP; + else return SINGLE_HOLD; + } else if (state->count == 2) { + if (!state->pressed) return DOUBLE_TAP; + else return DOUBLE_HOLD; + } else if (state->count == 3) { + if (!state->pressed) return TRIPLE_TAP; + else return TRIPLE_HOLD; + } else return 8; +} + +// Initialize tap structure associated with example tap dance key +static tap esc_tap_state = { + .is_press_action = true, + .state = 0 +}; + +static tap grav_tap_state = { + .is_press_action = true, + .state = 0 +}; + +void enableProfileColor (uint8_t * profile) { + if(is_caps_set) { + annepro2LedSetForegroundColor(caps_profile[0], caps_profile[1], caps_profile[2]); + } else { + annepro2LedSetForegroundColor(profile[0], profile[1], profile[2]); + } +} + +void resetProfileColor(void) { + if(is_caps_set) { + annepro2LedSetForegroundColor(caps_profile[0], caps_profile[1], caps_profile[2]); + } else if(base_profile == IDLE_PROFILE_INDEX) { + annepro2LedSetForegroundColor(idle_profile[0], idle_profile[1], idle_profile[2]); + } else { + annepro2LedSetProfile(cyclabe_profiles[base_profile]); + } +} + +bool process_record_user(uint16_t keycode, keyrecord_t *record) { + switch (keycode) { + case NEXT_PROFILE: + if (record->event.pressed) { + base_profile++; + if(base_profile >= (sizeof(cyclabe_profiles)/sizeof(cyclabe_profiles[0]))) + base_profile = IDLE_PROFILE_INDEX; + + if(base_profile == IDLE_PROFILE_INDEX) { + annepro2LedSetForegroundColor(idle_profile[0], idle_profile[1], idle_profile[2]); + } else { + annepro2LedSetProfile(cyclabe_profiles[base_profile]); + } + } + return true; + case ENABLE_OR_DISABLE_LEDS: + if (record->event.pressed) { + if(is_led_on) { + is_led_on = false; + annepro2LedDisable(); + } else { + annepro2LedEnable(); + is_led_on = true; + } + } + return true; + default: + return true; + } +} + +// Functions that control what our tap dance key does +void esc_layer_finished(qk_tap_dance_state_t *state, void *user_data) { + esc_tap_state.state = cur_dance(state); + + switch (esc_tap_state.state) { + case SINGLE_TAP: + tap_code(KC_ESC); + break; + case SINGLE_HOLD: + layer_on(_FUNCTION_LAYER); + break; + case DOUBLE_TAP: + if (layer_state_is(_MOUSE_LAYER) || layer_state_is(_NUMPAD_LAYER)) { + layer_off(_MOUSE_LAYER); + layer_off(_NUMPAD_LAYER); + } else { + tap_code(KC_ESC); + tap_code(KC_ESC); + } + break; + case DOUBLE_HOLD: + layer_on(_NUMPAD_LAYER); + break; + case TRIPLE_TAP: + if (layer_state_is(_MOUSE_LAYER)) { + layer_off(_MOUSE_LAYER); + } else { + layer_on(_MOUSE_LAYER); + } + break; + case TRIPLE_HOLD: + layer_on(_MOUSE_LAYER); + break; + } +} + +void esc_layer_reset(qk_tap_dance_state_t *state, void *user_data) { + // If the key was held down and now is released then switch off the layer + if (esc_tap_state.state == SINGLE_HOLD) { + layer_off(_FUNCTION_LAYER); + } + if (esc_tap_state.state == DOUBLE_HOLD) { + layer_off(_NUMPAD_LAYER); + } + if (esc_tap_state.state == TRIPLE_HOLD) { + layer_off(_MOUSE_LAYER); + } + esc_tap_state.state = 0; +} + +// Functions that control what our tap dance key does +void grave_layer_finished(qk_tap_dance_state_t *state, void *user_data) { + grav_tap_state.state = cur_dance(state); + + switch (grav_tap_state.state) { + case SINGLE_TAP: + tap_code(KC_GRV); + break; + case SINGLE_HOLD: + tap_code(KC_GRV); + break; + case DOUBLE_TAP: + // Check to see if the layer is already set + if (layer_state_is(_MOUSE_LAYER)) { + // If already set, then switch it off + layer_off(_MOUSE_LAYER); + } else { + // If not already set, then switch the layer on + layer_on(_MOUSE_LAYER); + } + break; + } +} + +void grave_layer_reset(qk_tap_dance_state_t *state, void *user_data) { + // If the key was held down and now is released then switch off the layer + if (grav_tap_state.state == SINGLE_HOLD) { + layer_off(_FUNCTION_LAYER); + } + if (grav_tap_state.state == DOUBLE_HOLD) { + layer_off(_NUMPAD_LAYER); + } + grav_tap_state.state = 0; +} + +// Associate our tap dance key with its functionality +qk_tap_dance_action_t tap_dance_actions[] = { + [ESC_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(NULL, esc_layer_finished, esc_layer_reset, 250), + [GRV_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(NULL, grave_layer_finished, grave_layer_reset, 300) +}; + diff --git a/keyboards/annepro2/keymaps/thomazmoura/rules.mk b/keyboards/annepro2/keymaps/thomazmoura/rules.mk new file mode 100644 index 000000000000..32697215d61f --- /dev/null +++ b/keyboards/annepro2/keymaps/thomazmoura/rules.mk @@ -0,0 +1,47 @@ +# Anne Pro 2 +SRC = \ + matrix.c \ + hardfault_handler.c \ + annepro2_ble.c \ + qmk_ap2_led.c + +ifeq ($(strip $(ANNEPRO2_EEPROM)), yes) + OPT_DEFS += -DANNEPRO2_EEPROM + SRC += spi_master.c eeprom_w25x20cl.c +endif + +LAYOUTS += + +# MCU +MCU = cortex-m0plus +ARMV = 6 +USE_FPU = no +MCU_FAMILY = HT32 +MCU_SERIES = HT32F523x2 +MCU_LDSCRIPT = HT32F52342_ANNEPRO2 +MCU_STARTUP = ht32f523x2 + +BOARD = ANNEPRO2_C18 + +OPT_DEFS = -Wno-unused-function -fdump-rtl-dfinish -fstack-usage +#EXTRALDFLAGS = -Wl,--print-memory-usage + +# Options + +# Keys +CUSTOM_MATRIX = yes +NKRO_ENABLE = no +MOUSEKEY_ENABLE = yes +TAP_DANCE_ENABLE = yes +EXTRAKEY_ENABLE = yes +KEY_LOCK_ENABLE = no + +# Other featues +BOOTMAGIC_ENABLE = no +CONSOLE_ENABLE = no +COMMAND_ENABLE = yes +RAW_ENABLE = yes +MIDI_ENABLE = no +VIRTSER_ENABLE = no +COMBO_ENABLE = no + diff --git a/keyboards/annepro2/qmk_ap2_led.c b/keyboards/annepro2/qmk_ap2_led.c index 1a81e73f69a3..d92c13928480 100644 --- a/keyboards/annepro2/qmk_ap2_led.c +++ b/keyboards/annepro2/qmk_ap2_led.c @@ -80,3 +80,17 @@ void annepro2LedClearMask(uint8_t key) sdPut(&SD0, CMD_LED_CLEAR_MASK); sdPut(&SD0, key); } + +void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue) +{ + sdPut(&SD0, CMD_LED_SET_FOREGROUND_COLOR); + uint8_t colors[3]={red,green,blue}; + sdWrite(&SD0, (uint8_t *)&colors, sizeof(uint8_t)*3); +} + +void annepro2LedResetForegroundColor() +{ + uint8_t currentProfile = annepro2LedGetProfile(); + annepro2LedSetProfile(currentProfile); +} + diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/qmk_ap2_led.h index 4a501789dd4d..c626fc14c124 100644 --- a/keyboards/annepro2/qmk_ap2_led.h +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -13,6 +13,7 @@ #define CMD_LED_CLEAR_MASK 0xB #define CMD_LED_NEXT_INTENSITY 0xC #define CMD_LED_NEXT_ANIMATION_SPEED 0xD +#define CMD_LED_SET_FOREGROUND_COLOR 0xE void annepro2LedDisable(void); void annepro2LedEnable(void); @@ -27,3 +28,5 @@ void annepro2LedSetMask(uint8_t key); void annepro2LedClearMask(uint8_t key); void annepro2LedNextIntensity(void); void annepro2LedNextAnimationSpeed(void); +void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue); +void annepro2LedResetForegroundColor(void); From b63980e0ef187dd16d2997d317f23e13a4cd4bfe Mon Sep 17 00:00:00 2001 From: Darkhan Date: Tue, 8 Dec 2020 04:28:13 +0600 Subject: [PATCH 32/88] Implement reactive lighting effects (#18) --- keyboards/annepro2/annepro2.c | 4 ++++ keyboards/annepro2/qmk_ap2_led.c | 26 ++++++++++++++++++++++++++ keyboards/annepro2/qmk_ap2_led.h | 6 ++++++ 3 files changed, 36 insertions(+) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index cdabe35fb457..f978039459c3 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -89,6 +89,10 @@ void matrix_scan_kb() { */ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { + if (AP2_LED_ENABLED && AP2_LED_DYNAMIC_PROFILE) { + annepro2LedForwardKeypress(record->event.key.row, record->event.key.col); + } + switch (keycode) { case KC_AP2_BT1: annepro2_ble_broadcast(0); diff --git a/keyboards/annepro2/qmk_ap2_led.c b/keyboards/annepro2/qmk_ap2_led.c index d92c13928480..08a59adf6e8e 100644 --- a/keyboards/annepro2/qmk_ap2_led.c +++ b/keyboards/annepro2/qmk_ap2_led.c @@ -2,14 +2,19 @@ #include "annepro2.h" #include "qmk_ap2_led.h" +bool AP2_LED_ENABLED = false; +bool AP2_LED_DYNAMIC_PROFILE = false; + void annepro2LedDisable(void) { sdPut(&SD0, CMD_LED_OFF); + AP2_LED_ENABLED = false; } void annepro2LedEnable(void) { sdPut(&SD0, CMD_LED_ON); + AP2_LED_ENABLED = true; } void annepro2LedUpdate(uint8_t row, uint8_t col) @@ -31,6 +36,8 @@ void annepro2LedSetProfile(uint8_t prof) { sdPut(&SD0, CMD_LED_SET_PROFILE); sdPut(&SD0, prof); + uint8_t buf = sdGet(&SD0); + AP2_LED_DYNAMIC_PROFILE = buf; } uint8_t annepro2LedGetProfile() @@ -52,6 +59,8 @@ uint8_t annepro2LedGetNumProfiles() void annepro2LedNextProfile() { sdPut(&SD0, CMD_LED_NEXT_PROFILE); + uint8_t buf = sdGet(&SD0); + AP2_LED_DYNAMIC_PROFILE = buf; } void annepro2LedNextIntensity() @@ -94,3 +103,20 @@ void annepro2LedResetForegroundColor() annepro2LedSetProfile(currentProfile); } +/* + * If enabled, this data is sent to LED MCU on every keypress. + * In order to improve performance, both row and column values + * are packed into a single byte. + * Row range is [0, 4] and requires only 3 bits. + * Column range is [0, 13] and requires 4 bits. + * + * In order to differentiate this command from regular commands, + * the leftmost bit is set to 1 (0b10000000). + * Following it are 3 bits of row and 4 bits of col. + * 1 + 3 + 4 = 8 bits - only a single byte is sent for every keypress. + */ +void annepro2LedForwardKeypress(uint8_t row, uint8_t col) +{ + uint8_t msg = 0b10000000 | (row << 4) | col; + sdPut(&SD0, msg); +} diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/qmk_ap2_led.h index c626fc14c124..664944c0d47d 100644 --- a/keyboards/annepro2/qmk_ap2_led.h +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -14,6 +14,7 @@ #define CMD_LED_NEXT_INTENSITY 0xC #define CMD_LED_NEXT_ANIMATION_SPEED 0xD #define CMD_LED_SET_FOREGROUND_COLOR 0xE +#define CMD_LED_KEYPRESS 0xF void annepro2LedDisable(void); void annepro2LedEnable(void); @@ -30,3 +31,8 @@ void annepro2LedNextIntensity(void); void annepro2LedNextAnimationSpeed(void); void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue); void annepro2LedResetForegroundColor(void); +void annepro2LedForwardKeypress(uint8_t row, uint8_t col); + + +extern bool AP2_LED_ENABLED; +extern bool AP2_LED_DYNAMIC_PROFILE; From 218e35275eb2185484bbbdad4792ee0f83e7f0cb Mon Sep 17 00:00:00 2001 From: Paco <70448173+packorf@users.noreply.github.com> Date: Mon, 7 Dec 2020 23:29:19 +0100 Subject: [PATCH 33/88] Added multiarrow keymap (#19) --- .../annepro2/keymaps/multiarrow/keymap.c | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 keyboards/annepro2/keymaps/multiarrow/keymap.c diff --git a/keyboards/annepro2/keymaps/multiarrow/keymap.c b/keyboards/annepro2/keymaps/multiarrow/keymap.c new file mode 100644 index 000000000000..a71bfe92ef6c --- /dev/null +++ b/keyboards/annepro2/keymaps/multiarrow/keymap.c @@ -0,0 +1,91 @@ +#include +#include "annepro2.h" +#include "qmk_ap2_led.h" + +enum anne_pro_layers { + _BASE_LAYER, + _FN1_LAYER, + _FN2_LAYER, +}; + +/* +* Layer _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | +* |-----------------------------------------------------------------------------------------+ +* | Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | +* |-----------------------------------------------------------------------------------------+ +* | FN1 | a | s | d | f | g | h | j | k | l | ; | ' | Enter | +* |-----------------------------------------------------------------------------------------+ +* | Shift | z | x | c | v | b | n | m | , | . | / | Shift | +* |-----------------------------------------------------------------------------------------+ +* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | +* \-----------------------------------------------------------------------------------------/ +* +*/ + const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { +[_BASE_LAYER] = KEYMAP( /* Base */ + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + MO(_FN1_LAYER), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSHIFT, + KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_RCTRL +), + /* + * Layer _FN1_LAYER + * ,-----------------------------------------------------------------------------------------. + * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | + * |-----------------------------------------------------------------------------------------+ + * | Tab | HOM | UP | END | PGU | t | y | PGU | UP | PDN | PS | [ | ] | \ | + * |-----------------------------------------------------------------------------------------+ + * | FN1 |LEFT |DOWN |RIGHT| PDN | g | HOM |LEFT |DOWN |RIGHT| END | ' | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift |V-UP |V-DWN|MUTE | PAUS | NEX | n | m | , |INSRT| / | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | Enter | Alt | FN1 | FN2 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN1_LAYER] = KEYMAP( /* Base */ + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, + KC_TRNS, KC_HOME, KC_UP, KC_END, KC_PGUP, KC_TRNS, KC_TRNS, KC_PGUP, KC_UP, KC_PGDN, KC_PSCR, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, KC_TRNS, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_END, KC_TRNS, KC_TRNS, + KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, KC_MPLY, KC_MNXT, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_ENT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS +), + /* + * Layer _FN2_LAYER + * ,-----------------------------------------------------------------------------------------. + * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 | F8 |LEDOF|LEDON|LED_I |LED_S | Bksp | + * |-----------------------------------------------------------------------------------------+ + * | Tab | HOM | UP | END | PGU | t | y | u | UP | o | PS | [ | ] | \ | + * |-----------------------------------------------------------------------------------------+ + * | CAPS |LEFT |DOWN |RIGHT| PDN | g | HOM |LEFT |DOWN |RIGHT| END | ' | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift | z | x | c | v | b | n | m | , | . | / | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | Enter | Alt | FN1 | FN2 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN2_LAYER] = KEYMAP( /* Base */ + KC_TILD, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, + KC_TRNS, KC_HOME, KC_UP, KC_END, KC_PGUP, KC_TRNS, KC_TRNS, KC_PGUP, KC_UP, KC_PGDN, KC_PSCR, KC_TRNS, KC_TRNS, KC_TRNS, + KC_CAPS, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, KC_TRNS, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_END, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_ENT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS + ), +}; +const uint16_t keymaps_size = sizeof(keymaps); + + +void matrix_init_user(void) { + +} + +void matrix_scan_user(void) { +} + +layer_state_t layer_state_set_user(layer_state_t layer) { + return layer; +} From 853388d9dd5e4fd91a0400c41fe06c65ec0103a8 Mon Sep 17 00:00:00 2001 From: jmarmstrong1207 <32995055+jmarmstrong1207@users.noreply.github.com> Date: Tue, 26 Jan 2021 19:24:21 -0800 Subject: [PATCH 34/88] Add LED documentation (#26) * add LED documentation * add LED documentation to other default profiles --- .../annepro2/keymaps/default-full-caps/keymap.c | 13 +++++++++++++ .../keymaps/default-layer-indicators/keymap.c | 13 +++++++++++++ keyboards/annepro2/keymaps/default/keymap.c | 13 +++++++++++++ 3 files changed, 39 insertions(+) diff --git a/keyboards/annepro2/keymaps/default-full-caps/keymap.c b/keyboards/annepro2/keymaps/default-full-caps/keymap.c index 329c70dd4abc..4204985b53d5 100644 --- a/keyboards/annepro2/keymaps/default-full-caps/keymap.c +++ b/keyboards/annepro2/keymaps/default-full-caps/keymap.c @@ -8,6 +8,7 @@ enum anne_pro_layers { _FN2_LAYER, }; +// Key symbols are based on QMK. Use them to remap your keyboard /* * Layer _BASE_LAYER * ,-----------------------------------------------------------------------------------------. @@ -97,6 +98,18 @@ void matrix_init_user(void) { void matrix_scan_user(void) { } +// Code to run after initializing the keyboard +void keyboard_post_init_user(void) { + // Here are two common functions that you can use. For more LED functions, refer to the file "qmk_ap2_led.h" + + // annepro2-shine disables LEDs by default. Uncomment this function to enable them at startup. + // annepro2LedEnable(); + + // Additionally, it also chooses the first LED profile by default. Refer to the "profiles" array in main.c in + // annepro2-shine to see the order. Replace "i" with the index of your preferred profile. (i.e the RED profile is index 0) + // annepro2LedSetProfile(i); +} + layer_state_t layer_state_set_user(layer_state_t layer) { return layer; } diff --git a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c index b58f916b47c0..6ab7f8a5cce4 100644 --- a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c +++ b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c @@ -8,6 +8,7 @@ enum anne_pro_layers { _FN2_LAYER, }; +// Key symbols are based on QMK. Use them to remap your keyboard /* * Layer _BASE_LAYER * ,-----------------------------------------------------------------------------------------. @@ -97,6 +98,18 @@ void matrix_init_user(void) { void matrix_scan_user(void) { } +// Code to run after initializing the keyboard +void keyboard_post_init_user(void) { + // Here are two common functions that you can use. For more LED functions, refer to the file "qmk_ap2_led.h" + + // annepro2-shine disables LEDs by default. Uncomment this function to enable them at startup. + // annepro2LedEnable(); + + // Additionally, it also chooses the first LED profile by default. Refer to the "profiles" array in main.c in + // annepro2-shine to see the order. Replace "i" with the index of your preferred profile. (i.e the RED profile is index 0) + // annepro2LedSetProfile(i); +} + layer_state_t layer_state_set_user(layer_state_t layer) { switch(get_highest_layer(layer)) { case _FN1_LAYER: diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 33f81fc38fc0..5e8f778958b5 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -8,6 +8,7 @@ enum anne_pro_layers { _FN2_LAYER, }; +// Key symbols are based on QMK. Use them to remap your keyboard /* * Layer _BASE_LAYER * ,-----------------------------------------------------------------------------------------. @@ -97,6 +98,18 @@ void matrix_init_user(void) { void matrix_scan_user(void) { } +// Code to run after initializing the keyboard +void keyboard_post_init_user(void) { + // Here are two common functions that you can use. For more LED functions, refer to the file "qmk_ap2_led.h" + + // annepro2-shine disables LEDs by default. Uncomment this function to enable them at startup. + // annepro2LedEnable(); + + // Additionally, it also chooses the first LED profile by default. Refer to the "profiles" array in main.c in + // annepro2-shine to see the order. Replace "i" with the index of your preferred profile. (i.e the RED profile is index 0) + // annepro2LedSetProfile(i); +} + layer_state_t layer_state_set_user(layer_state_t layer) { return layer; } From 54de886aab6d3ced7df382217347d043c38d09c8 Mon Sep 17 00:00:00 2001 From: jmarmstrong1207 <32995055+jmarmstrong1207@users.noreply.github.com> Date: Sat, 30 Jan 2021 22:09:18 -0800 Subject: [PATCH 35/88] Implement QMK's IAP default keybind (#29) * Add keymap for going into IAP * switch to default QMK keybind for IAP mode * implement bluetooth IAP mode --- keyboards/annepro2/annepro2.c | 21 +++++++++++++++++++++ keyboards/annepro2/annepro2_ble.c | 8 ++++++++ keyboards/annepro2/annepro2_ble.h | 1 + keyboards/annepro2/c18/rules.mk | 2 +- keyboards/annepro2/qmk_ap2_led.h | 2 ++ 5 files changed, 33 insertions(+), 1 deletion(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index f978039459c3..5c2ebfc934fa 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -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(); @@ -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; } diff --git a/keyboards/annepro2/annepro2_ble.c b/keyboards/annepro2/annepro2_ble.c index 5fce1716aa72..43290fdc8cfb 100644 --- a/keyboards/annepro2/annepro2_ble.c +++ b/keyboards/annepro2/annepro2_ble.c @@ -54,6 +54,10 @@ 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; @@ -61,6 +65,10 @@ static bool lastNkroStatus = false; /* -------------------- Public Function Implementation ---------------------- */ +void annepro2_ble_bootload(void) { + sdWrite(&SD1, bleMcuBootload, 11); +} + void annepro2_ble_startup(void) { sdWrite(&SD1, bleMcuWakeup, 11); } diff --git a/keyboards/annepro2/annepro2_ble.h b/keyboards/annepro2/annepro2_ble.h index 71498890fdee..0cfb68e07163 100644 --- a/keyboards/annepro2/annepro2_ble.h +++ b/keyboards/annepro2/annepro2_ble.h @@ -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); diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 11efab064870..1bf42df7d4e3 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -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 diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/qmk_ap2_led.h index 664944c0d47d..cbb08ffa7d91 100644 --- a/keyboards/annepro2/qmk_ap2_led.h +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -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); From 83d7f9a984878fa9a1600aa0a89909233f53c70f Mon Sep 17 00:00:00 2001 From: jmarmstrong1207 <32995055+jmarmstrong1207@users.noreply.github.com> Date: Tue, 2 Feb 2021 16:13:21 -0800 Subject: [PATCH 36/88] Make default config more like Obins stock default (#30) --- keyboards/annepro2/keymaps/default-full-caps/config.h | 2 ++ keyboards/annepro2/keymaps/default-full-caps/keymap.c | 3 ++- keyboards/annepro2/keymaps/default-layer-indicators/config.h | 2 ++ keyboards/annepro2/keymaps/default-layer-indicators/keymap.c | 3 ++- keyboards/annepro2/keymaps/default/config.h | 2 ++ keyboards/annepro2/keymaps/default/keymap.c | 3 ++- 6 files changed, 12 insertions(+), 3 deletions(-) create mode 100644 keyboards/annepro2/keymaps/default-full-caps/config.h create mode 100644 keyboards/annepro2/keymaps/default-layer-indicators/config.h create mode 100644 keyboards/annepro2/keymaps/default/config.h diff --git a/keyboards/annepro2/keymaps/default-full-caps/config.h b/keyboards/annepro2/keymaps/default-full-caps/config.h new file mode 100644 index 000000000000..1840bc748496 --- /dev/null +++ b/keyboards/annepro2/keymaps/default-full-caps/config.h @@ -0,0 +1,2 @@ +// Obins stock firmware has something similar to this already enabled, but disabled by default in QMK +#define PERMISSIVE_HOLD diff --git a/keyboards/annepro2/keymaps/default-full-caps/keymap.c b/keyboards/annepro2/keymaps/default-full-caps/keymap.c index 4204985b53d5..b65a3108bf10 100644 --- a/keyboards/annepro2/keymaps/default-full-caps/keymap.c +++ b/keyboards/annepro2/keymaps/default-full-caps/keymap.c @@ -1,6 +1,7 @@ #include #include "annepro2.h" #include "qmk_ap2_led.h" +#include "config.h" enum anne_pro_layers { _BASE_LAYER, @@ -39,7 +40,7 @@ enum anne_pro_layers { [_BASE_LAYER] = KEYMAP( /* Base */ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, - KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + LT(_FN1_LAYER,KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LAYER,KC_LEFT), LT(_FN2_LAYER,KC_DOWN), RCTL_T(KC_RGHT) ), diff --git a/keyboards/annepro2/keymaps/default-layer-indicators/config.h b/keyboards/annepro2/keymaps/default-layer-indicators/config.h new file mode 100644 index 000000000000..1840bc748496 --- /dev/null +++ b/keyboards/annepro2/keymaps/default-layer-indicators/config.h @@ -0,0 +1,2 @@ +// Obins stock firmware has something similar to this already enabled, but disabled by default in QMK +#define PERMISSIVE_HOLD diff --git a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c index 6ab7f8a5cce4..4ab9fad3d93b 100644 --- a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c +++ b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c @@ -1,6 +1,7 @@ #include #include "annepro2.h" #include "qmk_ap2_led.h" +#include "config.h" enum anne_pro_layers { _BASE_LAYER, @@ -39,7 +40,7 @@ enum anne_pro_layers { [_BASE_LAYER] = KEYMAP( /* Base */ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, - KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + LT(_FN1_LAYER,KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LAYER,KC_LEFT), LT(_FN2_LAYER,KC_DOWN), RCTL_T(KC_RGHT) ), diff --git a/keyboards/annepro2/keymaps/default/config.h b/keyboards/annepro2/keymaps/default/config.h new file mode 100644 index 000000000000..1840bc748496 --- /dev/null +++ b/keyboards/annepro2/keymaps/default/config.h @@ -0,0 +1,2 @@ +// Obins stock firmware has something similar to this already enabled, but disabled by default in QMK +#define PERMISSIVE_HOLD diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 5e8f778958b5..71a969fafb0a 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -1,6 +1,7 @@ #include #include "annepro2.h" #include "qmk_ap2_led.h" +#include "config.h" enum anne_pro_layers { _BASE_LAYER, @@ -39,7 +40,7 @@ enum anne_pro_layers { [_BASE_LAYER] = KEYMAP( /* Base */ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, - KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + LT(_FN1_LAYER,KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LAYER,KC_LEFT), LT(_FN2_LAYER,KC_DOWN), RCTL_T(KC_RGHT) ), From 365eb5c4c2b972d2a1de02eb9cc11edf24793e64 Mon Sep 17 00:00:00 2001 From: Darkhan Date: Wed, 3 Feb 2021 00:14:06 +0000 Subject: [PATCH 37/88] Add new message type for resetting foreground color (#31) --- keyboards/annepro2/annepro2.c | 2 +- keyboards/annepro2/qmk_ap2_led.c | 12 +++++++++--- keyboards/annepro2/qmk_ap2_led.h | 4 +++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 5c2ebfc934fa..f9f90ac58ec7 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -109,7 +109,7 @@ void matrix_scan_kb() { */ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { - if (AP2_LED_ENABLED && AP2_LED_DYNAMIC_PROFILE) { + if (AP2_LED_ENABLED && AP2_LED_DYNAMIC_PROFILE && !AP2_FOREGROUND_COLOR_SET) { annepro2LedForwardKeypress(record->event.key.row, record->event.key.col); } diff --git a/keyboards/annepro2/qmk_ap2_led.c b/keyboards/annepro2/qmk_ap2_led.c index 08a59adf6e8e..5f7e9fcf83d5 100644 --- a/keyboards/annepro2/qmk_ap2_led.c +++ b/keyboards/annepro2/qmk_ap2_led.c @@ -4,6 +4,7 @@ bool AP2_LED_ENABLED = false; bool AP2_LED_DYNAMIC_PROFILE = false; +bool AP2_FOREGROUND_COLOR_SET = false; void annepro2LedDisable(void) { @@ -76,6 +77,8 @@ void annepro2LedNextAnimationSpeed() void annepro2LedPrevProfile() { sdPut(&SD0, CMD_LED_PREV_PROFILE); + uint8_t buf = sdGet(&SD0); + AP2_LED_DYNAMIC_PROFILE = buf; } void annepro2LedSetMask(uint8_t key) @@ -94,13 +97,16 @@ void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue) { sdPut(&SD0, CMD_LED_SET_FOREGROUND_COLOR); uint8_t colors[3]={red,green,blue}; - sdWrite(&SD0, (uint8_t *)&colors, sizeof(uint8_t)*3); + sdWrite(&SD0, (uint8_t *)&colors, sizeof(colors)); + AP2_FOREGROUND_COLOR_SET = true; } void annepro2LedResetForegroundColor() { - uint8_t currentProfile = annepro2LedGetProfile(); - annepro2LedSetProfile(currentProfile); + sdPut(&SD0, CMD_LED_CLEAR_FOREGROUND_COLOR); + uint8_t buf = sdGet(&SD0); + AP2_LED_DYNAMIC_PROFILE = buf; + AP2_FOREGROUND_COLOR_SET = false; } /* diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/qmk_ap2_led.h index cbb08ffa7d91..d4658119afdf 100644 --- a/keyboards/annepro2/qmk_ap2_led.h +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -14,8 +14,9 @@ #define CMD_LED_NEXT_INTENSITY 0xC #define CMD_LED_NEXT_ANIMATION_SPEED 0xD #define CMD_LED_SET_FOREGROUND_COLOR 0xE -#define CMD_LED_KEYPRESS 0xF +#define CMD_LED_CLEAR_FOREGROUND_COLOR 0xF #define CMD_LED_IAP 0x10 +#define CMD_LED_KEYPRESS 0x11 void annepro2SetIAP(void); void annepro2LedDisable(void); @@ -38,3 +39,4 @@ void annepro2LedForwardKeypress(uint8_t row, uint8_t col); extern bool AP2_LED_ENABLED; extern bool AP2_LED_DYNAMIC_PROFILE; +extern bool AP2_FOREGROUND_COLOR_SET; From 1637c81d9c17b524844e0b1823f89daec4c16d4c Mon Sep 17 00:00:00 2001 From: 1Conan <7620342+1Conan@users.noreply.github.com> Date: Thu, 15 Jul 2021 21:12:33 +0800 Subject: [PATCH 38/88] annepro2(bluetooth): add media keys support (#41) --- keyboards/annepro2/annepro2_ble.c | 38 ++++++++++++++++++++++++++----- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/keyboards/annepro2/annepro2_ble.c b/keyboards/annepro2/annepro2_ble.c index 43290fdc8cfb..6c19f9b4a158 100644 --- a/keyboards/annepro2/annepro2_ble.c +++ b/keyboards/annepro2/annepro2_ble.c @@ -19,6 +19,7 @@ #include "hal.h" #include "host.h" #include "host_driver.h" +#include "report.h" /* -------------------- Static Function Prototypes -------------------------- */ static uint8_t ap2_ble_leds(void); @@ -39,19 +40,27 @@ static host_driver_t ap2_ble_driver = { }; static uint8_t bleMcuWakeup[11] = { - 0x7b, 0x10, 0x53, 0x10, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02 + 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02 }; + static uint8_t bleMcuStartBroadcast[11] = { - 0x7b, 0x10, 0x53, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x01, 0x00 // Broadcast ID[0-3] + 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x01, 0x00 // Broadcast ID[0-3] }; + static uint8_t bleMcuConnect[11] = { - 0x7b, 0x10, 0x53, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x04, 0x00 // Connect ID [0-3] + 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x04, 0x00 // Connect ID [0-3] }; + static uint8_t bleMcuSendReport[10] = { - 0x7b, 0x10, 0x53, 0x10, 0x0A, 0x00, 0x00, 0x7d, 0x10, 0x04, + 0x7b, 0x12, 0x53, 0x00, 0x0A, 0x00, 0x00, 0x7d, 0x10, 0x04, }; + +static uint8_t bleMcuSendConsumerReport[10] = { + 0x7b, 0x12, 0x53, 0x00, 0x06, 0x00, 0x00, 0x7d, 0x10, 0x08, +}; + static uint8_t bleMcuUnpair[10] = { - 0x7b, 0x10, 0x53, 0x10, 0x02, 0x00, 0x00, 0x7d, 0x40, 0x05, + 0x7b, 0x12, 0x53, 0x00, 0x02, 0x00, 0x00, 0x7d, 0x40, 0x05, }; static uint8_t bleMcuBootload[11] = { @@ -138,8 +147,25 @@ static void ap2_ble_mouse(report_mouse_t *report){ static void ap2_ble_system(uint16_t data) { } -static void ap2_ble_consumer(uint16_t data) { + +static inline uint16_t CONSUMER2AP2(uint16_t usage) { + switch(usage) { + case AUDIO_VOL_DOWN: return 0x04; + case AUDIO_VOL_UP: return 0x02; + case AUDIO_MUTE: return 0x01; + case TRANSPORT_PLAY_PAUSE: return 0x08; + case TRANSPORT_NEXT_TRACK: return 0x10; + case TRANSPORT_PREV_TRACK: return 0x20; + default: return 0x00; + } +} + +static void ap2_ble_consumer(uint16_t data) { + sdPut(&SD1, 0x0); + sdWrite(&SD1, bleMcuSendConsumerReport, 10); + sdPut(&SD1, CONSUMER2AP2(data)); + sdWrite(&SD1, 0x0, 3); } /*! From f771cb545f5e86f41b39babf675bbbcfed85f860 Mon Sep 17 00:00:00 2001 From: Tomasz bla Fortuna Date: Thu, 15 Jul 2021 17:56:22 +0200 Subject: [PATCH 39/88] Asynchronous, robust serial protocol. (#39) * bla personal ap2-c18 keymap. * Bidirectional, asynchronous message-based communication with Shine. - Requires a matching Shine version. - Protocol is resiliant to loosing bytes during communication, chips won't lock waiting for bytes that aren't coming. - Chips resynchronize in event of loosing a byte using a AA0D header. Regressions: - Key masking/locking doesn't work right now. (did it work before?) - Not all user keymaps build against it. * Clang-format + code to ease reducing speed of LED UART. - Did clang-format --style=file -i on multiple files according to coding_conventions_c.md - Added separate serial speed for IAP boot and Led communication, it's possible that reducing this to 9600 helped someone with faulty HW. With this code they can do it with simple replacing of a value. * Main chip can set/clear foreground using a mask mechanism. - Some preparations for selective colouring. * Selective mask works - tested on capslock. - Migrated personal keymaps to new status API. * Clear the foreground colors to show profile when it's modified. - Show example of achieving selective caps-lock painting + foreground painting for layers. - annepro2LedMaskSetRow is implemented, but still requires testing. * Implement the QMK side of led blinking to indicate the command was received. - This stupidly blinks the key when user presses one of the bluetooth commands to let the user know that the command was received and forwarded to the BT chip. - TODO: Row/col key positions are hardcoded and not taken from the keymap. * Reduce memory footprint. Applying code review suggestions. Moved msgId to globals - preparing for transmission without copying payload when no retries are necessary. Added empty readme.md files - required by QMK lint. Co-authored-by: Tomasz bla Fortuna --- keyboards/annepro2/annepro2.c | 95 ++++++---- keyboards/annepro2/annepro2.h | 4 +- keyboards/annepro2/c15/readme.md | 1 + keyboards/annepro2/c15/rules.mk | 3 +- keyboards/annepro2/c18/config.h | 3 +- keyboards/annepro2/c18/readme.md | 1 + keyboards/annepro2/c18/rules.mk | 3 +- keyboards/annepro2/keymaps/bla/config.h | 2 + keyboards/annepro2/keymaps/bla/keymap.c | 157 +++++++++++++++++ .../keymaps/default-layer-indicators/keymap.c | 25 ++- keyboards/annepro2/keymaps/tech2077/keymap.c | 7 +- .../annepro2/keymaps/thomazmoura/rules.mk | 4 +- keyboards/annepro2/matrix.c | 24 ++- keyboards/annepro2/protocol.c | 118 +++++++++++++ keyboards/annepro2/protocol.h | 115 ++++++++++++ keyboards/annepro2/qmk_ap2_led.c | 166 ++++++++---------- keyboards/annepro2/qmk_ap2_led.h | 80 ++++++--- 17 files changed, 622 insertions(+), 186 deletions(-) create mode 100644 keyboards/annepro2/c15/readme.md create mode 100644 keyboards/annepro2/c18/readme.md create mode 100644 keyboards/annepro2/keymaps/bla/config.h create mode 100644 keyboards/annepro2/keymaps/bla/keymap.c create mode 100644 keyboards/annepro2/protocol.c create mode 100644 keyboards/annepro2/protocol.h diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index f9f90ac58ec7..acfab3e07fc1 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -4,35 +4,31 @@ #include "annepro2_ble.h" #include "spi_master.h" #include "qmk_ap2_led.h" +#include "protocol.h" -static const SerialConfig ledUartConfig = { - .speed = 115200, +static const SerialConfig ledUartInitConfig = { + .speed = 115200, }; -static const SerialConfig bleUartConfig = { - .speed = 115200, +/* + * Some people have serial issues between main chip and led chip. + * This code allows them to easily reduce the speed to 9600 for testing + */ +static const SerialConfig ledUartRuntimeConfig = { + .speed = 115200, }; -static uint8_t ledMcuWakeup[11] = { - 0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02 +static const SerialConfig bleUartConfig = { + .speed = 115200, }; -static bool ledEnabled = false; +static uint8_t ledMcuWakeup[11] = {0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02}; ble_capslock_t BLECapsLock = {._dummy = {0}, .caps_lock = false}; -uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS] = { - 0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 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); + annepro2SetIAP(); // wait for shine to boot into IAP wait_ms(15); @@ -42,7 +38,7 @@ void OVERRIDE bootloader_jump(void) { wait_ms(15); // Magic key to set keyboard to IAP - *((uint32_t*)0x20001ffc) = 0x0000fab2; + *((uint32_t *)0x20001ffc) = 0x0000fab2; // Load the main MCU into IAP __disable_irq(); @@ -53,20 +49,21 @@ void OVERRIDE keyboard_pre_init_kb(void) { #if HAL_USE_SPI == TRUE spi_init(); #endif -} - -void OVERRIDE keyboard_post_init_kb(void) { // Start LED UART - sdStart(&SD0, &ledUartConfig); + sdStart(&SD0, &ledUartInitConfig); sdWrite(&SD0, ledMcuWakeup, 11); - // wait to receive response from wakeup wait_ms(15); + protoInit(&proto, ledCommandCallback); + // loop to clear out receive buffer from shine wakeup - while(!sdGetWouldBlock(&SD0)) - sdGet(&SD0); + while (!sdGetWouldBlock(&SD0)) sdGet(&SD0); + + sdStart(&SD0, &ledUartRuntimeConfig); +} +void OVERRIDE keyboard_post_init_kb(void) { // Start BLE UART sdStart(&SD1, &bleUartConfig); annepro2_ble_startup(); @@ -76,30 +73,34 @@ void OVERRIDE keyboard_post_init_kb(void) { wait_ms(15); // loop to clear out receive buffer from ble wakeup - while(!sdGetWouldBlock(&SD1)) - sdGet(&SD1); + while (!sdGetWouldBlock(&SD1)) sdGet(&SD1); + + annepro2LedGetStatus(); keyboard_post_init_user(); } -void OVERRIDE matrix_init_kb(void) { - matrix_init_user(); -} +void OVERRIDE matrix_init_kb(void) { matrix_init_user(); } void matrix_scan_kb() { // if there's stuff on the ble serial buffer // read it into the capslock struct - while(!sdGetWouldBlock(&SD1)) { - sdReadTimeout(&SD1, (uint8_t *) &BLECapsLock, sizeof(ble_capslock_t), 10); + while (!sdGetWouldBlock(&SD1)) { + sdReadTimeout(&SD1, (uint8_t *)&BLECapsLock, sizeof(ble_capslock_t), 10); // if it's capslock from ble, darken led if (BLECapsLock.caps_lock) { - annepro2LedClearMask(MATRIX_COLS * 2); + // annepro2LedClearMask(MATRIX_COLS * 2); } else { - annepro2LedSetMask(MATRIX_COLS * 2); + // annepro2LedSetMask(MATRIX_COLS * 2); } } + /* While there's data from LED keyboard sent - read it. */ + while (!sdGetWouldBlock(&SD0)) { + uint8_t byte = sdGet(&SD0); + protoConsume(&proto, byte); + } matrix_scan_user(); } @@ -109,25 +110,37 @@ void matrix_scan_kb() { */ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { - if (AP2_LED_ENABLED && AP2_LED_DYNAMIC_PROFILE && !AP2_FOREGROUND_COLOR_SET) { + if (annepro2LedStatus.matrixEnabled && annepro2LedStatus.isReactive) { annepro2LedForwardKeypress(record->event.key.row, record->event.key.col); } + const annepro2Led_t blue = { + .p.blue = 0xff, + .p.red = 0x00, + .p.green = 0x00, + .p.alpha = 0xff, + }; + switch (keycode) { case KC_AP2_BT1: annepro2_ble_broadcast(0); + /* FIXME: This hardcodes col/row position */ + annepro2LedBlink(0, 1, blue, 8, 50); return false; case KC_AP2_BT2: annepro2_ble_broadcast(1); + annepro2LedBlink(0, 2, blue, 8, 50); return false; case KC_AP2_BT3: annepro2_ble_broadcast(2); + annepro2LedBlink(0, 3, blue, 8, 50); return false; case KC_AP2_BT4: annepro2_ble_broadcast(3); + annepro2LedBlink(0, 4, blue, 8, 50); return false; case KC_AP2_USB: @@ -140,31 +153,35 @@ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { case KC_AP_LED_OFF: annepro2LedDisable(); - ledEnabled = false; break; case KC_AP_LED_ON: - if (ledEnabled) { + if (annepro2LedStatus.matrixEnabled) { annepro2LedNextProfile(); } else { - ledEnabled = true; annepro2LedEnable(); } + annepro2LedResetForegroundColor(); break; case KC_AP_LED_NEXT_PROFILE: annepro2LedNextProfile(); + annepro2LedResetForegroundColor(); break; case KC_AP_LED_PREV_PROFILE: annepro2LedPrevProfile(); + annepro2LedResetForegroundColor(); break; case KC_AP_LED_NEXT_INTENSITY: annepro2LedNextIntensity(); + annepro2LedResetForegroundColor(); return false; + case KC_AP_LED_SPEED: annepro2LedNextAnimationSpeed(); + annepro2LedResetForegroundColor(); return false; default: @@ -172,4 +189,4 @@ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { } } return process_record_user(keycode, record); -} +} \ No newline at end of file diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index a7383c759788..a6c984d75d4c 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -18,11 +18,11 @@ #pragma once #include "quantum.h" -#define OVERRIDE __attribute__ ((noinline)) +#define OVERRIDE __attribute__((noinline)) typedef struct __attribute__((__packed__)) { uint8_t _dummy[10]; - bool caps_lock; + bool caps_lock; } ble_capslock_t; extern uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS]; diff --git a/keyboards/annepro2/c15/readme.md b/keyboards/annepro2/c15/readme.md new file mode 100644 index 000000000000..5fadb7390951 --- /dev/null +++ b/keyboards/annepro2/c15/readme.md @@ -0,0 +1 @@ +AnnePro2, ANSI C15 version. diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index cbef25300e5c..e50ee99516b7 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -3,7 +3,8 @@ SRC = \ matrix.c \ hardfault_handler.c \ annepro2_ble.c \ - qmk_ap2_led.c + qmk_ap2_led.c \ + protocol.c LAYOUTS += diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h index f47d622229bf..726e4a3995e0 100644 --- a/keyboards/annepro2/c18/config.h +++ b/keyboards/annepro2/c18/config.h @@ -184,7 +184,7 @@ // #define NO_DEBUG /* disable print */ -// #define NO_PRINTg +// #define NO_PRINT /* disable action features */ //#define NO_ACTION_LAYER @@ -192,4 +192,3 @@ //#define NO_ACTION_ONESHOT //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION - diff --git a/keyboards/annepro2/c18/readme.md b/keyboards/annepro2/c18/readme.md new file mode 100644 index 000000000000..f2e2fc45b8f2 --- /dev/null +++ b/keyboards/annepro2/c18/readme.md @@ -0,0 +1 @@ +AnnePro2, ANSI C18 version. diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 1bf42df7d4e3..c63a90ace46c 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -3,7 +3,8 @@ SRC = \ matrix.c \ hardfault_handler.c \ annepro2_ble.c \ - qmk_ap2_led.c + qmk_ap2_led.c \ + protocol.c ifeq ($(strip $(ANNEPRO2_EEPROM)), yes) OPT_DEFS += -DANNEPRO2_EEPROM diff --git a/keyboards/annepro2/keymaps/bla/config.h b/keyboards/annepro2/keymaps/bla/config.h new file mode 100644 index 000000000000..1840bc748496 --- /dev/null +++ b/keyboards/annepro2/keymaps/bla/config.h @@ -0,0 +1,2 @@ +// Obins stock firmware has something similar to this already enabled, but disabled by default in QMK +#define PERMISSIVE_HOLD diff --git a/keyboards/annepro2/keymaps/bla/keymap.c b/keyboards/annepro2/keymaps/bla/keymap.c new file mode 100644 index 000000000000..c0af30ff56bc --- /dev/null +++ b/keyboards/annepro2/keymaps/bla/keymap.c @@ -0,0 +1,157 @@ +#include +#include "annepro2.h" +#include "qmk_ap2_led.h" +#include "config.h" + +enum anne_pro_layers { + _BASE_LAYER, + _FN1_LY, + _FN2_LY, +}; + +// Key symbols are based on QMK. Use them to remap your keyboard +/* +* Layer _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | +* |-----------------------------------------------------------------------------------------+ +* | Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | +* |-----------------------------------------------------------------------------------------+ +* | Ctrl/Bks| a | s | d | f | g | h | j | k | l | ; | ' | Enter | +* |-----------------------------------------------------------------------------------------+ +* | Shift | z | x | c | v | b | n | m | , | . | / | Shift | +* |-----------------------------------------------------------------------------------------+ +* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | +* \-----------------------------------------------------------------------------------------/ +* Layer TAP in _BASE_LAYER +* ,-----------------------------------------------------------------------------------------. +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | Bksp | | | | | | | | | | | | | +* |-----------------------------------------------------------------------------------------+ +* | | | | | | | | | | | | UP | +* |-----------------------------------------------------------------------------------------+ +* | | `~ | | | | LEFT | DOWN | RIGHT | +* \-----------------------------------------------------------------------------------------/ +*/ + const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { + [_BASE_LAYER] = KEYMAP( /* Base */ + KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, + KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, + MT(MOD_LCTL, KC_ESC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, + KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), + KC_LCTL, MT(MOD_LGUI, KC_GRV), KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LY,KC_LEFT), LT(_FN2_LY,KC_DOWN), RCTL_T(KC_RGHT) +), + /* + * Layer _FN1_LY + * ,-----------------------------------------------------------------------------------------. + * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | MEDIA PLAY| + * |-----------------------------------------------------------------------------------------+ + * | Tab | q | UP | e | 7 | 8 | 9 | u | i | o | PS | HOME | END | \ | + * |-----------------------------------------------------------------------------------------+ + * | |LEFT |DOWN |RIGHT| 4 | 5 | 6 | j | k | l | PGUP|PGDN | Enter | + * |-----------------------------------------------------------------------------------------+ + * | LayerHold? |V-UP |V-DWN|MUTE | 1 | 2 | 3 | m | , |INSRT| DEL | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | 0 | Alt | FN1 | FN2 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN1_LY] = KEYMAP( /* Base */ + KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_MEDIA_PLAY_PAUSE, + KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_7, KC_8, KC_9, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + MO(_FN2_LY), KC_LEFT, KC_DOWN, KC_RGHT, KC_4, KC_5, KC_6, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_1, KC_2, KC_3, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_0, KC_TRNS, KC_TRNS, MO(_FN2_LY), KC_TRNS +), + /* + * Layer _FN2_LY + * ,-----------------------------------------------------------------------------------------. + * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | MEDIA PLAY| + * |-----------------------------------------------------------------------------------------+ + * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | + * |-----------------------------------------------------------------------------------------+ + * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | + * |-----------------------------------------------------------------------------------------+ + * | Shift | z | x | c | v | b | n | m | , |INSRT| DEL | Shift | + * |-----------------------------------------------------------------------------------------+ + * | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | + * \-----------------------------------------------------------------------------------------/ + * + */ + [_FN2_LY] = KEYMAP( /* Base */ + KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_MEDIA_PLAY_PAUSE, + MO(_FN2_LY), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, + KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, + KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LY), MO(_FN2_LY), KC_TRNS + ), +}; +const uint16_t keymaps_size = sizeof(keymaps); + + +void matrix_init_user(void) { +} + +void matrix_scan_user(void) { +} + +// Code to run after initializing the keyboard +void keyboard_post_init_user(void) { + // Here are two common functions that you can use. For more LED functions, refer to the file "qmk_ap2_led.h" + + // annepro2-shine disables LEDs by default. Uncomment this function to enable them at startup. + // annepro2LedEnable(); + + // Additionally, it also chooses the first LED profile by default. Refer to the "profiles" array in main.c in + // annepro2-shine to see the order. Replace "i" with the index of your preferred profile. (i.e the RED profile is index 0) + // annepro2LedSetProfile(i); + debug_enable=true; +} + +layer_state_t layer_state_set_user(layer_state_t layer) { + switch(get_highest_layer(layer)) { + case _FN1_LY: + // Set the leds to green + annepro2LedSetForegroundColor(0x00, 0xFF, 0x00); + break; + case _FN2_LY: + // Set the leds to blue + annepro2LedSetForegroundColor(0x00, 0x00, 0xFF); + break; + default: + // Reset back to the current profile + annepro2LedResetForegroundColor(); + break; + } + return layer; +} + +// The function to handle the caps lock logic. It's executed after caps or layer +// changes state, after layer_state_set_user. +bool led_update_user(led_t leds) { + if (leds.caps_lock) { + const annepro2Led_t color = { + .p.red = 0xff, + .p.green = 0x00, + .p.blue = 0x00, + .p.alpha = 0xff + }; + + annepro2LedMaskSetKey(2, 0, color); + return true; + } + + if(!layer_state_is(_FN1_LY) && !layer_state_is(_FN2_LY)) { + const annepro2Led_t color = { + .p.red = 0xff, + .p.green = 0x00, + .p.blue = 0x00, + .p.alpha = 0x00 + }; + annepro2LedMaskSetKey(2, 0, color); + } + return true; +} diff --git a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c index 4ab9fad3d93b..6cabda933006 100644 --- a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c +++ b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c @@ -130,17 +130,32 @@ layer_state_t layer_state_set_user(layer_state_t layer) { } // The function to handle the caps lock logic +// It's called after the capslock changes state or after entering layers 1 and 2. bool led_update_user(led_t leds) { if (leds.caps_lock) { - // Set the leds to red - annepro2LedSetForegroundColor(0xFF, 0x00, 0x00); + // Set the caps-lock to red + const annepro2Led_t color = { + .p.red = 0xff, + .p.green = 0x00, + .p.blue = 0x00, + .p.alpha = 0xff + }; + + annepro2LedMaskSetKey(2, 0, color); + /* NOTE: Instead of colouring the capslock only, you can change the whole + keyboard with annepro2LedSetForegroundColor */ } else { - // Reset back to the current profile if there is no layer active + // Reset the capslock if there is no layer active if(!layer_state_is(_FN1_LAYER) && !layer_state_is(_FN2_LAYER)) { - annepro2LedResetForegroundColor(); + const annepro2Led_t color = { + .p.red = 0xff, + .p.green = 0x00, + .p.blue = 0x00, + .p.alpha = 0x00 + }; + annepro2LedMaskSetKey(2, 0, color); } } return true; } - diff --git a/keyboards/annepro2/keymaps/tech2077/keymap.c b/keyboards/annepro2/keymaps/tech2077/keymap.c index 28d76edab02f..f35555c897c7 100644 --- a/keyboards/annepro2/keymaps/tech2077/keymap.c +++ b/keyboards/annepro2/keymaps/tech2077/keymap.c @@ -21,9 +21,6 @@ typedef union { // define out default user_config user_config_t user_config = {.magic = 0xDE, .leds_on = 0, .leds_profile = 0}; -// keep the number of profiles so we can track along with the shine proc -uint8_t numProfiles = 0; - static uint8_t usb_buf[256]; static uint8_t buf_fil = 0; @@ -165,7 +162,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t* record) return false; case KC_AP_LED_NEXT_PROFILE: if (record->event.pressed) { - user_config.leds_profile = (user_config.leds_profile + 1) % numProfiles; + user_config.leds_profile = (user_config.leds_profile + 1) % annepro2LedStatus.amountOfProfiles; annepro2LedSetProfile(user_config.leds_profile); eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); } @@ -206,6 +203,4 @@ void keyboard_post_init_user(void) annepro2LedDisable(); } #endif - - numProfiles = annepro2LedGetNumProfiles(); } diff --git a/keyboards/annepro2/keymaps/thomazmoura/rules.mk b/keyboards/annepro2/keymaps/thomazmoura/rules.mk index 32697215d61f..2b6ec483cca1 100644 --- a/keyboards/annepro2/keymaps/thomazmoura/rules.mk +++ b/keyboards/annepro2/keymaps/thomazmoura/rules.mk @@ -3,7 +3,8 @@ SRC = \ matrix.c \ hardfault_handler.c \ annepro2_ble.c \ - qmk_ap2_led.c + qmk_ap2_led.c \ + protocol.c ifeq ($(strip $(ANNEPRO2_EEPROM)), yes) OPT_DEFS += -DANNEPRO2_EEPROM @@ -44,4 +45,3 @@ RAW_ENABLE = yes MIDI_ENABLE = no VIRTSER_ENABLE = no COMBO_ENABLE = no - diff --git a/keyboards/annepro2/matrix.c b/keyboards/annepro2/matrix.c index 5e9f2895fbc8..a723e523a738 100644 --- a/keyboards/annepro2/matrix.c +++ b/keyboards/annepro2/matrix.c @@ -27,7 +27,7 @@ static matrix_row_t matrix[MATRIX_ROWS]; static matrix_row_t matrix_debouncing[MATRIX_ROWS]; -static uint32_t debounce_times[MATRIX_ROWS]; +static uint32_t debounce_times[MATRIX_ROWS]; extern ioline_t row_list[MATRIX_ROWS]; extern ioline_t col_list[MATRIX_COLS]; @@ -45,7 +45,10 @@ uint8_t matrix_scan(void) { // scan each row for (int row = 0; row < MATRIX_ROWS; row++) { palClearLine(row_list[row]); - __NOP(); __NOP(); __NOP(); __NOP(); + __NOP(); + __NOP(); + __NOP(); + __NOP(); // read i/o ports port_cache[0] = palReadPort(IOPORTA); port_cache[1] = palReadPort(IOPORTB); @@ -67,10 +70,10 @@ uint8_t matrix_scan(void) { if (matrix_debouncing[row] != data) { // whenever row changes restart debouncing matrix_debouncing[row] = data; - debounce_times[row] = timer_read32(); - } else if(debounce_times[row] && timer_elapsed32(debounce_times[row]) >= DEBOUNCE){ + debounce_times[row] = timer_read32(); + } else if (debounce_times[row] && timer_elapsed32(debounce_times[row]) >= DEBOUNCE) { // when debouncing complete, update matrix - matrix[row] = matrix_debouncing[row]; + matrix[row] = matrix_debouncing[row]; debounce_times[row] = 0; } } @@ -79,13 +82,8 @@ uint8_t matrix_scan(void) { return 1; } -bool matrix_is_on(uint8_t row, uint8_t col) { - return (matrix[row] & (1 << col)); -} +bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & (1 << col)); } -matrix_row_t matrix_get_row(uint8_t row) { - return matrix[row]; -} +matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; } -void matrix_print(void) { -} +void matrix_print(void) {} diff --git a/keyboards/annepro2/protocol.c b/keyboards/annepro2/protocol.c new file mode 100644 index 000000000000..ff2f328e4c9f --- /dev/null +++ b/keyboards/annepro2/protocol.c @@ -0,0 +1,118 @@ +/* + * (c) 2021 by Tomasz bla Fortuna + * License: GPLv2 + * + * This file is shared with the Shine firmware. Keep it in sync (and in the + * shine's clang formatting). + * + * Implementation of a robust serial protocol which can handle single dropped + * characters during transit without locking. + * + * At 115200, transmitting the shortest message takes 0.043ms, at 9600 - 0.52ms. + * + */ + +#include "protocol.h" +#include "board.h" +#include "ch.h" +#include "hal.h" + +/* UART communication protocol state */ +protocol_t proto; + +void protoInit(protocol_t *proto, void (*callback)(const message_t *)) { + proto->previousId = 0; + proto->callback = callback; + proto->state = STATE_SYNC_1; + proto->errors = 0; +} + +static uint8_t msgId = 0; +void protoTx(uint8_t cmd, const unsigned char *buf, int payloadSize, + int retries) { + chDbgCheck(payloadSize <= MAX_PAYLOAD_SIZE); + + const uint8_t header[5] = { + 0x7A, 0x1D, cmd, ++msgId, payloadSize, + }; + + /* We don't implement ACKs, yet some messages should not be lost. */ + for (int i = 0; i < retries; i++) { + sdWrite(&PROTOCOL_SD, header, sizeof(header)); + if (payloadSize) + sdWrite(&PROTOCOL_SD, buf, payloadSize); + } +} + +static inline void messageReceived(protocol_t *proto) { + if (proto->buffer.msgId != proto->previousId) { + /* It's not a resend / duplicate */ + proto->callback(&proto->buffer); + proto->previousId = proto->buffer.msgId; + } + proto->state = STATE_SYNC_1; +} + +void protoConsume(protocol_t *proto, uint8_t byte) { + switch (proto->state) { + case STATE_SYNC_1: + if (byte == 0x7A) { + proto->state = STATE_SYNC_2; + } else { + proto->errors++; + } + return; + + case STATE_SYNC_2: + if (byte == 0x1D) { + proto->state = STATE_CMD; + } else { + proto->state = STATE_SYNC_1; + proto->errors++; + } + return; + + case STATE_CMD: + proto->buffer.command = byte; + proto->state = STATE_ID; + return; + + case STATE_ID: + proto->buffer.msgId = byte; + proto->state = STATE_PAYLOAD_SIZE; + return; + + case STATE_PAYLOAD_SIZE: + proto->buffer.payloadSize = byte; + if (proto->buffer.payloadSize > MAX_PAYLOAD_SIZE) { + proto->buffer.payloadSize = MAX_PAYLOAD_SIZE; + proto->errors++; + } + proto->payloadPosition = 0; + if (proto->buffer.payloadSize == 0) { + /* No payload - whole message received */ + messageReceived(proto); + } else { + proto->state = STATE_PAYLOAD; + } + return; + + case STATE_PAYLOAD: + /* NOTE: This could be read with sdReadTimeout probably, but that breaks + * abstraction */ + proto->buffer.payload[proto->payloadPosition] = byte; + proto->payloadPosition++; + if (proto->payloadPosition == proto->buffer.payloadSize) { + /* Payload read - message received */ + messageReceived(proto); + } + return; + } +} + +void protoSilence(protocol_t *proto) { + if (proto->state != STATE_SYNC_1) { + proto->state = STATE_SYNC_1; + proto->errors++; + } +} diff --git a/keyboards/annepro2/protocol.h b/keyboards/annepro2/protocol.h new file mode 100644 index 000000000000..9effea44d618 --- /dev/null +++ b/keyboards/annepro2/protocol.h @@ -0,0 +1,115 @@ +/* + * (c) 2021 by Tomasz bla Fortuna + * License: GPLv2 + * + * This file is shared with the Shine firmware. Keep it in sync (and in the + * shine's clang formatting). + */ + +#ifndef PROTOCOL_INCLUDED +#define PROTOCOL_INCLUDED +#include + +#define PROTOCOL_SD SD0 + +enum { + /* + * Main -> LED + */ + /* Basic config */ + CMD_LED_ON = 0x01, + CMD_LED_OFF = 0x02, + + CMD_LED_SET_PROFILE = 0x03, + CMD_LED_NEXT_PROFILE = 0x04, + CMD_LED_PREV_PROFILE = 0x05, + + CMD_LED_NEXT_INTENSITY = 0x06, + CMD_LED_NEXT_ANIMATION_SPEED = 0x07, + + /* Masks */ + /* Override a key color, eg. capslock */ + CMD_LED_MASK_SET_KEY = 0x10, + /* Override all keys in a row with configurable colors */ + CMD_LED_MASK_SET_ROW = 0x11, + + /* Override all keys with single color (eg. foreground color) */ + CMD_LED_MASK_SET_MONO = 0x12, + + /* Reactive / status */ + CMD_LED_GET_STATUS = 0x20, + CMD_LED_KEY_BLINK = 0x21, + CMD_LED_KEY_DOWN = 0x22, + CMD_LED_KEY_UP = 0x23, /* TODO */ + CMD_LED_IAP = 0x24, + + /* LED -> Main */ + /* Payload with data to send over HID */ + CMD_LED_DEBUG = 0x40, + + /* Number of profiles, current profile, on/off state, + reactive flag, brightness, errors */ + CMD_LED_STATUS = 0x41, +}; + +/* 1 ROW * 14 COLS * 4B (RGBX) = 56 + header prefix. */ +#define MAX_PAYLOAD_SIZE 64 + +/** Enum of the states used for the serial protocol finite-state automaton */ +enum protoState { + /* 2-byte initial start-of-message sync */ + STATE_SYNC_1, + STATE_SYNC_2, + /* Waiting for command byte */ + STATE_CMD, + /* Waiting for ID byte */ + STATE_ID, + /* Waiting for payload size */ + STATE_PAYLOAD_SIZE, + /* Reading payload until payloadPosition == payloadSize */ + STATE_PAYLOAD, +}; + +/* Buffer holding a single message */ +typedef struct { + uint8_t command; + uint8_t msgId; + uint8_t payloadSize; + uint8_t payload[MAX_PAYLOAD_SIZE]; +} message_t; + +/* Internal protocol state */ +typedef struct { + /* Callback to call upon receiving a valid message */ + void (*callback)(const message_t *); + + /* Number of read payload bytes */ + uint8_t payloadPosition; + + /* Current finite-state-automata state */ + enum protoState state; + + uint8_t previousId; + uint8_t errors; + + /* Currently received message */ + message_t buffer; +} protocol_t; + +/* NOTE: This didn't work when defined on stack */ +extern protocol_t proto; + +/* Init state */ +extern void protoInit(protocol_t *proto, void (*callback)(const message_t *)); + +/* Consume one byte and push state forward - might call the callback */ +extern void protoConsume(protocol_t *proto, uint8_t byte); + +/* Prolonged silence - reset state */ +extern void protoSilence(protocol_t *proto); + +/* Transmit message */ +extern void protoTx(uint8_t cmd, const unsigned char *buf, int payloadSize, + int retries); + +#endif diff --git a/keyboards/annepro2/qmk_ap2_led.c b/keyboards/annepro2/qmk_ap2_led.c index 5f7e9fcf83d5..d0b34122c27a 100644 --- a/keyboards/annepro2/qmk_ap2_led.c +++ b/keyboards/annepro2/qmk_ap2_led.c @@ -1,115 +1,106 @@ +#include +#include #include "hal.h" #include "annepro2.h" #include "qmk_ap2_led.h" +#include "protocol.h" -bool AP2_LED_ENABLED = false; -bool AP2_LED_DYNAMIC_PROFILE = false; -bool AP2_FOREGROUND_COLOR_SET = false; +annepro2Led_t ledMask[KEY_COUNT]; +annepro2LedStatus_t annepro2LedStatus; -void annepro2LedDisable(void) -{ - sdPut(&SD0, CMD_LED_OFF); - AP2_LED_ENABLED = false; -} +void ledCommandCallback(const message_t *msg) { + switch (msg->command) { + case CMD_LED_STATUS: + annepro2LedStatus.amountOfProfiles = msg->payload[0]; + annepro2LedStatus.currentProfile = msg->payload[1]; + annepro2LedStatus.matrixEnabled = msg->payload[2]; + annepro2LedStatus.isReactive = msg->payload[3]; + annepro2LedStatus.ledIntensity = msg->payload[4]; + annepro2LedStatus.errors = msg->payload[5]; + break; -void annepro2LedEnable(void) -{ - sdPut(&SD0, CMD_LED_ON); - AP2_LED_ENABLED = true; +#ifdef CONSOLE_ENABLE + case CMD_LED_DEBUG: + /* TODO: Don't use printf. */ + printf("LED:"); + for (int i = 0; i < msg->payloadSize; i++) { + printf("%02x ", msg->payload[i]); + } + for (int i = 0; i < msg->payloadSize; i++) { + printf("%c", msg->payload[i]); + } + printf("\n"); + break; +#endif + } } -void annepro2LedUpdate(uint8_t row, uint8_t col) -{ - sdPut(&SD0, CMD_LED_SET); - sdPut(&SD0, row); - sdPut(&SD0, col); - sdWrite(&SD0, (uint8_t *)&annepro2LedMatrix[row * MATRIX_COLS + col], sizeof(uint16_t)); -} +void annepro2SetIAP(void) { protoTx(CMD_LED_IAP, NULL, 0, 3); } -void annepro2LedUpdateRow(uint8_t row) -{ - sdPut(&SD0, CMD_LED_SET_ROW); - sdPut(&SD0, row); - sdWrite(&SD0, (uint8_t *)&annepro2LedMatrix[row * MATRIX_COLS], sizeof(uint16_t) * MATRIX_COLS); -} +void annepro2LedDisable(void) { protoTx(CMD_LED_OFF, NULL, 0, 3); } -void annepro2LedSetProfile(uint8_t prof) -{ - sdPut(&SD0, CMD_LED_SET_PROFILE); - sdPut(&SD0, prof); - uint8_t buf = sdGet(&SD0); - AP2_LED_DYNAMIC_PROFILE = buf; -} +void annepro2LedEnable(void) { protoTx(CMD_LED_ON, NULL, 0, 3); } -uint8_t annepro2LedGetProfile() -{ - uint8_t buf = 0; - sdPut(&SD0, CMD_LED_GET_PROFILE); - buf = sdGet(&SD0); - return buf; -} +void annepro2LedSetProfile(uint8_t prof) { protoTx(CMD_LED_SET_PROFILE, &prof, sizeof(prof), 3); } -uint8_t annepro2LedGetNumProfiles() -{ - uint8_t buf = 0; - sdPut(&SD0, CMD_LED_GET_NUM_PROFILES); - buf = sdGet(&SD0); - return buf; -} +void annepro2LedGetStatus() { protoTx(CMD_LED_GET_STATUS, NULL, 0, 3); } -void annepro2LedNextProfile() -{ - sdPut(&SD0, CMD_LED_NEXT_PROFILE); - uint8_t buf = sdGet(&SD0); - AP2_LED_DYNAMIC_PROFILE = buf; -} +void annepro2LedNextProfile() { protoTx(CMD_LED_NEXT_PROFILE, NULL, 0, 3); } -void annepro2LedNextIntensity() -{ - sdPut(&SD0, CMD_LED_NEXT_INTENSITY); -} +void annepro2LedNextIntensity() { protoTx(CMD_LED_NEXT_INTENSITY, NULL, 0, 3); } + +void annepro2LedNextAnimationSpeed() { protoTx(CMD_LED_NEXT_ANIMATION_SPEED, NULL, 0, 3); } + +void annepro2LedPrevProfile() { protoTx(CMD_LED_PREV_PROFILE, NULL, 0, 3); } -void annepro2LedNextAnimationSpeed() -{ - sdPut(&SD0, CMD_LED_NEXT_ANIMATION_SPEED); +void annepro2LedMaskSetKey(uint8_t row, uint8_t col, annepro2Led_t color) { + uint8_t payload[] = {row, col, color.p.blue, color.p.green, color.p.red, color.p.alpha}; + protoTx(CMD_LED_MASK_SET_KEY, payload, sizeof(payload), 1); } -void annepro2LedPrevProfile() -{ - sdPut(&SD0, CMD_LED_PREV_PROFILE); - uint8_t buf = sdGet(&SD0); - AP2_LED_DYNAMIC_PROFILE = buf; +/* Push a whole local row to the shine */ +void annepro2LedMaskSetRow(uint8_t row) { + uint8_t payload[NUM_COLUMN * sizeof(annepro2Led_t) + 1]; + payload[0] = row; + memcpy(payload + 1, &ledMask[ROWCOL2IDX(row, 0)], sizeof(*ledMask) * NUM_COLUMN); + protoTx(CMD_LED_MASK_SET_KEY, payload, sizeof(payload), 1); } -void annepro2LedSetMask(uint8_t key) -{ - sdPut(&SD0, CMD_LED_SET_MASK); - sdPut(&SD0, key); +/* Synchronize all rows */ +void annepro2LedMaskSetAll(void) { + for (int row = 0; row < 5; row++) annepro2LedMaskSetRow(row); } -void annepro2LedClearMask(uint8_t key) -{ - sdPut(&SD0, CMD_LED_CLEAR_MASK); - sdPut(&SD0, key); +/* Set all keys to a given color */ +void annepro2LedMaskSetMono(const annepro2Led_t color) { protoTx(CMD_LED_MASK_SET_MONO, (uint8_t *)&color, sizeof(color), 1); } + +void annepro2LedBlink(uint8_t row, uint8_t col, annepro2Led_t color, uint8_t count, uint8_t hundredths) { + uint8_t payload[] = {row, col, color.p.blue, color.p.green, color.p.red, color.p.alpha, count, hundredths}; + protoTx(CMD_LED_KEY_BLINK, payload, sizeof(payload), 1); } -void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue) -{ - sdPut(&SD0, CMD_LED_SET_FOREGROUND_COLOR); - uint8_t colors[3]={red,green,blue}; - sdWrite(&SD0, (uint8_t *)&colors, sizeof(colors)); - AP2_FOREGROUND_COLOR_SET = true; +void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue) { + annepro2Led_t color = {.p.red = red, .p.green = green, .p.blue = blue, .p.alpha = 0xff}; + annepro2LedMaskSetMono(color); } -void annepro2LedResetForegroundColor() -{ - sdPut(&SD0, CMD_LED_CLEAR_FOREGROUND_COLOR); - uint8_t buf = sdGet(&SD0); - AP2_LED_DYNAMIC_PROFILE = buf; - AP2_FOREGROUND_COLOR_SET = false; +void annepro2LedResetForegroundColor() { + annepro2Led_t color = { + .p.red = 0, + .p.green = 0, + .p.blue = 0, + .p.alpha = 0, + }; + annepro2LedMaskSetMono(color); } /* + * Currently keypresses are unified with other messages, still with single 1 + * byte payload. Transfer is normally fast enough for that to not be a problem - + * especially with asynchronous message reading. + * + * + * Previous description: * If enabled, this data is sent to LED MCU on every keypress. * In order to improve performance, both row and column values * are packed into a single byte. @@ -121,8 +112,7 @@ void annepro2LedResetForegroundColor() * Following it are 3 bits of row and 4 bits of col. * 1 + 3 + 4 = 8 bits - only a single byte is sent for every keypress. */ -void annepro2LedForwardKeypress(uint8_t row, uint8_t col) -{ - uint8_t msg = 0b10000000 | (row << 4) | col; - sdPut(&SD0, msg); +void annepro2LedForwardKeypress(uint8_t row, uint8_t col) { + const uint8_t payload = row << 4 | col; + protoTx(CMD_LED_KEY_DOWN, &payload, 1, 1); } diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/qmk_ap2_led.h index d4658119afdf..0abec2dcba09 100644 --- a/keyboards/annepro2/qmk_ap2_led.h +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -1,42 +1,68 @@ #pragma once -#define CMD_LED_ON 0x1 -#define CMD_LED_OFF 0x2 -#define CMD_LED_SET 0x3 -#define CMD_LED_SET_ROW 0x4 -#define CMD_LED_SET_PROFILE 0x5 -#define CMD_LED_NEXT_PROFILE 0x6 -#define CMD_LED_PREV_PROFILE 0x7 -#define CMD_LED_GET_PROFILE 0x8 -#define CMD_LED_GET_NUM_PROFILES 0x9 -#define CMD_LED_SET_MASK 0xA -#define CMD_LED_CLEAR_MASK 0xB -#define CMD_LED_NEXT_INTENSITY 0xC -#define CMD_LED_NEXT_ANIMATION_SPEED 0xD -#define CMD_LED_SET_FOREGROUND_COLOR 0xE -#define CMD_LED_CLEAR_FOREGROUND_COLOR 0xF -#define CMD_LED_IAP 0x10 -#define CMD_LED_KEYPRESS 0x11 +#include "protocol.h" + +// Struct defining an LED and its RGB color components +// Compatible with Shine firmware. +typedef union { + struct { + /* Little endian ordering to match uint32_t */ + uint8_t blue, green, red; + /* Used in mask; nonzero means - use color from mask. */ + uint8_t alpha; + } p; /* parts */ + /* Parts vector access: 0 - blue, 1 - green, 2 - red */ + uint8_t pv[4]; + /* 0xrgb in mem is b g r a */ + uint32_t rgb; +} annepro2Led_t; + +#define ROWCOL2IDX(row, col) (NUM_COLUMN * (row) + (col)) +#define NUM_COLUMN 14 +#define NUM_ROW 5 +#define KEY_COUNT 70 + +/* Local copy of ledMask, used to override colors on the board */ +extern annepro2Led_t ledMask[KEY_COUNT]; + +/* Handle incoming messages */ +extern void ledCommandCallback(const message_t *msg); void annepro2SetIAP(void); void annepro2LedDisable(void); void annepro2LedEnable(void); -void annepro2LedUpdate(uint8_t row, uint8_t col); -void annepro2LedUpdateRow(uint8_t row); void annepro2LedSetProfile(uint8_t prof); -uint8_t annepro2LedGetProfile(void); -uint8_t annepro2LedGetNumProfiles(void); +void annepro2LedGetStatus(void); void annepro2LedNextProfile(void); void annepro2LedPrevProfile(void); -void annepro2LedSetMask(uint8_t key); -void annepro2LedClearMask(uint8_t key); void annepro2LedNextIntensity(void); void annepro2LedNextAnimationSpeed(void); +void annepro2LedForwardKeypress(uint8_t row, uint8_t col); + +/* Set single key to a given color; alpha controls which is displayed */ +void annepro2LedMaskSetKey(uint8_t row, uint8_t col, annepro2Led_t color); +/* Push a whole local row to the shine */ +void annepro2LedMaskSetRow(uint8_t row); +/* Synchronize all rows */ +void annepro2LedMaskSetAll(void); + +/* Set all keys to a given color */ +void annepro2LedMaskSetMono(annepro2Led_t color); + +/* Blink given key `count` times by masking it with a `color`. Blink takes `hundredths` of a second */ +void annepro2LedBlink(uint8_t row, uint8_t col, annepro2Led_t color, uint8_t count, uint8_t hundredths); + +/* Kept for compatibility, but implemented using masks */ void annepro2LedSetForegroundColor(uint8_t red, uint8_t green, uint8_t blue); void annepro2LedResetForegroundColor(void); -void annepro2LedForwardKeypress(uint8_t row, uint8_t col); +typedef struct { + uint8_t amountOfProfiles; + uint8_t currentProfile; + uint8_t matrixEnabled; + uint8_t isReactive; + uint8_t ledIntensity; + uint8_t errors; +} annepro2LedStatus_t; -extern bool AP2_LED_ENABLED; -extern bool AP2_LED_DYNAMIC_PROFILE; -extern bool AP2_FOREGROUND_COLOR_SET; +extern annepro2LedStatus_t annepro2LedStatus; From 8963c3bed035a31619b2034622f45f5b97b696b8 Mon Sep 17 00:00:00 2001 From: Tomasz bla Fortuna Date: Sun, 25 Jul 2021 18:05:12 +0200 Subject: [PATCH 40/88] Let the LED chip settle a bit before waking it from the bootloader. (#42) At least for one person that helps to reliably get the LEDs working without disconnecting/reconnecting the power to the board multiple times. Co-authored-by: Tomasz bla Fortuna --- keyboards/annepro2/annepro2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index acfab3e07fc1..cdca573d53b6 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -51,7 +51,11 @@ void OVERRIDE keyboard_pre_init_kb(void) { #endif // Start LED UART sdStart(&SD0, &ledUartInitConfig); + /* Let the LED chip settle a bit before switching the mode. + * That helped at least one person. */ + wait_ms(15); sdWrite(&SD0, ledMcuWakeup, 11); + // wait to receive response from wakeup wait_ms(15); From 5408f57b114c0d3a146f9e886c68ca5c3e41a964 Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 29 Aug 2021 13:59:54 +0200 Subject: [PATCH 41/88] annepro2: rename KEYMAP to LAYOUT, as required by new version of QMK --- keyboards/annepro2/c15/config.h | 3 +-- keyboards/annepro2/c18/config.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/keyboards/annepro2/c15/config.h b/keyboards/annepro2/c15/config.h index 76d0217cca7c..7510debe3df3 100644 --- a/keyboards/annepro2/c15/config.h +++ b/keyboards/annepro2/c15/config.h @@ -43,7 +43,7 @@ // Matrix keymap -#define KEYMAP( \ +#define LAYOUT( \ K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \ @@ -167,4 +167,3 @@ //#define NO_ACTION_ONESHOT //#define NO_ACTION_MACRO //#define NO_ACTION_FUNCTION - diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h index 726e4a3995e0..21a3333f08ec 100644 --- a/keyboards/annepro2/c18/config.h +++ b/keyboards/annepro2/c18/config.h @@ -43,7 +43,7 @@ // Matrix keymap -#define KEYMAP( \ +#define LAYOUT( \ K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \ From 64b80864f0f4c377739e3140816645971cd81369 Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 29 Aug 2021 14:01:06 +0200 Subject: [PATCH 42/88] annepro2: update ChibiOS configuration files --- keyboards/annepro2/chconf.h | 699 ++--------------------------------- keyboards/annepro2/halconf.h | 388 +------------------ 2 files changed, 59 insertions(+), 1028 deletions(-) diff --git a/keyboards/annepro2/chconf.h b/keyboards/annepro2/chconf.h index f5c09246d67c..0a29c7ad885e 100644 --- a/keyboards/annepro2/chconf.h +++ b/keyboards/annepro2/chconf.h @@ -1,691 +1,70 @@ -/* - ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file templates/chconf.h - * @brief Configuration file template. - * @details A copy of this file must be placed in each project directory, it - * contains the application specific kernel settings. - * - * @addtogroup config - * @details Kernel related settings and hooks. - * @{ - */ - -#ifndef CHCONF_H -#define CHCONF_H - -#define _CHIBIOS_RT_CONF_ -#define _CHIBIOS_RT_CONF_VER_6_0_ - - -/*===========================================================================*/ -/** - * @name System timers settings - * @{ - */ -/*===========================================================================*/ - -/** - * @brief System time counter resolution. - * @note Allowed values are 16 or 32 bits. - */ -#if !defined(CH_CFG_ST_RESOLUTION) -#define CH_CFG_ST_RESOLUTION 32 -#endif -/** - * @brief System tick frequency. - * @details Frequency of the system timer that drives the system ticks. This - * setting also defines the system tick time unit. - */ -#if !defined(CH_CFG_ST_FREQUENCY) -#define CH_CFG_ST_FREQUENCY 1000 -#endif - -/** - * @brief Time intervals data size. - * @note Allowed values are 16, 32 or 64 bits. - */ -#if !defined(CH_CFG_INTERVALS_SIZE) -#define CH_CFG_INTERVALS_SIZE 32 -#endif - -/** - * @brief Time types data size. - * @note Allowed values are 16 or 32 bits. - */ -#if !defined(CH_CFG_TIME_TYPES_SIZE) -#define CH_CFG_TIME_TYPES_SIZE 32 -#endif - -/** - * @brief Time delta constant for the tick-less mode. - * @note If this value is zero then the system uses the classic - * periodic tick. This value represents the minimum number - * of ticks that is safe to specify in a timeout directive. - * The value one is not valid, timeouts are rounded up to - * this value. - */ -#if !defined(CH_CFG_ST_TIMEDELTA) -#define CH_CFG_ST_TIMEDELTA 0 -#endif -/** @} */ - -/*===========================================================================*/ -/** - * @name Kernel parameters and options - * @{ - */ -/*===========================================================================*/ - -/** - * @brief Round robin interval. - * @details This constant is the number of system ticks allowed for the - * threads before preemption occurs. Setting this value to zero - * disables the preemption for threads with equal priority and the - * round robin becomes cooperative. Note that higher priority - * threads can still preempt, the kernel is always preemptive. - * @note Disabling the round robin preemption makes the kernel more compact - * and generally faster. - * @note The round robin preemption is not supported in tickless mode and - * must be set to zero in that case. - */ -#if !defined(CH_CFG_TIME_QUANTUM) -#define CH_CFG_TIME_QUANTUM 20 -#endif - -/** - * @brief Managed RAM size. - * @details Size of the RAM area to be managed by the OS. If set to zero - * then the whole available RAM is used. The core memory is made - * available to the heap allocator and/or can be used directly through - * the simplified core memory allocator. - * - * @note In order to let the OS manage the whole RAM the linker script must - * provide the @p __heap_base__ and @p __heap_end__ symbols. - * @note Requires @p CH_CFG_USE_MEMCORE. - */ -#if !defined(CH_CFG_MEMCORE_SIZE) -#define CH_CFG_MEMCORE_SIZE 0 -#endif - -/** - * @brief Idle thread automatic spawn suppression. - * @details When this option is activated the function @p chSysInit() - * does not spawn the idle thread. The application @p main() - * function becomes the idle thread and must implement an - * infinite loop. - */ -#if !defined(CH_CFG_NO_IDLE_THREAD) -#define CH_CFG_NO_IDLE_THREAD FALSE -#endif - - -/** @} */ - -/*===========================================================================*/ -/** - * @name Performance options - * @{ - */ -/*===========================================================================*/ - -/** - * @brief OS optimization. - * @details If enabled then time efficient rather than space efficient code - * is used when two possible implementations exist. - * - * @note This is not related to the compiler optimization options. - * @note The default is @p TRUE. - */ -#if !defined(CH_CFG_OPTIMIZE_SPEED) -#define CH_CFG_OPTIMIZE_SPEED TRUE -#endif -/** @} */ - -/** - * @brief Time Measurement APIs. - * @details If enabled then the time measurement APIs are included in - * the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_CFG_USE_TM) -#define CH_CFG_USE_TM FALSE -#endif - -/** - * @brief Threads registry APIs. - * @details If enabled then the registry APIs are included in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_CFG_USE_REGISTRY) -#define CH_CFG_USE_REGISTRY TRUE -#endif - -/** - * @brief Threads synchronization APIs. - * @details If enabled then the @p chThdWait() function is included in - * the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_CFG_USE_WAITEXIT) -#define CH_CFG_USE_WAITEXIT TRUE -#endif - -/** - * @brief Semaphores APIs. - * @details If enabled then the Semaphores APIs are included in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_CFG_USE_SEMAPHORES) -#define CH_CFG_USE_SEMAPHORES TRUE -#endif - -/** - * @brief Semaphores queuing mode. - * @details If enabled then the threads are enqueued on semaphores by - * priority rather than in FIFO order. - * - * @note The default is @p FALSE. Enable this if you have special - * requirements. - * @note Requires @p CH_CFG_USE_SEMAPHORES. - */ -#if !defined(CH_CFG_USE_SEMAPHORES_PRIORITY) -#define CH_CFG_USE_SEMAPHORES_PRIORITY FALSE -#endif - -/** - * @brief Mutexes APIs. - * @details If enabled then the mutexes APIs are included in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_CFG_USE_MUTEXES) -#define CH_CFG_USE_MUTEXES TRUE -#endif - -/** - * @brief Enables recursive behavior on mutexes. - * @note Recursive mutexes are heavier and have an increased - * memory footprint. - * - * @note The default is @p FALSE. - * @note Requires @p CH_CFG_USE_MUTEXES. - */ -#if !defined(CH_CFG_USE_MUTEXES_RECURSIVE) -#define CH_CFG_USE_MUTEXES_RECURSIVE FALSE -#endif - -/** - * @brief Conditional Variables APIs. - * @details If enabled then the conditional variables APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_CFG_USE_MUTEXES. - */ -#if !defined(CH_CFG_USE_CONDVARS) -#define CH_CFG_USE_CONDVARS TRUE -#endif - -/** - * @brief Conditional Variables APIs with timeout. - * @details If enabled then the conditional variables APIs with timeout - * specification are included in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_CFG_USE_CONDVARS. - */ -#if !defined(CH_CFG_USE_CONDVARS_TIMEOUT) -#define CH_CFG_USE_CONDVARS_TIMEOUT TRUE -#endif - -/** - * @brief Events Flags APIs. - * @details If enabled then the event flags APIs are included in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_CFG_USE_EVENTS) -#define CH_CFG_USE_EVENTS TRUE -#endif - -/** - * @brief Events Flags APIs with timeout. - * @details If enabled then the events APIs with timeout specification - * are included in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_CFG_USE_EVENTS. - */ -#if !defined(CH_CFG_USE_EVENTS_TIMEOUT) -#define CH_CFG_USE_EVENTS_TIMEOUT TRUE -#endif - -/** - * @brief Synchronous Messages APIs. - * @details If enabled then the synchronous messages APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_CFG_USE_MESSAGES) -#define CH_CFG_USE_MESSAGES TRUE -#endif - -/** - * @brief Synchronous Messages queuing mode. - * @details If enabled then messages are served by priority rather than in - * FIFO order. - * - * @note The default is @p FALSE. Enable this if you have special - * requirements. - * @note Requires @p CH_CFG_USE_MESSAGES. - */ -#if !defined(CH_CFG_USE_MESSAGES_PRIORITY) -#define CH_CFG_USE_MESSAGES_PRIORITY FALSE -#endif - -/** - * @brief Mailboxes APIs. - * @details If enabled then the asynchronous messages (mailboxes) APIs are - * included in the kernel. +/* Copyright 2020 QMK * - * @note The default is @p TRUE. - * @note Requires @p CH_CFG_USE_SEMAPHORES. - */ -#if !defined(CH_CFG_USE_MAILBOXES) -#define CH_CFG_USE_MAILBOXES TRUE -#endif - -/** - * @brief Core Memory Manager APIs. - * @details If enabled then the core memory manager APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_CFG_USE_MEMCORE) -#define CH_CFG_USE_MEMCORE TRUE -#endif - -/** - * @brief Heap Allocator APIs. - * @details If enabled then the memory heap allocator APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - * @note Requires @p CH_CFG_USE_MEMCORE and either @p CH_CFG_USE_MUTEXES or - * @p CH_CFG_USE_SEMAPHORES. - * @note Mutexes are recommended. - */ -#if !defined(CH_CFG_USE_HEAP) -#define CH_CFG_USE_HEAP TRUE -#endif - -/** - * @brief Memory Pools Allocator APIs. - * @details If enabled then the memory pools allocator APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_CFG_USE_MEMPOOLS) -#define CH_CFG_USE_MEMPOOLS TRUE -#endif - -/** - * @brief Objects FIFOs APIs. - * @details If enabled then the objects FIFOs APIs are included - * in the kernel. + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. * - * @note The default is @p TRUE. - */ -#if !defined(CH_CFG_USE_OBJ_FIFOS) -#define CH_CFG_USE_OBJ_FIFOS TRUE -#endif - -/** - * @brief Pipes APIs. - * @details If enabled then the pipes APIs are included - * in the kernel. - * - * @note The default is @p TRUE. - */ -#if !defined(CH_CFG_USE_PIPES) -#define CH_CFG_USE_PIPES TRUE -#endif - -/** - * @brief Dynamic Threads APIs. - * @details If enabled then the dynamic threads creation APIs are included - * in the kernel. + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. * - * @note The default is @p TRUE. - * @note Requires @p CH_CFG_USE_WAITEXIT. - * @note Requires @p CH_CFG_USE_HEAP and/or @p CH_CFG_USE_MEMPOOLS. - */ -#if !defined(CH_CFG_USE_DYNAMIC) -#define CH_CFG_USE_DYNAMIC TRUE -#endif - -/** @} */ - - -/*===========================================================================*/ -/** - * @name Objects factory options - * @{ + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -/*===========================================================================*/ -/** - * @brief Objects Factory APIs. - * @details If enabled then the objects factory APIs are included in the - * kernel. - * - * @note The default is @p FALSE. - */ -#if !defined(CH_CFG_USE_FACTORY) -#define CH_CFG_USE_FACTORY TRUE -#endif - -/** - * @brief Maximum length for object names. - * @details If the specified length is zero then the name is stored by - * pointer but this could have unintended side effects. - */ -#if !defined(CH_CFG_FACTORY_MAX_NAMES_LENGTH) -#define CH_CFG_FACTORY_MAX_NAMES_LENGTH 8 -#endif - -/** - * @brief Enables the registry of generic objects. - */ -#if !defined(CH_CFG_FACTORY_OBJECTS_REGISTRY) -#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE -#endif - -/** - * @brief Enables factory for generic buffers. - */ -#if !defined(CH_CFG_FACTORY_GENERIC_BUFFERS) -#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE -#endif - -/** - * @brief Enables factory for semaphores. - */ -#if !defined(CH_CFG_FACTORY_SEMAPHORES) -#define CH_CFG_FACTORY_SEMAPHORES TRUE -#endif - -/** - * @brief Enables factory for mailboxes. - */ -#if !defined(CH_CFG_FACTORY_MAILBOXES) -#define CH_CFG_FACTORY_MAILBOXES TRUE -#endif - -/** - * @brief Enables factory for objects FIFOs. - */ -#if !defined(CH_CFG_FACTORY_OBJ_FIFOS) -#define CH_CFG_FACTORY_OBJ_FIFOS TRUE -#endif - -/** - * @brief Enables factory for Pipes. - */ -#if !defined(CH_CFG_FACTORY_PIPES) || defined(__DOXYGEN__) -#define CH_CFG_FACTORY_PIPES TRUE -#endif - -/** @} */ - -/*===========================================================================*/ -/** - * @name Debug options - * @{ - */ -/*===========================================================================*/ - -/** - * @brief Debug option, kernel statistics. - * - * @note The default is @p FALSE. - */ -#define CH_DBG_STATISTICS FALSE - -/** - * @brief Debug option, system state check. - * @details If enabled the correct call protocol for system APIs is checked - * at runtime. - * - * @note The default is @p FALSE. - */ -#define CH_DBG_SYSTEM_STATE_CHECK FALSE // adds about 1K code - -/** - * @brief Debug option, parameters checks. - * @details If enabled then the checks on the API functions input - * parameters are activated. - * - * @note The default is @p FALSE. - */ -#define CH_DBG_ENABLE_CHECKS FALSE // adds < 1K code - -/** - * @brief Debug option, consistency checks. - * @details If enabled then all the assertions in the kernel code are - * activated. This includes consistency checks inside the kernel, - * runtime anomalies and port-defined checks. - * - * @note The default is @p FALSE. +/* + * This file was auto-generated by: + * `qmk chibios-confmigrate -i keyboards/annepro2/chconf.h -r platforms/chibios/common/configs/chconf.h` */ -#define CH_DBG_ENABLE_ASSERTS FALSE // adds about 3K code -/** - * @brief Debug option, trace buffer. - * @details If enabled then the trace buffer is activated. - * - * @note The default is @p CH_DBG_TRACE_MASK_DISABLED. - */ -#define CH_DBG_TRACE_MASK CH_DBG_TRACE_MASK_DISABLED +#pragma once -/** - * @brief Trace buffer entries. - * @note The trace buffer is only allocated if @p CH_DBG_TRACE_MASK is - * different from @p CH_DBG_TRACE_MASK_DISABLED. - */ -#define CH_DBG_TRACE_BUFFER_SIZE 128 +#define CH_CFG_ST_FREQUENCY 1000 -/** - * @brief Debug option, stack checks. - * @details If enabled then a runtime stack check is performed. - * - * @note The default is @p FALSE. - * @note The stack check is performed in a architecture/port dependent way. - * It may not be implemented or some ports. - * @note The default failure mode is to halt the system with the global - * @p panic_msg variable set to @p NULL. - */ -#define CH_DBG_ENABLE_STACK_CHECK FALSE - -/** - * @brief Debug option, stacks initialization. - * @details If enabled then the threads working area is filled with a byte - * value when a thread is created. This can be useful for the - * runtime measurement of the used stack. - * - * @note The default is @p FALSE. - */ -#define CH_DBG_FILL_THREADS FALSE +#define CH_CFG_ST_TIMEDELTA 0 -/** - * @brief Debug option, threads profiling. - * @details If enabled then a field is added to the @p thread_t structure that - * counts the system ticks occurred while executing the thread. - * - * @note The default is @p FALSE. - * @note This debug option is not currently compatible with the - * tickless mode. - */ -#define CH_DBG_THREADS_PROFILING FALSE +#define CH_CFG_TIME_QUANTUM 20 -/** @} */ +#define CH_CFG_USE_REGISTRY TRUE -/*===========================================================================*/ -/** - * @name Kernel hooks - * @{ - */ -/*===========================================================================*/ +#define CH_CFG_USE_WAITEXIT TRUE -/** - * @brief System structure extension. - * @details User fields added to the end of the @p ch_system_t structure. - */ -#define CH_CFG_SYSTEM_EXTRA_FIELDS \ - /* Add threads custom fields here.*/ +#define CH_CFG_USE_CONDVARS TRUE -/** - * @brief System initialization hook. - * @details User initialization code added to the @p chSysInit() function - * just before interrupts are enabled globally. - */ -#define CH_CFG_SYSTEM_INIT_HOOK() { \ - /* Add threads initialization code here.*/ \ -} +#define CH_CFG_USE_MESSAGES TRUE -/** - * @brief Threads descriptor structure extension. - * @details User fields added to the end of the @p thread_t structure. - */ -#define CH_CFG_THREAD_EXTRA_FIELDS \ - /* Add threads custom fields here.*/ +#define CH_CFG_USE_MAILBOXES TRUE -/** - * @brief Threads initialization hook. - * @details User initialization code added to the @p _thread_init() function. - * - * @note It is invoked from within @p _thread_init() and implicitly from all - * the threads creation APIs. - */ -#define CH_CFG_THREAD_INIT_HOOK(tp) { \ - /* Add threads initialization code here.*/ \ -} +#define CH_CFG_USE_HEAP TRUE -/** - * @brief Threads finalization hook. - * @details User finalization code added to the @p chThdExit() API. - */ -#define CH_CFG_THREAD_EXIT_HOOK(tp) { \ - /* Add threads finalization code here.*/ \ -} +#define CH_CFG_USE_MEMPOOLS TRUE -/** - * @brief Context switch hook. - * @details This hook is invoked just before switching between threads. - */ -#define CH_CFG_CONTEXT_SWITCH_HOOK(ntp, otp) { \ - /* Context switch code here.*/ \ -} +#define CH_CFG_USE_OBJ_FIFOS TRUE -/** - * @brief ISR enter hook. - */ -#define CH_CFG_IRQ_PROLOGUE_HOOK() { \ - /* IRQ prologue code here.*/ \ -} +#define CH_CFG_USE_PIPES TRUE -/** - * @brief ISR exit hook. - */ -#define CH_CFG_IRQ_EPILOGUE_HOOK() { \ - /* IRQ epilogue code here.*/ \ -} +#define CH_CFG_USE_DYNAMIC TRUE -/** - * @brief Idle thread enter hook. - * @note This hook is invoked within a critical zone, no OS functions - * should be invoked from here. - * @note This macro can be used to activate a power saving mode. - */ -#define CH_CFG_IDLE_ENTER_HOOK() { \ - /* Idle-enter code here.*/ \ -} +#define CH_CFG_USE_FACTORY TRUE -/** - * @brief Idle thread leave hook. - * @note This hook is invoked within a critical zone, no OS functions - * should be invoked from here. - * @note This macro can be used to deactivate a power saving mode. - */ -#define CH_CFG_IDLE_LEAVE_HOOK() { \ - /* Idle-leave code here.*/ \ -} +#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE -/** - * @brief Idle Loop hook. - * @details This hook is continuously invoked by the idle thread loop. - */ -#define CH_CFG_IDLE_LOOP_HOOK() { \ - /* Idle loop code here.*/ \ -} +#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE -/** - * @brief System tick event hook. - * @details This hook is invoked in the system tick handler immediately - * after processing the virtual timers queue. - */ -#define CH_CFG_SYSTEM_TICK_HOOK() { \ - /* System tick event code here.*/ \ -} +#define CH_CFG_FACTORY_SEMAPHORES TRUE -/** - * @brief System halt hook. - * @details This hook is invoked in case to a system halting error before - * the system is halted. - */ -#define CH_CFG_SYSTEM_HALT_HOOK(reason) { \ - /* System halt code here.*/ \ -} +#define CH_CFG_FACTORY_MAILBOXES TRUE -/** - * @brief Trace hook. - * @details This hook is invoked each time a new record is written in the - * trace buffer. - */ -#define CH_CFG_TRACE_HOOK(tep) { \ - /* Trace code here.*/ \ -} +#define CH_CFG_FACTORY_OBJ_FIFOS TRUE -/** @} */ +#define CH_CFG_FACTORY_PIPES TRUE -/*===========================================================================*/ -/* Port-specific settings (override port settings defaulted in chcore.h). */ -/*===========================================================================*/ +#define CH_DBG_SYSTEM_STATE_CHECK FALSE // adds about 1K code -#define CH_HT32_WAIT_US_POLL TRUE +#define CH_DBG_ENABLE_CHECKS FALSE // adds < 1K code -#endif /* CHCONF_H */ +#define CH_DBG_ENABLE_ASSERTS FALSE // adds about 3K code -/** @} */ +#include_next \ No newline at end of file diff --git a/keyboards/annepro2/halconf.h b/keyboards/annepro2/halconf.h index ea9c8da299aa..686b91a7fb2f 100644 --- a/keyboards/annepro2/halconf.h +++ b/keyboards/annepro2/halconf.h @@ -1,376 +1,28 @@ -/* - ChibiOS - Copyright (C) 2006..2015 Giovanni Di Sirio - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -/** - * @file templates/halconf.h - * @brief HAL configuration header. - * @details HAL configuration file, this file allows to enable or disable the - * various device drivers from your application. You may also use - * this file in order to override the device drivers default settings. +/* Copyright 2020 QMK * - * @addtogroup HAL_CONF - * @{ - */ - -#ifndef _HALCONF_H_ -#define _HALCONF_H_ - -#define _CHIBIOS_HAL_CONF_ -#define _CHIBIOS_HAL_CONF_VER_7_0_ - -#include "mcuconf.h" - -/** - * @brief Enables the PAL subsystem. - */ -#if !defined(HAL_USE_PAL) || defined(__DOXYGEN__) -#define HAL_USE_PAL TRUE -#endif - -/** - * @brief Enables the ADC subsystem. - */ -#if !defined(HAL_USE_ADC) || defined(__DOXYGEN__) -#define HAL_USE_ADC FALSE -#endif - -/** - * @brief Enables the CAN subsystem. - */ -#if !defined(HAL_USE_CAN) || defined(__DOXYGEN__) -#define HAL_USE_CAN FALSE -#endif - -/** - * @brief Enables the DAC subsystem. - */ -#if !defined(HAL_USE_DAC) || defined(__DOXYGEN__) -#define HAL_USE_DAC FALSE -#endif - -/** - * @brief Enables the EXT subsystem. - */ -#if !defined(HAL_USE_EXT) || defined(__DOXYGEN__) -#define HAL_USE_EXT FALSE -#endif - -/** - * @brief Enables the GPT subsystem. - */ -#if !defined(HAL_USE_GPT) || defined(__DOXYGEN__) -#define HAL_USE_GPT FALSE -#endif - -/** - * @brief Enables the I2C subsystem. - */ -#if !defined(HAL_USE_I2C) || defined(__DOXYGEN__) -#define HAL_USE_I2C FALSE -#endif - -/** - * @brief Enables the I2S subsystem. - */ -#if !defined(HAL_USE_I2S) || defined(__DOXYGEN__) -#define HAL_USE_I2S FALSE -#endif - -/** - * @brief Enables the ICU subsystem. - */ -#if !defined(HAL_USE_ICU) || defined(__DOXYGEN__) -#define HAL_USE_ICU FALSE -#endif - -/** - * @brief Enables the MAC subsystem. - */ -#if !defined(HAL_USE_MAC) || defined(__DOXYGEN__) -#define HAL_USE_MAC FALSE -#endif - -/** - * @brief Enables the MMC_SPI subsystem. - */ -#if !defined(HAL_USE_MMC_SPI) || defined(__DOXYGEN__) -#define HAL_USE_MMC_SPI FALSE -#endif - -/** - * @brief Enables the PWM subsystem. - */ -#if !defined(HAL_USE_PWM) || defined(__DOXYGEN__) -#define HAL_USE_PWM FALSE -#endif - -/** - * @brief Enables the RTC subsystem. - */ -#if !defined(HAL_USE_RTC) || defined(__DOXYGEN__) -#define HAL_USE_RTC FALSE -#endif - -/** - * @brief Enables the SDC subsystem. - */ -#if !defined(HAL_USE_SDC) || defined(__DOXYGEN__) -#define HAL_USE_SDC FALSE -#endif - -/** - * @brief Enables the SERIAL subsystem. - */ -#if !defined(HAL_USE_SERIAL) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL TRUE -#endif - -/** - * @brief Enables the SERIAL over USB subsystem. - */ -#if !defined(HAL_USE_SERIAL_USB) || defined(__DOXYGEN__) -#define HAL_USE_SERIAL_USB FALSE -#endif - -/** - * @brief Enables the SPI subsystem. - */ -#if !defined(HAL_USE_SPI) || defined(__DOXYGEN__) -#define HAL_USE_SPI FALSE -#endif - -/** - * @brief Enables the UART subsystem. - */ -#if !defined(HAL_USE_UART) || defined(__DOXYGEN__) -#define HAL_USE_UART FALSE -#endif - -/** - * @brief Enables the USB subsystem. - */ -#if !defined(HAL_USE_USB) || defined(__DOXYGEN__) -#define HAL_USE_USB TRUE -#endif - -/** - * @brief Enables the WDG subsystem. - */ -#if !defined(HAL_USE_WDG) || defined(__DOXYGEN__) -#define HAL_USE_WDG FALSE -#endif - -/*===========================================================================*/ -/* PAL driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(PAL_USE_CALLBACKS) || defined(__DOXYGEN__) -#define PAL_USE_CALLBACKS FALSE -#endif - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(PAL_USE_WAIT) || defined(__DOXYGEN__) -#define PAL_USE_WAIT FALSE -#endif - -/*===========================================================================*/ -/* ADC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(ADC_USE_WAIT) || defined(__DOXYGEN__) -#define ADC_USE_WAIT TRUE -#endif - -/** - * @brief Enables the @p adcAcquireBus() and @p adcReleaseBus() APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(ADC_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define ADC_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* CAN driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Sleep mode related APIs inclusion switch. - */ -#if !defined(CAN_USE_SLEEP_MODE) || defined(__DOXYGEN__) -#define CAN_USE_SLEEP_MODE TRUE -#endif - -/*===========================================================================*/ -/* I2C driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables the mutual exclusion APIs on the I2C bus. - */ -#if !defined(I2C_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define I2C_USE_MUTUAL_EXCLUSION TRUE -#endif - -/*===========================================================================*/ -/* MAC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables an event sources for incoming packets. - */ -#if !defined(MAC_USE_ZERO_COPY) || defined(__DOXYGEN__) -#define MAC_USE_ZERO_COPY FALSE -#endif - -/** - * @brief Enables an event sources for incoming packets. - */ -#if !defined(MAC_USE_EVENTS) || defined(__DOXYGEN__) -#define MAC_USE_EVENTS TRUE -#endif - -/*===========================================================================*/ -/* MMC_SPI driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Delays insertions. - * @details If enabled this options inserts delays into the MMC waiting - * routines releasing some extra CPU time for the threads with - * lower priority, this may slow down the driver a bit however. - * This option is recommended also if the SPI driver does not - * use a DMA channel and heavily loads the CPU. - */ -#if !defined(MMC_NICE_WAITING) || defined(__DOXYGEN__) -#define MMC_NICE_WAITING TRUE -#endif - -/*===========================================================================*/ -/* SDC driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Number of initialization attempts before rejecting the card. - * @note Attempts are performed at 10mS intervals. - */ -#if !defined(SDC_INIT_RETRY) || defined(__DOXYGEN__) -#define SDC_INIT_RETRY 100 -#endif - -/** - * @brief Include support for MMC cards. - * @note MMC support is not yet implemented so this option must be kept - * at @p FALSE. - */ -#if !defined(SDC_MMC_SUPPORT) || defined(__DOXYGEN__) -#define SDC_MMC_SUPPORT FALSE -#endif - -/** - * @brief Delays insertions. - * @details If enabled this options inserts delays into the MMC waiting - * routines releasing some extra CPU time for the threads with - * lower priority, this may slow down the driver a bit however. - */ -#if !defined(SDC_NICE_WAITING) || defined(__DOXYGEN__) -#define SDC_NICE_WAITING TRUE -#endif - -/*===========================================================================*/ -/* SERIAL driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Default bit rate. - * @details Configuration parameter, this is the baud rate selected for the - * default configuration. - */ -#if !defined(SERIAL_DEFAULT_BITRATE) || defined(__DOXYGEN__) -#define SERIAL_DEFAULT_BITRATE 38400 -#endif - -/** - * @brief Serial buffers size. - * @details Configuration parameter, you can change the depth of the queue - * buffers depending on the requirements of your application. - * @note The default is 64 bytes for both the transmission and receive - * buffers. - */ -#if !defined(SERIAL_BUFFERS_SIZE) || defined(__DOXYGEN__) -#define SERIAL_BUFFERS_SIZE 16 -#endif - -/*===========================================================================*/ -/* SERIAL_USB driver related setting. */ -/*===========================================================================*/ - -/** - * @brief Serial over USB buffers size. - * @details Configuration parameter, the buffer size must be a multiple of - * the USB data endpoint maximum packet size. - * @note The default is 64 bytes for both the transmission and receive - * buffers. - */ -#if !defined(SERIAL_USB_BUFFERS_SIZE) || defined(__DOXYGEN__) -#define SERIAL_USB_BUFFERS_SIZE 256 -#endif - -/*===========================================================================*/ -/* SPI driver related settings. */ -/*===========================================================================*/ - -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . */ -#if !defined(SPI_USE_WAIT) || defined(__DOXYGEN__) -#define SPI_USE_WAIT TRUE -#endif -/** - * @brief Enables the @p spiAcquireBus() and @p spiReleaseBus() APIs. - * @note Disabling this option saves both code and data space. +/* + * This file was auto-generated by: + * `qmk chibios-confmigrate -i keyboards/annepro2/halconf.h -r platforms/chibios/common/configs/halconf.h` */ -#if !defined(SPI_USE_MUTUAL_EXCLUSION) || defined(__DOXYGEN__) -#define SPI_USE_MUTUAL_EXCLUSION TRUE -#endif -/*===========================================================================*/ -/* USB driver related settings. */ -/*===========================================================================*/ +#pragma once -/** - * @brief Enables synchronous APIs. - * @note Disabling this option saves both code and data space. - */ -#if !defined(USB_USE_WAIT) || defined(__DOXYGEN__) -#define USB_USE_WAIT TRUE -#endif +#define HAL_USE_SERIAL TRUE -#endif /* _HALCONF_H_ */ +#define SERIAL_USB_BUFFERS_SIZE 256 -/** @} */ +#include_next From 22504e649d6168314a978159b207ea613049961a Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 29 Aug 2021 14:02:34 +0200 Subject: [PATCH 43/88] annepro2: fix undefined reference to dprint and timer_read32 --- keyboards/annepro2/eeprom_w25x20cl.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/keyboards/annepro2/eeprom_w25x20cl.c b/keyboards/annepro2/eeprom_w25x20cl.c index 6f96e650fcbd..279aa3978b0a 100644 --- a/keyboards/annepro2/eeprom_w25x20cl.c +++ b/keyboards/annepro2/eeprom_w25x20cl.c @@ -34,6 +34,8 @@ #include "spi_master.h" #include "eeprom.h" #include "eeprom_w25x20cl.h" +#include "timer.h" +#include "debug.h" #define CMD_WREN 0x06u #define CMD_WRDI 0x04u @@ -51,11 +53,6 @@ # define EXTERNAL_EEPROM_SPI_TIMEOUT 100 #endif -#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) -# include "timer.h" -# include "debug.h" -#endif // CONSOLE_ENABLE - bool spi_eeprom_start(void) { return spi_start(EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN, EXTERNAL_EEPROM_SPI_LSBFIRST, EXTERNAL_EEPROM_SPI_MODE, EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR); } From 48069e37abc5481cfd9569e3b8a0e7c1349fbeda Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 29 Aug 2021 14:24:47 +0200 Subject: [PATCH 44/88] annepro2: update ChibiOS MCU name --- keyboards/annepro2/c15/rules.mk | 4 ++-- keyboards/annepro2/c18/rules.mk | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index e50ee99516b7..082e010abe8e 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -13,9 +13,9 @@ MCU = cortex-m0plus ARMV = 6 USE_FPU = no MCU_FAMILY = HT32 -MCU_SERIES = HT32F523x2 +MCU_SERIES = HT32F523xx MCU_LDSCRIPT = HT32F52342_ANNEPRO2 -MCU_STARTUP = ht32f523x2 +MCU_STARTUP = ht32f523xx BOARD = ANNEPRO2 diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index c63a90ace46c..b0b844715fbd 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -18,9 +18,9 @@ MCU = cortex-m0plus ARMV = 6 USE_FPU = no MCU_FAMILY = HT32 -MCU_SERIES = HT32F523x2 +MCU_SERIES = HT32F523xx MCU_LDSCRIPT = HT32F52342_ANNEPRO2 -MCU_STARTUP = ht32f523x2 +MCU_STARTUP = ht32f523xx BOARD = ANNEPRO2_C18 From 3ec41ff65f61129491bc0a720e79f058fc32cfc6 Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 29 Aug 2021 14:25:59 +0200 Subject: [PATCH 45/88] update spi driver, fix bad merging with master --- platforms/chibios/drivers/spi_master.c | 62 +++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 7 deletions(-) diff --git a/platforms/chibios/drivers/spi_master.c b/platforms/chibios/drivers/spi_master.c index 78695369fb35..c49d807c3bda 100644 --- a/platforms/chibios/drivers/spi_master.c +++ b/platforms/chibios/drivers/spi_master.c @@ -38,13 +38,13 @@ __attribute__((weak)) void spi_init(void) { chThdSleepMilliseconds(10); #if defined(USE_GPIOV1) - palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_STM32_ALTERNATE_PUSHPULL); - palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_STM32_ALTERNATE_PUSHPULL); - palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), PAL_MODE_STM32_ALTERNATE_PUSHPULL); + palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), SPI_SCK_PAL_MODE); + palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), SPI_MOSI_PAL_MODE); + palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), SPI_MISO_PAL_MODE); #elif defined(HT32_SPI_USE_SPI1) || defined(HT32_SPI_USE_SPI2) - palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_HT32_MODE_AF(SPI_SCK_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL); - palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_HT32_MODE_AF(SPI_MOSI_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL); - palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), PAL_HT32_MODE_AF(SPI_MISO_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_HT32_MODE_AF(SPI_SCK_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_HT32_MODE_AF(SPI_MOSI_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL); + palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), PAL_HT32_MODE_AF(SPI_MISO_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL); #else palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_ALTERNATE(SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); @@ -66,8 +66,56 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) { if (roundedDivisor < 2 || roundedDivisor > 256) { return false; } + +#if defined(K20x) || defined(KL2x) + spiConfig.tar0 = SPIx_CTARn_FMSZ(7) | SPIx_CTARn_ASC(1); + + if (lsbFirst) { + spiConfig.tar0 |= SPIx_CTARn_LSBFE; + } + + switch (mode) { + case 0: + break; + case 1: + spiConfig.tar0 |= SPIx_CTARn_CPHA; + break; + case 2: + spiConfig.tar0 |= SPIx_CTARn_CPOL; + break; + case 3: + spiConfig.tar0 |= SPIx_CTARn_CPHA | SPIx_CTARn_CPOL; + break; + } -#if defined(HT32_SPI_USE_SPI1) || defined(HT32_SPI_USE_SPI2) + switch (roundedDivisor) { + case 2: + spiConfig.tar0 |= SPIx_CTARn_BR(0); + break; + case 4: + spiConfig.tar0 |= SPIx_CTARn_BR(1); + break; + case 8: + spiConfig.tar0 |= SPIx_CTARn_BR(3); + break; + case 16: + spiConfig.tar0 |= SPIx_CTARn_BR(4); + break; + case 32: + spiConfig.tar0 |= SPIx_CTARn_BR(5); + break; + case 64: + spiConfig.tar0 |= SPIx_CTARn_BR(6); + break; + case 128: + spiConfig.tar0 |= SPIx_CTARn_BR(7); + break; + case 256: + spiConfig.tar0 |= SPIx_CTARn_BR(8); + break; + } + +#elif defined(HT32_SPI_USE_SPI1) || defined(HT32_SPI_USE_SPI2) spiConfig.cr0 = SPI_CR0_SELOEN; spiConfig.cr1 = SPI_CR1_MODE | 8; // 8 bits and in master mode From bc761b5170b2f56ce24f4382b187250bc81a311a Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 29 Aug 2021 15:57:07 +0200 Subject: [PATCH 46/88] annepro2: add readme and info.json --- keyboards/annepro2/info.json | 332 +++++++++++++++++++++++++++++++++++ keyboards/annepro2/readme.md | 27 +++ 2 files changed, 359 insertions(+) create mode 100644 keyboards/annepro2/info.json create mode 100644 keyboards/annepro2/readme.md diff --git a/keyboards/annepro2/info.json b/keyboards/annepro2/info.json new file mode 100644 index 000000000000..0e16a1057cc0 --- /dev/null +++ b/keyboards/annepro2/info.json @@ -0,0 +1,332 @@ +{ + "keyboard_name": "Anne Pro 2", + "url": "https://openannepro.github.io/", + "maintainer": "community", + "width": 15, + "height": 5, + "layouts": { + "LAYOUT": { + "layout": [ + { + "label": "~", + "x": 0, + "y": 0 + }, + { + "label": "!", + "x": 1, + "y": 0 + }, + { + "label": "@", + "x": 2, + "y": 0 + }, + { + "label": "#", + "x": 3, + "y": 0 + }, + { + "label": "$", + "x": 4, + "y": 0 + }, + { + "label": "%", + "x": 5, + "y": 0 + }, + { + "label": "^", + "x": 6, + "y": 0 + }, + { + "label": "&", + "x": 7, + "y": 0 + }, + { + "label": "*", + "x": 8, + "y": 0 + }, + { + "label": "(", + "x": 9, + "y": 0 + }, + { + "label": ")", + "x": 10, + "y": 0 + }, + { + "label": "_", + "x": 11, + "y": 0 + }, + { + "label": "+", + "x": 12, + "y": 0 + }, + { + "label": "Backspace", + "x": 13, + "y": 0, + "w": 2 + }, + { + "label": "Tab", + "x": 0, + "y": 1, + "w": 1.5 + }, + { + "label": "Q", + "x": 1.5, + "y": 1 + }, + { + "label": "W", + "x": 2.5, + "y": 1 + }, + { + "label": "E", + "x": 3.5, + "y": 1 + }, + { + "label": "R", + "x": 4.5, + "y": 1 + }, + { + "label": "T", + "x": 5.5, + "y": 1 + }, + { + "label": "Y", + "x": 6.5, + "y": 1 + }, + { + "label": "U", + "x": 7.5, + "y": 1 + }, + { + "label": "I", + "x": 8.5, + "y": 1 + }, + { + "label": "O", + "x": 9.5, + "y": 1 + }, + { + "label": "P", + "x": 10.5, + "y": 1 + }, + { + "label": "{", + "x": 11.5, + "y": 1 + }, + { + "label": "}", + "x": 12.5, + "y": 1 + }, + { + "label": "|", + "x": 13.5, + "y": 1, + "w": 1.5 + }, + { + "label": "Caps Lock", + "x": 0, + "y": 2, + "w": 1.75 + }, + { + "label": "A", + "x": 1.75, + "y": 2 + }, + { + "label": "S", + "x": 2.75, + "y": 2 + }, + { + "label": "D", + "x": 3.75, + "y": 2 + }, + { + "label": "F", + "x": 4.75, + "y": 2 + }, + { + "label": "G", + "x": 5.75, + "y": 2 + }, + { + "label": "H", + "x": 6.75, + "y": 2 + }, + { + "label": "J", + "x": 7.75, + "y": 2 + }, + { + "label": "K", + "x": 8.75, + "y": 2 + }, + { + "label": "L", + "x": 9.75, + "y": 2 + }, + { + "label": ":", + "x": 10.75, + "y": 2 + }, + { + "label": "\"", + "x": 11.75, + "y": 2 + }, + { + "label": "Enter", + "x": 12.75, + "y": 2, + "w": 2.25 + }, + { + "label": "Shift", + "x": 0, + "y": 3, + "w": 2.25 + }, + { + "label": "Z", + "x": 2.25, + "y": 3 + }, + { + "label": "X", + "x": 3.25, + "y": 3 + }, + { + "label": "C", + "x": 4.25, + "y": 3 + }, + { + "label": "V", + "x": 5.25, + "y": 3 + }, + { + "label": "B", + "x": 6.25, + "y": 3 + }, + { + "label": "N", + "x": 7.25, + "y": 3 + }, + { + "label": "M", + "x": 8.25, + "y": 3 + }, + { + "label": "<", + "x": 9.25, + "y": 3 + }, + { + "label": ">", + "x": 10.25, + "y": 3 + }, + { + "label": "?", + "x": 11.25, + "y": 3 + }, + { + "label": "Shift", + "x": 12.25, + "y": 3, + "w": 2.75 + }, + { + "label": "Ctrl", + "x": 0, + "y": 4, + "w": 1.25 + }, + { + "label": "Win", + "x": 1.25, + "y": 4, + "w": 1.25 + }, + { + "label": "Alt", + "x": 2.5, + "y": 4, + "w": 1.25 + }, + { + "x": 3.75, + "y": 4, + "w": 6.25 + }, + { + "label": "Alt", + "x": 10, + "y": 4, + "w": 1.25 + }, + { + "label": "Win", + "x": 11.25, + "y": 4, + "w": 1.25 + }, + { + "label": "Menu", + "x": 12.5, + "y": 4, + "w": 1.25 + }, + { + "label": "Ctrl", + "x": 13.75, + "y": 4, + "w": 1.25 + } + ] + } + } +} \ No newline at end of file diff --git a/keyboards/annepro2/readme.md b/keyboards/annepro2/readme.md new file mode 100644 index 000000000000..c1d11e10d926 --- /dev/null +++ b/keyboards/annepro2/readme.md @@ -0,0 +1,27 @@ +# Anne Pro 2 rev. C15 and C18 QMK firmware + +## Introduction + +This is the QMK firmware repository for the Anne Pro 2 rev. C15 and C18 keyboard. + + +## Layouts + +Keyboard has 60% ANSI standard layout. + + +## How to compile + +After setting up your build environment, you can compile the Anne Pro 2 C18 default keymap by using: + + make annepro2/c18:default + +If you want to compile the Anne Pro 2 C15 default keymap use: + + make annepro2/c15:default + +## Installing + +See the [installing instructions](https://openannepro.github.io/install/) + +See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). \ No newline at end of file From b276ac6845d6cd02c25f7187391b00d7719858b7 Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 29 Aug 2021 15:59:24 +0200 Subject: [PATCH 47/88] annepro2: make code compatible with QMK coding conventions --- keyboards/annepro2/annepro2_ble.c | 70 ++- keyboards/annepro2/c15/config.h | 16 +- keyboards/annepro2/c18/config.h | 18 +- keyboards/annepro2/eeprom_w25x20cl.c | 7 +- keyboards/annepro2/hardfault_handler.c | 42 +- keyboards/annepro2/keymaps/bla/keymap.c | 2 + .../keymaps/default-full-caps/keymap.c | 36 +- .../keymaps/default-layer-indicators/keymap.c | 84 ++-- keyboards/annepro2/keymaps/default/keymap.c | 20 +- .../annepro2/keymaps/multiarrow/keymap.c | 21 +- keyboards/annepro2/keymaps/tech2077/keymap.c | 115 +++-- .../annepro2/keymaps/thomazmoura/keymap.c | 403 ++++++++---------- .../annepro2/keymaps/thomazmoura/rules.mk | 4 +- keyboards/annepro2/mcuconf.h | 31 +- keyboards/annepro2/protocol.c | 146 ++++--- keyboards/annepro2/protocol.h | 127 +++--- 16 files changed, 532 insertions(+), 610 deletions(-) diff --git a/keyboards/annepro2/annepro2_ble.c b/keyboards/annepro2/annepro2_ble.c index 6c19f9b4a158..69a8ba1acfc0 100644 --- a/keyboards/annepro2/annepro2_ble.c +++ b/keyboards/annepro2/annepro2_ble.c @@ -23,32 +23,26 @@ /* -------------------- Static Function Prototypes -------------------------- */ static uint8_t ap2_ble_leds(void); -static void ap2_ble_mouse(report_mouse_t *report); -static void ap2_ble_system(uint16_t data); -static void ap2_ble_consumer(uint16_t data); -static void ap2_ble_keyboard(report_keyboard_t *report); +static void ap2_ble_mouse(report_mouse_t *report); +static void ap2_ble_system(uint16_t data); +static void ap2_ble_consumer(uint16_t data); +static void ap2_ble_keyboard(report_keyboard_t *report); static void ap2_ble_swtich_ble_driver(void); /* -------------------- Static Local Variables ------------------------------ */ static host_driver_t ap2_ble_driver = { - ap2_ble_leds, - ap2_ble_keyboard, - ap2_ble_mouse, - ap2_ble_system, - ap2_ble_consumer, + ap2_ble_leds, ap2_ble_keyboard, ap2_ble_mouse, ap2_ble_system, ap2_ble_consumer, }; -static uint8_t bleMcuWakeup[11] = { - 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02 -}; +static uint8_t bleMcuWakeup[11] = {0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x01, 0x7d, 0x02, 0x01, 0x02}; static uint8_t bleMcuStartBroadcast[11] = { - 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x01, 0x00 // Broadcast ID[0-3] + 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x01, 0x00 // Broadcast ID[0-3] }; static uint8_t bleMcuConnect[11] = { - 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x04, 0x00 // Connect ID [0-3] + 0x7b, 0x12, 0x53, 0x00, 0x03, 0x00, 0x00, 0x7d, 0x40, 0x04, 0x00 // Connect ID [0-3] }; static uint8_t bleMcuSendReport[10] = { @@ -63,24 +57,18 @@ static uint8_t bleMcuUnpair[10] = { 0x7b, 0x12, 0x53, 0x00, 0x02, 0x00, 0x00, 0x7d, 0x40, 0x05, }; -static uint8_t bleMcuBootload[11] = { - 0x7b, 0x10, 0x51, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x01 -}; +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 +#endif // NKRO_ENABLE /* -------------------- Public Function Implementation ---------------------- */ -void annepro2_ble_bootload(void) { - sdWrite(&SD1, bleMcuBootload, 11); -} +void annepro2_ble_bootload(void) { sdWrite(&SD1, bleMcuBootload, 11); } -void annepro2_ble_startup(void) { - sdWrite(&SD1, bleMcuWakeup, 11); -} +void annepro2_ble_startup(void) { sdWrite(&SD1, bleMcuWakeup, 11); } void annepro2_ble_broadcast(uint8_t port) { if (port > 3) { @@ -138,26 +126,29 @@ static void ap2_ble_swtich_ble_driver(void) { } static uint8_t ap2_ble_leds(void) { - return 0; // TODO: Figure out how to obtain LED status -} - -static void ap2_ble_mouse(report_mouse_t *report){ -} - -static void ap2_ble_system(uint16_t data) { + return 0; // TODO: Figure out how to obtain LED status } +static void ap2_ble_mouse(report_mouse_t *report) {} +static void ap2_ble_system(uint16_t data) {} static inline uint16_t CONSUMER2AP2(uint16_t usage) { - switch(usage) { - case AUDIO_VOL_DOWN: return 0x04; - case AUDIO_VOL_UP: return 0x02; - case AUDIO_MUTE: return 0x01; - case TRANSPORT_PLAY_PAUSE: return 0x08; - case TRANSPORT_NEXT_TRACK: return 0x10; - case TRANSPORT_PREV_TRACK: return 0x20; - default: return 0x00; + switch (usage) { + case AUDIO_VOL_DOWN: + return 0x04; + case AUDIO_VOL_UP: + return 0x02; + case AUDIO_MUTE: + return 0x01; + case TRANSPORT_PLAY_PAUSE: + return 0x08; + case TRANSPORT_NEXT_TRACK: + return 0x10; + case TRANSPORT_PREV_TRACK: + return 0x20; + default: + return 0x00; } } @@ -176,4 +167,3 @@ static void ap2_ble_keyboard(report_keyboard_t *report) { sdWrite(&SD1, bleMcuSendReport, 10); sdWrite(&SD1, &report->raw[0], 8); } - diff --git a/keyboards/annepro2/c15/config.h b/keyboards/annepro2/c15/config.h index 7510debe3df3..947700f28b8f 100644 --- a/keyboards/annepro2/c15/config.h +++ b/keyboards/annepro2/c15/config.h @@ -18,13 +18,11 @@ #pragma once /* USB Device descriptor parameter */ -#define VENDOR_ID 0x04d9 -#define PRODUCT_ID 0xa290 -#define DEVICE_VER 0x1337 -#define MANUFACTURER Holtek -#define PRODUCT Anne Pro 2 QMK -#define DESCRIPTION Anne Pro 2 with QMK -#define NAME_SLUG "annepro2" +#define VENDOR_ID 0x04d9 +#define PRODUCT_ID 0xa290 +#define DEVICE_VER 0x1337 +#define MANUFACTURER Holtek +#define PRODUCT Anne Pro 2 QMK #define ANNEPRO2_C15 @@ -42,7 +40,7 @@ #define NUM_LAYOUTS 4 // Matrix keymap - +// clang-format off #define LAYOUT( \ K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ @@ -57,7 +55,7 @@ /* ROW4 */ { K30, KC_NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, KC_NO}, \ /* ROW5 */ { K40, KC_NO, K42, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, K49, K4A, K4B, K4C, KC_NO}, \ } - +// clang-format on /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h index 21a3333f08ec..4b1f8878ab2d 100644 --- a/keyboards/annepro2/c18/config.h +++ b/keyboards/annepro2/c18/config.h @@ -18,13 +18,11 @@ #pragma once /* USB Device descriptor parameter */ -#define VENDOR_ID 0x04d9 -#define PRODUCT_ID 0xa291 -#define DEVICE_VER 0x1337 -#define MANUFACTURER Holtek -#define PRODUCT Anne Pro 2 (c18) QMK -#define DESCRIPTION Anne Pro 2 (c18) with QMK -#define NAME_SLUG "annepro2" +#define VENDOR_ID 0x04d9 +#define PRODUCT_ID 0xa291 +#define DEVICE_VER 0x1337 +#define MANUFACTURER Holtek +#define PRODUCT Anne Pro 2(c18)QMK #define ANNEPRO2_C18 @@ -42,7 +40,7 @@ #define NUM_LAYOUTS 4 // Matrix keymap - +// clang-format off #define LAYOUT( \ K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ @@ -57,7 +55,7 @@ /* ROW4 */ { K30, KC_NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, KC_NO}, \ /* ROW5 */ { K40, KC_NO, K42, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, K49, K4A, K4B, K4C, KC_NO}, \ } - +// clang-format on /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 @@ -73,7 +71,7 @@ // EEPROM Config for W25X20CL #define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN A3 #define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 16 -#define EXTERNAL_EEPROM_BYTE_COUNT 1024 // 262144 +#define EXTERNAL_EEPROM_BYTE_COUNT 1024 // 262144 #define EXTERNAL_EEPROM_PAGE_SIZE 256 #define EXTERNAL_EEPROM_ADDRESS_SIZE 3 #define EXTERNAL_EEPROM_SPI_LSBFIRST false diff --git a/keyboards/annepro2/eeprom_w25x20cl.c b/keyboards/annepro2/eeprom_w25x20cl.c index 279aa3978b0a..7272cb3c69ed 100644 --- a/keyboards/annepro2/eeprom_w25x20cl.c +++ b/keyboards/annepro2/eeprom_w25x20cl.c @@ -45,7 +45,7 @@ #define CMD_WRITE 0x02u #define CMD_SECTOR_ERASE 0x20u -#define SR_WIP 0x01u +#define SR_WIP 0x01u // #define DEBUG_EEPROM_OUTPUT @@ -53,9 +53,7 @@ # define EXTERNAL_EEPROM_SPI_TIMEOUT 100 #endif -bool spi_eeprom_start(void) { - return spi_start(EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN, EXTERNAL_EEPROM_SPI_LSBFIRST, EXTERNAL_EEPROM_SPI_MODE, EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR); -} +bool spi_eeprom_start(void) { return spi_start(EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN, EXTERNAL_EEPROM_SPI_LSBFIRST, EXTERNAL_EEPROM_SPI_MODE, EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR); } static spi_status_t spi_eeprom_wait_while_busy(int timeout) { uint32_t deadline = timer_read32() + timeout; @@ -141,7 +139,6 @@ void eeprom_read(void *buf, uint32_t addr, size_t len) { } dprintf("\n"); #endif // DEBUG_EEPROM_OUTPUT - } void eeprom_write(const void *buf, uint32_t addr, size_t len) { diff --git a/keyboards/annepro2/hardfault_handler.c b/keyboards/annepro2/hardfault_handler.c index dd65535feff2..78d2b6417837 100644 --- a/keyboards/annepro2/hardfault_handler.c +++ b/keyboards/annepro2/hardfault_handler.c @@ -4,38 +4,44 @@ #define bkpt() __asm volatile("BKPT #0\n") OSAL_IRQ_HANDLER(HardFault_Handler) { -//Copy to local variables (not pointers) to allow GDB "i loc" to directly show the info - struct port_extctx ctx; - volatile unsigned long _CFSR ; - volatile unsigned long _HFSR ; - volatile unsigned long _DFSR ; - volatile unsigned long _AFSR ; - volatile unsigned long _BFAR ; - volatile unsigned long _MMAR ; - //Get thread context. Contains main registers including PC and LR - memcpy(&ctx, (void*)__get_PSP(), sizeof(struct port_extctx)); + // Copy to local variables (not pointers) to allow GDB "i loc" to directly show the info + struct port_extctx ctx; + volatile unsigned long _CFSR; + volatile unsigned long _HFSR; + volatile unsigned long _DFSR; + volatile unsigned long _AFSR; + volatile unsigned long _BFAR; + volatile unsigned long _MMAR; + // Get thread context. Contains main registers including PC and LR + memcpy(&ctx, (void *)__get_PSP(), sizeof(struct port_extctx)); (void)ctx; // Configurable Fault Status Register // Consists of MMSR, BFSR and UFSR - _CFSR = (*((volatile unsigned long *)(0xE000ED28))); (void)(_CFSR); + _CFSR = (*((volatile unsigned long *)(0xE000ED28))); + (void)(_CFSR); // Hard Fault Status Register - _HFSR = (*((volatile unsigned long *)(0xE000ED2C))); (void)(_HFSR); + _HFSR = (*((volatile unsigned long *)(0xE000ED2C))); + (void)(_HFSR); // Debug Fault Status Register - _DFSR = (*((volatile unsigned long *)(0xE000ED30))); (void)(_DFSR); + _DFSR = (*((volatile unsigned long *)(0xE000ED30))); + (void)(_DFSR); // Auxiliary Fault Status Register - _AFSR = (*((volatile unsigned long *)(0xE000ED3C))); (void)(_AFSR); + _AFSR = (*((volatile unsigned long *)(0xE000ED3C))); + (void)(_AFSR); // Read the Fault Address Registers. These may not contain valid values. // Check BFARVALID/MMARVALID to see if they are valid values // MemManage Fault Address Register - _MMAR = (*((volatile unsigned long *)(0xE000ED34))) ; (void)(_MMAR); + _MMAR = (*((volatile unsigned long *)(0xE000ED34))); + (void)(_MMAR); // Bus Fault Address Register - _BFAR = (*((volatile unsigned long *)(0xE000ED38))); (void)(_BFAR); - //Cause debugger to stop. Ignored if no debugger is attached + _BFAR = (*((volatile unsigned long *)(0xE000ED38))); + (void)(_BFAR); + // Cause debugger to stop. Ignored if no debugger is attached bkpt(); - NVIC_SystemReset(); // If no debugger connected, just reset the board + NVIC_SystemReset(); // If no debugger connected, just reset the board } diff --git a/keyboards/annepro2/keymaps/bla/keymap.c b/keyboards/annepro2/keymaps/bla/keymap.c index c0af30ff56bc..c0d72cdef63e 100644 --- a/keyboards/annepro2/keymaps/bla/keymap.c +++ b/keyboards/annepro2/keymaps/bla/keymap.c @@ -36,6 +36,7 @@ enum anne_pro_layers { * | | `~ | | | | LEFT | DOWN | RIGHT | * \-----------------------------------------------------------------------------------------/ */ +// clang-format off const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [_BASE_LAYER] = KEYMAP( /* Base */ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, @@ -89,6 +90,7 @@ enum anne_pro_layers { KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LY), MO(_FN2_LY), KC_TRNS ), }; +// clang-format on const uint16_t keymaps_size = sizeof(keymaps); diff --git a/keyboards/annepro2/keymaps/default-full-caps/keymap.c b/keyboards/annepro2/keymaps/default-full-caps/keymap.c index b65a3108bf10..c67a92644b29 100644 --- a/keyboards/annepro2/keymaps/default-full-caps/keymap.c +++ b/keyboards/annepro2/keymaps/default-full-caps/keymap.c @@ -4,11 +4,13 @@ #include "config.h" enum anne_pro_layers { - _BASE_LAYER, - _FN1_LAYER, - _FN2_LAYER, + _BASE_LAYER, + _FN1_LAYER, + _FN2_LAYER, }; +// clang-format off + // Key symbols are based on QMK. Use them to remap your keyboard /* * Layer _BASE_LAYER @@ -89,15 +91,14 @@ enum anne_pro_layers { KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_TRNS ), }; -const uint16_t keymaps_size = sizeof(keymaps); +// clang-format on -void matrix_init_user(void) { +const uint16_t keymaps_size = sizeof(keymaps); -} +void matrix_init_user(void) {} -void matrix_scan_user(void) { -} +void matrix_scan_user(void) {} // Code to run after initializing the keyboard void keyboard_post_init_user(void) { @@ -111,19 +112,16 @@ void keyboard_post_init_user(void) { // annepro2LedSetProfile(i); } -layer_state_t layer_state_set_user(layer_state_t layer) { - return layer; -} +layer_state_t layer_state_set_user(layer_state_t layer) { return layer; } // The function to handle the caps lock logic bool led_update_user(led_t leds) { - if (leds.caps_lock) { - // Set the leds to red - annepro2LedSetForegroundColor(0xFF, 0x00, 0x00); - } else { - annepro2LedResetForegroundColor(); - } + if (leds.caps_lock) { + // Set the leds to red + annepro2LedSetForegroundColor(0xFF, 0x00, 0x00); + } else { + annepro2LedResetForegroundColor(); + } - return true; + return true; } - diff --git a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c index 6cabda933006..c840145f454d 100644 --- a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c +++ b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c @@ -4,11 +4,13 @@ #include "config.h" enum anne_pro_layers { - _BASE_LAYER, - _FN1_LAYER, - _FN2_LAYER, + _BASE_LAYER, + _FN1_LAYER, + _FN2_LAYER, }; +// clang-format off + // Key symbols are based on QMK. Use them to remap your keyboard /* * Layer _BASE_LAYER @@ -89,15 +91,13 @@ enum anne_pro_layers { KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_TRNS ), }; -const uint16_t keymaps_size = sizeof(keymaps); +// clang-format on +const uint16_t keymaps_size = sizeof(keymaps); -void matrix_init_user(void) { +void matrix_init_user(void) {} -} - -void matrix_scan_user(void) { -} +void matrix_scan_user(void) {} // Code to run after initializing the keyboard void keyboard_post_init_user(void) { @@ -112,50 +112,40 @@ void keyboard_post_init_user(void) { } layer_state_t layer_state_set_user(layer_state_t layer) { - switch(get_highest_layer(layer)) { - case _FN1_LAYER: - // Set the leds to green - annepro2LedSetForegroundColor(0x00, 0xFF, 0x00); - break; - case _FN2_LAYER: - // Set the leds to blue - annepro2LedSetForegroundColor(0x00, 0x00, 0xFF); - break; - default: - // Reset back to the current profile - annepro2LedResetForegroundColor(); - break; - } - return layer; + switch (get_highest_layer(layer)) { + case _FN1_LAYER: + // Set the leds to green + annepro2LedSetForegroundColor(0x00, 0xFF, 0x00); + break; + case _FN2_LAYER: + // Set the leds to blue + annepro2LedSetForegroundColor(0x00, 0x00, 0xFF); + break; + default: + // Reset back to the current profile + annepro2LedResetForegroundColor(); + break; + } + return layer; } // The function to handle the caps lock logic // It's called after the capslock changes state or after entering layers 1 and 2. bool led_update_user(led_t leds) { - if (leds.caps_lock) { - // Set the caps-lock to red - const annepro2Led_t color = { - .p.red = 0xff, - .p.green = 0x00, - .p.blue = 0x00, - .p.alpha = 0xff - }; + if (leds.caps_lock) { + // Set the caps-lock to red + const annepro2Led_t color = {.p.red = 0xff, .p.green = 0x00, .p.blue = 0x00, .p.alpha = 0xff}; - annepro2LedMaskSetKey(2, 0, color); - /* NOTE: Instead of colouring the capslock only, you can change the whole - keyboard with annepro2LedSetForegroundColor */ - } else { - // Reset the capslock if there is no layer active - if(!layer_state_is(_FN1_LAYER) && !layer_state_is(_FN2_LAYER)) { - const annepro2Led_t color = { - .p.red = 0xff, - .p.green = 0x00, - .p.blue = 0x00, - .p.alpha = 0x00 - }; - annepro2LedMaskSetKey(2, 0, color); + annepro2LedMaskSetKey(2, 0, color); + /* NOTE: Instead of colouring the capslock only, you can change the whole + keyboard with annepro2LedSetForegroundColor */ + } else { + // Reset the capslock if there is no layer active + if (!layer_state_is(_FN1_LAYER) && !layer_state_is(_FN2_LAYER)) { + const annepro2Led_t color = {.p.red = 0xff, .p.green = 0x00, .p.blue = 0x00, .p.alpha = 0x00}; + annepro2LedMaskSetKey(2, 0, color); + } } - } - return true; + return true; } diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 71a969fafb0a..95a72a1df771 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -4,11 +4,12 @@ #include "config.h" enum anne_pro_layers { - _BASE_LAYER, - _FN1_LAYER, - _FN2_LAYER, + _BASE_LAYER, + _FN1_LAYER, + _FN2_LAYER, }; +// clang-format off // Key symbols are based on QMK. Use them to remap your keyboard /* * Layer _BASE_LAYER @@ -89,15 +90,12 @@ enum anne_pro_layers { KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_TRNS ), }; +// clang-format on const uint16_t keymaps_size = sizeof(keymaps); +void matrix_init_user(void) {} -void matrix_init_user(void) { - -} - -void matrix_scan_user(void) { -} +void matrix_scan_user(void) {} // Code to run after initializing the keyboard void keyboard_post_init_user(void) { @@ -111,6 +109,4 @@ void keyboard_post_init_user(void) { // annepro2LedSetProfile(i); } -layer_state_t layer_state_set_user(layer_state_t layer) { - return layer; -} +layer_state_t layer_state_set_user(layer_state_t layer) { return layer; } diff --git a/keyboards/annepro2/keymaps/multiarrow/keymap.c b/keyboards/annepro2/keymaps/multiarrow/keymap.c index a71bfe92ef6c..cfdf360dda14 100644 --- a/keyboards/annepro2/keymaps/multiarrow/keymap.c +++ b/keyboards/annepro2/keymaps/multiarrow/keymap.c @@ -3,11 +3,11 @@ #include "qmk_ap2_led.h" enum anne_pro_layers { - _BASE_LAYER, - _FN1_LAYER, - _FN2_LAYER, + _BASE_LAYER, + _FN1_LAYER, + _FN2_LAYER, }; - +// clang-format off /* * Layer _BASE_LAYER * ,-----------------------------------------------------------------------------------------. @@ -76,16 +76,11 @@ enum anne_pro_layers { KC_TRNS, KC_TRNS, KC_TRNS, KC_ENT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS ), }; +// clang-format on const uint16_t keymaps_size = sizeof(keymaps); +void matrix_init_user(void) {} -void matrix_init_user(void) { - -} - -void matrix_scan_user(void) { -} +void matrix_scan_user(void) {} -layer_state_t layer_state_set_user(layer_state_t layer) { - return layer; -} +layer_state_t layer_state_set_user(layer_state_t layer) { return layer; } diff --git a/keyboards/annepro2/keymaps/tech2077/keymap.c b/keyboards/annepro2/keymaps/tech2077/keymap.c index f35555c897c7..c1b75ce68b37 100644 --- a/keyboards/annepro2/keymaps/tech2077/keymap.c +++ b/keyboards/annepro2/keymaps/tech2077/keymap.c @@ -3,7 +3,7 @@ #include #include "qmk_ap2_led.h" #ifdef ANNEPRO2_C18 -#include "eeprom_w25x20cl.h" +# include "eeprom_w25x20cl.h" #endif // layout using eeprom and bidir-comms to keep user led settings persistent @@ -13,7 +13,7 @@ typedef union { uint32_t raw; struct { uint8_t magic : 8; - bool leds_on : 1; + bool leds_on : 1; uint8_t leds_profile : 8; }; } user_config_t; @@ -29,7 +29,7 @@ enum anne_pro_layers { _FN1_LAYER, _FN2_LAYER, }; - +// clang-format off /* * Layer _BASE_LAYER * ,-----------------------------------------------------------------------------------------. @@ -106,91 +106,82 @@ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), MO(_FN1_LAYER), KC_TRNS), }; +// clang-format on const uint16_t keymaps_size = sizeof(keymaps); -void matrix_init_user(void) -{ -} +void matrix_init_user(void) {} -void matrix_scan_user(void) -{ -} +void matrix_scan_user(void) {} -layer_state_t layer_state_set_user(layer_state_t layer) -{ - return layer; -} +layer_state_t layer_state_set_user(layer_state_t layer) { return layer; } -void raw_hid_receive(uint8_t *data, uint8_t length) { - uprintf("raw_hid len: %u\n", length); - if (length == 1) - annepro2LedSetProfile(data[0]); - else { - for (uint8_t i = 0; i < length; i++){ - usb_buf[buf_fil + i] = data[i]; - } - buf_fil += length; - if (buf_fil >= 211) { - sdWrite(&SD0, usb_buf, 211); - buf_fil = 0; +void raw_hid_receive(uint8_t* data, uint8_t length) { + uprintf("raw_hid len: %u\n", length); + if (length == 1) + annepro2LedSetProfile(data[0]); + else { + for (uint8_t i = 0; i < length; i++) { + usb_buf[buf_fil + i] = data[i]; + } + buf_fil += length; + if (buf_fil >= 211) { + sdWrite(&SD0, usb_buf, 211); + buf_fil = 0; + } + // for (int i = 0; i < length; i++) { + // sdPut(&SD0, data[i]); + // sdGet(&SD0); + // } } -// for (int i = 0; i < length; i++) { -// sdPut(&SD0, data[i]); -// sdGet(&SD0); -// } - } } /*! * @returns false processing for this keycode has been completed. */ -bool process_record_user(uint16_t keycode, keyrecord_t* record) -{ +bool process_record_user(uint16_t keycode, keyrecord_t* record) { #ifdef ANNEPRO2_C18 switch (keycode) { - case KC_AP_LED_OFF: - if (record->event.pressed) { - user_config.leds_on = false; - eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); - } - return false; - case KC_AP_LED_ON: - if (record->event.pressed) { - user_config.leds_on = true; - eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); - } - return false; - case KC_AP_LED_NEXT_PROFILE: - if (record->event.pressed) { - user_config.leds_profile = (user_config.leds_profile + 1) % annepro2LedStatus.amountOfProfiles; - annepro2LedSetProfile(user_config.leds_profile); - eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); - } - return false; - default: - break; + case KC_AP_LED_OFF: + if (record->event.pressed) { + user_config.leds_on = false; + eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); + } + return false; + case KC_AP_LED_ON: + if (record->event.pressed) { + user_config.leds_on = true; + eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); + } + return false; + case KC_AP_LED_NEXT_PROFILE: + if (record->event.pressed) { + user_config.leds_profile = (user_config.leds_profile + 1) % annepro2LedStatus.amountOfProfiles; + annepro2LedSetProfile(user_config.leds_profile); + eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); + } + return false; + default: + break; } #endif return true; } -void keyboard_post_init_user(void) -{ +void keyboard_post_init_user(void) { // Customize these values to desired behavior debug_enable = true; - //debug_matrix = true; - //debug_keyboard=true; - //debug_mouse=true; + // debug_matrix = true; + // debug_keyboard=true; + // debug_mouse=true; #ifdef ANNEPRO2_C18 // Read the user config from EEPROM eeprom_read((void*)&user_config, 0, sizeof(user_config_t)); // initialize a new eeprom - if (user_config.magic != 0xDE) - { - user_config.magic = 0xDE; - user_config.leds_on = false; + if (user_config.magic != 0xDE) { + user_config.magic = 0xDE; + user_config.leds_on = false; user_config.leds_profile = 0; eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); } diff --git a/keyboards/annepro2/keymaps/thomazmoura/keymap.c b/keyboards/annepro2/keymaps/thomazmoura/keymap.c index 6db81c6876bc..d0cc498b6fad 100644 --- a/keyboards/annepro2/keymaps/thomazmoura/keymap.c +++ b/keyboards/annepro2/keymaps/thomazmoura/keymap.c @@ -4,60 +4,32 @@ #include "config.h" enum anne_pro_layers { - _BASE_LAYER, - _MOUSE_LAYER, - _FUNCTION_LAYER, - _MEDIA_AND_NAVIGATION_LAYER, - _NUMPAD_LAYER, + _BASE_LAYER, + _MOUSE_LAYER, + _FUNCTION_LAYER, + _MEDIA_AND_NAVIGATION_LAYER, + _NUMPAD_LAYER, }; typedef struct { - bool is_press_action; + bool is_press_action; uint8_t state; } tap; // Define a type for as many tap dance states as you need -enum { - SINGLE_TAP = 1, - SINGLE_HOLD, - DOUBLE_TAP, - DOUBLE_HOLD, - TRIPLE_TAP, - TRIPLE_HOLD -}; +enum { SINGLE_TAP = 1, SINGLE_HOLD, DOUBLE_TAP, DOUBLE_HOLD, TRIPLE_TAP, TRIPLE_HOLD }; -enum profile { - RED, - GREEN, - BLUE, - RAINBOWHORIZONTAL, - RAINBOWVERTICAL, - ANIMATEDRAINBOWVERTICAL, - ANIMATEDRAINBOWFLOW, - ANIMATEDRAINBOWWATERFALL, - ANIMATEDBREATHING, - ANIMATEDSPECTRUM -}; +enum profile { RED, GREEN, BLUE, RAINBOWHORIZONTAL, RAINBOWVERTICAL, ANIMATEDRAINBOWVERTICAL, ANIMATEDRAINBOWFLOW, ANIMATEDRAINBOWWATERFALL, ANIMATEDBREATHING, ANIMATEDSPECTRUM }; -uint8_t cyclabe_profiles[] = { - IDLE_PROFILE_INDEX, - ANIMATEDRAINBOWFLOW, - ANIMATEDRAINBOWVERTICAL, - ANIMATEDRAINBOWWATERFALL, - ANIMATEDBREATHING, - ANIMATEDSPECTRUM -}; +uint8_t cyclabe_profiles[] = {IDLE_PROFILE_INDEX, ANIMATEDRAINBOWFLOW, ANIMATEDRAINBOWVERTICAL, ANIMATEDRAINBOWWATERFALL, ANIMATEDBREATHING, ANIMATEDSPECTRUM}; -enum custom_codes { - NEXT_PROFILE = AP2_SAFE_RANGE, - ENABLE_OR_DISABLE_LEDS -}; +enum custom_codes { NEXT_PROFILE = AP2_SAFE_RANGE, ENABLE_OR_DISABLE_LEDS }; enum { ESC_TAP_DANCE, GRV_TAP_DANCE, }; - +// clang-format off /* * Layer _BASE_LAYER * ,-----------------------------------------------------------------------------------------. @@ -179,241 +151,234 @@ enum { _______, _______, _______, KC_BTN1, _______, _______, _______, _______ ), }; +// clang-format on const uint16_t keymaps_size = sizeof(keymaps); - // Declare the functions to be used with your tap dance key(s) // Function associated with all tap dances uint8_t cur_dance(qk_tap_dance_state_t *state); // Functions associated with individual tap dances -void enableProfileColor(uint8_t * profile); +void enableProfileColor(uint8_t *profile); void resetProfileColor(void); void esc_layer_finished(qk_tap_dance_state_t *state, void *user_data); void esc_layer_reset(qk_tap_dance_state_t *state, void *user_data); -bool is_caps_set = false; -bool is_led_on = true; +bool is_caps_set = false; +bool is_led_on = true; uint8_t base_profile = IDLE_PROFILE_INDEX; -uint8_t idle_profile[] = {0x00,0x00,0x00}; -uint8_t caps_profile[] = {0xFF,0x00,0x00}; -uint8_t function_profile[] = {0x00,0xFF,0x00}; -uint8_t navigation_profile[] = {0x44,0x00,0xFF}; -uint8_t numpad_profile[] = {0xFF,0xDD,0x00}; -uint8_t mouse_profile[] = {0x00,0x88,0xFF}; +uint8_t idle_profile[] = {0x00, 0x00, 0x00}; +uint8_t caps_profile[] = {0xFF, 0x00, 0x00}; +uint8_t function_profile[] = {0x00, 0xFF, 0x00}; +uint8_t navigation_profile[] = {0x44, 0x00, 0xFF}; +uint8_t numpad_profile[] = {0xFF, 0xDD, 0x00}; +uint8_t mouse_profile[] = {0x00, 0x88, 0xFF}; -void matrix_init_user(void) { +void matrix_init_user(void) {} -} - -void matrix_scan_user(void) { -} +void matrix_scan_user(void) {} void keyboard_post_init_user(void) { - annepro2LedEnable(); - resetProfileColor(); + annepro2LedEnable(); + resetProfileColor(); } // The function to handle the caps lock logic bool led_update_user(led_t leds) { - if (leds.caps_lock) { - is_caps_set = true; - enableProfileColor(caps_profile); - return true; - } else if(is_caps_set) { - is_caps_set = false; - resetProfileColor(); - } + if (leds.caps_lock) { + is_caps_set = true; + enableProfileColor(caps_profile); + return true; + } else if (is_caps_set) { + is_caps_set = false; + resetProfileColor(); + } - return true; + return true; } layer_state_t layer_state_set_user(layer_state_t state) { - switch(get_highest_layer(state)) { - case _FUNCTION_LAYER: - enableProfileColor(function_profile); - break; - case _NUMPAD_LAYER: - enableProfileColor(numpad_profile); - break; - case _MOUSE_LAYER: - enableProfileColor(mouse_profile); - break; - case _MEDIA_AND_NAVIGATION_LAYER: - enableProfileColor(navigation_profile); - break; - default: - resetProfileColor(); - break; - } - - return state; + switch (get_highest_layer(state)) { + case _FUNCTION_LAYER: + enableProfileColor(function_profile); + break; + case _NUMPAD_LAYER: + enableProfileColor(numpad_profile); + break; + case _MOUSE_LAYER: + enableProfileColor(mouse_profile); + break; + case _MEDIA_AND_NAVIGATION_LAYER: + enableProfileColor(navigation_profile); + break; + default: + resetProfileColor(); + break; + } + + return state; } // Determine the current tap dance state uint8_t cur_dance(qk_tap_dance_state_t *state) { - if (state->count == 1) { - if (!state->pressed) return SINGLE_TAP; - else return SINGLE_HOLD; - } else if (state->count == 2) { - if (!state->pressed) return DOUBLE_TAP; - else return DOUBLE_HOLD; - } else if (state->count == 3) { - if (!state->pressed) return TRIPLE_TAP; - else return TRIPLE_HOLD; - } else return 8; + if (state->count == 1) { + if (!state->pressed) + return SINGLE_TAP; + else + return SINGLE_HOLD; + } else if (state->count == 2) { + if (!state->pressed) + return DOUBLE_TAP; + else + return DOUBLE_HOLD; + } else if (state->count == 3) { + if (!state->pressed) + return TRIPLE_TAP; + else + return TRIPLE_HOLD; + } else + return 8; } // Initialize tap structure associated with example tap dance key -static tap esc_tap_state = { - .is_press_action = true, - .state = 0 -}; +static tap esc_tap_state = {.is_press_action = true, .state = 0}; -static tap grav_tap_state = { - .is_press_action = true, - .state = 0 -}; +static tap grav_tap_state = {.is_press_action = true, .state = 0}; -void enableProfileColor (uint8_t * profile) { - if(is_caps_set) { - annepro2LedSetForegroundColor(caps_profile[0], caps_profile[1], caps_profile[2]); - } else { - annepro2LedSetForegroundColor(profile[0], profile[1], profile[2]); - } +void enableProfileColor(uint8_t *profile) { + if (is_caps_set) { + annepro2LedSetForegroundColor(caps_profile[0], caps_profile[1], caps_profile[2]); + } else { + annepro2LedSetForegroundColor(profile[0], profile[1], profile[2]); + } } void resetProfileColor(void) { - if(is_caps_set) { - annepro2LedSetForegroundColor(caps_profile[0], caps_profile[1], caps_profile[2]); - } else if(base_profile == IDLE_PROFILE_INDEX) { - annepro2LedSetForegroundColor(idle_profile[0], idle_profile[1], idle_profile[2]); - } else { - annepro2LedSetProfile(cyclabe_profiles[base_profile]); - } + if (is_caps_set) { + annepro2LedSetForegroundColor(caps_profile[0], caps_profile[1], caps_profile[2]); + } else if (base_profile == IDLE_PROFILE_INDEX) { + annepro2LedSetForegroundColor(idle_profile[0], idle_profile[1], idle_profile[2]); + } else { + annepro2LedSetProfile(cyclabe_profiles[base_profile]); + } } bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case NEXT_PROFILE: - if (record->event.pressed) { - base_profile++; - if(base_profile >= (sizeof(cyclabe_profiles)/sizeof(cyclabe_profiles[0]))) - base_profile = IDLE_PROFILE_INDEX; - - if(base_profile == IDLE_PROFILE_INDEX) { - annepro2LedSetForegroundColor(idle_profile[0], idle_profile[1], idle_profile[2]); - } else { - annepro2LedSetProfile(cyclabe_profiles[base_profile]); - } - } - return true; - case ENABLE_OR_DISABLE_LEDS: - if (record->event.pressed) { - if(is_led_on) { - is_led_on = false; - annepro2LedDisable(); - } else { - annepro2LedEnable(); - is_led_on = true; - } - } - return true; - default: - return true; - } + switch (keycode) { + case NEXT_PROFILE: + if (record->event.pressed) { + base_profile++; + if (base_profile >= (sizeof(cyclabe_profiles) / sizeof(cyclabe_profiles[0]))) base_profile = IDLE_PROFILE_INDEX; + + if (base_profile == IDLE_PROFILE_INDEX) { + annepro2LedSetForegroundColor(idle_profile[0], idle_profile[1], idle_profile[2]); + } else { + annepro2LedSetProfile(cyclabe_profiles[base_profile]); + } + } + return true; + case ENABLE_OR_DISABLE_LEDS: + if (record->event.pressed) { + if (is_led_on) { + is_led_on = false; + annepro2LedDisable(); + } else { + annepro2LedEnable(); + is_led_on = true; + } + } + return true; + default: + return true; + } } // Functions that control what our tap dance key does void esc_layer_finished(qk_tap_dance_state_t *state, void *user_data) { - esc_tap_state.state = cur_dance(state); - - switch (esc_tap_state.state) { - case SINGLE_TAP: - tap_code(KC_ESC); - break; - case SINGLE_HOLD: - layer_on(_FUNCTION_LAYER); - break; - case DOUBLE_TAP: - if (layer_state_is(_MOUSE_LAYER) || layer_state_is(_NUMPAD_LAYER)) { - layer_off(_MOUSE_LAYER); - layer_off(_NUMPAD_LAYER); - } else { - tap_code(KC_ESC); - tap_code(KC_ESC); - } - break; - case DOUBLE_HOLD: - layer_on(_NUMPAD_LAYER); - break; - case TRIPLE_TAP: - if (layer_state_is(_MOUSE_LAYER)) { - layer_off(_MOUSE_LAYER); - } else { - layer_on(_MOUSE_LAYER); - } - break; - case TRIPLE_HOLD: - layer_on(_MOUSE_LAYER); - break; - } + esc_tap_state.state = cur_dance(state); + + switch (esc_tap_state.state) { + case SINGLE_TAP: + tap_code(KC_ESC); + break; + case SINGLE_HOLD: + layer_on(_FUNCTION_LAYER); + break; + case DOUBLE_TAP: + if (layer_state_is(_MOUSE_LAYER) || layer_state_is(_NUMPAD_LAYER)) { + layer_off(_MOUSE_LAYER); + layer_off(_NUMPAD_LAYER); + } else { + tap_code(KC_ESC); + tap_code(KC_ESC); + } + break; + case DOUBLE_HOLD: + layer_on(_NUMPAD_LAYER); + break; + case TRIPLE_TAP: + if (layer_state_is(_MOUSE_LAYER)) { + layer_off(_MOUSE_LAYER); + } else { + layer_on(_MOUSE_LAYER); + } + break; + case TRIPLE_HOLD: + layer_on(_MOUSE_LAYER); + break; + } } void esc_layer_reset(qk_tap_dance_state_t *state, void *user_data) { - // If the key was held down and now is released then switch off the layer - if (esc_tap_state.state == SINGLE_HOLD) { - layer_off(_FUNCTION_LAYER); - } - if (esc_tap_state.state == DOUBLE_HOLD) { - layer_off(_NUMPAD_LAYER); - } - if (esc_tap_state.state == TRIPLE_HOLD) { - layer_off(_MOUSE_LAYER); - } - esc_tap_state.state = 0; + // If the key was held down and now is released then switch off the layer + if (esc_tap_state.state == SINGLE_HOLD) { + layer_off(_FUNCTION_LAYER); + } + if (esc_tap_state.state == DOUBLE_HOLD) { + layer_off(_NUMPAD_LAYER); + } + if (esc_tap_state.state == TRIPLE_HOLD) { + layer_off(_MOUSE_LAYER); + } + esc_tap_state.state = 0; } // Functions that control what our tap dance key does void grave_layer_finished(qk_tap_dance_state_t *state, void *user_data) { - grav_tap_state.state = cur_dance(state); - - switch (grav_tap_state.state) { - case SINGLE_TAP: - tap_code(KC_GRV); - break; - case SINGLE_HOLD: - tap_code(KC_GRV); - break; - case DOUBLE_TAP: - // Check to see if the layer is already set - if (layer_state_is(_MOUSE_LAYER)) { - // If already set, then switch it off - layer_off(_MOUSE_LAYER); - } else { - // If not already set, then switch the layer on - layer_on(_MOUSE_LAYER); - } - break; - } + grav_tap_state.state = cur_dance(state); + + switch (grav_tap_state.state) { + case SINGLE_TAP: + tap_code(KC_GRV); + break; + case SINGLE_HOLD: + tap_code(KC_GRV); + break; + case DOUBLE_TAP: + // Check to see if the layer is already set + if (layer_state_is(_MOUSE_LAYER)) { + // If already set, then switch it off + layer_off(_MOUSE_LAYER); + } else { + // If not already set, then switch the layer on + layer_on(_MOUSE_LAYER); + } + break; + } } void grave_layer_reset(qk_tap_dance_state_t *state, void *user_data) { - // If the key was held down and now is released then switch off the layer - if (grav_tap_state.state == SINGLE_HOLD) { - layer_off(_FUNCTION_LAYER); - } - if (grav_tap_state.state == DOUBLE_HOLD) { - layer_off(_NUMPAD_LAYER); - } - grav_tap_state.state = 0; + // If the key was held down and now is released then switch off the layer + if (grav_tap_state.state == SINGLE_HOLD) { + layer_off(_FUNCTION_LAYER); + } + if (grav_tap_state.state == DOUBLE_HOLD) { + layer_off(_NUMPAD_LAYER); + } + grav_tap_state.state = 0; } // Associate our tap dance key with its functionality -qk_tap_dance_action_t tap_dance_actions[] = { - [ESC_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(NULL, esc_layer_finished, esc_layer_reset, 250), - [GRV_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(NULL, grave_layer_finished, grave_layer_reset, 300) -}; - +qk_tap_dance_action_t tap_dance_actions[] = {[ESC_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(NULL, esc_layer_finished, esc_layer_reset, 250), [GRV_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(NULL, grave_layer_finished, grave_layer_reset, 300)}; diff --git a/keyboards/annepro2/keymaps/thomazmoura/rules.mk b/keyboards/annepro2/keymaps/thomazmoura/rules.mk index 2b6ec483cca1..3534b644a15c 100644 --- a/keyboards/annepro2/keymaps/thomazmoura/rules.mk +++ b/keyboards/annepro2/keymaps/thomazmoura/rules.mk @@ -18,9 +18,9 @@ MCU = cortex-m0plus ARMV = 6 USE_FPU = no MCU_FAMILY = HT32 -MCU_SERIES = HT32F523x2 +MCU_SERIES = HT32F523xx MCU_LDSCRIPT = HT32F52342_ANNEPRO2 -MCU_STARTUP = ht32f523x2 +MCU_STARTUP = ht32f523xx BOARD = ANNEPRO2_C18 diff --git a/keyboards/annepro2/mcuconf.h b/keyboards/annepro2/mcuconf.h index d57afebd4a65..12b8771baa87 100644 --- a/keyboards/annepro2/mcuconf.h +++ b/keyboards/annepro2/mcuconf.h @@ -35,33 +35,32 @@ // 48 MHz to UART // 48 MHz to USB -#define HT32_CK_HSE_FREQUENCY 8000000UL // 8 MHz -#define HT32_CKCU_SW CKCU_GCCR_SW_PLL -#define HT32_PLL_USE_HSE TRUE -#define HT32_PLL_FBDIV 6 // 8 MHz -> 48 MHz -#define HT32_PLL_OTDIV 0 -#define HT32_AHB_PRESCALER 1 // 48 MHz -> 48 MHz -#define HT32_USART_PRESCALER 1 // 48 MHz -#define HT32_USB_PRESCALER 1 // 48 MHz -> 48 MHz +#define HT32_CK_HSE_FREQUENCY 8000000UL // 8 MHz +#define HT32_CKCU_SW CKCU_GCCR_SW_PLL +#define HT32_PLL_USE_HSE TRUE +#define HT32_PLL_FBDIV 6 // 8 MHz -> 48 MHz +#define HT32_PLL_OTDIV 0 +#define HT32_AHB_PRESCALER 1 // 48 MHz -> 48 MHz +#define HT32_USART_PRESCALER 1 // 48 MHz +#define HT32_USB_PRESCALER 1 // 48 MHz -> 48 MHz // SysTick uses processor clock at 48MHz -#define HT32_ST_USE_HCLK TRUE +#define HT32_ST_USE_HCLK TRUE /* * Peripheral driver settings */ -#define HT32_SERIAL_USE_USART0 TRUE -#define HT32_USART0_IRQ_PRIORITY 6 +#define HT32_SERIAL_USE_USART0 TRUE +#define HT32_USART0_IRQ_PRIORITY 6 -#define HT32_SERIAL_USE_USART1 TRUE -#define HT32_USART1_IRQ_PRIORITY 7 +#define HT32_SERIAL_USE_USART1 TRUE +#define HT32_USART1_IRQ_PRIORITY 7 /* * USB driver settings */ -#define HT32_USB_USE_USB0 TRUE -#define HT32_USB_USB0_IRQ_PRIORITY 5 - +#define HT32_USB_USE_USB0 TRUE +#define HT32_USB_USB0_IRQ_PRIORITY 5 #endif /* _MCUCONF_H_ */ diff --git a/keyboards/annepro2/protocol.c b/keyboards/annepro2/protocol.c index ff2f328e4c9f..171ac5c23955 100644 --- a/keyboards/annepro2/protocol.c +++ b/keyboards/annepro2/protocol.c @@ -21,98 +21,96 @@ protocol_t proto; void protoInit(protocol_t *proto, void (*callback)(const message_t *)) { - proto->previousId = 0; - proto->callback = callback; - proto->state = STATE_SYNC_1; - proto->errors = 0; + proto->previousId = 0; + proto->callback = callback; + proto->state = STATE_SYNC_1; + proto->errors = 0; } static uint8_t msgId = 0; -void protoTx(uint8_t cmd, const unsigned char *buf, int payloadSize, - int retries) { - chDbgCheck(payloadSize <= MAX_PAYLOAD_SIZE); +void protoTx(uint8_t cmd, const unsigned char *buf, int payloadSize, int retries) { + chDbgCheck(payloadSize <= MAX_PAYLOAD_SIZE); - const uint8_t header[5] = { - 0x7A, 0x1D, cmd, ++msgId, payloadSize, - }; + const uint8_t header[5] = { + 0x7A, 0x1D, cmd, ++msgId, payloadSize, + }; - /* We don't implement ACKs, yet some messages should not be lost. */ - for (int i = 0; i < retries; i++) { - sdWrite(&PROTOCOL_SD, header, sizeof(header)); - if (payloadSize) - sdWrite(&PROTOCOL_SD, buf, payloadSize); - } + /* We don't implement ACKs, yet some messages should not be lost. */ + for (int i = 0; i < retries; i++) { + sdWrite(&PROTOCOL_SD, header, sizeof(header)); + if (payloadSize) sdWrite(&PROTOCOL_SD, buf, payloadSize); + } } static inline void messageReceived(protocol_t *proto) { - if (proto->buffer.msgId != proto->previousId) { - /* It's not a resend / duplicate */ - proto->callback(&proto->buffer); - proto->previousId = proto->buffer.msgId; - } - proto->state = STATE_SYNC_1; + if (proto->buffer.msgId != proto->previousId) { + /* It's not a resend / duplicate */ + proto->callback(&proto->buffer); + proto->previousId = proto->buffer.msgId; + } + proto->state = STATE_SYNC_1; } void protoConsume(protocol_t *proto, uint8_t byte) { - switch (proto->state) { - case STATE_SYNC_1: - if (byte == 0x7A) { - proto->state = STATE_SYNC_2; - } else { - proto->errors++; - } - return; + switch (proto->state) { + case STATE_SYNC_1: + if (byte == 0x7A) { + proto->state = STATE_SYNC_2; + } else { + proto->errors++; + } + return; - case STATE_SYNC_2: - if (byte == 0x1D) { - proto->state = STATE_CMD; - } else { - proto->state = STATE_SYNC_1; - proto->errors++; - } - return; + case STATE_SYNC_2: + if (byte == 0x1D) { + proto->state = STATE_CMD; + } else { + proto->state = STATE_SYNC_1; + proto->errors++; + } + return; - case STATE_CMD: - proto->buffer.command = byte; - proto->state = STATE_ID; - return; + case STATE_CMD: + proto->buffer.command = byte; + proto->state = STATE_ID; + return; - case STATE_ID: - proto->buffer.msgId = byte; - proto->state = STATE_PAYLOAD_SIZE; - return; + case STATE_ID: + proto->buffer.msgId = byte; + proto->state = STATE_PAYLOAD_SIZE; + return; - case STATE_PAYLOAD_SIZE: - proto->buffer.payloadSize = byte; - if (proto->buffer.payloadSize > MAX_PAYLOAD_SIZE) { - proto->buffer.payloadSize = MAX_PAYLOAD_SIZE; - proto->errors++; - } - proto->payloadPosition = 0; - if (proto->buffer.payloadSize == 0) { - /* No payload - whole message received */ - messageReceived(proto); - } else { - proto->state = STATE_PAYLOAD; - } - return; + case STATE_PAYLOAD_SIZE: + proto->buffer.payloadSize = byte; + if (proto->buffer.payloadSize > MAX_PAYLOAD_SIZE) { + proto->buffer.payloadSize = MAX_PAYLOAD_SIZE; + proto->errors++; + } + proto->payloadPosition = 0; + if (proto->buffer.payloadSize == 0) { + /* No payload - whole message received */ + messageReceived(proto); + } else { + proto->state = STATE_PAYLOAD; + } + return; - case STATE_PAYLOAD: - /* NOTE: This could be read with sdReadTimeout probably, but that breaks - * abstraction */ - proto->buffer.payload[proto->payloadPosition] = byte; - proto->payloadPosition++; - if (proto->payloadPosition == proto->buffer.payloadSize) { - /* Payload read - message received */ - messageReceived(proto); + case STATE_PAYLOAD: + /* NOTE: This could be read with sdReadTimeout probably, but that breaks + * abstraction */ + proto->buffer.payload[proto->payloadPosition] = byte; + proto->payloadPosition++; + if (proto->payloadPosition == proto->buffer.payloadSize) { + /* Payload read - message received */ + messageReceived(proto); + } + return; } - return; - } } void protoSilence(protocol_t *proto) { - if (proto->state != STATE_SYNC_1) { - proto->state = STATE_SYNC_1; - proto->errors++; - } + if (proto->state != STATE_SYNC_1) { + proto->state = STATE_SYNC_1; + proto->errors++; + } } diff --git a/keyboards/annepro2/protocol.h b/keyboards/annepro2/protocol.h index 9effea44d618..4e07908b404e 100644 --- a/keyboards/annepro2/protocol.h +++ b/keyboards/annepro2/protocol.h @@ -13,43 +13,43 @@ #define PROTOCOL_SD SD0 enum { - /* - * Main -> LED - */ - /* Basic config */ - CMD_LED_ON = 0x01, - CMD_LED_OFF = 0x02, - - CMD_LED_SET_PROFILE = 0x03, - CMD_LED_NEXT_PROFILE = 0x04, - CMD_LED_PREV_PROFILE = 0x05, - - CMD_LED_NEXT_INTENSITY = 0x06, - CMD_LED_NEXT_ANIMATION_SPEED = 0x07, - - /* Masks */ - /* Override a key color, eg. capslock */ - CMD_LED_MASK_SET_KEY = 0x10, - /* Override all keys in a row with configurable colors */ - CMD_LED_MASK_SET_ROW = 0x11, - - /* Override all keys with single color (eg. foreground color) */ - CMD_LED_MASK_SET_MONO = 0x12, - - /* Reactive / status */ - CMD_LED_GET_STATUS = 0x20, - CMD_LED_KEY_BLINK = 0x21, - CMD_LED_KEY_DOWN = 0x22, - CMD_LED_KEY_UP = 0x23, /* TODO */ - CMD_LED_IAP = 0x24, - - /* LED -> Main */ - /* Payload with data to send over HID */ - CMD_LED_DEBUG = 0x40, - - /* Number of profiles, current profile, on/off state, - reactive flag, brightness, errors */ - CMD_LED_STATUS = 0x41, + /* + * Main -> LED + */ + /* Basic config */ + CMD_LED_ON = 0x01, + CMD_LED_OFF = 0x02, + + CMD_LED_SET_PROFILE = 0x03, + CMD_LED_NEXT_PROFILE = 0x04, + CMD_LED_PREV_PROFILE = 0x05, + + CMD_LED_NEXT_INTENSITY = 0x06, + CMD_LED_NEXT_ANIMATION_SPEED = 0x07, + + /* Masks */ + /* Override a key color, eg. capslock */ + CMD_LED_MASK_SET_KEY = 0x10, + /* Override all keys in a row with configurable colors */ + CMD_LED_MASK_SET_ROW = 0x11, + + /* Override all keys with single color (eg. foreground color) */ + CMD_LED_MASK_SET_MONO = 0x12, + + /* Reactive / status */ + CMD_LED_GET_STATUS = 0x20, + CMD_LED_KEY_BLINK = 0x21, + CMD_LED_KEY_DOWN = 0x22, + CMD_LED_KEY_UP = 0x23, /* TODO */ + CMD_LED_IAP = 0x24, + + /* LED -> Main */ + /* Payload with data to send over HID */ + CMD_LED_DEBUG = 0x40, + + /* Number of profiles, current profile, on/off state, + reactive flag, brightness, errors */ + CMD_LED_STATUS = 0x41, }; /* 1 ROW * 14 COLS * 4B (RGBX) = 56 + header prefix. */ @@ -57,43 +57,43 @@ enum { /** Enum of the states used for the serial protocol finite-state automaton */ enum protoState { - /* 2-byte initial start-of-message sync */ - STATE_SYNC_1, - STATE_SYNC_2, - /* Waiting for command byte */ - STATE_CMD, - /* Waiting for ID byte */ - STATE_ID, - /* Waiting for payload size */ - STATE_PAYLOAD_SIZE, - /* Reading payload until payloadPosition == payloadSize */ - STATE_PAYLOAD, + /* 2-byte initial start-of-message sync */ + STATE_SYNC_1, + STATE_SYNC_2, + /* Waiting for command byte */ + STATE_CMD, + /* Waiting for ID byte */ + STATE_ID, + /* Waiting for payload size */ + STATE_PAYLOAD_SIZE, + /* Reading payload until payloadPosition == payloadSize */ + STATE_PAYLOAD, }; /* Buffer holding a single message */ typedef struct { - uint8_t command; - uint8_t msgId; - uint8_t payloadSize; - uint8_t payload[MAX_PAYLOAD_SIZE]; + uint8_t command; + uint8_t msgId; + uint8_t payloadSize; + uint8_t payload[MAX_PAYLOAD_SIZE]; } message_t; /* Internal protocol state */ typedef struct { - /* Callback to call upon receiving a valid message */ - void (*callback)(const message_t *); + /* Callback to call upon receiving a valid message */ + void (*callback)(const message_t *); - /* Number of read payload bytes */ - uint8_t payloadPosition; + /* Number of read payload bytes */ + uint8_t payloadPosition; - /* Current finite-state-automata state */ - enum protoState state; + /* Current finite-state-automata state */ + enum protoState state; - uint8_t previousId; - uint8_t errors; + uint8_t previousId; + uint8_t errors; - /* Currently received message */ - message_t buffer; + /* Currently received message */ + message_t buffer; } protocol_t; /* NOTE: This didn't work when defined on stack */ @@ -109,7 +109,6 @@ extern void protoConsume(protocol_t *proto, uint8_t byte); extern void protoSilence(protocol_t *proto); /* Transmit message */ -extern void protoTx(uint8_t cmd, const unsigned char *buf, int payloadSize, - int retries); +extern void protoTx(uint8_t cmd, const unsigned char *buf, int payloadSize, int retries); #endif From 83fd7baf5ea57ea673f43550a54a0b858ecc6916 Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 29 Aug 2021 16:33:59 +0200 Subject: [PATCH 48/88] tmk_core: temporary fix to allow HT32 based keyboards to work without patched ChibiOS-contrib (AnnePro2) --- tmk_core/protocol/chibios/usb_main.c | 74 ++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 10 deletions(-) diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index cc282e6a9b44..cfd839b35075 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -103,7 +103,7 @@ static const USBDescriptor *usb_get_descriptor_cb(USBDriver *usbp, uint8_t dtype static USBDescriptor desc; uint16_t wValue = ((uint16_t)dtype << 8) | dindex; desc.ud_string = NULL; - desc.ud_size = get_usb_descriptor(wValue, wIndex, (const void **const) & desc.ud_string); + desc.ud_size = get_usb_descriptor(wValue, wIndex, (const void **const)&desc.ud_string); if (desc.ud_string == NULL) return NULL; else @@ -122,9 +122,13 @@ static const USBEndpointConfig kbd_ep_config = { KEYBOARD_EPSIZE, /* IN maximum packet size */ 0, /* OUT maximum packet size */ &kbd_ep_state, /* IN Endpoint state */ - NULL, /* OUT endpoint state */ - 2, /* IN multiplier */ - NULL /* SETUP buffer (not a SETUP endpoint) */ +# ifndef MCU_HT32 + NULL, /* OUT endpoint state */ + 2, /* IN multiplier */ + NULL /* SETUP buffer (not a SETUP endpoint) */ +# else + NULL /* OUT endpoint state */ +# endif }; #endif @@ -141,9 +145,13 @@ static const USBEndpointConfig mouse_ep_config = { MOUSE_EPSIZE, /* IN maximum packet size */ 0, /* OUT maximum packet size */ &mouse_ep_state, /* IN Endpoint state */ - NULL, /* OUT endpoint state */ - 2, /* IN multiplier */ - NULL /* SETUP buffer (not a SETUP endpoint) */ +# ifndef MCU_HT32 + NULL, /* OUT endpoint state */ + 2, /* IN multiplier */ + NULL /* SETUP buffer (not a SETUP endpoint) */ +# else + NULL /* OUT endpoint state */ +# endif }; #endif @@ -160,9 +168,13 @@ static const USBEndpointConfig shared_ep_config = { SHARED_EPSIZE, /* IN maximum packet size */ 0, /* OUT maximum packet size */ &shared_ep_state, /* IN Endpoint state */ - NULL, /* OUT endpoint state */ - 2, /* IN multiplier */ - NULL /* SETUP buffer (not a SETUP endpoint) */ +# ifndef MCU_HT32 + NULL, /* OUT endpoint state */ + 2, /* IN multiplier */ + NULL /* SETUP buffer (not a SETUP endpoint) */ +# else + NULL /* OUT endpoint state */ +# endif }; #endif @@ -238,6 +250,48 @@ typedef struct { .ob = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \ } \ } +#elif defined(MCU_HT32) +# define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \ + { \ + .queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \ + .in_ep_config = {stream##_IN_MODE, /* Interrupt EP */ \ + NULL, /* SETUP packet notification callback */ \ + qmkusbDataTransmitted, /* IN notification callback */ \ + NULL, /* OUT notification callback */ \ + stream##_EPSIZE, /* IN maximum packet size */ \ + 0, /* OUT maximum packet size */ \ + NULL, /* IN Endpoint state */ \ + NULL}, \ + .out_ep_config = {stream##_OUT_MODE, /* Interrupt EP */ \ + NULL, /* SETUP packet notification callback */ \ + NULL, /* IN notification callback */ \ + qmkusbDataReceived, /* OUT notification callback */ \ + 0, /* IN maximum packet size */ \ + stream##_EPSIZE, /* OUT maximum packet size */ \ + NULL, /* IN Endpoint state */ \ + NULL}, \ + .int_ep_config = {USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ \ + NULL, /* SETUP packet notification callback */ \ + qmkusbInterruptTransmitted, /* IN notification callback */ \ + NULL, /* OUT notification callback */ \ + CDC_NOTIFICATION_EPSIZE, /* IN maximum packet size */ \ + 0, /* OUT maximum packet size */ \ + NULL, /* IN Endpoint state */ \ + NULL}, \ + .config = { \ + .usbp = &USB_DRIVER, \ + .bulk_in = stream##_IN_EPNUM, \ + .bulk_out = stream##_OUT_EPNUM, \ + .int_in = notification, \ + .in_buffers = stream##_IN_CAPACITY, \ + .out_buffers = stream##_OUT_CAPACITY, \ + .in_size = stream##_EPSIZE, \ + .out_size = stream##_EPSIZE, \ + .fixed_size = fixedsize, \ + .ib = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_IN_CAPACITY, stream##_EPSIZE)]){}, \ + .ob = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \ + } \ + } #else /* Reusable initialization structure - see USBEndpointConfig comment at top of file */ # define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \ From d3c57098dd16b57e330fde1489aa977c3ccadd0f Mon Sep 17 00:00:00 2001 From: bwisn Date: Sat, 11 Sep 2021 18:33:26 +0200 Subject: [PATCH 49/88] AnnePro2: removed core changes --- platforms/chibios/drivers/spi_master.c | 32 +---------- tmk_core/protocol/chibios/usb_main.c | 74 ++++---------------------- 2 files changed, 12 insertions(+), 94 deletions(-) diff --git a/platforms/chibios/drivers/spi_master.c b/platforms/chibios/drivers/spi_master.c index c49d807c3bda..28ddcbb2ba67 100644 --- a/platforms/chibios/drivers/spi_master.c +++ b/platforms/chibios/drivers/spi_master.c @@ -41,10 +41,6 @@ __attribute__((weak)) void spi_init(void) { palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), SPI_SCK_PAL_MODE); palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), SPI_MOSI_PAL_MODE); palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), SPI_MISO_PAL_MODE); -#elif defined(HT32_SPI_USE_SPI1) || defined(HT32_SPI_USE_SPI2) - palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_HT32_MODE_AF(SPI_SCK_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL); - palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_HT32_MODE_AF(SPI_MOSI_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL); - palSetPadMode(PAL_PORT(SPI_MISO_PIN), PAL_PAD(SPI_MISO_PIN), PAL_HT32_MODE_AF(SPI_MISO_PAL_MODE) | PAL_MODE_OUTPUT_PUSHPULL); #else palSetPadMode(PAL_PORT(SPI_SCK_PIN), PAL_PAD(SPI_SCK_PIN), PAL_MODE_ALTERNATE(SPI_SCK_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); palSetPadMode(PAL_PORT(SPI_MOSI_PIN), PAL_PAD(SPI_MOSI_PIN), PAL_MODE_ALTERNATE(SPI_MOSI_PAL_MODE) | PAL_STM32_OTYPE_PUSHPULL | PAL_STM32_OSPEED_HIGHEST); @@ -66,7 +62,7 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) { if (roundedDivisor < 2 || roundedDivisor > 256) { return false; } - + #if defined(K20x) || defined(KL2x) spiConfig.tar0 = SPIx_CTARn_FMSZ(7) | SPIx_CTARn_ASC(1); @@ -114,37 +110,13 @@ bool spi_start(pin_t slavePin, bool lsbFirst, uint8_t mode, uint16_t divisor) { spiConfig.tar0 |= SPIx_CTARn_BR(8); break; } - -#elif defined(HT32_SPI_USE_SPI1) || defined(HT32_SPI_USE_SPI2) - spiConfig.cr0 = SPI_CR0_SELOEN; - spiConfig.cr1 = SPI_CR1_MODE | 8; // 8 bits and in master mode - - if (lsbFirst) { - spiConfig.cr1 |= SPI_CR1_FIRSTBIT; - } - - switch (mode) { - case 0: - spiConfig.cr1 |= SPI_CR1_FORMAT_MODE0; - break; - case 1: - spiConfig.cr1 |= SPI_CR1_FORMAT_MODE1; - break; - case 2: - spiConfig.cr1 |= SPI_CR1_FORMAT_MODE2; - break; - case 3: - spiConfig.cr1 |= SPI_CR1_FORMAT_MODE3; - break; - } - - spiConfig.cpr = (roundedDivisor - 1) >> 1; #else spiConfig.cr1 = 0; if (lsbFirst) { spiConfig.cr1 |= SPI_CR1_LSBFIRST; } + switch (mode) { case 0: break; diff --git a/tmk_core/protocol/chibios/usb_main.c b/tmk_core/protocol/chibios/usb_main.c index cfd839b35075..cc282e6a9b44 100644 --- a/tmk_core/protocol/chibios/usb_main.c +++ b/tmk_core/protocol/chibios/usb_main.c @@ -103,7 +103,7 @@ static const USBDescriptor *usb_get_descriptor_cb(USBDriver *usbp, uint8_t dtype static USBDescriptor desc; uint16_t wValue = ((uint16_t)dtype << 8) | dindex; desc.ud_string = NULL; - desc.ud_size = get_usb_descriptor(wValue, wIndex, (const void **const)&desc.ud_string); + desc.ud_size = get_usb_descriptor(wValue, wIndex, (const void **const) & desc.ud_string); if (desc.ud_string == NULL) return NULL; else @@ -122,13 +122,9 @@ static const USBEndpointConfig kbd_ep_config = { KEYBOARD_EPSIZE, /* IN maximum packet size */ 0, /* OUT maximum packet size */ &kbd_ep_state, /* IN Endpoint state */ -# ifndef MCU_HT32 - NULL, /* OUT endpoint state */ - 2, /* IN multiplier */ - NULL /* SETUP buffer (not a SETUP endpoint) */ -# else - NULL /* OUT endpoint state */ -# endif + NULL, /* OUT endpoint state */ + 2, /* IN multiplier */ + NULL /* SETUP buffer (not a SETUP endpoint) */ }; #endif @@ -145,13 +141,9 @@ static const USBEndpointConfig mouse_ep_config = { MOUSE_EPSIZE, /* IN maximum packet size */ 0, /* OUT maximum packet size */ &mouse_ep_state, /* IN Endpoint state */ -# ifndef MCU_HT32 - NULL, /* OUT endpoint state */ - 2, /* IN multiplier */ - NULL /* SETUP buffer (not a SETUP endpoint) */ -# else - NULL /* OUT endpoint state */ -# endif + NULL, /* OUT endpoint state */ + 2, /* IN multiplier */ + NULL /* SETUP buffer (not a SETUP endpoint) */ }; #endif @@ -168,13 +160,9 @@ static const USBEndpointConfig shared_ep_config = { SHARED_EPSIZE, /* IN maximum packet size */ 0, /* OUT maximum packet size */ &shared_ep_state, /* IN Endpoint state */ -# ifndef MCU_HT32 - NULL, /* OUT endpoint state */ - 2, /* IN multiplier */ - NULL /* SETUP buffer (not a SETUP endpoint) */ -# else - NULL /* OUT endpoint state */ -# endif + NULL, /* OUT endpoint state */ + 2, /* IN multiplier */ + NULL /* SETUP buffer (not a SETUP endpoint) */ }; #endif @@ -250,48 +238,6 @@ typedef struct { .ob = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \ } \ } -#elif defined(MCU_HT32) -# define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \ - { \ - .queue_capacity_in = stream##_IN_CAPACITY, .queue_capacity_out = stream##_OUT_CAPACITY, \ - .in_ep_config = {stream##_IN_MODE, /* Interrupt EP */ \ - NULL, /* SETUP packet notification callback */ \ - qmkusbDataTransmitted, /* IN notification callback */ \ - NULL, /* OUT notification callback */ \ - stream##_EPSIZE, /* IN maximum packet size */ \ - 0, /* OUT maximum packet size */ \ - NULL, /* IN Endpoint state */ \ - NULL}, \ - .out_ep_config = {stream##_OUT_MODE, /* Interrupt EP */ \ - NULL, /* SETUP packet notification callback */ \ - NULL, /* IN notification callback */ \ - qmkusbDataReceived, /* OUT notification callback */ \ - 0, /* IN maximum packet size */ \ - stream##_EPSIZE, /* OUT maximum packet size */ \ - NULL, /* IN Endpoint state */ \ - NULL}, \ - .int_ep_config = {USB_EP_MODE_TYPE_INTR, /* Interrupt EP */ \ - NULL, /* SETUP packet notification callback */ \ - qmkusbInterruptTransmitted, /* IN notification callback */ \ - NULL, /* OUT notification callback */ \ - CDC_NOTIFICATION_EPSIZE, /* IN maximum packet size */ \ - 0, /* OUT maximum packet size */ \ - NULL, /* IN Endpoint state */ \ - NULL}, \ - .config = { \ - .usbp = &USB_DRIVER, \ - .bulk_in = stream##_IN_EPNUM, \ - .bulk_out = stream##_OUT_EPNUM, \ - .int_in = notification, \ - .in_buffers = stream##_IN_CAPACITY, \ - .out_buffers = stream##_OUT_CAPACITY, \ - .in_size = stream##_EPSIZE, \ - .out_size = stream##_EPSIZE, \ - .fixed_size = fixedsize, \ - .ib = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_IN_CAPACITY, stream##_EPSIZE)]){}, \ - .ob = (__attribute__((aligned(4))) uint8_t[BQ_BUFFER_SIZE(stream##_OUT_CAPACITY, stream##_EPSIZE)]){}, \ - } \ - } #else /* Reusable initialization structure - see USBEndpointConfig comment at top of file */ # define QMK_USB_DRIVER_CONFIG(stream, notification, fixedsize) \ From 8ad8264cca27ea5280518d17a853c535d7971a9a Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 12 Sep 2021 09:36:16 +0200 Subject: [PATCH 50/88] AnnePro2: Leave only default keymaps Missing keymaps will be restored in another PR --- keyboards/annepro2/keymaps/bla/config.h | 2 - keyboards/annepro2/keymaps/bla/keymap.c | 159 -------- .../annepro2/keymaps/multiarrow/keymap.c | 86 ---- keyboards/annepro2/keymaps/tech2077/keymap.c | 197 --------- keyboards/annepro2/keymaps/tech2077/rules.mk | 13 - .../annepro2/keymaps/thomazmoura/config.h | 15 - .../annepro2/keymaps/thomazmoura/keymap.c | 384 ------------------ .../annepro2/keymaps/thomazmoura/rules.mk | 47 --- 8 files changed, 903 deletions(-) delete mode 100644 keyboards/annepro2/keymaps/bla/config.h delete mode 100644 keyboards/annepro2/keymaps/bla/keymap.c delete mode 100644 keyboards/annepro2/keymaps/multiarrow/keymap.c delete mode 100644 keyboards/annepro2/keymaps/tech2077/keymap.c delete mode 100644 keyboards/annepro2/keymaps/tech2077/rules.mk delete mode 100644 keyboards/annepro2/keymaps/thomazmoura/config.h delete mode 100644 keyboards/annepro2/keymaps/thomazmoura/keymap.c delete mode 100644 keyboards/annepro2/keymaps/thomazmoura/rules.mk diff --git a/keyboards/annepro2/keymaps/bla/config.h b/keyboards/annepro2/keymaps/bla/config.h deleted file mode 100644 index 1840bc748496..000000000000 --- a/keyboards/annepro2/keymaps/bla/config.h +++ /dev/null @@ -1,2 +0,0 @@ -// Obins stock firmware has something similar to this already enabled, but disabled by default in QMK -#define PERMISSIVE_HOLD diff --git a/keyboards/annepro2/keymaps/bla/keymap.c b/keyboards/annepro2/keymaps/bla/keymap.c deleted file mode 100644 index c0d72cdef63e..000000000000 --- a/keyboards/annepro2/keymaps/bla/keymap.c +++ /dev/null @@ -1,159 +0,0 @@ -#include -#include "annepro2.h" -#include "qmk_ap2_led.h" -#include "config.h" - -enum anne_pro_layers { - _BASE_LAYER, - _FN1_LY, - _FN2_LY, -}; - -// Key symbols are based on QMK. Use them to remap your keyboard -/* -* Layer _BASE_LAYER -* ,-----------------------------------------------------------------------------------------. -* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | -* |-----------------------------------------------------------------------------------------+ -* | Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | -* |-----------------------------------------------------------------------------------------+ -* | Ctrl/Bks| a | s | d | f | g | h | j | k | l | ; | ' | Enter | -* |-----------------------------------------------------------------------------------------+ -* | Shift | z | x | c | v | b | n | m | , | . | / | Shift | -* |-----------------------------------------------------------------------------------------+ -* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | -* \-----------------------------------------------------------------------------------------/ -* Layer TAP in _BASE_LAYER -* ,-----------------------------------------------------------------------------------------. -* | | | | | | | | | | | | | | | -* |-----------------------------------------------------------------------------------------+ -* | | | | | | | | | | | | | | | -* |-----------------------------------------------------------------------------------------+ -* | Bksp | | | | | | | | | | | | | -* |-----------------------------------------------------------------------------------------+ -* | | | | | | | | | | | | UP | -* |-----------------------------------------------------------------------------------------+ -* | | `~ | | | | LEFT | DOWN | RIGHT | -* \-----------------------------------------------------------------------------------------/ -*/ -// clang-format off - const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [_BASE_LAYER] = KEYMAP( /* Base */ - KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, - KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, - MT(MOD_LCTL, KC_ESC), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), - KC_LCTL, MT(MOD_LGUI, KC_GRV), KC_LALT, KC_SPC, KC_RALT, LT(_FN1_LY,KC_LEFT), LT(_FN2_LY,KC_DOWN), RCTL_T(KC_RGHT) -), - /* - * Layer _FN1_LY - * ,-----------------------------------------------------------------------------------------. - * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | MEDIA PLAY| - * |-----------------------------------------------------------------------------------------+ - * | Tab | q | UP | e | 7 | 8 | 9 | u | i | o | PS | HOME | END | \ | - * |-----------------------------------------------------------------------------------------+ - * | |LEFT |DOWN |RIGHT| 4 | 5 | 6 | j | k | l | PGUP|PGDN | Enter | - * |-----------------------------------------------------------------------------------------+ - * | LayerHold? |V-UP |V-DWN|MUTE | 1 | 2 | 3 | m | , |INSRT| DEL | Shift | - * |-----------------------------------------------------------------------------------------+ - * | Ctrl | L1 | Alt | 0 | Alt | FN1 | FN2 | Ctrl | - * \-----------------------------------------------------------------------------------------/ - * - */ - [_FN1_LY] = KEYMAP( /* Base */ - KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_MEDIA_PLAY_PAUSE, - KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_7, KC_8, KC_9, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, - MO(_FN2_LY), KC_LEFT, KC_DOWN, KC_RGHT, KC_4, KC_5, KC_6, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, - KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_1, KC_2, KC_3, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_0, KC_TRNS, KC_TRNS, MO(_FN2_LY), KC_TRNS -), - /* - * Layer _FN2_LY - * ,-----------------------------------------------------------------------------------------. - * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | MEDIA PLAY| - * |-----------------------------------------------------------------------------------------+ - * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | - * |-----------------------------------------------------------------------------------------+ - * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | - * |-----------------------------------------------------------------------------------------+ - * | Shift | z | x | c | v | b | n | m | , |INSRT| DEL | Shift | - * |-----------------------------------------------------------------------------------------+ - * | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | - * \-----------------------------------------------------------------------------------------/ - * - */ - [_FN2_LY] = KEYMAP( /* Base */ - KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_MEDIA_PLAY_PAUSE, - MO(_FN2_LY), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, - KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN1_LY), MO(_FN2_LY), KC_TRNS - ), -}; -// clang-format on -const uint16_t keymaps_size = sizeof(keymaps); - - -void matrix_init_user(void) { -} - -void matrix_scan_user(void) { -} - -// Code to run after initializing the keyboard -void keyboard_post_init_user(void) { - // Here are two common functions that you can use. For more LED functions, refer to the file "qmk_ap2_led.h" - - // annepro2-shine disables LEDs by default. Uncomment this function to enable them at startup. - // annepro2LedEnable(); - - // Additionally, it also chooses the first LED profile by default. Refer to the "profiles" array in main.c in - // annepro2-shine to see the order. Replace "i" with the index of your preferred profile. (i.e the RED profile is index 0) - // annepro2LedSetProfile(i); - debug_enable=true; -} - -layer_state_t layer_state_set_user(layer_state_t layer) { - switch(get_highest_layer(layer)) { - case _FN1_LY: - // Set the leds to green - annepro2LedSetForegroundColor(0x00, 0xFF, 0x00); - break; - case _FN2_LY: - // Set the leds to blue - annepro2LedSetForegroundColor(0x00, 0x00, 0xFF); - break; - default: - // Reset back to the current profile - annepro2LedResetForegroundColor(); - break; - } - return layer; -} - -// The function to handle the caps lock logic. It's executed after caps or layer -// changes state, after layer_state_set_user. -bool led_update_user(led_t leds) { - if (leds.caps_lock) { - const annepro2Led_t color = { - .p.red = 0xff, - .p.green = 0x00, - .p.blue = 0x00, - .p.alpha = 0xff - }; - - annepro2LedMaskSetKey(2, 0, color); - return true; - } - - if(!layer_state_is(_FN1_LY) && !layer_state_is(_FN2_LY)) { - const annepro2Led_t color = { - .p.red = 0xff, - .p.green = 0x00, - .p.blue = 0x00, - .p.alpha = 0x00 - }; - annepro2LedMaskSetKey(2, 0, color); - } - return true; -} diff --git a/keyboards/annepro2/keymaps/multiarrow/keymap.c b/keyboards/annepro2/keymaps/multiarrow/keymap.c deleted file mode 100644 index cfdf360dda14..000000000000 --- a/keyboards/annepro2/keymaps/multiarrow/keymap.c +++ /dev/null @@ -1,86 +0,0 @@ -#include -#include "annepro2.h" -#include "qmk_ap2_led.h" - -enum anne_pro_layers { - _BASE_LAYER, - _FN1_LAYER, - _FN2_LAYER, -}; -// clang-format off -/* -* Layer _BASE_LAYER -* ,-----------------------------------------------------------------------------------------. -* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | -* |-----------------------------------------------------------------------------------------+ -* | Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | -* |-----------------------------------------------------------------------------------------+ -* | FN1 | a | s | d | f | g | h | j | k | l | ; | ' | Enter | -* |-----------------------------------------------------------------------------------------+ -* | Shift | z | x | c | v | b | n | m | , | . | / | Shift | -* |-----------------------------------------------------------------------------------------+ -* | Ctrl | L1 | Alt | space | Alt | FN1 | FN2 | Ctrl | -* \-----------------------------------------------------------------------------------------/ -* -*/ - const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { -[_BASE_LAYER] = KEYMAP( /* Base */ - KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, - KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, - MO(_FN1_LAYER), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSHIFT, - KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN1_LAYER), MO(_FN2_LAYER), KC_RCTRL -), - /* - * Layer _FN1_LAYER - * ,-----------------------------------------------------------------------------------------. - * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | - * |-----------------------------------------------------------------------------------------+ - * | Tab | HOM | UP | END | PGU | t | y | PGU | UP | PDN | PS | [ | ] | \ | - * |-----------------------------------------------------------------------------------------+ - * | FN1 |LEFT |DOWN |RIGHT| PDN | g | HOM |LEFT |DOWN |RIGHT| END | ' | Enter | - * |-----------------------------------------------------------------------------------------+ - * | Shift |V-UP |V-DWN|MUTE | PAUS | NEX | n | m | , |INSRT| / | Shift | - * |-----------------------------------------------------------------------------------------+ - * | Ctrl | L1 | Alt | Enter | Alt | FN1 | FN2 | Ctrl | - * \-----------------------------------------------------------------------------------------/ - * - */ - [_FN1_LAYER] = KEYMAP( /* Base */ - KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, - KC_TRNS, KC_HOME, KC_UP, KC_END, KC_PGUP, KC_TRNS, KC_TRNS, KC_PGUP, KC_UP, KC_PGDN, KC_PSCR, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, KC_TRNS, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_END, KC_TRNS, KC_TRNS, - KC_TRNS, KC_MUTE, KC_VOLD, KC_VOLU, KC_MPLY, KC_MNXT, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_ENT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS -), - /* - * Layer _FN2_LAYER - * ,-----------------------------------------------------------------------------------------. - * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 | F8 |LEDOF|LEDON|LED_I |LED_S | Bksp | - * |-----------------------------------------------------------------------------------------+ - * | Tab | HOM | UP | END | PGU | t | y | u | UP | o | PS | [ | ] | \ | - * |-----------------------------------------------------------------------------------------+ - * | CAPS |LEFT |DOWN |RIGHT| PDN | g | HOM |LEFT |DOWN |RIGHT| END | ' | Enter | - * |-----------------------------------------------------------------------------------------+ - * | Shift | z | x | c | v | b | n | m | , | . | / | Shift | - * |-----------------------------------------------------------------------------------------+ - * | Ctrl | L1 | Alt | Enter | Alt | FN1 | FN2 | Ctrl | - * \-----------------------------------------------------------------------------------------/ - * - */ - [_FN2_LAYER] = KEYMAP( /* Base */ - KC_TILD, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, - KC_TRNS, KC_HOME, KC_UP, KC_END, KC_PGUP, KC_TRNS, KC_TRNS, KC_PGUP, KC_UP, KC_PGDN, KC_PSCR, KC_TRNS, KC_TRNS, KC_TRNS, - KC_CAPS, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, KC_TRNS, KC_HOME, KC_LEFT, KC_DOWN, KC_RGHT, KC_END, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_ENT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS - ), -}; -// clang-format on -const uint16_t keymaps_size = sizeof(keymaps); - -void matrix_init_user(void) {} - -void matrix_scan_user(void) {} - -layer_state_t layer_state_set_user(layer_state_t layer) { return layer; } diff --git a/keyboards/annepro2/keymaps/tech2077/keymap.c b/keyboards/annepro2/keymaps/tech2077/keymap.c deleted file mode 100644 index c1b75ce68b37..000000000000 --- a/keyboards/annepro2/keymaps/tech2077/keymap.c +++ /dev/null @@ -1,197 +0,0 @@ -#include "annepro2.h" -#include -#include -#include "qmk_ap2_led.h" -#ifdef ANNEPRO2_C18 -# include "eeprom_w25x20cl.h" -#endif - -// layout using eeprom and bidir-comms to keep user led settings persistent - -// eeprom memory layout -typedef union { - uint32_t raw; - struct { - uint8_t magic : 8; - bool leds_on : 1; - uint8_t leds_profile : 8; - }; -} user_config_t; - -// define out default user_config -user_config_t user_config = {.magic = 0xDE, .leds_on = 0, .leds_profile = 0}; - -static uint8_t usb_buf[256]; -static uint8_t buf_fil = 0; - -enum anne_pro_layers { - _BASE_LAYER, - _FN1_LAYER, - _FN2_LAYER, -}; -// clang-format off -/* -* Layer _BASE_LAYER -* ,-----------------------------------------------------------------------------------------. -* | esc | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | -* |-----------------------------------------------------------------------------------------+ -* | Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | -* |-----------------------------------------------------------------------------------------+ -* | Caps | a | s | d | f | g | h | j | k | l | ; | ' | Enter | -* |-----------------------------------------------------------------------------------------+ -* | Shift | z | x | c | v | b | n | m | , | . | / | Shift | -* |-----------------------------------------------------------------------------------------+ -* | Ctrl | GUI | Alt | space | GUI | ALT | FN1 | Ctrl | -* \-----------------------------------------------------------------------------------------/ -* Layer TAP in _BASE_LAYER -* ,-----------------------------------------------------------------------------------------. -* | | | | | | | | | | | | | | | -* |-----------------------------------------------------------------------------------------+ -* | | | | | | | | | | | | | | | -* |-----------------------------------------------------------------------------------------+ -* | | | | | | | | | | | | | | -* |-----------------------------------------------------------------------------------------+ -* | | | | | | | | | | | | UP | -* |-----------------------------------------------------------------------------------------+ -* | | | | | | LEFT | DOWN | RIGHT | -* \-----------------------------------------------------------------------------------------/ -*/ -const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [_BASE_LAYER] = KEYMAP(/* Base */ - KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, - KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, - KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, RSFT_T(KC_UP), - KC_LCTL, KC_LALT, KC_LGUI, KC_SPC, KC_RGUI, LT(_FN2_LAYER, KC_LEFT), LT(_FN1_LAYER, KC_DOWN), RCTL_T(KC_RGHT)), - /* - * Layer _FN1_LAYER - * ,-----------------------------------------------------------------------------------------. - * | ` | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | - * |-----------------------------------------------------------------------------------------+ - * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | - * |-----------------------------------------------------------------------------------------+ - * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | - * |-----------------------------------------------------------------------------------------+ - * | Shift |V-UP |V-DWN|MUTE | v | b | n | m | , |INSRT| DEL | Shift | - * |-----------------------------------------------------------------------------------------+ - * | Ctrl | L1 | Alt | space | Alt | FN2 | FN1 | Ctrl | - * \-----------------------------------------------------------------------------------------/ - * - */ - [_FN1_LAYER] = KEYMAP(/* Base */ - KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, - KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, - MO(_FN2_LAYER), KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, - KC_TRNS, KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS, KC_TRNS), - /* - * Layer _FN2_LAYER - * ,-----------------------------------------------------------------------------------------. - * | ~ | BT1 | BT2 | BT3 | BT4 | F5 | F6 | F7 |LEDOF|LEDON| F10 | F11 | F12 | Bksp | - * |-----------------------------------------------------------------------------------------+ - * | Tab | q | UP | e | r | t | y | u | i | o | PS | HOME | END | \ | - * |-----------------------------------------------------------------------------------------+ - * | Esc |LEFT |DOWN |RIGHT| f | g | h | j | k | l | PGUP|PGDN | Enter | - * |-----------------------------------------------------------------------------------------+ - * | Shift | z | x | c | v | b | n | m | , |INSRT| DEL | Shift | - * |-----------------------------------------------------------------------------------------+ - * | Ctrl | L1 | Alt | space | Alt | FN2 | FN1 | Ctrl | - * \-----------------------------------------------------------------------------------------/ - * - */ - [_FN2_LAYER] = KEYMAP(/* Base */ - KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_PROFILE, KC_TRNS, KC_TRNS, KC_TRNS, - MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, - KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS, KC_DEL, KC_TRNS, - KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), MO(_FN1_LAYER), KC_TRNS), -}; -// clang-format on -const uint16_t keymaps_size = sizeof(keymaps); - -void matrix_init_user(void) {} - -void matrix_scan_user(void) {} - -layer_state_t layer_state_set_user(layer_state_t layer) { return layer; } - -void raw_hid_receive(uint8_t* data, uint8_t length) { - uprintf("raw_hid len: %u\n", length); - if (length == 1) - annepro2LedSetProfile(data[0]); - else { - for (uint8_t i = 0; i < length; i++) { - usb_buf[buf_fil + i] = data[i]; - } - buf_fil += length; - if (buf_fil >= 211) { - sdWrite(&SD0, usb_buf, 211); - buf_fil = 0; - } - // for (int i = 0; i < length; i++) { - // sdPut(&SD0, data[i]); - // sdGet(&SD0); - // } - } -} - -/*! - * @returns false processing for this keycode has been completed. - */ -bool process_record_user(uint16_t keycode, keyrecord_t* record) { -#ifdef ANNEPRO2_C18 - switch (keycode) { - case KC_AP_LED_OFF: - if (record->event.pressed) { - user_config.leds_on = false; - eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); - } - return false; - case KC_AP_LED_ON: - if (record->event.pressed) { - user_config.leds_on = true; - eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); - } - return false; - case KC_AP_LED_NEXT_PROFILE: - if (record->event.pressed) { - user_config.leds_profile = (user_config.leds_profile + 1) % annepro2LedStatus.amountOfProfiles; - annepro2LedSetProfile(user_config.leds_profile); - eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); - } - return false; - default: - break; - } -#endif - return true; -} - -void keyboard_post_init_user(void) { - // Customize these values to desired behavior - debug_enable = true; - // debug_matrix = true; - // debug_keyboard=true; - // debug_mouse=true; - -#ifdef ANNEPRO2_C18 - // Read the user config from EEPROM - eeprom_read((void*)&user_config, 0, sizeof(user_config_t)); - - // initialize a new eeprom - if (user_config.magic != 0xDE) { - user_config.magic = 0xDE; - user_config.leds_on = false; - user_config.leds_profile = 0; - eeprom_write((void*)&user_config, 0, sizeof(user_config_t)); - } - - if (user_config.leds_on) { - // send profile before so that we don't get a flicker on startup - annepro2LedSetProfile(user_config.leds_profile); - annepro2LedEnable(); - } else { - annepro2LedDisable(); - } -#endif -} diff --git a/keyboards/annepro2/keymaps/tech2077/rules.mk b/keyboards/annepro2/keymaps/tech2077/rules.mk deleted file mode 100644 index 73e1375afc0a..000000000000 --- a/keyboards/annepro2/keymaps/tech2077/rules.mk +++ /dev/null @@ -1,13 +0,0 @@ -# Other featues -CONSOLE_ENABLE = yes -COMMAND_ENABLE = yes -DEBUG_EEPROM = yes - -ifeq ($(strip $(BOARD)), ANNEPRO2_C18) -ANNEPRO2_EEPROM = yes -endif - -ifeq ($(strip $(ANNEPRO2_EEPROM)), yes) - OPT_DEFS += -DANNEPRO2_EEPROM - SRC += spi_master.c eeprom_w25x20cl.c -endif diff --git a/keyboards/annepro2/keymaps/thomazmoura/config.h b/keyboards/annepro2/keymaps/thomazmoura/config.h deleted file mode 100644 index 639124e1703f..000000000000 --- a/keyboards/annepro2/keymaps/thomazmoura/config.h +++ /dev/null @@ -1,15 +0,0 @@ -#pragma once - -#undef TAPPING_TERM -#define TAPPING_TERM 200 -#define RETRO_TAPPING - -#undef TAPPING_TOGGLE -#define TAPPING_TOGGLE 2 - -#define MK_3_SPEED -#define MK_MOMENTARY_ACCEL - -#define CAPS_LOCATION (MATRIX_COLS * 0 + 0) - -#define IDLE_PROFILE_INDEX 0 diff --git a/keyboards/annepro2/keymaps/thomazmoura/keymap.c b/keyboards/annepro2/keymaps/thomazmoura/keymap.c deleted file mode 100644 index d0cc498b6fad..000000000000 --- a/keyboards/annepro2/keymaps/thomazmoura/keymap.c +++ /dev/null @@ -1,384 +0,0 @@ -#include -#include "annepro2.h" -#include "qmk_ap2_led.h" -#include "config.h" - -enum anne_pro_layers { - _BASE_LAYER, - _MOUSE_LAYER, - _FUNCTION_LAYER, - _MEDIA_AND_NAVIGATION_LAYER, - _NUMPAD_LAYER, -}; - -typedef struct { - bool is_press_action; - uint8_t state; -} tap; - -// Define a type for as many tap dance states as you need -enum { SINGLE_TAP = 1, SINGLE_HOLD, DOUBLE_TAP, DOUBLE_HOLD, TRIPLE_TAP, TRIPLE_HOLD }; - -enum profile { RED, GREEN, BLUE, RAINBOWHORIZONTAL, RAINBOWVERTICAL, ANIMATEDRAINBOWVERTICAL, ANIMATEDRAINBOWFLOW, ANIMATEDRAINBOWWATERFALL, ANIMATEDBREATHING, ANIMATEDSPECTRUM }; - -uint8_t cyclabe_profiles[] = {IDLE_PROFILE_INDEX, ANIMATEDRAINBOWFLOW, ANIMATEDRAINBOWVERTICAL, ANIMATEDRAINBOWWATERFALL, ANIMATEDBREATHING, ANIMATEDSPECTRUM}; - -enum custom_codes { NEXT_PROFILE = AP2_SAFE_RANGE, ENABLE_OR_DISABLE_LEDS }; - -enum { - ESC_TAP_DANCE, - GRV_TAP_DANCE, -}; -// clang-format off -/* -* Layer _BASE_LAYER -* ,-----------------------------------------------------------------------------------------. -* | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | - | = | Bksp | -* |-----------------------------------------------------------------------------------------+ -* | Tab | q | w | e | r | t | y | u | i | o | p | [ | ] | \ | -* |-----------------------------------------------------------------------------------------+ -* |-----------------------------------------------------------------------------------------+ | Shift | z | x | c | v | b | n | m | , | . | / | Shift | -* |-----------------------------------------------------------------------------------------+ -* | Ctrl | FN2 | Alt | FN2 | Win | FN2 | FN1 | Ctrl | -* \-----------------------------------------------------------------------------------------/ -* Layer TAP in _BASE_LAYER -* ,-----------------------------------------------------------------------------------------. -* | | | | | | | | | | | | | | | -* |-----------------------------------------------------------------------------------------+ -* | | | | | | | | | | | | | | | -* |-----------------------------------------------------------------------------------------+ -* | ESC | | | | | | | | | | | | | -* |-----------------------------------------------------------------------------------------+ -* | | | | | | | | | | | | | -* |-----------------------------------------------------------------------------------------+ -* | | | | Space | | | | | -* \-----------------------------------------------------------------------------------------/ -*/ - const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [_BASE_LAYER] = KEYMAP( /* Base */ - KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, - KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, - TD(ESC_TAP_DANCE), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, - KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, - KC_LCTL, KC_LGUI, KC_LALT, LT(_MEDIA_AND_NAVIGATION_LAYER, KC_SPC), LALT_T(KC_APP), KC_RGUI, MO(_FUNCTION_LAYER), KC_RCTL -), - /* - * Layer _FUNCTION_LAYER - * ,-----------------------------------------------------------------------------------------. - * | Caps| F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 | DELETE | - * |-----------------------------------------------------------------------------------------+ - * | | | 7 | 8 | 9 | | | | | | | | | | - * |-----------------------------------------------------------------------------------------+ - * | | 0 | 4 | 5 | 6 | | LFT | DWN | UP | RGT | ; | ' | | - * |-----------------------------------------------------------------------------------------+ - * | | | 1 | 2 | 3 | | | | | | | | - * |-----------------------------------------------------------------------------------------+ - * | | | | | | | | | - * \-----------------------------------------------------------------------------------------/ - * - */ - [_FUNCTION_LAYER] = KEYMAP( /* Base */ - KC_CAPS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, - KC_PSCR, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______ -), - /* - * Layer _MEDIA_AND_NAVIGATION_LAYER - * ,-----------------------------------------------------------------------------------------. - * | USB | BT1 | BT2 | BT3 | BT4 | | | |LEDCH|LEDON| | | | | - * |-----------------------------------------------------------------------------------------+ - * | | | | | | | MUTE| PREV| PLAY| NEXT| | | | | - * |-----------------------------------------------------------------------------------------+ - * | | | | | | | HOME|PGDWN| PGUP| END | | | | - * |-----------------------------------------------------------------------------------------+ - * | | | | | | | | |VOLDN|VOLUP| | | - * |-----------------------------------------------------------------------------------------+ - * | | | | | | | | | - * \-----------------------------------------------------------------------------------------/ - * - */ - [_MEDIA_AND_NAVIGATION_LAYER] = KEYMAP( /* Base */ - KC_AP2_USB, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, _______, _______, _______, _______, NEXT_PROFILE, ENABLE_OR_DISABLE_LEDS, _______, _______, KC_AP2_BT_UNPAIR, - _______, _______, _______, KC_UP, _______, _______, KC_MUTE, KC_MPRV, KC_MPLY, KC_MNXT, _______, KC_BRID, KC_BRIU, _______, - _______, _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, KC_HOME, KC_PGDN, KC_PGUP, KC_END, _______, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLD, KC_VOLU, _______, _______, - _______, _______, _______, _______, _______, _______, _______, _______ - ), - /* - * Layer _NUMPAD_LAYER - * ,-----------------------------------------------------------------------------------------. -* | | | | | | | | | | | | | | | -* |-----------------------------------------------------------------------------------------+ -* | | | 7 | 8 | 9 | | + | 7 | 8 | 9 | . | | | | -* |-----------------------------------------------------------------------------------------+ -* | | 0 | 4 | 5 | 6 | | 0 | 4 | 5 | 6 | / | | | -* |-----------------------------------------------------------------------------------------+ -* | | | 1 | 2 | 3 | , | * | 1 | 2 | 3 | - | | -* |-----------------------------------------------------------------------------------------+ -* | | | | 0 | | | | | - * \-----------------------------------------------------------------------------------------/ - * - */ - [_NUMPAD_LAYER] = KEYMAP( /* Base */ - _______, _______, _______, _______, _______, _______, _______, _______, KC_PAST, _______, KC_PSLS, KC_PMNS, KC_PPLS, _______, - _______, _______, _______, _______, _______, _______, _______, KC_7, KC_8, KC_9, KC_COMM, _______, _______, _______, - _______, _______, _______, _______, _______, _______, KC_0, KC_4, KC_5, KC_6, KC_PDOT, _______, _______, - _______, _______, _______, _______, _______, _______, _______, KC_1, KC_2, KC_3, _______, _______, - _______, _______, _______, KC_0, _______, _______, _______, _______ - ), - /* - * Layer _MOUSE_LAYER - Mouse Layer - * ,-----------------------------------------------------------------------------------------. - * | | | | | | | | | | | | | | | - * |-----------------------------------------------------------------------------------------+ - * | | | | | | |ACL2 |WL-U |MS-U |WL-D |ACL1 |ACL0 | | | - * |-----------------------------------------------------------------------------------------+ - * | | | ACL0 | ACL1 | ACL2 | |BTN3 |MS-L |MS-D |MS-R |BTN2 | | | - * |-----------------------------------------------------------------------------------------+ - * | | | | | | |BTN4 |BTN5 |WL-L |WL-R | | | - * |-----------------------------------------------------------------------------------------+ - * | | | | BTN1 | | | | | - * \-----------------------------------------------------------------------------------------/ - * - */ - [_MOUSE_LAYER] = KEYMAP( /* Base */ - _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, - _______, _______, _______, _______, _______, _______, KC_WH_L, KC_WH_D, KC_WH_U, KC_WH_R, _______, _______, _______, _______, - _______, _______, KC_ACL0, KC_ACL1, KC_ACL2, _______, KC_MS_L, KC_MS_D, KC_MS_U, KC_MS_R, KC_BTN2, _______, _______, - _______, _______, _______, _______, _______, _______, KC_BTN3, KC_BTN4, KC_BTN5, _______, _______, _______, - _______, _______, _______, KC_BTN1, _______, _______, _______, _______ - ), -}; -// clang-format on -const uint16_t keymaps_size = sizeof(keymaps); - -// Declare the functions to be used with your tap dance key(s) - -// Function associated with all tap dances -uint8_t cur_dance(qk_tap_dance_state_t *state); - -// Functions associated with individual tap dances -void enableProfileColor(uint8_t *profile); -void resetProfileColor(void); -void esc_layer_finished(qk_tap_dance_state_t *state, void *user_data); -void esc_layer_reset(qk_tap_dance_state_t *state, void *user_data); - -bool is_caps_set = false; -bool is_led_on = true; -uint8_t base_profile = IDLE_PROFILE_INDEX; - -uint8_t idle_profile[] = {0x00, 0x00, 0x00}; -uint8_t caps_profile[] = {0xFF, 0x00, 0x00}; -uint8_t function_profile[] = {0x00, 0xFF, 0x00}; -uint8_t navigation_profile[] = {0x44, 0x00, 0xFF}; -uint8_t numpad_profile[] = {0xFF, 0xDD, 0x00}; -uint8_t mouse_profile[] = {0x00, 0x88, 0xFF}; - -void matrix_init_user(void) {} - -void matrix_scan_user(void) {} - -void keyboard_post_init_user(void) { - annepro2LedEnable(); - resetProfileColor(); -} - -// The function to handle the caps lock logic -bool led_update_user(led_t leds) { - if (leds.caps_lock) { - is_caps_set = true; - enableProfileColor(caps_profile); - return true; - } else if (is_caps_set) { - is_caps_set = false; - resetProfileColor(); - } - - return true; -} - -layer_state_t layer_state_set_user(layer_state_t state) { - switch (get_highest_layer(state)) { - case _FUNCTION_LAYER: - enableProfileColor(function_profile); - break; - case _NUMPAD_LAYER: - enableProfileColor(numpad_profile); - break; - case _MOUSE_LAYER: - enableProfileColor(mouse_profile); - break; - case _MEDIA_AND_NAVIGATION_LAYER: - enableProfileColor(navigation_profile); - break; - default: - resetProfileColor(); - break; - } - - return state; -} - -// Determine the current tap dance state -uint8_t cur_dance(qk_tap_dance_state_t *state) { - if (state->count == 1) { - if (!state->pressed) - return SINGLE_TAP; - else - return SINGLE_HOLD; - } else if (state->count == 2) { - if (!state->pressed) - return DOUBLE_TAP; - else - return DOUBLE_HOLD; - } else if (state->count == 3) { - if (!state->pressed) - return TRIPLE_TAP; - else - return TRIPLE_HOLD; - } else - return 8; -} - -// Initialize tap structure associated with example tap dance key -static tap esc_tap_state = {.is_press_action = true, .state = 0}; - -static tap grav_tap_state = {.is_press_action = true, .state = 0}; - -void enableProfileColor(uint8_t *profile) { - if (is_caps_set) { - annepro2LedSetForegroundColor(caps_profile[0], caps_profile[1], caps_profile[2]); - } else { - annepro2LedSetForegroundColor(profile[0], profile[1], profile[2]); - } -} - -void resetProfileColor(void) { - if (is_caps_set) { - annepro2LedSetForegroundColor(caps_profile[0], caps_profile[1], caps_profile[2]); - } else if (base_profile == IDLE_PROFILE_INDEX) { - annepro2LedSetForegroundColor(idle_profile[0], idle_profile[1], idle_profile[2]); - } else { - annepro2LedSetProfile(cyclabe_profiles[base_profile]); - } -} - -bool process_record_user(uint16_t keycode, keyrecord_t *record) { - switch (keycode) { - case NEXT_PROFILE: - if (record->event.pressed) { - base_profile++; - if (base_profile >= (sizeof(cyclabe_profiles) / sizeof(cyclabe_profiles[0]))) base_profile = IDLE_PROFILE_INDEX; - - if (base_profile == IDLE_PROFILE_INDEX) { - annepro2LedSetForegroundColor(idle_profile[0], idle_profile[1], idle_profile[2]); - } else { - annepro2LedSetProfile(cyclabe_profiles[base_profile]); - } - } - return true; - case ENABLE_OR_DISABLE_LEDS: - if (record->event.pressed) { - if (is_led_on) { - is_led_on = false; - annepro2LedDisable(); - } else { - annepro2LedEnable(); - is_led_on = true; - } - } - return true; - default: - return true; - } -} - -// Functions that control what our tap dance key does -void esc_layer_finished(qk_tap_dance_state_t *state, void *user_data) { - esc_tap_state.state = cur_dance(state); - - switch (esc_tap_state.state) { - case SINGLE_TAP: - tap_code(KC_ESC); - break; - case SINGLE_HOLD: - layer_on(_FUNCTION_LAYER); - break; - case DOUBLE_TAP: - if (layer_state_is(_MOUSE_LAYER) || layer_state_is(_NUMPAD_LAYER)) { - layer_off(_MOUSE_LAYER); - layer_off(_NUMPAD_LAYER); - } else { - tap_code(KC_ESC); - tap_code(KC_ESC); - } - break; - case DOUBLE_HOLD: - layer_on(_NUMPAD_LAYER); - break; - case TRIPLE_TAP: - if (layer_state_is(_MOUSE_LAYER)) { - layer_off(_MOUSE_LAYER); - } else { - layer_on(_MOUSE_LAYER); - } - break; - case TRIPLE_HOLD: - layer_on(_MOUSE_LAYER); - break; - } -} - -void esc_layer_reset(qk_tap_dance_state_t *state, void *user_data) { - // If the key was held down and now is released then switch off the layer - if (esc_tap_state.state == SINGLE_HOLD) { - layer_off(_FUNCTION_LAYER); - } - if (esc_tap_state.state == DOUBLE_HOLD) { - layer_off(_NUMPAD_LAYER); - } - if (esc_tap_state.state == TRIPLE_HOLD) { - layer_off(_MOUSE_LAYER); - } - esc_tap_state.state = 0; -} - -// Functions that control what our tap dance key does -void grave_layer_finished(qk_tap_dance_state_t *state, void *user_data) { - grav_tap_state.state = cur_dance(state); - - switch (grav_tap_state.state) { - case SINGLE_TAP: - tap_code(KC_GRV); - break; - case SINGLE_HOLD: - tap_code(KC_GRV); - break; - case DOUBLE_TAP: - // Check to see if the layer is already set - if (layer_state_is(_MOUSE_LAYER)) { - // If already set, then switch it off - layer_off(_MOUSE_LAYER); - } else { - // If not already set, then switch the layer on - layer_on(_MOUSE_LAYER); - } - break; - } -} - -void grave_layer_reset(qk_tap_dance_state_t *state, void *user_data) { - // If the key was held down and now is released then switch off the layer - if (grav_tap_state.state == SINGLE_HOLD) { - layer_off(_FUNCTION_LAYER); - } - if (grav_tap_state.state == DOUBLE_HOLD) { - layer_off(_NUMPAD_LAYER); - } - grav_tap_state.state = 0; -} - -// Associate our tap dance key with its functionality -qk_tap_dance_action_t tap_dance_actions[] = {[ESC_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(NULL, esc_layer_finished, esc_layer_reset, 250), [GRV_TAP_DANCE] = ACTION_TAP_DANCE_FN_ADVANCED_TIME(NULL, grave_layer_finished, grave_layer_reset, 300)}; diff --git a/keyboards/annepro2/keymaps/thomazmoura/rules.mk b/keyboards/annepro2/keymaps/thomazmoura/rules.mk deleted file mode 100644 index 3534b644a15c..000000000000 --- a/keyboards/annepro2/keymaps/thomazmoura/rules.mk +++ /dev/null @@ -1,47 +0,0 @@ -# Anne Pro 2 -SRC = \ - matrix.c \ - hardfault_handler.c \ - annepro2_ble.c \ - qmk_ap2_led.c \ - protocol.c - -ifeq ($(strip $(ANNEPRO2_EEPROM)), yes) - OPT_DEFS += -DANNEPRO2_EEPROM - SRC += spi_master.c eeprom_w25x20cl.c -endif - -LAYOUTS += - -# MCU -MCU = cortex-m0plus -ARMV = 6 -USE_FPU = no -MCU_FAMILY = HT32 -MCU_SERIES = HT32F523xx -MCU_LDSCRIPT = HT32F52342_ANNEPRO2 -MCU_STARTUP = ht32f523xx - -BOARD = ANNEPRO2_C18 - -OPT_DEFS = -Wno-unused-function -fdump-rtl-dfinish -fstack-usage -#EXTRALDFLAGS = -Wl,--print-memory-usage - -# Options - -# Keys -CUSTOM_MATRIX = yes -NKRO_ENABLE = no -MOUSEKEY_ENABLE = yes -TAP_DANCE_ENABLE = yes -EXTRAKEY_ENABLE = yes -KEY_LOCK_ENABLE = no - -# Other featues -BOOTMAGIC_ENABLE = no -CONSOLE_ENABLE = no -COMMAND_ENABLE = yes -RAW_ENABLE = yes -MIDI_ENABLE = no -VIRTSER_ENABLE = no -COMBO_ENABLE = no From 807582e172d300ca277df78e1f7b2093a74565df Mon Sep 17 00:00:00 2001 From: bwisn Date: Wed, 15 Sep 2021 09:11:35 +0200 Subject: [PATCH 51/88] annepro2: add licence information --- keyboards/annepro2/annepro2.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index cdca573d53b6..95dc8e90f439 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -1,3 +1,19 @@ + /* Copyright 2021 OpenAnnePro community + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include "ch.h" #include "hal.h" #include "annepro2.h" @@ -193,4 +209,4 @@ bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { } } return process_record_user(keycode, record); -} \ No newline at end of file +} From 0df099b593c93483d42797a23759f5a821f0bc16 Mon Sep 17 00:00:00 2001 From: bwisn Date: Wed, 15 Sep 2021 09:16:16 +0200 Subject: [PATCH 52/88] annepro2: satisfy qmk lint --- keyboards/annepro2/c18/post_rules.mk | 4 ++++ keyboards/annepro2/c18/rules.mk | 5 ----- 2 files changed, 4 insertions(+), 5 deletions(-) create mode 100644 keyboards/annepro2/c18/post_rules.mk diff --git a/keyboards/annepro2/c18/post_rules.mk b/keyboards/annepro2/c18/post_rules.mk new file mode 100644 index 000000000000..5cfbe9a7d168 --- /dev/null +++ b/keyboards/annepro2/c18/post_rules.mk @@ -0,0 +1,4 @@ +ifeq ($(strip $(ANNEPRO2_EEPROM)), yes) + OPT_DEFS += -DANNEPRO2_EEPROM + SRC += spi_master.c eeprom_w25x20cl.c +endif diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index b0b844715fbd..17ff59c6e3f8 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -6,11 +6,6 @@ SRC = \ qmk_ap2_led.c \ protocol.c -ifeq ($(strip $(ANNEPRO2_EEPROM)), yes) - OPT_DEFS += -DANNEPRO2_EEPROM - SRC += spi_master.c eeprom_w25x20cl.c -endif - LAYOUTS += # MCU From 6e08944570dc4353dfcb04513a5ab656fab96ffe Mon Sep 17 00:00:00 2001 From: bwisn Date: Wed, 15 Sep 2021 09:29:07 +0200 Subject: [PATCH 53/88] annepro2: fix drashna's suggestions --- keyboards/annepro2/annepro2.h | 18 ++++++++++ keyboards/annepro2/c15/config.h | 60 --------------------------------- keyboards/annepro2/c15/rules.mk | 4 +-- keyboards/annepro2/c18/config.h | 52 ---------------------------- keyboards/annepro2/c18/rules.mk | 4 +-- keyboards/annepro2/matrix.c | 11 +++--- 6 files changed, 25 insertions(+), 124 deletions(-) diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index a6c984d75d4c..449997241dab 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -29,6 +29,24 @@ extern uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS]; extern ble_capslock_t BLECapsLock; +// Matrix keymap +// clang-format off +#define LAYOUT( \ + K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ + K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ + K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \ + K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, \ + K40, K42, K43, K46, K49, K4A, K4B, K4C \ +) { \ + /* COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14*/ \ + /* ROW1 */ { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \ + /* ROW2 */ { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D }, \ + /* ROW3 */ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, KC_NO}, \ + /* ROW4 */ { K30, KC_NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, KC_NO}, \ + /* ROW5 */ { K40, KC_NO, K42, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, K49, K4A, K4B, K4C, KC_NO}, \ +} +// clang-format on + enum AP2KeyCodes { KC_AP2_BT1 = SAFE_RANGE, KC_AP2_BT2, diff --git a/keyboards/annepro2/c15/config.h b/keyboards/annepro2/c15/config.h index 947700f28b8f..9c6516fbe659 100644 --- a/keyboards/annepro2/c15/config.h +++ b/keyboards/annepro2/c15/config.h @@ -39,23 +39,6 @@ // Number of supported layouts #define NUM_LAYOUTS 4 -// Matrix keymap -// clang-format off -#define LAYOUT( \ - K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ - K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ - K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \ - K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, \ - K40, K42, K43, K46, K49, K4A, K4B, K4C \ -) { \ - /* COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14*/ \ - /* ROW1 */ { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \ - /* ROW2 */ { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D }, \ - /* ROW3 */ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, KC_NO}, \ - /* ROW4 */ { K30, KC_NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, KC_NO}, \ - /* ROW5 */ { K40, KC_NO, K42, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, K49, K4A, K4B, K4C, KC_NO}, \ -} -// clang-format on /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 @@ -105,49 +88,6 @@ * */ -/* key combination for magic key command */ -/* -#define IS_COMMAND() ( \ - keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ -) -*/ - -/* control how magic key switches layers */ -//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true -//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true -//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false - -/* override magic key keymap */ -//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS -//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS -//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM -//#define MAGIC_KEY_HELP1 H -//#define MAGIC_KEY_HELP2 SLASH -//#define MAGIC_KEY_DEBUG D -//#define MAGIC_KEY_DEBUG_MATRIX X -//#define MAGIC_KEY_DEBUG_KBD K -//#define MAGIC_KEY_DEBUG_MOUSE M -//#define MAGIC_KEY_VERSION V -//#define MAGIC_KEY_STATUS S -//#define MAGIC_KEY_CONSOLE C -//#define MAGIC_KEY_LAYER0_ALT1 ESC -//#define MAGIC_KEY_LAYER0_ALT2 GRAVE -//#define MAGIC_KEY_LAYER0 0 -//#define MAGIC_KEY_LAYER1 1 -//#define MAGIC_KEY_LAYER2 2 -//#define MAGIC_KEY_LAYER3 3 -//#define MAGIC_KEY_LAYER4 4 -//#define MAGIC_KEY_LAYER5 5 -//#define MAGIC_KEY_LAYER6 6 -//#define MAGIC_KEY_LAYER7 7 -//#define MAGIC_KEY_LAYER8 8 -//#define MAGIC_KEY_LAYER9 9 -//#define MAGIC_KEY_BOOTLOADER R -//#define MAGIC_KEY_LOCK CAPS -//#define MAGIC_KEY_EEPROM E -//#define MAGIC_KEY_NKRO N -//#define MAGIC_KEY_SLEEP_LED Z - /* * Feature disable options * These options are also useful to firmware size reduction. diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index 082e010abe8e..da0de1e56ab7 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -6,8 +6,6 @@ SRC = \ qmk_ap2_led.c \ protocol.c -LAYOUTS += - # MCU MCU = cortex-m0plus ARMV = 6 @@ -25,7 +23,7 @@ OPT_DEFS = -Wno-unused-function -fdump-rtl-dfinish -fstack-usage # Options # Keys -CUSTOM_MATRIX = yes +CUSTOM_MATRIX = lite NKRO_ENABLE = no MOUSEKEY_ENABLE = no EXTRAKEY_ENABLE = yes diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h index 4b1f8878ab2d..800bf09d053b 100644 --- a/keyboards/annepro2/c18/config.h +++ b/keyboards/annepro2/c18/config.h @@ -39,23 +39,6 @@ // Number of supported layouts #define NUM_LAYOUTS 4 -// Matrix keymap -// clang-format off -#define LAYOUT( \ - K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D, \ - K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D, \ - K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, \ - K30, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, \ - K40, K42, K43, K46, K49, K4A, K4B, K4C \ -) { \ - /* COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 COL9 COL10 COL11 COL12 COL13 COL14*/ \ - /* ROW1 */ { K00, K01, K02, K03, K04, K05, K06, K07, K08, K09, K0A, K0B, K0C, K0D }, \ - /* ROW2 */ { K10, K11, K12, K13, K14, K15, K16, K17, K18, K19, K1A, K1B, K1C, K1D }, \ - /* ROW3 */ { K20, K21, K22, K23, K24, K25, K26, K27, K28, K29, K2A, K2B, K2C, KC_NO}, \ - /* ROW4 */ { K30, KC_NO, K32, K33, K34, K35, K36, K37, K38, K39, K3A, K3B, K3C, KC_NO}, \ - /* ROW5 */ { K40, KC_NO, K42, K43, KC_NO, KC_NO, K46, KC_NO, KC_NO, K49, K4A, K4B, K4C, KC_NO}, \ -} -// clang-format on /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 @@ -137,41 +120,6 @@ ) */ -/* control how magic key switches layers */ -//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS true -//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS true -//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM false - -/* override magic key keymap */ -//#define MAGIC_KEY_SWITCH_LAYER_WITH_FKEYS -//#define MAGIC_KEY_SWITCH_LAYER_WITH_NKEYS -//#define MAGIC_KEY_SWITCH_LAYER_WITH_CUSTOM -//#define MAGIC_KEY_HELP1 H -//#define MAGIC_KEY_HELP2 SLASH -//#define MAGIC_KEY_DEBUG D -//#define MAGIC_KEY_DEBUG_MATRIX X -//#define MAGIC_KEY_DEBUG_KBD K -//#define MAGIC_KEY_DEBUG_MOUSE M -//#define MAGIC_KEY_VERSION V -//#define MAGIC_KEY_STATUS S -//#define MAGIC_KEY_CONSOLE C -//#define MAGIC_KEY_LAYER0_ALT1 ESC -//#define MAGIC_KEY_LAYER0_ALT2 GRAVE -//#define MAGIC_KEY_LAYER0 0 -//#define MAGIC_KEY_LAYER1 1 -//#define MAGIC_KEY_LAYER2 2 -//#define MAGIC_KEY_LAYER3 3 -//#define MAGIC_KEY_LAYER4 4 -//#define MAGIC_KEY_LAYER5 5 -//#define MAGIC_KEY_LAYER6 6 -//#define MAGIC_KEY_LAYER7 7 -//#define MAGIC_KEY_LAYER8 8 -//#define MAGIC_KEY_LAYER9 9 -//#define MAGIC_KEY_BOOTLOADER R -//#define MAGIC_KEY_LOCK CAPS -//#define MAGIC_KEY_EEPROM E -//#define MAGIC_KEY_NKRO N -//#define MAGIC_KEY_SLEEP_LED Z /* * Feature disable options diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 17ff59c6e3f8..532d6be8b804 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -6,8 +6,6 @@ SRC = \ qmk_ap2_led.c \ protocol.c -LAYOUTS += - # MCU MCU = cortex-m0plus ARMV = 6 @@ -25,7 +23,7 @@ OPT_DEFS = -Wno-unused-function -fdump-rtl-dfinish -fstack-usage # Options # Keys -CUSTOM_MATRIX = yes +CUSTOM_MATRIX = lite NKRO_ENABLE = no MOUSEKEY_ENABLE = no EXTRAKEY_ENABLE = yes diff --git a/keyboards/annepro2/matrix.c b/keyboards/annepro2/matrix.c index a723e523a738..86b3c48d88d7 100644 --- a/keyboards/annepro2/matrix.c +++ b/keyboards/annepro2/matrix.c @@ -32,14 +32,14 @@ static uint32_t debounce_times[MATRIX_ROWS]; extern ioline_t row_list[MATRIX_ROWS]; extern ioline_t col_list[MATRIX_COLS]; -void matrix_init(void) { +void matrix_init_custom(void) { memset(matrix, 0, MATRIX_ROWS * sizeof(matrix_row_t)); memset(matrix_debouncing, 0, MATRIX_ROWS * sizeof(matrix_row_t)); memset(debounce_times, 0, MATRIX_ROWS * sizeof(uint32_t)); - matrix_init_quantum(); } -uint8_t matrix_scan(void) { +uint8_t matrix_scan_custom(void) { + bool matrix_has_changed = false; // cache of input ports for columns static uint16_t port_cache[4]; // scan each row @@ -75,11 +75,10 @@ uint8_t matrix_scan(void) { // when debouncing complete, update matrix matrix[row] = matrix_debouncing[row]; debounce_times[row] = 0; + matrix_has_changed = true; } } - matrix_scan_quantum(); - - return 1; + return matrix_has_changed; } bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & (1 << col)); } From 5ebfacb99f600a39b691444953742f3a732e9a3f Mon Sep 17 00:00:00 2001 From: bwisn Date: Wed, 15 Sep 2021 09:39:38 +0200 Subject: [PATCH 54/88] annepro2: fix matrix --- keyboards/annepro2/annepro2.h | 3 +++ keyboards/annepro2/matrix.c | 6 ------ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index 449997241dab..aa8f485e27a4 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -29,6 +29,9 @@ extern uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS]; extern ble_capslock_t BLECapsLock; +/* System clock - needed for custom matrix lite */ +#define STM32_SYSCLK HT32_CK_SYS_FREQUENCY + // Matrix keymap // clang-format off #define LAYOUT( \ diff --git a/keyboards/annepro2/matrix.c b/keyboards/annepro2/matrix.c index 86b3c48d88d7..2ea0d4107a41 100644 --- a/keyboards/annepro2/matrix.c +++ b/keyboards/annepro2/matrix.c @@ -80,9 +80,3 @@ uint8_t matrix_scan_custom(void) { } return matrix_has_changed; } - -bool matrix_is_on(uint8_t row, uint8_t col) { return (matrix[row] & (1 << col)); } - -matrix_row_t matrix_get_row(uint8_t row) { return matrix[row]; } - -void matrix_print(void) {} From e68f6a507fbbfc0a3a1ce137742aa810661a10dd Mon Sep 17 00:00:00 2001 From: bwisn Date: Thu, 16 Sep 2021 08:28:05 +0200 Subject: [PATCH 55/88] annepro2: apply code review suggestions --- keyboards/annepro2/annepro2.h | 3 ++ .../keymaps/default-full-caps/config.h | 18 +++++++++++ .../keymaps/default-full-caps/keymap.c | 29 ++++++++++------- .../keymaps/default-layer-indicators/config.h | 18 +++++++++++ .../keymaps/default-layer-indicators/keymap.c | 32 ++++++++++++------- keyboards/annepro2/keymaps/default/config.h | 18 +++++++++++ keyboards/annepro2/keymaps/default/keymap.c | 28 +++++++++------- 7 files changed, 111 insertions(+), 35 deletions(-) diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index aa8f485e27a4..007f2d5471e5 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -17,6 +17,9 @@ #pragma once #include "quantum.h" +#include +#include "qmk_ap2_led.h" +#include "config.h" #define OVERRIDE __attribute__((noinline)) diff --git a/keyboards/annepro2/keymaps/default-full-caps/config.h b/keyboards/annepro2/keymaps/default-full-caps/config.h index 1840bc748496..413c5d8dc520 100644 --- a/keyboards/annepro2/keymaps/default-full-caps/config.h +++ b/keyboards/annepro2/keymaps/default-full-caps/config.h @@ -1,2 +1,20 @@ + /* Copyright 2021 OpenAnnePro community + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + // Obins stock firmware has something similar to this already enabled, but disabled by default in QMK #define PERMISSIVE_HOLD diff --git a/keyboards/annepro2/keymaps/default-full-caps/keymap.c b/keyboards/annepro2/keymaps/default-full-caps/keymap.c index c67a92644b29..a46e111799e9 100644 --- a/keyboards/annepro2/keymaps/default-full-caps/keymap.c +++ b/keyboards/annepro2/keymaps/default-full-caps/keymap.c @@ -1,7 +1,20 @@ -#include -#include "annepro2.h" -#include "qmk_ap2_led.h" -#include "config.h" + /* Copyright 2021 OpenAnnePro community + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include QMK_KEYBOARD_H enum anne_pro_layers { _BASE_LAYER, @@ -94,12 +107,6 @@ enum anne_pro_layers { // clang-format on -const uint16_t keymaps_size = sizeof(keymaps); - -void matrix_init_user(void) {} - -void matrix_scan_user(void) {} - // Code to run after initializing the keyboard void keyboard_post_init_user(void) { // Here are two common functions that you can use. For more LED functions, refer to the file "qmk_ap2_led.h" @@ -112,8 +119,6 @@ void keyboard_post_init_user(void) { // annepro2LedSetProfile(i); } -layer_state_t layer_state_set_user(layer_state_t layer) { return layer; } - // The function to handle the caps lock logic bool led_update_user(led_t leds) { if (leds.caps_lock) { diff --git a/keyboards/annepro2/keymaps/default-layer-indicators/config.h b/keyboards/annepro2/keymaps/default-layer-indicators/config.h index 1840bc748496..413c5d8dc520 100644 --- a/keyboards/annepro2/keymaps/default-layer-indicators/config.h +++ b/keyboards/annepro2/keymaps/default-layer-indicators/config.h @@ -1,2 +1,20 @@ + /* Copyright 2021 OpenAnnePro community + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + // Obins stock firmware has something similar to this already enabled, but disabled by default in QMK #define PERMISSIVE_HOLD diff --git a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c index c840145f454d..ecdf6cf479ac 100644 --- a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c +++ b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c @@ -1,7 +1,20 @@ -#include -#include "annepro2.h" -#include "qmk_ap2_led.h" -#include "config.h" + /* Copyright 2021 OpenAnnePro community + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include QMK_KEYBOARD_H enum anne_pro_layers { _BASE_LAYER, @@ -93,11 +106,6 @@ enum anne_pro_layers { }; // clang-format on -const uint16_t keymaps_size = sizeof(keymaps); - -void matrix_init_user(void) {} - -void matrix_scan_user(void) {} // Code to run after initializing the keyboard void keyboard_post_init_user(void) { @@ -111,8 +119,8 @@ void keyboard_post_init_user(void) { // annepro2LedSetProfile(i); } -layer_state_t layer_state_set_user(layer_state_t layer) { - switch (get_highest_layer(layer)) { +layer_state_t layer_state_set_user(layer_state_t state) { + switch (get_highest_layer(state)) { case _FN1_LAYER: // Set the leds to green annepro2LedSetForegroundColor(0x00, 0xFF, 0x00); @@ -126,7 +134,7 @@ layer_state_t layer_state_set_user(layer_state_t layer) { annepro2LedResetForegroundColor(); break; } - return layer; + return state; } // The function to handle the caps lock logic diff --git a/keyboards/annepro2/keymaps/default/config.h b/keyboards/annepro2/keymaps/default/config.h index 1840bc748496..413c5d8dc520 100644 --- a/keyboards/annepro2/keymaps/default/config.h +++ b/keyboards/annepro2/keymaps/default/config.h @@ -1,2 +1,20 @@ + /* Copyright 2021 OpenAnnePro community + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#pragma once + // Obins stock firmware has something similar to this already enabled, but disabled by default in QMK #define PERMISSIVE_HOLD diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 95a72a1df771..f3a3063167a0 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -1,7 +1,20 @@ -#include -#include "annepro2.h" -#include "qmk_ap2_led.h" -#include "config.h" + /* Copyright 2021 OpenAnnePro community + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +#include QMK_KEYBOARD_H enum anne_pro_layers { _BASE_LAYER, @@ -91,11 +104,6 @@ enum anne_pro_layers { ), }; // clang-format on -const uint16_t keymaps_size = sizeof(keymaps); - -void matrix_init_user(void) {} - -void matrix_scan_user(void) {} // Code to run after initializing the keyboard void keyboard_post_init_user(void) { @@ -108,5 +116,3 @@ void keyboard_post_init_user(void) { // annepro2-shine to see the order. Replace "i" with the index of your preferred profile. (i.e the RED profile is index 0) // annepro2LedSetProfile(i); } - -layer_state_t layer_state_set_user(layer_state_t layer) { return layer; } From 46d861f7e0a8b432a95f635a8c04ca4a0622ee1e Mon Sep 17 00:00:00 2001 From: bwisn Date: Thu, 16 Sep 2021 08:31:00 +0200 Subject: [PATCH 56/88] annepro2: apply remaining code review suggestions --- keyboards/annepro2/qmk_ap2_led.c | 16 ++++++++++++++++ keyboards/annepro2/qmk_ap2_led.h | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/keyboards/annepro2/qmk_ap2_led.c b/keyboards/annepro2/qmk_ap2_led.c index d0b34122c27a..2f08d7dc394f 100644 --- a/keyboards/annepro2/qmk_ap2_led.c +++ b/keyboards/annepro2/qmk_ap2_led.c @@ -1,3 +1,19 @@ + /* Copyright 2021 OpenAnnePro community + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include #include #include "hal.h" diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/qmk_ap2_led.h index 0abec2dcba09..23712a255564 100644 --- a/keyboards/annepro2/qmk_ap2_led.h +++ b/keyboards/annepro2/qmk_ap2_led.h @@ -1,3 +1,19 @@ + /* Copyright 2021 OpenAnnePro community + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #pragma once #include "protocol.h" From 6a32f0e168c7522ee9a9ac7bb9677da5cf65302e Mon Sep 17 00:00:00 2001 From: bwisn Date: Thu, 16 Sep 2021 21:53:51 +0200 Subject: [PATCH 57/88] annepro2: update info.json --- keyboards/annepro2/info.json | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/keyboards/annepro2/info.json b/keyboards/annepro2/info.json index 0e16a1057cc0..8fd515bd1042 100644 --- a/keyboards/annepro2/info.json +++ b/keyboards/annepro2/info.json @@ -2,8 +2,6 @@ "keyboard_name": "Anne Pro 2", "url": "https://openannepro.github.io/", "maintainer": "community", - "width": 15, - "height": 5, "layouts": { "LAYOUT": { "layout": [ @@ -329,4 +327,4 @@ ] } } -} \ No newline at end of file +} From b697196f297bf43009e933232cd5fada2f404820 Mon Sep 17 00:00:00 2001 From: bwisn Date: Fri, 17 Sep 2021 07:48:47 +0200 Subject: [PATCH 58/88] annepro2: remove include --- keyboards/annepro2/annepro2.h | 1 - 1 file changed, 1 deletion(-) diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index 007f2d5471e5..d5d88d7498a5 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -19,7 +19,6 @@ #include "quantum.h" #include #include "qmk_ap2_led.h" -#include "config.h" #define OVERRIDE __attribute__((noinline)) From 1fbaa280e236f3c72e4fc529b1387e28c5788bb9 Mon Sep 17 00:00:00 2001 From: bwisn Date: Sat, 18 Sep 2021 08:49:03 +0200 Subject: [PATCH 59/88] annepro2: rename keymap to layout --- keyboards/annepro2/keymaps/default-full-caps/keymap.c | 6 +++--- .../annepro2/keymaps/default-layer-indicators/keymap.c | 6 +++--- keyboards/annepro2/keymaps/default/keymap.c | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/keyboards/annepro2/keymaps/default-full-caps/keymap.c b/keyboards/annepro2/keymaps/default-full-caps/keymap.c index a46e111799e9..40fb87359a98 100644 --- a/keyboards/annepro2/keymaps/default-full-caps/keymap.c +++ b/keyboards/annepro2/keymaps/default-full-caps/keymap.c @@ -52,7 +52,7 @@ enum anne_pro_layers { * \-----------------------------------------------------------------------------------------/ */ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [_BASE_LAYER] = KEYMAP( /* Base */ + [_BASE_LAYER] = LAYOUT( /* Base */ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, LT(_FN1_LAYER,KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, @@ -74,7 +74,7 @@ enum anne_pro_layers { * \-----------------------------------------------------------------------------------------/ * */ - [_FN1_LAYER] = KEYMAP( /* Base */ + [_FN1_LAYER] = LAYOUT( /* Base */ KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, @@ -96,7 +96,7 @@ enum anne_pro_layers { * \-----------------------------------------------------------------------------------------/ * */ - [_FN2_LAYER] = KEYMAP( /* Base */ + [_FN2_LAYER] = LAYOUT( /* Base */ KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, diff --git a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c index ecdf6cf479ac..ab23c29bffe6 100644 --- a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c +++ b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c @@ -52,7 +52,7 @@ enum anne_pro_layers { * \-----------------------------------------------------------------------------------------/ */ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [_BASE_LAYER] = KEYMAP( /* Base */ + [_BASE_LAYER] = LAYOUT( /* Base */ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, LT(_FN1_LAYER,KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, @@ -74,7 +74,7 @@ enum anne_pro_layers { * \-----------------------------------------------------------------------------------------/ * */ - [_FN1_LAYER] = KEYMAP( /* Base */ + [_FN1_LAYER] = LAYOUT( /* Base */ KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, @@ -96,7 +96,7 @@ enum anne_pro_layers { * \-----------------------------------------------------------------------------------------/ * */ - [_FN2_LAYER] = KEYMAP( /* Base */ + [_FN2_LAYER] = LAYOUT( /* Base */ KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index f3a3063167a0..0c52220b8d04 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -51,7 +51,7 @@ enum anne_pro_layers { * \-----------------------------------------------------------------------------------------/ */ const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS] = { - [_BASE_LAYER] = KEYMAP( /* Base */ + [_BASE_LAYER] = LAYOUT( /* Base */ KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, LT(_FN1_LAYER,KC_CAPS), KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, @@ -73,7 +73,7 @@ enum anne_pro_layers { * \-----------------------------------------------------------------------------------------/ * */ - [_FN1_LAYER] = KEYMAP( /* Base */ + [_FN1_LAYER] = LAYOUT( /* Base */ KC_GRV, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, @@ -95,7 +95,7 @@ enum anne_pro_layers { * \-----------------------------------------------------------------------------------------/ * */ - [_FN2_LAYER] = KEYMAP( /* Base */ + [_FN2_LAYER] = LAYOUT( /* Base */ KC_TRNS, KC_AP2_BT1, KC_AP2_BT2, KC_AP2_BT3, KC_AP2_BT4, KC_TRNS, KC_TRNS, KC_TRNS, KC_AP_LED_OFF, KC_AP_LED_ON, KC_AP_LED_NEXT_INTENSITY, KC_AP_LED_SPEED, KC_TRNS, KC_TRNS, MO(_FN2_LAYER), KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PSCR, KC_HOME, KC_END, KC_TRNS, KC_TRNS, KC_LEFT, KC_DOWN, KC_RGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PGUP, KC_PGDN, KC_TRNS, From b4cac43d61a58eead4cf63518e882d5a25bd7b4f Mon Sep 17 00:00:00 2001 From: bwisn Date: Mon, 18 Oct 2021 22:07:05 +0200 Subject: [PATCH 60/88] annepro2: fix typing --- keyboards/annepro2/matrix.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/keyboards/annepro2/matrix.c b/keyboards/annepro2/matrix.c index 2ea0d4107a41..177518756fb2 100644 --- a/keyboards/annepro2/matrix.c +++ b/keyboards/annepro2/matrix.c @@ -25,7 +25,6 @@ #include "matrix.h" #include "annepro2.h" -static matrix_row_t matrix[MATRIX_ROWS]; static matrix_row_t matrix_debouncing[MATRIX_ROWS]; static uint32_t debounce_times[MATRIX_ROWS]; @@ -33,12 +32,11 @@ extern ioline_t row_list[MATRIX_ROWS]; extern ioline_t col_list[MATRIX_COLS]; void matrix_init_custom(void) { - memset(matrix, 0, MATRIX_ROWS * sizeof(matrix_row_t)); memset(matrix_debouncing, 0, MATRIX_ROWS * sizeof(matrix_row_t)); memset(debounce_times, 0, MATRIX_ROWS * sizeof(uint32_t)); } -uint8_t matrix_scan_custom(void) { +bool matrix_scan_custom(matrix_row_t current_matrix[]) { bool matrix_has_changed = false; // cache of input ports for columns static uint16_t port_cache[4]; @@ -73,7 +71,7 @@ uint8_t matrix_scan_custom(void) { debounce_times[row] = timer_read32(); } else if (debounce_times[row] && timer_elapsed32(debounce_times[row]) >= DEBOUNCE) { // when debouncing complete, update matrix - matrix[row] = matrix_debouncing[row]; + current_matrix[row] = matrix_debouncing[row]; debounce_times[row] = 0; matrix_has_changed = true; } From 77ada6d94b1d55a84529c6af6a9ca8a9934b95d9 Mon Sep 17 00:00:00 2001 From: bwisn <56162793+bwisn@users.noreply.github.com> Date: Mon, 18 Oct 2021 22:49:54 +0200 Subject: [PATCH 61/88] annepro2: apply suggestions from tzarc's code review Co-authored-by: Nick Brassel --- keyboards/annepro2/annepro2.c | 10 +-- keyboards/annepro2/annepro2.h | 2 - keyboards/annepro2/c15/config.h | 70 +------------------ keyboards/annepro2/c15/rules.mk | 4 +- keyboards/annepro2/c18/rules.mk | 2 +- .../keymaps/default-full-caps/keymap.c | 12 ---- .../keymaps/default-layer-indicators/keymap.c | 12 ---- keyboards/annepro2/keymaps/default/keymap.c | 12 ---- 8 files changed, 7 insertions(+), 117 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 95dc8e90f439..4d479aa241fb 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -61,7 +61,7 @@ void OVERRIDE bootloader_jump(void) { NVIC_SystemReset(); } -void OVERRIDE keyboard_pre_init_kb(void) { +void keyboard_pre_init_kb(void) { #if HAL_USE_SPI == TRUE spi_init(); #endif @@ -83,7 +83,7 @@ void OVERRIDE keyboard_pre_init_kb(void) { sdStart(&SD0, &ledUartRuntimeConfig); } -void OVERRIDE keyboard_post_init_kb(void) { +void keyboard_post_init_kb(void) { // Start BLE UART sdStart(&SD1, &bleUartConfig); annepro2_ble_startup(); @@ -100,7 +100,6 @@ void OVERRIDE keyboard_post_init_kb(void) { keyboard_post_init_user(); } -void OVERRIDE matrix_init_kb(void) { matrix_init_user(); } void matrix_scan_kb() { // if there's stuff on the ble serial buffer @@ -125,10 +124,7 @@ void matrix_scan_kb() { matrix_scan_user(); } -/*! - * @returns false processing for this keycode has been completed. - */ -bool OVERRIDE process_record_kb(uint16_t keycode, keyrecord_t *record) { +bool process_record_kb(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { if (annepro2LedStatus.matrixEnabled && annepro2LedStatus.isReactive) { annepro2LedForwardKeypress(record->event.key.row, record->event.key.col); diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index d5d88d7498a5..25e0cf4932f1 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -20,8 +20,6 @@ #include #include "qmk_ap2_led.h" -#define OVERRIDE __attribute__((noinline)) - typedef struct __attribute__((__packed__)) { uint8_t _dummy[10]; bool caps_lock; diff --git a/keyboards/annepro2/c15/config.h b/keyboards/annepro2/c15/config.h index 9c6516fbe659..2a74608adf2b 100644 --- a/keyboards/annepro2/c15/config.h +++ b/keyboards/annepro2/c15/config.h @@ -21,7 +21,7 @@ #define VENDOR_ID 0x04d9 #define PRODUCT_ID 0xa290 #define DEVICE_VER 0x1337 -#define MANUFACTURER Holtek +#define MANUFACTURER Obins #define PRODUCT Anne Pro 2 QMK #define ANNEPRO2_C15 @@ -31,77 +31,9 @@ #define MATRIX_COLS 14 // layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 144 bytes -// Max available layers -#define MAX_LAYERS 8 -// keymaps size: layer size * MAX_LAYERS = 1152 bytes - -#define KEYMAP_60_ANSI // Number of supported layouts #define NUM_LAYOUTS 4 /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 -/* number of backlight levels */ -// #define BACKLIGHT_LEVELS 10 - -/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ -//#define LOCKING_SUPPORT_ENABLE -/* Locking resynchronize hack */ -//#define LOCKING_RESYNC_ENABLE - -/* If defined, GRAVE_ESC will always act as ESC when CTRL is held. - * This is userful for the Windows task manager shortcut (ctrl+shift+esc). - */ -// #define GRAVE_ESC_CTRL_OVERRIDE - -/* - * Force NKRO - * - * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved - * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the - * makefile for this to work.) - * - * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) - * until the next keyboard reset. - * - * NKRO may prevent your keystrokes from being detected in the BIOS, but it is - * fully operational during normal computer usage. - * - * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) - * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by - * bootmagic, NKRO mode will always be enabled until it is toggled again during a - * power-up. - * - */ -#define FORCE_NKRO - -/* - * Magic Key Options - * - * Magic keys are hotkey commands that allow control over firmware functions of - * the keyboard. They are best used in combination with the HID Listen program, - * found here: https://www.pjrc.com/teensy/hid_listen.html - * - * The options below allow the magic key functionality to be changed. This is - * useful if your keyboard/keypad is missing keys and you want magic key support. - * - */ - -/* - * Feature disable options - * These options are also useful to firmware size reduction. - */ - -/* disable debug print */ -// #define NO_DEBUG - -/* disable print */ -// #define NO_PRINTg - -/* disable action features */ -//#define NO_ACTION_LAYER -//#define NO_ACTION_TAPPING -//#define NO_ACTION_ONESHOT -//#define NO_ACTION_MACRO -//#define NO_ACTION_FUNCTION diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index da0de1e56ab7..243fd7bfb040 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -15,9 +15,9 @@ MCU_SERIES = HT32F523xx MCU_LDSCRIPT = HT32F52342_ANNEPRO2 MCU_STARTUP = ht32f523xx -BOARD = ANNEPRO2 +BOARD = ANNEPRO2_C15 -OPT_DEFS = -Wno-unused-function -fdump-rtl-dfinish -fstack-usage +OPT_DEFS += -Wno-unused-function -fdump-rtl-dfinish -fstack-usage #EXTRALDFLAGS = -Wl,--print-memory-usage # Options diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 532d6be8b804..67334011a6b6 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -17,7 +17,7 @@ MCU_STARTUP = ht32f523xx BOARD = ANNEPRO2_C18 -OPT_DEFS = -Wno-unused-function -fdump-rtl-dfinish -fstack-usage +OPT_DEFS += -Wno-unused-function -fdump-rtl-dfinish -fstack-usage #EXTRALDFLAGS = -Wl,--print-memory-usage # Options diff --git a/keyboards/annepro2/keymaps/default-full-caps/keymap.c b/keyboards/annepro2/keymaps/default-full-caps/keymap.c index 40fb87359a98..8ac9211ac431 100644 --- a/keyboards/annepro2/keymaps/default-full-caps/keymap.c +++ b/keyboards/annepro2/keymaps/default-full-caps/keymap.c @@ -107,18 +107,6 @@ enum anne_pro_layers { // clang-format on -// Code to run after initializing the keyboard -void keyboard_post_init_user(void) { - // Here are two common functions that you can use. For more LED functions, refer to the file "qmk_ap2_led.h" - - // annepro2-shine disables LEDs by default. Uncomment this function to enable them at startup. - // annepro2LedEnable(); - - // Additionally, it also chooses the first LED profile by default. Refer to the "profiles" array in main.c in - // annepro2-shine to see the order. Replace "i" with the index of your preferred profile. (i.e the RED profile is index 0) - // annepro2LedSetProfile(i); -} - // The function to handle the caps lock logic bool led_update_user(led_t leds) { if (leds.caps_lock) { diff --git a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c index ab23c29bffe6..ac2b421d06f4 100644 --- a/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c +++ b/keyboards/annepro2/keymaps/default-layer-indicators/keymap.c @@ -107,18 +107,6 @@ enum anne_pro_layers { // clang-format on -// Code to run after initializing the keyboard -void keyboard_post_init_user(void) { - // Here are two common functions that you can use. For more LED functions, refer to the file "qmk_ap2_led.h" - - // annepro2-shine disables LEDs by default. Uncomment this function to enable them at startup. - // annepro2LedEnable(); - - // Additionally, it also chooses the first LED profile by default. Refer to the "profiles" array in main.c in - // annepro2-shine to see the order. Replace "i" with the index of your preferred profile. (i.e the RED profile is index 0) - // annepro2LedSetProfile(i); -} - layer_state_t layer_state_set_user(layer_state_t state) { switch (get_highest_layer(state)) { case _FN1_LAYER: diff --git a/keyboards/annepro2/keymaps/default/keymap.c b/keyboards/annepro2/keymaps/default/keymap.c index 0c52220b8d04..a984b05830b2 100644 --- a/keyboards/annepro2/keymaps/default/keymap.c +++ b/keyboards/annepro2/keymaps/default/keymap.c @@ -104,15 +104,3 @@ enum anne_pro_layers { ), }; // clang-format on - -// Code to run after initializing the keyboard -void keyboard_post_init_user(void) { - // Here are two common functions that you can use. For more LED functions, refer to the file "qmk_ap2_led.h" - - // annepro2-shine disables LEDs by default. Uncomment this function to enable them at startup. - // annepro2LedEnable(); - - // Additionally, it also chooses the first LED profile by default. Refer to the "profiles" array in main.c in - // annepro2-shine to see the order. Replace "i" with the index of your preferred profile. (i.e the RED profile is index 0) - // annepro2LedSetProfile(i); -} From 41a8091a08d65f712bbf0a55478f89d6212cc9a8 Mon Sep 17 00:00:00 2001 From: bwisn Date: Mon, 18 Oct 2021 23:33:02 +0200 Subject: [PATCH 62/88] annepro2: more fixes --- keyboards/annepro2/annepro2.c | 14 +- keyboards/annepro2/annepro2.h | 3 - keyboards/annepro2/boards/ANNEPRO2/board.mk | 5 - .../boards/{ANNEPRO2 => ANNEPRO2_C15}/board.c | 9 - .../boards/{ANNEPRO2 => ANNEPRO2_C15}/board.h | 0 .../annepro2/boards/ANNEPRO2_C15/board.mk | 5 + .../annepro2/boards/ANNEPRO2_C18/board.mk | 2 +- keyboards/annepro2/c15/config.h | 4 +- keyboards/annepro2/c18/config.h | 97 +-------- keyboards/annepro2/eeprom_w25x20cl.c | 197 ------------------ keyboards/annepro2/eeprom_w25x20cl.h | 84 -------- keyboards/annepro2/halconf.h | 5 + keyboards/annepro2/hardfault_handler.c | 17 +- keyboards/annepro2/matrix.c | 18 +- keyboards/annepro2/mcuconf.h | 5 + 15 files changed, 40 insertions(+), 425 deletions(-) delete mode 100644 keyboards/annepro2/boards/ANNEPRO2/board.mk rename keyboards/annepro2/boards/{ANNEPRO2 => ANNEPRO2_C15}/board.c (96%) rename keyboards/annepro2/boards/{ANNEPRO2 => ANNEPRO2_C15}/board.h (100%) create mode 100644 keyboards/annepro2/boards/ANNEPRO2_C15/board.mk delete mode 100644 keyboards/annepro2/eeprom_w25x20cl.c delete mode 100644 keyboards/annepro2/eeprom_w25x20cl.h diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 4d479aa241fb..4bd2cecadd50 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -14,7 +14,6 @@ * along with this program. If not, see . */ -#include "ch.h" #include "hal.h" #include "annepro2.h" #include "annepro2_ble.h" @@ -26,10 +25,6 @@ static const SerialConfig ledUartInitConfig = { .speed = 115200, }; -/* - * Some people have serial issues between main chip and led chip. - * This code allows them to easily reduce the speed to 9600 for testing - */ static const SerialConfig ledUartRuntimeConfig = { .speed = 115200, }; @@ -42,7 +37,7 @@ static uint8_t ledMcuWakeup[11] = {0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7 ble_capslock_t BLECapsLock = {._dummy = {0}, .caps_lock = false}; -void OVERRIDE bootloader_jump(void) { +void bootloader_jump(void) { // Send msg to shine to boot into IAP annepro2SetIAP(); @@ -106,13 +101,6 @@ void matrix_scan_kb() { // read it into the capslock struct while (!sdGetWouldBlock(&SD1)) { sdReadTimeout(&SD1, (uint8_t *)&BLECapsLock, sizeof(ble_capslock_t), 10); - - // if it's capslock from ble, darken led - if (BLECapsLock.caps_lock) { - // annepro2LedClearMask(MATRIX_COLS * 2); - } else { - // annepro2LedSetMask(MATRIX_COLS * 2); - } } /* While there's data from LED keyboard sent - read it. */ diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index 25e0cf4932f1..e952c2dcb5a3 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -29,9 +29,6 @@ extern uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS]; extern ble_capslock_t BLECapsLock; -/* System clock - needed for custom matrix lite */ -#define STM32_SYSCLK HT32_CK_SYS_FREQUENCY - // Matrix keymap // clang-format off #define LAYOUT( \ diff --git a/keyboards/annepro2/boards/ANNEPRO2/board.mk b/keyboards/annepro2/boards/ANNEPRO2/board.mk deleted file mode 100644 index 0464919caf22..000000000000 --- a/keyboards/annepro2/boards/ANNEPRO2/board.mk +++ /dev/null @@ -1,5 +0,0 @@ -# List of all the board related files. -BOARDSRC = $(BOARD_PATH)/boards/ANNEPRO2/board.c - -# Required include directories -BOARDINC = $(BOARD_PATH)/boards/ANNEPRO2 diff --git a/keyboards/annepro2/boards/ANNEPRO2/board.c b/keyboards/annepro2/boards/ANNEPRO2_C15/board.c similarity index 96% rename from keyboards/annepro2/boards/ANNEPRO2/board.c rename to keyboards/annepro2/boards/ANNEPRO2_C15/board.c index 98f9d9590185..2be9e0f31c28 100644 --- a/keyboards/annepro2/boards/ANNEPRO2/board.c +++ b/keyboards/annepro2/boards/ANNEPRO2_C15/board.c @@ -15,7 +15,6 @@ */ #include -#include "ch.h" #include "hal.h" #include "wait.h" #include "led.h" @@ -176,13 +175,5 @@ void __early_init(void) { ht32_clock_init(); } -/** - * @brief Board-specific initialization code. - * @todo Add your board-specific code, if any. - */ void boardInit(void) { -#if HAL_USE_GPT == TRUE - gpt_init(); -#endif - // spi_init(); } diff --git a/keyboards/annepro2/boards/ANNEPRO2/board.h b/keyboards/annepro2/boards/ANNEPRO2_C15/board.h similarity index 100% rename from keyboards/annepro2/boards/ANNEPRO2/board.h rename to keyboards/annepro2/boards/ANNEPRO2_C15/board.h diff --git a/keyboards/annepro2/boards/ANNEPRO2_C15/board.mk b/keyboards/annepro2/boards/ANNEPRO2_C15/board.mk new file mode 100644 index 000000000000..f308892e7c45 --- /dev/null +++ b/keyboards/annepro2/boards/ANNEPRO2_C15/board.mk @@ -0,0 +1,5 @@ +# List of all the board related files. +BOARDSRC = $(BOARD_PATH)/boards/ANNEPRO2_C15/board.c + +# Required include directories +BOARDINC = $(BOARD_PATH)/boards/ANNEPRO2_C15 diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.mk b/keyboards/annepro2/boards/ANNEPRO2_C18/board.mk index d3ebf910b572..eb35a913da50 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C18/board.mk +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.mk @@ -1,5 +1,5 @@ # List of all the board related files. -BOARDSRC = $(BOARD_PATH)/boards/ANNEPRO2/board.c +BOARDSRC = $(BOARD_PATH)/boards/ANNEPRO2_C15/board.c # Required include directories BOARDINC = $(BOARD_PATH)/boards/ANNEPRO2_C18 diff --git a/keyboards/annepro2/c15/config.h b/keyboards/annepro2/c15/config.h index 2a74608adf2b..490ce9c3916a 100644 --- a/keyboards/annepro2/c15/config.h +++ b/keyboards/annepro2/c15/config.h @@ -18,8 +18,8 @@ #pragma once /* USB Device descriptor parameter */ -#define VENDOR_ID 0x04d9 -#define PRODUCT_ID 0xa290 +#define VENDOR_ID 0xfeed +#define PRODUCT_ID 0xac15 #define DEVICE_VER 0x1337 #define MANUFACTURER Obins #define PRODUCT Anne Pro 2 QMK diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h index 800bf09d053b..eb23bde144d4 100644 --- a/keyboards/annepro2/c18/config.h +++ b/keyboards/annepro2/c18/config.h @@ -18,10 +18,10 @@ #pragma once /* USB Device descriptor parameter */ -#define VENDOR_ID 0x04d9 -#define PRODUCT_ID 0xa291 +#define VENDOR_ID 0xfeed +#define PRODUCT_ID 0xac18 #define DEVICE_VER 0x1337 -#define MANUFACTURER Holtek +#define MANUFACTURER Obins #define PRODUCT Anne Pro 2(c18)QMK #define ANNEPRO2_C18 @@ -31,11 +31,6 @@ #define MATRIX_COLS 14 // layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 144 bytes -// Max available layers -#define MAX_LAYERS 8 -// keymaps size: layer size * MAX_LAYERS = 1152 bytes - -#define KEYMAP_60_ANSI // Number of supported layouts #define NUM_LAYOUTS 4 @@ -51,90 +46,4 @@ #define SPI_MOSI_PAL_MODE 5 #define SPI_MISO_PIN A2 #define SPI_MISO_PAL_MODE 5 -// EEPROM Config for W25X20CL -#define EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN A3 -#define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 16 -#define EXTERNAL_EEPROM_BYTE_COUNT 1024 // 262144 -#define EXTERNAL_EEPROM_PAGE_SIZE 256 -#define EXTERNAL_EEPROM_ADDRESS_SIZE 3 -#define EXTERNAL_EEPROM_SPI_LSBFIRST false -#define EXTERNAL_EEPROM_SPI_MODE 3 -// HAL Config -#define HAL_USE_SPI TRUE -#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD -// MCU Config -#define HT32_SPI_USE_SPI1 TRUE -#define HT32_SPI1_IRQ_PRIORITY 9 #endif - -/* number of backlight levels */ -// #define BACKLIGHT_LEVELS 10 - -/* Mechanical locking support. Use KC_LCAP, KC_LNUM or KC_LSCR instead in keymap */ -//#define LOCKING_SUPPORT_ENABLE -/* Locking resynchronize hack */ -//#define LOCKING_RESYNC_ENABLE - -/* If defined, GRAVE_ESC will always act as ESC when CTRL is held. - * This is userful for the Windows task manager shortcut (ctrl+shift+esc). - */ -// #define GRAVE_ESC_CTRL_OVERRIDE - -/* - * Force NKRO - * - * Force NKRO (nKey Rollover) to be enabled by default, regardless of the saved - * state in the bootmagic EEPROM settings. (Note that NKRO must be enabled in the - * makefile for this to work.) - * - * If forced on, NKRO can be disabled via magic key (default = LShift+RShift+N) - * until the next keyboard reset. - * - * NKRO may prevent your keystrokes from being detected in the BIOS, but it is - * fully operational during normal computer usage. - * - * For a less heavy-handed approach, enable NKRO via magic key (LShift+RShift+N) - * or via bootmagic (hold SPACE+N while plugging in the keyboard). Once set by - * bootmagic, NKRO mode will always be enabled until it is toggled again during a - * power-up. - * - */ -#define FORCE_NKRO - -/* - * Magic Key Options - * - * Magic keys are hotkey commands that allow control over firmware functions of - * the keyboard. They are best used in combination with the HID Listen program, - * found here: https://www.pjrc.com/teensy/hid_listen.html - * - * The options below allow the magic key functionality to be changed. This is - * useful if your keyboard/keypad is missing keys and you want magic key support. - * - */ - -/* key combination for magic key command */ -/* -#define IS_COMMAND() ( \ - keyboard_report->mods == (MOD_BIT(KC_LSHIFT) | MOD_BIT(KC_RSHIFT)) \ -) -*/ - - -/* - * Feature disable options - * These options are also useful to firmware size reduction. - */ - -/* disable debug print */ -// #define NO_DEBUG - -/* disable print */ -// #define NO_PRINT - -/* disable action features */ -//#define NO_ACTION_LAYER -//#define NO_ACTION_TAPPING -//#define NO_ACTION_ONESHOT -//#define NO_ACTION_MACRO -//#define NO_ACTION_FUNCTION diff --git a/keyboards/annepro2/eeprom_w25x20cl.c b/keyboards/annepro2/eeprom_w25x20cl.c deleted file mode 100644 index 7272cb3c69ed..000000000000 --- a/keyboards/annepro2/eeprom_w25x20cl.c +++ /dev/null @@ -1,197 +0,0 @@ -/* Copyright 2020 Nick Brassel (tzarc) and tech2077 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include - -/* - Note that the implementations of eeprom_XXXX_YYYY on AVR are normally - provided by avr-libc. The same functions are reimplemented below and are - rerouted to the external SPI equivalent. - - Seemingly, as this is compiled from within QMK, the object file generated - during the build overrides the avr-libc implementation during the linking - stage. - - On other platforms such as ARM, there are no provided implementations, so - there is nothing to override during linkage. -*/ - -#include "wait.h" -#include "spi_master.h" -#include "eeprom.h" -#include "eeprom_w25x20cl.h" -#include "timer.h" -#include "debug.h" - -#define CMD_WREN 0x06u -#define CMD_WRDI 0x04u -#define CMD_RDSR 0x05u -#define CMD_WRSR 0x01u -#define CMD_READ 0x03u -#define CMD_WRITE 0x02u -#define CMD_SECTOR_ERASE 0x20u - -#define SR_WIP 0x01u - -// #define DEBUG_EEPROM_OUTPUT - -#ifndef EXTERNAL_EEPROM_SPI_TIMEOUT -# define EXTERNAL_EEPROM_SPI_TIMEOUT 100 -#endif - -bool spi_eeprom_start(void) { return spi_start(EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN, EXTERNAL_EEPROM_SPI_LSBFIRST, EXTERNAL_EEPROM_SPI_MODE, EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR); } - -static spi_status_t spi_eeprom_wait_while_busy(int timeout) { - uint32_t deadline = timer_read32() + timeout; - spi_status_t response; - spi_write(CMD_RDSR); - do { - response = spi_read(); - if (timer_read32() >= deadline) { - return SPI_STATUS_TIMEOUT; - } - } while ((uint16_t)response & SR_WIP); - return SPI_STATUS_SUCCESS; -} -//---------------------------------------------------------------------------------------------------------------------- - -void eeprom_erase(uint32_t addr) { -#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) - uint32_t start = timer_read32(); -#endif - - spi_eeprom_start(); - spi_write(CMD_WREN); - spi_stop(); - - spi_eeprom_start(); - spi_write(CMD_SECTOR_ERASE); - spi_write((uint8_t)((addr & 0xFF0000u) >> 16u)); - spi_write((uint8_t)((addr & 0x00FF00u) >> 8u)); - spi_write((uint8_t)((addr & 0x0000FFu))); - spi_stop(); - - spi_eeprom_start(); - spi_status_t response = spi_eeprom_wait_while_busy(10000); - spi_stop(); - if (response == SPI_STATUS_TIMEOUT) { - dprint("SPI timeout for WIP check\n"); - return; - } - -#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) - dprintf("EEPROM erase took %ldms to complete\n", ((long)(timer_read32() - start))); -#endif -} - -void eeprom_read(void *buf, uint32_t addr, size_t len) { - //------------------------------------------------- - // Wait for the write-in-progress bit to be cleared - bool res = spi_eeprom_start(); - if (!res) { - dprint("failed to start SPI for WIP check\n"); - spi_stop(); - return; - } - - spi_status_t response = spi_eeprom_wait_while_busy(EXTERNAL_EEPROM_SPI_TIMEOUT); - spi_stop(); - if (response == SPI_STATUS_TIMEOUT) { - dprint("SPI timeout for WIP check\n"); - spi_stop(); - return; - } - - //------------------------------------------------- - // Perform read - res = spi_eeprom_start(); - if (!res) { - dprint("failed to start SPI for read\n"); - spi_stop(); - return; - } - - spi_write(CMD_READ); - spi_write((uint8_t)((addr & 0xFF0000u) >> 16u)); - spi_write((uint8_t)((addr & 0x00FF00u) >> 8u)); - spi_write((uint8_t)((addr & 0x0000FFu))); - spi_receive(buf, len); - spi_stop(); - -#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) - dprintf("[EEPROM R] 0x%08lX: ", (addr)); - for (size_t i = 0; i < len; ++i) { - dprintf(" %02X", (int)(((uint8_t *)buf)[i])); - } - dprintf("\n"); -#endif // DEBUG_EEPROM_OUTPUT -} - -void eeprom_write(const void *buf, uint32_t addr, size_t len) { - eeprom_erase(addr); - - //------------------------------------------------- - // Enable writes - bool res = spi_eeprom_start(); - if (!res) { - dprint("failed to start SPI for write-enable\n"); - spi_stop(); - return; - } - - spi_write(CMD_WREN); - spi_stop(); - - wait_us(1); - - //------------------------------------------------- - // Perform the write - res = spi_eeprom_start(); - if (!res) { - dprint("failed to start SPI for write\n"); - spi_stop(); - return; - } - -#if defined(CONSOLE_ENABLE) && defined(DEBUG_EEPROM_OUTPUT) - dprintf("[EEPROM W] 0x%08lX: ", ((uint32_t)(uintptr_t)addr)); - for (size_t i = 0; i < len; i++) { - dprintf(" %02X", (int)(uint8_t)(buf[i])); - } - dprintf("\n"); -#endif // DEBUG_EEPROM_OUTPUT - - spi_write(CMD_WRITE); - spi_write((uint8_t)((addr & 0xFF0000u) >> 16u)); - spi_write((uint8_t)((addr & 0x00FF00u) >> 8u)); - spi_write((uint8_t)((addr & 0x0000FFu))); - spi_transmit(buf, len); - spi_stop(); - - res = spi_eeprom_start(); - if (!res) { - dprint("failed to start SPI for status\n"); - spi_stop(); - return; - } - spi_status_t response = spi_eeprom_wait_while_busy(EXTERNAL_EEPROM_SPI_TIMEOUT); - spi_stop(); - if (response == SPI_STATUS_TIMEOUT) { - dprint("SPI timeout for WIP check\n"); - return; - } -} diff --git a/keyboards/annepro2/eeprom_w25x20cl.h b/keyboards/annepro2/eeprom_w25x20cl.h deleted file mode 100644 index 17021daded64..000000000000 --- a/keyboards/annepro2/eeprom_w25x20cl.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright 2020 Nick Brassel (tzarc) and tech2077 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#pragma once - -void eeprom_erase(uint32_t addr); -void eeprom_read(void *buf, uint32_t addr, size_t len); -void eeprom_write(const void *buf, uint32_t addr, size_t len); - -/* - The slave select pin of the EEPROM. - This needs to be a normal GPIO pin_t value, such as A7. -*/ -#ifndef EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN -# error "No chip select pin defined -- missing EXTERNAL_EEPROM_SPI_SLAVE_SELECT_PIN" -#endif - -/* - The clock divisor for SPI to ensure that the MCU is within the - specifications of the EEPROM chip. Generally this will be PCLK divided by - the intended divisor -- check your clock settings and the datasheet of - your EEPROM. -*/ -#ifndef EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR -# ifdef __AVR__ -# define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 8 -# else -# define EXTERNAL_EEPROM_SPI_CLOCK_DIVISOR 64 -# endif -#endif - -/* - The SPI mode to communicate with the EEPROM. -*/ -#ifndef EXTERNAL_EEPROM_SPI_MODE -# define EXTERNAL_EEPROM_SPI_MODE 0 -#endif - -/* - Whether or not the SPI communication between the MCU and EEPROM should be - LSB-first. -*/ -#ifndef EXTERNAL_EEPROM_SPI_LSBFIRST -# define EXTERNAL_EEPROM_SPI_LSBFIRST false -#endif - -/* - The total size of the EEPROM, in bytes. The EEPROM datasheet will usually - specify this value in kbits, and will require conversion to bytes. -*/ -#ifndef EXTERNAL_EEPROM_BYTE_COUNT -# define EXTERNAL_EEPROM_BYTE_COUNT 8192 -#endif - -/* - The page size in bytes of the EEPROM, as specified in the datasheet. -*/ -#ifndef EXTERNAL_EEPROM_PAGE_SIZE -# define EXTERNAL_EEPROM_PAGE_SIZE 32 -#endif - -/* - The address size in bytes of the EEPROM. For EEPROMs with <=256 bytes, this - will likely be 1. For EEPROMs >256 and <=65536, this will be 2. For EEPROMs - >65536, this will likely need to be 4. - - As expected, consult the datasheet for specifics of your EEPROM. -*/ -#ifndef EXTERNAL_EEPROM_ADDRESS_SIZE -# define EXTERNAL_EEPROM_ADDRESS_SIZE 2 -#endif \ No newline at end of file diff --git a/keyboards/annepro2/halconf.h b/keyboards/annepro2/halconf.h index 686b91a7fb2f..b0cb44003a30 100644 --- a/keyboards/annepro2/halconf.h +++ b/keyboards/annepro2/halconf.h @@ -25,4 +25,9 @@ #define SERIAL_USB_BUFFERS_SIZE 256 +#if defined(ANNEPRO2_EEPROM) +#define HAL_USE_SPI TRUE +#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD +#endif + #include_next diff --git a/keyboards/annepro2/hardfault_handler.c b/keyboards/annepro2/hardfault_handler.c index 78d2b6417837..f9d32c75a06d 100644 --- a/keyboards/annepro2/hardfault_handler.c +++ b/keyboards/annepro2/hardfault_handler.c @@ -1,4 +1,19 @@ -#include "ch.h" + /* Copyright 2021 OpenAnnePro community + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + #include #include "hal.h" diff --git a/keyboards/annepro2/matrix.c b/keyboards/annepro2/matrix.c index 177518756fb2..ffab3be49658 100644 --- a/keyboards/annepro2/matrix.c +++ b/keyboards/annepro2/matrix.c @@ -25,15 +25,10 @@ #include "matrix.h" #include "annepro2.h" -static matrix_row_t matrix_debouncing[MATRIX_ROWS]; -static uint32_t debounce_times[MATRIX_ROWS]; - extern ioline_t row_list[MATRIX_ROWS]; extern ioline_t col_list[MATRIX_COLS]; void matrix_init_custom(void) { - memset(matrix_debouncing, 0, MATRIX_ROWS * sizeof(matrix_row_t)); - memset(debounce_times, 0, MATRIX_ROWS * sizeof(uint32_t)); } bool matrix_scan_custom(matrix_row_t current_matrix[]) { @@ -62,17 +57,8 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { data |= (((port & (1 << PAL_PAD(line))) ? 0 : 1) << col); } - // if a key event happens <5ms before the system time rolls over, - // the event will "never" debounce - // but any event on the same row will reset the debounce timer - if (matrix_debouncing[row] != data) { - // whenever row changes restart debouncing - matrix_debouncing[row] = data; - debounce_times[row] = timer_read32(); - } else if (debounce_times[row] && timer_elapsed32(debounce_times[row]) >= DEBOUNCE) { - // when debouncing complete, update matrix - current_matrix[row] = matrix_debouncing[row]; - debounce_times[row] = 0; + if (current_matrix[row] != data) { + current_matrix[row] = data; matrix_has_changed = true; } } diff --git a/keyboards/annepro2/mcuconf.h b/keyboards/annepro2/mcuconf.h index 12b8771baa87..a663cae5af31 100644 --- a/keyboards/annepro2/mcuconf.h +++ b/keyboards/annepro2/mcuconf.h @@ -63,4 +63,9 @@ #define HT32_USB_USE_USB0 TRUE #define HT32_USB_USB0_IRQ_PRIORITY 5 +#if defined(ANNEPRO2_EEPROM) +#define HT32_SPI_USE_SPI1 TRUE +#define HT32_SPI1_IRQ_PRIORITY 9 +#endif + #endif /* _MCUCONF_H_ */ From af30f799d6ffe819a205c3786bb8328bad68fb66 Mon Sep 17 00:00:00 2001 From: bwisn <56162793+bwisn@users.noreply.github.com> Date: Tue, 19 Oct 2021 22:00:04 +0200 Subject: [PATCH 63/88] annepro2: apply suggestions from code review Co-authored-by: Joel Challis --- keyboards/annepro2/annepro2.h | 7 ++++--- keyboards/annepro2/c15/config.h | 6 ------ keyboards/annepro2/c18/config.h | 6 ------ keyboards/annepro2/matrix.c | 3 --- 4 files changed, 4 insertions(+), 18 deletions(-) diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index e952c2dcb5a3..5f67f791b051 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -24,9 +24,6 @@ typedef struct __attribute__((__packed__)) { uint8_t _dummy[10]; bool caps_lock; } ble_capslock_t; - -extern uint16_t annepro2LedMatrix[MATRIX_ROWS * MATRIX_COLS]; - extern ble_capslock_t BLECapsLock; // Matrix keymap @@ -62,3 +59,7 @@ enum AP2KeyCodes { KC_AP_LED_SPEED, AP2_SAFE_RANGE, }; + +#undef SAFE_RANGE +#define SAFE_RANGE AP2_SAFE_RANGE + diff --git a/keyboards/annepro2/c15/config.h b/keyboards/annepro2/c15/config.h index 490ce9c3916a..4b6363507e4a 100644 --- a/keyboards/annepro2/c15/config.h +++ b/keyboards/annepro2/c15/config.h @@ -23,17 +23,11 @@ #define DEVICE_VER 0x1337 #define MANUFACTURER Obins #define PRODUCT Anne Pro 2 QMK - -#define ANNEPRO2_C15 - // key matrix size #define MATRIX_ROWS 5 #define MATRIX_COLS 14 // layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 144 bytes -// Number of supported layouts -#define NUM_LAYOUTS 4 - /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h index eb23bde144d4..ad77ed9d26e0 100644 --- a/keyboards/annepro2/c18/config.h +++ b/keyboards/annepro2/c18/config.h @@ -23,17 +23,11 @@ #define DEVICE_VER 0x1337 #define MANUFACTURER Obins #define PRODUCT Anne Pro 2(c18)QMK - -#define ANNEPRO2_C18 - // key matrix size #define MATRIX_ROWS 5 #define MATRIX_COLS 14 // layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 144 bytes -// Number of supported layouts -#define NUM_LAYOUTS 4 - /* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ #define DEBOUNCE 5 diff --git a/keyboards/annepro2/matrix.c b/keyboards/annepro2/matrix.c index ffab3be49658..cbd522a54a9a 100644 --- a/keyboards/annepro2/matrix.c +++ b/keyboards/annepro2/matrix.c @@ -28,9 +28,6 @@ extern ioline_t row_list[MATRIX_ROWS]; extern ioline_t col_list[MATRIX_COLS]; -void matrix_init_custom(void) { -} - bool matrix_scan_custom(matrix_row_t current_matrix[]) { bool matrix_has_changed = false; // cache of input ports for columns From 6f89eeea6bd1e58bf3d7c1a0003efd9e23857763 Mon Sep 17 00:00:00 2001 From: bwisn Date: Tue, 19 Oct 2021 22:15:30 +0200 Subject: [PATCH 64/88] annepro2: rename file --- keyboards/annepro2/annepro2.c | 2 +- keyboards/annepro2/annepro2.h | 2 +- keyboards/annepro2/{qmk_ap2_led.c => ap2_led.c} | 2 +- keyboards/annepro2/{qmk_ap2_led.h => ap2_led.h} | 0 keyboards/annepro2/c15/rules.mk | 2 +- keyboards/annepro2/c18/rules.mk | 2 +- 6 files changed, 5 insertions(+), 5 deletions(-) rename keyboards/annepro2/{qmk_ap2_led.c => ap2_led.c} (99%) rename keyboards/annepro2/{qmk_ap2_led.h => ap2_led.h} (100%) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 4bd2cecadd50..0216f13cde1f 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -18,7 +18,7 @@ #include "annepro2.h" #include "annepro2_ble.h" #include "spi_master.h" -#include "qmk_ap2_led.h" +#include "ap2_led.h" #include "protocol.h" static const SerialConfig ledUartInitConfig = { diff --git a/keyboards/annepro2/annepro2.h b/keyboards/annepro2/annepro2.h index 5f67f791b051..b08f8c5352aa 100644 --- a/keyboards/annepro2/annepro2.h +++ b/keyboards/annepro2/annepro2.h @@ -18,7 +18,7 @@ #pragma once #include "quantum.h" #include -#include "qmk_ap2_led.h" +#include "ap2_led.h" typedef struct __attribute__((__packed__)) { uint8_t _dummy[10]; diff --git a/keyboards/annepro2/qmk_ap2_led.c b/keyboards/annepro2/ap2_led.c similarity index 99% rename from keyboards/annepro2/qmk_ap2_led.c rename to keyboards/annepro2/ap2_led.c index 2f08d7dc394f..2a19d378755b 100644 --- a/keyboards/annepro2/qmk_ap2_led.c +++ b/keyboards/annepro2/ap2_led.c @@ -18,7 +18,7 @@ #include #include "hal.h" #include "annepro2.h" -#include "qmk_ap2_led.h" +#include "ap2_led.h" #include "protocol.h" annepro2Led_t ledMask[KEY_COUNT]; diff --git a/keyboards/annepro2/qmk_ap2_led.h b/keyboards/annepro2/ap2_led.h similarity index 100% rename from keyboards/annepro2/qmk_ap2_led.h rename to keyboards/annepro2/ap2_led.h diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index 243fd7bfb040..7f5c94bf6aac 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -3,7 +3,7 @@ SRC = \ matrix.c \ hardfault_handler.c \ annepro2_ble.c \ - qmk_ap2_led.c \ + ap2_led.c \ protocol.c # MCU diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 67334011a6b6..abb7de581594 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -3,7 +3,7 @@ SRC = \ matrix.c \ hardfault_handler.c \ annepro2_ble.c \ - qmk_ap2_led.c \ + ap2_led.c \ protocol.c # MCU From 0e1449c4589483a558af840f46096d7e4b580b3c Mon Sep 17 00:00:00 2001 From: bwisn Date: Mon, 1 Nov 2021 07:54:07 +0100 Subject: [PATCH 65/88] more fixes --- keyboards/annepro2/annepro2.c | 2 +- .../annepro2/boards/ANNEPRO2_C15/board.c | 188 ++++++------------ .../annepro2/boards/ANNEPRO2_C15/board.h | 67 +++---- .../annepro2/boards/ANNEPRO2_C18/board.h | 5 +- keyboards/annepro2/c15/config.h | 4 - keyboards/annepro2/c18/config.h | 3 - keyboards/annepro2/mcuconf.h | 6 +- keyboards/annepro2/protocol.h | 5 +- 8 files changed, 101 insertions(+), 179 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 0216f13cde1f..353bc20d447c 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -56,7 +56,7 @@ void bootloader_jump(void) { NVIC_SystemReset(); } -void keyboard_pre_init_kb(void) { +void keyboard_pre_init_user(void) { #if HAL_USE_SPI == TRUE spi_init(); #endif diff --git a/keyboards/annepro2/boards/ANNEPRO2_C15/board.c b/keyboards/annepro2/boards/ANNEPRO2_C15/board.c index 2be9e0f31c28..d5d6ba535bf8 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C15/board.c +++ b/keyboards/annepro2/boards/ANNEPRO2_C15/board.c @@ -24,65 +24,17 @@ /* ============ Function Prototypes ================== */ - #define PBIT(PORT, LINE) ((PAL_PORT(LINE) == PORT) ? (1 << PAL_PAD(LINE)) : 0) #define PAFIO_L(PORT, LINE, AF) (((PAL_PORT(LINE) == PORT) && (PAL_PAD(LINE) < 8)) ? (AF << (PAL_PAD(LINE) << 2)) : 0) #define PAFIO_H(PORT, LINE, AF) (((PAL_PORT(LINE) == PORT) && (PAL_PAD(LINE) >= 8)) ? (AF << ((PAL_PAD(LINE) - 8) << 2)) : 0) #define PAFIO(PORT, N, LINE, AF) ((N) ? PAFIO_H(PORT, LINE, AF) : PAFIO_L(PORT, LINE, AF)) -#define OUT_BITS(PORT) (\ - PBIT(PORT, LINE_ROW1 ) | \ - PBIT(PORT, LINE_ROW2 ) | \ - PBIT(PORT, LINE_ROW3 ) | \ - PBIT(PORT, LINE_ROW4 ) | \ - PBIT(PORT, LINE_ROW5 ) | \ -0) - -#define IN_BITS(PORT) (\ - PBIT(PORT, LINE_COL1) | \ - PBIT(PORT, LINE_COL2) | \ - PBIT(PORT, LINE_COL3) | \ - PBIT(PORT, LINE_COL4) | \ - PBIT(PORT, LINE_COL5) | \ - PBIT(PORT, LINE_COL6) | \ - PBIT(PORT, LINE_COL7) | \ - PBIT(PORT, LINE_COL8) | \ - PBIT(PORT, LINE_COL9) | \ - PBIT(PORT, LINE_COL10)| \ - PBIT(PORT, LINE_COL11)| \ - PBIT(PORT, LINE_COL12)| \ - PBIT(PORT, LINE_COL13)| \ - PBIT(PORT, LINE_COL14)| \ -0) - -// Alternate Functions -#define AF_BITS(PORT, N) (\ - PAFIO(PORT, N, LINE_UART_RX, AFIO_USART)| \ - PAFIO(PORT, N, LINE_UART_TX, AFIO_USART)| \ - PAFIO(PORT, N, LINE_BT_UART_TX, AFIO_USART)| \ - PAFIO(PORT, N, LINE_BT_UART_RX, AFIO_USART)| \ - PAFIO(PORT, N, LINE_ROW1, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_ROW2, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_ROW3, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_ROW4, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_ROW5, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_COL1, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_COL2, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_COL3, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_COL4, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_COL5, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_COL6, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_COL7, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_COL8, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_COL9, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_COL10, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_COL11, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_COL12, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_COL13, AFIO_GPIO) | \ - PAFIO(PORT, N, LINE_COL14, AFIO_GPIO) | \ -0) +#define OUT_BITS(PORT) (PBIT(PORT, LINE_ROW1) | PBIT(PORT, LINE_ROW2) | PBIT(PORT, LINE_ROW3) | PBIT(PORT, LINE_ROW4) | PBIT(PORT, LINE_ROW5) | 0) +#define IN_BITS(PORT) (PBIT(PORT, LINE_COL1) | PBIT(PORT, LINE_COL2) | PBIT(PORT, LINE_COL3) | PBIT(PORT, LINE_COL4) | PBIT(PORT, LINE_COL5) | PBIT(PORT, LINE_COL6) | PBIT(PORT, LINE_COL7) | PBIT(PORT, LINE_COL8) | PBIT(PORT, LINE_COL9) | PBIT(PORT, LINE_COL10) | PBIT(PORT, LINE_COL11) | PBIT(PORT, LINE_COL12) | PBIT(PORT, LINE_COL13) | PBIT(PORT, LINE_COL14) | 0) +// Alternate Functions +#define AF_BITS(PORT, N) (PAFIO(PORT, N, LINE_UART_RX, AFIO_USART) | PAFIO(PORT, N, LINE_UART_TX, AFIO_USART) | PAFIO(PORT, N, LINE_BT_UART_TX, AFIO_USART) | PAFIO(PORT, N, LINE_BT_UART_RX, AFIO_USART) | PAFIO(PORT, N, LINE_ROW1, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW2, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW3, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW4, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW5, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL1, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL2, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL3, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL4, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL5, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL6, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL7, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL8, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL9, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL10, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL11, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL12, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL13, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL14, AFIO_GPIO) | 0) /** * @brief PAL setup. @@ -91,89 +43,77 @@ */ const PALConfig pal_default_config = { // GPIO A - .setup[0] = { - .DIR = OUT_BITS(IOPORTA), - .INE = IN_BITS(IOPORTA), - .PU = IN_BITS(IOPORTA), - .PD = 0x0000, - .OD = 0x0000, - .DRV = 0x0000, - .LOCK = 0x0000, - .OUT = 0x0000, - .CFG[0] = AF_BITS(IOPORTA, 0), - .CFG[1] = AF_BITS(IOPORTA, 1), - }, + .setup[0] = + { + .DIR = OUT_BITS(IOPORTA), + .INE = IN_BITS(IOPORTA), + .PU = IN_BITS(IOPORTA), + .PD = 0x0000, + .OD = 0x0000, + .DRV = 0x0000, + .LOCK = 0x0000, + .OUT = 0x0000, + .CFG[0] = AF_BITS(IOPORTA, 0), + .CFG[1] = AF_BITS(IOPORTA, 1), + }, // GPIO B - .setup[1] = { - .DIR = OUT_BITS(IOPORTB), - .INE = IN_BITS(IOPORTB), - .PU = IN_BITS(IOPORTB), - .PD = 0x0000, - .OD = 0x0000, - .DRV = 0x0000, - .LOCK = 0x0000, - .OUT = 0x0000, - .CFG[0] = AF_BITS(IOPORTB, 0), - .CFG[1] = AF_BITS(IOPORTB, 1), - }, + .setup[1] = + { + .DIR = OUT_BITS(IOPORTB), + .INE = IN_BITS(IOPORTB), + .PU = IN_BITS(IOPORTB), + .PD = 0x0000, + .OD = 0x0000, + .DRV = 0x0000, + .LOCK = 0x0000, + .OUT = 0x0000, + .CFG[0] = AF_BITS(IOPORTB, 0), + .CFG[1] = AF_BITS(IOPORTB, 1), + }, // GPIO C - .setup[2] = { - .DIR = OUT_BITS(IOPORTC), - .INE = IN_BITS(IOPORTC), - .PU = IN_BITS(IOPORTC), - .PD = 0x0000, - .OD = 0x0000, - .DRV = 0x0000, - .LOCK = 0x0000, - .OUT = 0x0000, - .CFG[0] = AF_BITS(IOPORTC, 0), - .CFG[1] = AF_BITS(IOPORTC, 1), - }, + .setup[2] = + { + .DIR = OUT_BITS(IOPORTC), + .INE = IN_BITS(IOPORTC), + .PU = IN_BITS(IOPORTC), + .PD = 0x0000, + .OD = 0x0000, + .DRV = 0x0000, + .LOCK = 0x0000, + .OUT = 0x0000, + .CFG[0] = AF_BITS(IOPORTC, 0), + .CFG[1] = AF_BITS(IOPORTC, 1), + }, // GPIO D - .setup[3] = { - .DIR = OUT_BITS(IOPORTD), - .INE = IN_BITS(IOPORTD), - .PU = IN_BITS(IOPORTD), - .PD = 0x0000, - .OD = 0x0000, - .DRV = 0x0000, - .LOCK = 0x0000, - .OUT = 0x0000, - .CFG[0] = AF_BITS(IOPORTD, 0), - .CFG[1] = AF_BITS(IOPORTD, 1), - }, + .setup[3] = + { + .DIR = OUT_BITS(IOPORTD), + .INE = IN_BITS(IOPORTD), + .PU = IN_BITS(IOPORTD), + .PD = 0x0000, + .OD = 0x0000, + .DRV = 0x0000, + .LOCK = 0x0000, + .OUT = 0x0000, + .CFG[0] = AF_BITS(IOPORTD, 0), + .CFG[1] = AF_BITS(IOPORTD, 1), + }, .ESSR[0] = 0x00000000, .ESSR[1] = 0x00000000, }; const ioline_t row_list[MATRIX_ROWS] = { - LINE_ROW1, - LINE_ROW2, - LINE_ROW3, - LINE_ROW4, - LINE_ROW5, + LINE_ROW1, LINE_ROW2, LINE_ROW3, LINE_ROW4, LINE_ROW5, }; const ioline_t col_list[MATRIX_COLS] = { - LINE_COL1, - LINE_COL2, - LINE_COL3, - LINE_COL4, - LINE_COL5, - LINE_COL6, - LINE_COL7, - LINE_COL8, - LINE_COL9, - LINE_COL10, - LINE_COL11, - LINE_COL12, - LINE_COL13, - LINE_COL14, + LINE_COL1, LINE_COL2, LINE_COL3, LINE_COL4, LINE_COL5, LINE_COL6, LINE_COL7, LINE_COL8, LINE_COL9, LINE_COL10, LINE_COL11, LINE_COL12, LINE_COL13, LINE_COL14, }; -void __early_init(void) { - ht32_clock_init(); -} +void __early_init(void) {} + +void early_hardware_init_pre(void) { ht32_clock_init(); } + +void board_init(void) {} -void boardInit(void) { -} +void boardInit(void) {} diff --git a/keyboards/annepro2/boards/ANNEPRO2_C15/board.h b/keyboards/annepro2/boards/ANNEPRO2_C15/board.h index 695f1b7e96ac..e29a73956ae5 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C15/board.h +++ b/keyboards/annepro2/boards/ANNEPRO2_C15/board.h @@ -14,8 +14,7 @@ limitations under the License. */ -#ifndef BOARD_H -#define BOARD_H +#pragma once /* * Setup for Anne Pro 2 board. */ @@ -24,54 +23,52 @@ * Board identifier. */ #define ANNEPRO2 -#define BOARD_NAME "Anne Pro 2" +#define BOARD_NAME "Anne Pro 2" #define HT32F52342 -#define FLASH_SIZE (0x10000 - 0x4000) // 64kB - 16kB +#define FLASH_SIZE (0x10000 - 0x4000) // 64kB - 16kB /* * I/O */ -#define LINE_UART_TX PAL_LINE(IOPORTB, 0) // Master TX, LED RX -#define LINE_UART_RX PAL_LINE(IOPORTB, 1) // Master RX, LED TX +#define LINE_UART_TX PAL_LINE(IOPORTB, 0) // Master TX, LED RX +#define LINE_UART_RX PAL_LINE(IOPORTB, 1) // Master RX, LED TX -#define LINE_BT_UART_TX PAL_LINE(IOPORTA, 4) // Master TX, BLE RX -#define LINE_BT_UART_RX PAL_LINE(IOPORTA, 5) // Master RX, BLE TX +#define LINE_BT_UART_TX PAL_LINE(IOPORTA, 4) // Master TX, BLE RX +#define LINE_BT_UART_RX PAL_LINE(IOPORTA, 5) // Master RX, BLE TX // outputs (rows are pulled low) -#define LINE_ROW1 PAL_LINE(IOPORTC, 2) -#define LINE_ROW2 PAL_LINE(IOPORTC, 1) -#define LINE_ROW3 PAL_LINE(IOPORTB, 5) -#define LINE_ROW4 PAL_LINE(IOPORTB, 4) -#define LINE_ROW5 PAL_LINE(IOPORTC, 3) +#define LINE_ROW1 PAL_LINE(IOPORTC, 2) +#define LINE_ROW2 PAL_LINE(IOPORTC, 1) +#define LINE_ROW3 PAL_LINE(IOPORTB, 5) +#define LINE_ROW4 PAL_LINE(IOPORTB, 4) +#define LINE_ROW5 PAL_LINE(IOPORTC, 3) // inputs (columns are sampled) -#define LINE_COL1 PAL_LINE(IOPORTC, 4) -#define LINE_COL2 PAL_LINE(IOPORTC, 5) -#define LINE_COL3 PAL_LINE(IOPORTB, 10) -#define LINE_COL4 PAL_LINE(IOPORTB, 11) -#define LINE_COL5 PAL_LINE(IOPORTC, 0) -#define LINE_COL6 PAL_LINE(IOPORTA, 15) -#define LINE_COL7 PAL_LINE(IOPORTA, 8) -#define LINE_COL8 PAL_LINE(IOPORTA, 10) -#define LINE_COL9 PAL_LINE(IOPORTA, 11) +#define LINE_COL1 PAL_LINE(IOPORTC, 4) +#define LINE_COL2 PAL_LINE(IOPORTC, 5) +#define LINE_COL3 PAL_LINE(IOPORTB, 10) +#define LINE_COL4 PAL_LINE(IOPORTB, 11) +#define LINE_COL5 PAL_LINE(IOPORTC, 0) +#define LINE_COL6 PAL_LINE(IOPORTA, 15) +#define LINE_COL7 PAL_LINE(IOPORTA, 8) +#define LINE_COL8 PAL_LINE(IOPORTA, 10) +#define LINE_COL9 PAL_LINE(IOPORTA, 11) // PORTA 12,13 conflict with SWD -#define LINE_COL10 PAL_LINE(IOPORTA, 12) -#define LINE_COL11 PAL_LINE(IOPORTA, 13) -#define LINE_COL12 PAL_LINE(IOPORTA, 14) -#define LINE_COL13 PAL_LINE(IOPORTB, 2) -#define LINE_COL14 PAL_LINE(IOPORTB, 3) +#define LINE_COL10 PAL_LINE(IOPORTA, 12) +#define LINE_COL11 PAL_LINE(IOPORTA, 13) +#define LINE_COL12 PAL_LINE(IOPORTA, 14) +#define LINE_COL13 PAL_LINE(IOPORTB, 2) +#define LINE_COL14 PAL_LINE(IOPORTB, 3) #if !defined(_FROM_ASM_) -#ifdef __cplusplus +# ifdef __cplusplus extern "C" { -#endif - void boardInit(void); -#ifdef __cplusplus +# endif +void boardInit(void); +# ifdef __cplusplus } -#endif -#endif /* _FROM_ASM_ */ - -#endif /* BOARD_H */ +# endif +#endif /* _FROM_ASM_ */ \ No newline at end of file diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h index ee75f310d666..01ca26c917de 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h @@ -14,8 +14,7 @@ limitations under the License. */ -#ifndef BOARD_H -#define BOARD_H +#pragma once /* * Setup for Anne Pro 2 board. */ @@ -71,5 +70,3 @@ extern "C" { } #endif #endif /* _FROM_ASM_ */ - -#endif /* BOARD_H */ diff --git a/keyboards/annepro2/c15/config.h b/keyboards/annepro2/c15/config.h index 4b6363507e4a..3b7b56f58246 100644 --- a/keyboards/annepro2/c15/config.h +++ b/keyboards/annepro2/c15/config.h @@ -27,7 +27,3 @@ #define MATRIX_ROWS 5 #define MATRIX_COLS 14 // layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 144 bytes - -/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ -#define DEBOUNCE 5 - diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h index ad77ed9d26e0..957c0284c05f 100644 --- a/keyboards/annepro2/c18/config.h +++ b/keyboards/annepro2/c18/config.h @@ -28,9 +28,6 @@ #define MATRIX_COLS 14 // layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 144 bytes -/* Debounce reduces chatter (unintended double-presses) - set 0 if debouncing is not needed */ -#define DEBOUNCE 5 - #if defined(ANNEPRO2_EEPROM) // SPI Config #define SPI_DRIVER SPID1 diff --git a/keyboards/annepro2/mcuconf.h b/keyboards/annepro2/mcuconf.h index a663cae5af31..8c6e00c978e9 100644 --- a/keyboards/annepro2/mcuconf.h +++ b/keyboards/annepro2/mcuconf.h @@ -13,9 +13,7 @@ See the License for the specific language governing permissions and limitations under the License. */ - -#ifndef _MCUCONF_H_ -#define _MCUCONF_H_ +#pragma once #include "nvic.h" @@ -68,4 +66,4 @@ #define HT32_SPI1_IRQ_PRIORITY 9 #endif -#endif /* _MCUCONF_H_ */ + diff --git a/keyboards/annepro2/protocol.h b/keyboards/annepro2/protocol.h index 4e07908b404e..ccc85df09df2 100644 --- a/keyboards/annepro2/protocol.h +++ b/keyboards/annepro2/protocol.h @@ -6,8 +6,7 @@ * shine's clang formatting). */ -#ifndef PROTOCOL_INCLUDED -#define PROTOCOL_INCLUDED +#pragma once #include #define PROTOCOL_SD SD0 @@ -110,5 +109,3 @@ extern void protoSilence(protocol_t *proto); /* Transmit message */ extern void protoTx(uint8_t cmd, const unsigned char *buf, int payloadSize, int retries); - -#endif From 72884e63f9300ae73a7c49daabe18adfc214a6c7 Mon Sep 17 00:00:00 2001 From: bwisn <56162793+bwisn@users.noreply.github.com> Date: Tue, 2 Nov 2021 16:34:37 +0100 Subject: [PATCH 66/88] Apply suggestions from @tzarc code review Co-authored-by: Nick Brassel --- keyboards/annepro2/annepro2.c | 14 ++++++++------ keyboards/annepro2/annepro2_ble.c | 19 ++++++++++--------- .../annepro2/boards/ANNEPRO2_C15/board.c | 4 ---- .../annepro2/boards/ANNEPRO2_C15/board.h | 1 - .../annepro2/boards/ANNEPRO2_C18/board.h | 1 - keyboards/annepro2/c15/config.h | 2 +- keyboards/annepro2/c15/rules.mk | 5 ++--- keyboards/annepro2/c18/config.h | 13 +------------ keyboards/annepro2/c18/rules.mk | 5 ++--- keyboards/annepro2/halconf.h | 5 ----- keyboards/annepro2/mcuconf.h | 7 ------- 11 files changed, 24 insertions(+), 52 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 353bc20d447c..7ea5058883d6 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -25,8 +25,12 @@ static const SerialConfig ledUartInitConfig = { .speed = 115200, }; +#ifndef LED_UART_BAUD_RATE +# define LED_UART_BAUD_RATE 115200 +#endif // LED_UART_BAUD_RATE + static const SerialConfig ledUartRuntimeConfig = { - .speed = 115200, + .speed = LED_UART_BAUD_RATE, }; static const SerialConfig bleUartConfig = { @@ -56,16 +60,13 @@ void bootloader_jump(void) { NVIC_SystemReset(); } -void keyboard_pre_init_user(void) { -#if HAL_USE_SPI == TRUE - spi_init(); -#endif +void keyboard_pre_init_kb(void) { // Start LED UART sdStart(&SD0, &ledUartInitConfig); /* Let the LED chip settle a bit before switching the mode. * That helped at least one person. */ wait_ms(15); - sdWrite(&SD0, ledMcuWakeup, 11); + sdWrite(&SD0, ledMcuWakeup, sizeof(ledMcuWakeup)); // wait to receive response from wakeup wait_ms(15); @@ -76,6 +77,7 @@ void keyboard_pre_init_user(void) { while (!sdGetWouldBlock(&SD0)) sdGet(&SD0); sdStart(&SD0, &ledUartRuntimeConfig); + keyboard_pre_init_user(); } void keyboard_post_init_kb(void) { diff --git a/keyboards/annepro2/annepro2_ble.c b/keyboards/annepro2/annepro2_ble.c index 69a8ba1acfc0..72cbb6801675 100644 --- a/keyboards/annepro2/annepro2_ble.c +++ b/keyboards/annepro2/annepro2_ble.c @@ -66,16 +66,16 @@ static bool lastNkroStatus = false; /* -------------------- Public Function Implementation ---------------------- */ -void annepro2_ble_bootload(void) { sdWrite(&SD1, bleMcuBootload, 11); } +void annepro2_ble_bootload(void) { sdWrite(&SD1, bleMcuBootload, sizeof(bleMcuBootload)); } -void annepro2_ble_startup(void) { sdWrite(&SD1, bleMcuWakeup, 11); } +void annepro2_ble_startup(void) { sdWrite(&SD1, bleMcuWakeup, sizeof(bleMcuWakeup)); } void annepro2_ble_broadcast(uint8_t port) { if (port > 3) { port = 3; } // sdPut(&SD1, 0x00); - sdWrite(&SD1, bleMcuStartBroadcast, 10); + sdWrite(&SD1, bleMcuStartBroadcast, sizeof(bleMcuStartBroadcast)); sdPut(&SD1, port); static int lastBroadcast = -1; if (lastBroadcast == port) { @@ -88,7 +88,7 @@ void annepro2_ble_connect(uint8_t port) { if (port > 3) { port = 3; } - sdWrite(&SD1, bleMcuConnect, 10); + sdWrite(&SD1, bleMcuConnect, sizeof(bleMcuConnect)); sdPut(&SD1, port); ap2_ble_swtich_ble_driver(); } @@ -108,7 +108,7 @@ void annepro2_ble_disconnect(void) { void annepro2_ble_unpair(void) { // sdPut(&SD1, 0x0); - sdWrite(&SD1, bleMcuUnpair, 11); + sdWrite(&SD1, bleMcuUnpair, sizeof(bleMcuUnpair)); } /* ------------------- Static Function Implementation ----------------------- */ @@ -154,9 +154,10 @@ static inline uint16_t CONSUMER2AP2(uint16_t usage) { static void ap2_ble_consumer(uint16_t data) { sdPut(&SD1, 0x0); - sdWrite(&SD1, bleMcuSendConsumerReport, 10); + sdWrite(&SD1, bleMcuSendConsumerReport, sizeof(bleMcuSendConsumerReport)); sdPut(&SD1, CONSUMER2AP2(data)); - sdWrite(&SD1, 0x0, 3); + static const uint8_t dummy[3] = {0}; + sdWrite(&SD1, dummy, sizeof(dummy)); } /*! @@ -164,6 +165,6 @@ static void ap2_ble_consumer(uint16_t data) { */ static void ap2_ble_keyboard(report_keyboard_t *report) { sdPut(&SD1, 0x0); - sdWrite(&SD1, bleMcuSendReport, 10); - sdWrite(&SD1, &report->raw[0], 8); + sdWrite(&SD1, bleMcuSendReport, sizeof(bleMcuSendReport)); + sdWrite(&SD1, &report->raw[0], KEYBOARD_REPORT_SIZE); } diff --git a/keyboards/annepro2/boards/ANNEPRO2_C15/board.c b/keyboards/annepro2/boards/ANNEPRO2_C15/board.c index d5d6ba535bf8..d62bd1dbd051 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C15/board.c +++ b/keyboards/annepro2/boards/ANNEPRO2_C15/board.c @@ -14,11 +14,7 @@ limitations under the License. */ -#include #include "hal.h" -#include "wait.h" -#include "led.h" -#include "annepro2.h" /* ============ Private Defines ===================== */ diff --git a/keyboards/annepro2/boards/ANNEPRO2_C15/board.h b/keyboards/annepro2/boards/ANNEPRO2_C15/board.h index e29a73956ae5..48a65a135516 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C15/board.h +++ b/keyboards/annepro2/boards/ANNEPRO2_C15/board.h @@ -22,7 +22,6 @@ /* * Board identifier. */ -#define ANNEPRO2 #define BOARD_NAME "Anne Pro 2" #define HT32F52342 diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h index 01ca26c917de..8dd5c2e87860 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h @@ -22,7 +22,6 @@ /* * Board identifier. */ -#define ANNEPRO2 #define BOARD_NAME "Anne Pro 2" #define HT32F52342 diff --git a/keyboards/annepro2/c15/config.h b/keyboards/annepro2/c15/config.h index 3b7b56f58246..108a4e0bb51b 100644 --- a/keyboards/annepro2/c15/config.h +++ b/keyboards/annepro2/c15/config.h @@ -26,4 +26,4 @@ // key matrix size #define MATRIX_ROWS 5 #define MATRIX_COLS 14 -// layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 144 bytes +// layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 140 bytes diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index 7f5c94bf6aac..e62c0e88caac 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -1,7 +1,6 @@ # Anne Pro 2 SRC = \ matrix.c \ - hardfault_handler.c \ annepro2_ble.c \ ap2_led.c \ protocol.c @@ -32,8 +31,8 @@ KEY_LOCK_ENABLE = no # Other featues BOOTMAGIC_ENABLE = no CONSOLE_ENABLE = no -COMMAND_ENABLE = yes -RAW_ENABLE = yes +COMMAND_ENABLE = no +RAW_ENABLE = no MIDI_ENABLE = no VIRTSER_ENABLE = no COMBO_ENABLE = no diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h index 957c0284c05f..e99ec2bba7f6 100644 --- a/keyboards/annepro2/c18/config.h +++ b/keyboards/annepro2/c18/config.h @@ -26,15 +26,4 @@ // key matrix size #define MATRIX_ROWS 5 #define MATRIX_COLS 14 -// layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 144 bytes - -#if defined(ANNEPRO2_EEPROM) -// SPI Config -#define SPI_DRIVER SPID1 -#define SPI_SCK_PIN A0 -#define SPI_SCK_PAL_MODE 5 -#define SPI_MOSI_PIN A1 -#define SPI_MOSI_PAL_MODE 5 -#define SPI_MISO_PIN A2 -#define SPI_MISO_PAL_MODE 5 -#endif +// layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 140 bytes diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index abb7de581594..ee595ac3567a 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -1,7 +1,6 @@ # Anne Pro 2 SRC = \ matrix.c \ - hardfault_handler.c \ annepro2_ble.c \ ap2_led.c \ protocol.c @@ -32,8 +31,8 @@ KEY_LOCK_ENABLE = no # Other featues BOOTMAGIC_ENABLE = yes CONSOLE_ENABLE = no -COMMAND_ENABLE = yes -RAW_ENABLE = yes +COMMAND_ENABLE = no +RAW_ENABLE = no MIDI_ENABLE = no VIRTSER_ENABLE = no COMBO_ENABLE = no diff --git a/keyboards/annepro2/halconf.h b/keyboards/annepro2/halconf.h index b0cb44003a30..686b91a7fb2f 100644 --- a/keyboards/annepro2/halconf.h +++ b/keyboards/annepro2/halconf.h @@ -25,9 +25,4 @@ #define SERIAL_USB_BUFFERS_SIZE 256 -#if defined(ANNEPRO2_EEPROM) -#define HAL_USE_SPI TRUE -#define SPI_SELECT_MODE SPI_SELECT_MODE_PAD -#endif - #include_next diff --git a/keyboards/annepro2/mcuconf.h b/keyboards/annepro2/mcuconf.h index 8c6e00c978e9..8265fe6eb94f 100644 --- a/keyboards/annepro2/mcuconf.h +++ b/keyboards/annepro2/mcuconf.h @@ -60,10 +60,3 @@ #define HT32_USB_USE_USB0 TRUE #define HT32_USB_USB0_IRQ_PRIORITY 5 - -#if defined(ANNEPRO2_EEPROM) -#define HT32_SPI_USE_SPI1 TRUE -#define HT32_SPI1_IRQ_PRIORITY 9 -#endif - - From ae60484d16d10ba4fdb11f5bf30acb20bd2942c6 Mon Sep 17 00:00:00 2001 From: bwisn <56162793+bwisn@users.noreply.github.com> Date: Tue, 2 Nov 2021 16:35:29 +0100 Subject: [PATCH 67/88] Update keyboards/annepro2/protocol.h Co-authored-by: Nick Brassel --- keyboards/annepro2/protocol.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/annepro2/protocol.h b/keyboards/annepro2/protocol.h index ccc85df09df2..d1a05683c87b 100644 --- a/keyboards/annepro2/protocol.h +++ b/keyboards/annepro2/protocol.h @@ -7,7 +7,7 @@ */ #pragma once -#include +#include #define PROTOCOL_SD SD0 From d36ed0c2513d340c8d6bbbe4f35b7ff9bd531064 Mon Sep 17 00:00:00 2001 From: bwisn <56162793+bwisn@users.noreply.github.com> Date: Tue, 2 Nov 2021 16:35:52 +0100 Subject: [PATCH 68/88] Update keyboards/annepro2/chconf.h Co-authored-by: Nick Brassel --- keyboards/annepro2/chconf.h | 39 ------------------------------------- 1 file changed, 39 deletions(-) diff --git a/keyboards/annepro2/chconf.h b/keyboards/annepro2/chconf.h index 0a29c7ad885e..51fe38cf275c 100644 --- a/keyboards/annepro2/chconf.h +++ b/keyboards/annepro2/chconf.h @@ -27,44 +27,5 @@ #define CH_CFG_TIME_QUANTUM 20 -#define CH_CFG_USE_REGISTRY TRUE - -#define CH_CFG_USE_WAITEXIT TRUE - -#define CH_CFG_USE_CONDVARS TRUE - -#define CH_CFG_USE_MESSAGES TRUE - -#define CH_CFG_USE_MAILBOXES TRUE - -#define CH_CFG_USE_HEAP TRUE - -#define CH_CFG_USE_MEMPOOLS TRUE - -#define CH_CFG_USE_OBJ_FIFOS TRUE - -#define CH_CFG_USE_PIPES TRUE - -#define CH_CFG_USE_DYNAMIC TRUE - -#define CH_CFG_USE_FACTORY TRUE - -#define CH_CFG_FACTORY_OBJECTS_REGISTRY TRUE - -#define CH_CFG_FACTORY_GENERIC_BUFFERS TRUE - -#define CH_CFG_FACTORY_SEMAPHORES TRUE - -#define CH_CFG_FACTORY_MAILBOXES TRUE - -#define CH_CFG_FACTORY_OBJ_FIFOS TRUE - -#define CH_CFG_FACTORY_PIPES TRUE - -#define CH_DBG_SYSTEM_STATE_CHECK FALSE // adds about 1K code - -#define CH_DBG_ENABLE_CHECKS FALSE // adds < 1K code - -#define CH_DBG_ENABLE_ASSERTS FALSE // adds about 3K code #include_next \ No newline at end of file From f0d102c214d255067896a597882568db2f1aa58f Mon Sep 17 00:00:00 2001 From: bwisn Date: Sat, 13 Nov 2021 12:31:10 +0100 Subject: [PATCH 69/88] apply CR suggestions --- keyboards/annepro2/annepro2.c | 39 ++++--- .../annepro2/boards/ANNEPRO2_C15/board.c | 8 -- .../annepro2/boards/ANNEPRO2_C18/board.c | 107 ++++++++++++++++++ .../annepro2/boards/ANNEPRO2_C18/board.mk | 2 +- keyboards/annepro2/c15/rules.mk | 3 - keyboards/annepro2/c18/post_rules.mk | 4 - keyboards/annepro2/c18/rules.mk | 3 - keyboards/annepro2/hardfault_handler.c | 62 ---------- 8 files changed, 131 insertions(+), 97 deletions(-) create mode 100644 keyboards/annepro2/boards/ANNEPRO2_C18/board.c delete mode 100644 keyboards/annepro2/c18/post_rules.mk delete mode 100644 keyboards/annepro2/hardfault_handler.c diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 7ea5058883d6..596300a1aefa 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -1,18 +1,18 @@ - /* Copyright 2021 OpenAnnePro community - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ +/* Copyright 2021 OpenAnnePro community + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include "hal.h" #include "annepro2.h" @@ -37,6 +37,14 @@ static const SerialConfig bleUartConfig = { .speed = 115200, }; +const ioline_t row_list[MATRIX_ROWS] = { + LINE_ROW1, LINE_ROW2, LINE_ROW3, LINE_ROW4, LINE_ROW5, +}; + +const ioline_t col_list[MATRIX_COLS] = { + LINE_COL1, LINE_COL2, LINE_COL3, LINE_COL4, LINE_COL5, LINE_COL6, LINE_COL7, LINE_COL8, LINE_COL9, LINE_COL10, LINE_COL11, LINE_COL12, LINE_COL13, LINE_COL14, +}; + static uint8_t ledMcuWakeup[11] = {0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02}; ble_capslock_t BLECapsLock = {._dummy = {0}, .caps_lock = false}; @@ -97,7 +105,6 @@ void keyboard_post_init_kb(void) { keyboard_post_init_user(); } - void matrix_scan_kb() { // if there's stuff on the ble serial buffer // read it into the capslock struct diff --git a/keyboards/annepro2/boards/ANNEPRO2_C15/board.c b/keyboards/annepro2/boards/ANNEPRO2_C15/board.c index d62bd1dbd051..27ba153ee213 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C15/board.c +++ b/keyboards/annepro2/boards/ANNEPRO2_C15/board.c @@ -98,14 +98,6 @@ const PALConfig pal_default_config = { .ESSR[1] = 0x00000000, }; -const ioline_t row_list[MATRIX_ROWS] = { - LINE_ROW1, LINE_ROW2, LINE_ROW3, LINE_ROW4, LINE_ROW5, -}; - -const ioline_t col_list[MATRIX_COLS] = { - LINE_COL1, LINE_COL2, LINE_COL3, LINE_COL4, LINE_COL5, LINE_COL6, LINE_COL7, LINE_COL8, LINE_COL9, LINE_COL10, LINE_COL11, LINE_COL12, LINE_COL13, LINE_COL14, -}; - void __early_init(void) {} void early_hardware_init_pre(void) { ht32_clock_init(); } diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.c b/keyboards/annepro2/boards/ANNEPRO2_C18/board.c new file mode 100644 index 000000000000..27ba153ee213 --- /dev/null +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.c @@ -0,0 +1,107 @@ +/* + Copyright (C) 2020 Yaotian Feng, Codetector + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +#include "hal.h" + +/* ============ Private Defines ===================== */ + +/* ============ Function Prototypes ================== */ + +#define PBIT(PORT, LINE) ((PAL_PORT(LINE) == PORT) ? (1 << PAL_PAD(LINE)) : 0) +#define PAFIO_L(PORT, LINE, AF) (((PAL_PORT(LINE) == PORT) && (PAL_PAD(LINE) < 8)) ? (AF << (PAL_PAD(LINE) << 2)) : 0) +#define PAFIO_H(PORT, LINE, AF) (((PAL_PORT(LINE) == PORT) && (PAL_PAD(LINE) >= 8)) ? (AF << ((PAL_PAD(LINE) - 8) << 2)) : 0) +#define PAFIO(PORT, N, LINE, AF) ((N) ? PAFIO_H(PORT, LINE, AF) : PAFIO_L(PORT, LINE, AF)) + +#define OUT_BITS(PORT) (PBIT(PORT, LINE_ROW1) | PBIT(PORT, LINE_ROW2) | PBIT(PORT, LINE_ROW3) | PBIT(PORT, LINE_ROW4) | PBIT(PORT, LINE_ROW5) | 0) + +#define IN_BITS(PORT) (PBIT(PORT, LINE_COL1) | PBIT(PORT, LINE_COL2) | PBIT(PORT, LINE_COL3) | PBIT(PORT, LINE_COL4) | PBIT(PORT, LINE_COL5) | PBIT(PORT, LINE_COL6) | PBIT(PORT, LINE_COL7) | PBIT(PORT, LINE_COL8) | PBIT(PORT, LINE_COL9) | PBIT(PORT, LINE_COL10) | PBIT(PORT, LINE_COL11) | PBIT(PORT, LINE_COL12) | PBIT(PORT, LINE_COL13) | PBIT(PORT, LINE_COL14) | 0) + +// Alternate Functions +#define AF_BITS(PORT, N) (PAFIO(PORT, N, LINE_UART_RX, AFIO_USART) | PAFIO(PORT, N, LINE_UART_TX, AFIO_USART) | PAFIO(PORT, N, LINE_BT_UART_TX, AFIO_USART) | PAFIO(PORT, N, LINE_BT_UART_RX, AFIO_USART) | PAFIO(PORT, N, LINE_ROW1, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW2, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW3, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW4, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW5, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL1, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL2, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL3, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL4, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL5, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL6, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL7, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL8, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL9, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL10, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL11, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL12, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL13, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL14, AFIO_GPIO) | 0) + +/** + * @brief PAL setup. + * @details Digital I/O ports static configuration as defined in @p board.h. + * This variable is used by the HAL when initializing the PAL driver. + */ +const PALConfig pal_default_config = { + // GPIO A + .setup[0] = + { + .DIR = OUT_BITS(IOPORTA), + .INE = IN_BITS(IOPORTA), + .PU = IN_BITS(IOPORTA), + .PD = 0x0000, + .OD = 0x0000, + .DRV = 0x0000, + .LOCK = 0x0000, + .OUT = 0x0000, + .CFG[0] = AF_BITS(IOPORTA, 0), + .CFG[1] = AF_BITS(IOPORTA, 1), + }, + // GPIO B + .setup[1] = + { + .DIR = OUT_BITS(IOPORTB), + .INE = IN_BITS(IOPORTB), + .PU = IN_BITS(IOPORTB), + .PD = 0x0000, + .OD = 0x0000, + .DRV = 0x0000, + .LOCK = 0x0000, + .OUT = 0x0000, + .CFG[0] = AF_BITS(IOPORTB, 0), + .CFG[1] = AF_BITS(IOPORTB, 1), + }, + // GPIO C + .setup[2] = + { + .DIR = OUT_BITS(IOPORTC), + .INE = IN_BITS(IOPORTC), + .PU = IN_BITS(IOPORTC), + .PD = 0x0000, + .OD = 0x0000, + .DRV = 0x0000, + .LOCK = 0x0000, + .OUT = 0x0000, + .CFG[0] = AF_BITS(IOPORTC, 0), + .CFG[1] = AF_BITS(IOPORTC, 1), + }, + // GPIO D + .setup[3] = + { + .DIR = OUT_BITS(IOPORTD), + .INE = IN_BITS(IOPORTD), + .PU = IN_BITS(IOPORTD), + .PD = 0x0000, + .OD = 0x0000, + .DRV = 0x0000, + .LOCK = 0x0000, + .OUT = 0x0000, + .CFG[0] = AF_BITS(IOPORTD, 0), + .CFG[1] = AF_BITS(IOPORTD, 1), + }, + .ESSR[0] = 0x00000000, + .ESSR[1] = 0x00000000, +}; + +void __early_init(void) {} + +void early_hardware_init_pre(void) { ht32_clock_init(); } + +void board_init(void) {} + +void boardInit(void) {} diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.mk b/keyboards/annepro2/boards/ANNEPRO2_C18/board.mk index eb35a913da50..1b41dede851b 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C18/board.mk +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.mk @@ -1,5 +1,5 @@ # List of all the board related files. -BOARDSRC = $(BOARD_PATH)/boards/ANNEPRO2_C15/board.c +BOARDSRC = $(BOARD_PATH)/boards/ANNEPRO2_C18/board.c # Required include directories BOARDINC = $(BOARD_PATH)/boards/ANNEPRO2_C18 diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index e62c0e88caac..ea4d1b441220 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -16,9 +16,6 @@ MCU_STARTUP = ht32f523xx BOARD = ANNEPRO2_C15 -OPT_DEFS += -Wno-unused-function -fdump-rtl-dfinish -fstack-usage -#EXTRALDFLAGS = -Wl,--print-memory-usage - # Options # Keys diff --git a/keyboards/annepro2/c18/post_rules.mk b/keyboards/annepro2/c18/post_rules.mk deleted file mode 100644 index 5cfbe9a7d168..000000000000 --- a/keyboards/annepro2/c18/post_rules.mk +++ /dev/null @@ -1,4 +0,0 @@ -ifeq ($(strip $(ANNEPRO2_EEPROM)), yes) - OPT_DEFS += -DANNEPRO2_EEPROM - SRC += spi_master.c eeprom_w25x20cl.c -endif diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index ee595ac3567a..3858c7f46a47 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -16,9 +16,6 @@ MCU_STARTUP = ht32f523xx BOARD = ANNEPRO2_C18 -OPT_DEFS += -Wno-unused-function -fdump-rtl-dfinish -fstack-usage -#EXTRALDFLAGS = -Wl,--print-memory-usage - # Options # Keys diff --git a/keyboards/annepro2/hardfault_handler.c b/keyboards/annepro2/hardfault_handler.c deleted file mode 100644 index f9d32c75a06d..000000000000 --- a/keyboards/annepro2/hardfault_handler.c +++ /dev/null @@ -1,62 +0,0 @@ - /* Copyright 2021 OpenAnnePro community - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -#include -#include "hal.h" - -#define bkpt() __asm volatile("BKPT #0\n") -OSAL_IRQ_HANDLER(HardFault_Handler) { - // Copy to local variables (not pointers) to allow GDB "i loc" to directly show the info - struct port_extctx ctx; - volatile unsigned long _CFSR; - volatile unsigned long _HFSR; - volatile unsigned long _DFSR; - volatile unsigned long _AFSR; - volatile unsigned long _BFAR; - volatile unsigned long _MMAR; - // Get thread context. Contains main registers including PC and LR - memcpy(&ctx, (void *)__get_PSP(), sizeof(struct port_extctx)); - (void)ctx; - - // Configurable Fault Status Register - // Consists of MMSR, BFSR and UFSR - _CFSR = (*((volatile unsigned long *)(0xE000ED28))); - (void)(_CFSR); - - // Hard Fault Status Register - _HFSR = (*((volatile unsigned long *)(0xE000ED2C))); - (void)(_HFSR); - - // Debug Fault Status Register - _DFSR = (*((volatile unsigned long *)(0xE000ED30))); - (void)(_DFSR); - - // Auxiliary Fault Status Register - _AFSR = (*((volatile unsigned long *)(0xE000ED3C))); - (void)(_AFSR); - - // Read the Fault Address Registers. These may not contain valid values. - // Check BFARVALID/MMARVALID to see if they are valid values - // MemManage Fault Address Register - _MMAR = (*((volatile unsigned long *)(0xE000ED34))); - (void)(_MMAR); - // Bus Fault Address Register - _BFAR = (*((volatile unsigned long *)(0xE000ED38))); - (void)(_BFAR); - // Cause debugger to stop. Ignored if no debugger is attached - bkpt(); - NVIC_SystemReset(); // If no debugger connected, just reset the board -} From ff35e1871b3c9161239ccf1af55251bf065e794b Mon Sep 17 00:00:00 2001 From: bwisn Date: Sat, 13 Nov 2021 12:45:08 +0100 Subject: [PATCH 70/88] upgrade readme --- keyboards/annepro2/readme.md | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/keyboards/annepro2/readme.md b/keyboards/annepro2/readme.md index c1d11e10d926..e3e0b95be43f 100644 --- a/keyboards/annepro2/readme.md +++ b/keyboards/annepro2/readme.md @@ -4,12 +4,10 @@ This is the QMK firmware repository for the Anne Pro 2 rev. C15 and C18 keyboard. - ## Layouts Keyboard has 60% ANSI standard layout. - ## How to compile After setting up your build environment, you can compile the Anne Pro 2 C18 default keymap by using: @@ -22,6 +20,31 @@ If you want to compile the Anne Pro 2 C15 default keymap use: ## Installing -See the [installing instructions](https://openannepro.github.io/install/) +### Get AnnePro2 Tools + +If you want the executable instead of compiling it yourself, [download it here](https://ci.codetector.org/job/OpenAnnePro/job/AnnePro2-Tools/job/master/). +Windows and Linux versions are available. Otherwise, follow the steps below: + +0. Install the latest stable `rust` toolchain using [rustup](https://rustup.rs/) +0. Also install [Visual Studio Community edition](https://visualstudio.microsoft.com/downloads/) +including the C/C++ module to prevent errors while compiling +0. Download or Clone the [AnnePro2-Tools](https://github.com/OpenAnnePro/AnnePro2-Tools) project. +0. Compile the tool using +```bash +cargo build --release +``` +0. The compiled tool should be in `./target/release/annepro2_tools` (In later I will refer to this as `annepro2_tools`) + +### Flashing the firmware +0. Put the keyboard into DFU/IAP mode by unplugging the keyboard, then holding ESC while plugging it back in. +0. Run annepro2_tools with the firmware you just built. + +**Please substitute with the correct paths and correct bin file if you chose another keymap profile** +```bash +annepro2_tools annepro2_c15_default.bin +``` + +If the tool can't find the keyboard please double check you have the keyboard in IAP mode. + See the [build environment setup](https://docs.qmk.fm/#/getting_started_build_tools) and the [make instructions](https://docs.qmk.fm/#/getting_started_make_guide) for more information. Brand new to QMK? Start with our [Complete Newbs Guide](https://docs.qmk.fm/#/newbs). \ No newline at end of file From c0a39bef7b72bf072420a4aaeaaf5dfa92d3ecbe Mon Sep 17 00:00:00 2001 From: bwisn Date: Sat, 13 Nov 2021 12:50:55 +0100 Subject: [PATCH 71/88] IAP --- keyboards/annepro2/annepro2.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 596300a1aefa..4545a839ddf6 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -21,6 +21,9 @@ #include "ap2_led.h" #include "protocol.h" +#define MSP_STACK_POINTER 0x20001ffc +#define IAP_MODE 0x0000fab2 + static const SerialConfig ledUartInitConfig = { .speed = 115200, }; @@ -61,7 +64,7 @@ void bootloader_jump(void) { wait_ms(15); // Magic key to set keyboard to IAP - *((uint32_t *)0x20001ffc) = 0x0000fab2; + *((uint32_t *)MSP_STACK_POINTER) = IAP_MODE; // Load the main MCU into IAP __disable_irq(); From 78bd57f464411cff106c569e0e51164974ef8ba9 Mon Sep 17 00:00:00 2001 From: bwisn Date: Sat, 13 Nov 2021 17:30:45 +0100 Subject: [PATCH 72/88] update IAP comments, defines --- keyboards/annepro2/annepro2.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 4545a839ddf6..74bb2edcf76c 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -21,8 +21,8 @@ #include "ap2_led.h" #include "protocol.h" -#define MSP_STACK_POINTER 0x20001ffc -#define IAP_MODE 0x0000fab2 +#define RAM_MAGIC_LOCATION 0x20001ffc +#define IAP_MAGIC_VALUE 0x0000fab2 static const SerialConfig ledUartInitConfig = { .speed = 115200, @@ -64,7 +64,9 @@ void bootloader_jump(void) { wait_ms(15); // Magic key to set keyboard to IAP - *((uint32_t *)MSP_STACK_POINTER) = IAP_MODE; + // It’s from reversing original boot loader + // If value is that it stays in boot loader aka IAP + *((uint32_t *)RAM_MAGIC_LOCATION) = IAP_MAGIC_VALUE; // Load the main MCU into IAP __disable_irq(); From a2b7d34fdae7d4e06f9cb465952468c096353cc5 Mon Sep 17 00:00:00 2001 From: bwisn Date: Sat, 13 Nov 2021 23:11:45 +0100 Subject: [PATCH 73/88] led fix --- keyboards/annepro2/ap2_led.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/keyboards/annepro2/ap2_led.c b/keyboards/annepro2/ap2_led.c index 2a19d378755b..9969fcd02af3 100644 --- a/keyboards/annepro2/ap2_led.c +++ b/keyboards/annepro2/ap2_led.c @@ -1,18 +1,18 @@ - /* Copyright 2021 OpenAnnePro community - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ +/* Copyright 2021 OpenAnnePro community + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ #include #include @@ -79,7 +79,7 @@ void annepro2LedMaskSetRow(uint8_t row) { uint8_t payload[NUM_COLUMN * sizeof(annepro2Led_t) + 1]; payload[0] = row; memcpy(payload + 1, &ledMask[ROWCOL2IDX(row, 0)], sizeof(*ledMask) * NUM_COLUMN); - protoTx(CMD_LED_MASK_SET_KEY, payload, sizeof(payload), 1); + protoTx(CMD_LED_MASK_SET_ROW, payload, sizeof(payload), 1); } /* Synchronize all rows */ From 70273607fdb53ae90fd143f3d99d2e533784b97e Mon Sep 17 00:00:00 2001 From: bwisn Date: Sat, 13 Nov 2021 23:51:07 +0100 Subject: [PATCH 74/88] init fix --- keyboards/annepro2/boards/ANNEPRO2_C15/board.c | 6 +----- keyboards/annepro2/boards/ANNEPRO2_C18/board.c | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/keyboards/annepro2/boards/ANNEPRO2_C15/board.c b/keyboards/annepro2/boards/ANNEPRO2_C15/board.c index 27ba153ee213..9bac4d227107 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C15/board.c +++ b/keyboards/annepro2/boards/ANNEPRO2_C15/board.c @@ -98,10 +98,6 @@ const PALConfig pal_default_config = { .ESSR[1] = 0x00000000, }; -void __early_init(void) {} - -void early_hardware_init_pre(void) { ht32_clock_init(); } - -void board_init(void) {} +void __early_init(void) { ht32_clock_init(); } void boardInit(void) {} diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.c b/keyboards/annepro2/boards/ANNEPRO2_C18/board.c index 27ba153ee213..9bac4d227107 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C18/board.c +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.c @@ -98,10 +98,6 @@ const PALConfig pal_default_config = { .ESSR[1] = 0x00000000, }; -void __early_init(void) {} - -void early_hardware_init_pre(void) { ht32_clock_init(); } - -void board_init(void) {} +void __early_init(void) { ht32_clock_init(); } void boardInit(void) {} From 5f559c2d75a71fbeae0d7fdde0c976e788ddd921 Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 14 Nov 2021 08:00:02 +0100 Subject: [PATCH 75/88] annepro2: GPIO cleanup --- keyboards/annepro2/annepro2.c | 8 ---- .../annepro2/boards/ANNEPRO2_C15/board.c | 6 +-- .../annepro2/boards/ANNEPRO2_C15/board.h | 42 ++----------------- .../annepro2/boards/ANNEPRO2_C18/board.c | 6 +-- .../annepro2/boards/ANNEPRO2_C18/board.h | 38 ++--------------- keyboards/annepro2/c15/config.h | 18 ++++++++ keyboards/annepro2/c18/config.h | 16 +++++++ keyboards/annepro2/matrix.c | 10 ++--- 8 files changed, 52 insertions(+), 92 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 74bb2edcf76c..c681ca19b29c 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -40,14 +40,6 @@ static const SerialConfig bleUartConfig = { .speed = 115200, }; -const ioline_t row_list[MATRIX_ROWS] = { - LINE_ROW1, LINE_ROW2, LINE_ROW3, LINE_ROW4, LINE_ROW5, -}; - -const ioline_t col_list[MATRIX_COLS] = { - LINE_COL1, LINE_COL2, LINE_COL3, LINE_COL4, LINE_COL5, LINE_COL6, LINE_COL7, LINE_COL8, LINE_COL9, LINE_COL10, LINE_COL11, LINE_COL12, LINE_COL13, LINE_COL14, -}; - static uint8_t ledMcuWakeup[11] = {0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7d, 0x02, 0x01, 0x02}; ble_capslock_t BLECapsLock = {._dummy = {0}, .caps_lock = false}; diff --git a/keyboards/annepro2/boards/ANNEPRO2_C15/board.c b/keyboards/annepro2/boards/ANNEPRO2_C15/board.c index 9bac4d227107..60c1826155c9 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C15/board.c +++ b/keyboards/annepro2/boards/ANNEPRO2_C15/board.c @@ -25,12 +25,12 @@ #define PAFIO_H(PORT, LINE, AF) (((PAL_PORT(LINE) == PORT) && (PAL_PAD(LINE) >= 8)) ? (AF << ((PAL_PAD(LINE) - 8) << 2)) : 0) #define PAFIO(PORT, N, LINE, AF) ((N) ? PAFIO_H(PORT, LINE, AF) : PAFIO_L(PORT, LINE, AF)) -#define OUT_BITS(PORT) (PBIT(PORT, LINE_ROW1) | PBIT(PORT, LINE_ROW2) | PBIT(PORT, LINE_ROW3) | PBIT(PORT, LINE_ROW4) | PBIT(PORT, LINE_ROW5) | 0) +#define OUT_BITS(PORT) (PBIT(PORT, C2) | PBIT(PORT, C1) | PBIT(PORT, B5) | PBIT(PORT, B4) | PBIT(PORT, C3) | 0) -#define IN_BITS(PORT) (PBIT(PORT, LINE_COL1) | PBIT(PORT, LINE_COL2) | PBIT(PORT, LINE_COL3) | PBIT(PORT, LINE_COL4) | PBIT(PORT, LINE_COL5) | PBIT(PORT, LINE_COL6) | PBIT(PORT, LINE_COL7) | PBIT(PORT, LINE_COL8) | PBIT(PORT, LINE_COL9) | PBIT(PORT, LINE_COL10) | PBIT(PORT, LINE_COL11) | PBIT(PORT, LINE_COL12) | PBIT(PORT, LINE_COL13) | PBIT(PORT, LINE_COL14) | 0) +#define IN_BITS(PORT) (PBIT(PORT, C4) | PBIT(PORT, C5) | PBIT(PORT, B10) | PBIT(PORT, B11) | PBIT(PORT, C0) | PBIT(PORT, A15) | PBIT(PORT, A8) | PBIT(PORT, A10) | PBIT(PORT, A11) | PBIT(PORT, A12) | PBIT(PORT, A13) | PBIT(PORT, A14) | PBIT(PORT, B2) | PBIT(PORT, B3) | 0) // Alternate Functions -#define AF_BITS(PORT, N) (PAFIO(PORT, N, LINE_UART_RX, AFIO_USART) | PAFIO(PORT, N, LINE_UART_TX, AFIO_USART) | PAFIO(PORT, N, LINE_BT_UART_TX, AFIO_USART) | PAFIO(PORT, N, LINE_BT_UART_RX, AFIO_USART) | PAFIO(PORT, N, LINE_ROW1, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW2, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW3, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW4, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW5, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL1, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL2, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL3, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL4, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL5, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL6, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL7, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL8, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL9, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL10, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL11, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL12, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL13, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL14, AFIO_GPIO) | 0) +#define AF_BITS(PORT, N) (PAFIO(PORT, N, LINE_UART_RX, AFIO_USART) | PAFIO(PORT, N, LINE_UART_TX, AFIO_USART) | PAFIO(PORT, N, LINE_BT_UART_TX, AFIO_USART) | PAFIO(PORT, N, LINE_BT_UART_RX, AFIO_USART) | PAFIO(PORT, N, C2, AFIO_GPIO) | PAFIO(PORT, N, C1, AFIO_GPIO) | PAFIO(PORT, N, B5, AFIO_GPIO) | PAFIO(PORT, N, B4, AFIO_GPIO) | PAFIO(PORT, N, C3, AFIO_GPIO) | PAFIO(PORT, N, C4, AFIO_GPIO) | PAFIO(PORT, N, C5, AFIO_GPIO) | PAFIO(PORT, N, B10, AFIO_GPIO) | PAFIO(PORT, N, B11, AFIO_GPIO) | PAFIO(PORT, N, C0, AFIO_GPIO) | PAFIO(PORT, N, A15, AFIO_GPIO) | PAFIO(PORT, N, A8, AFIO_GPIO) | PAFIO(PORT, N, A10, AFIO_GPIO) | PAFIO(PORT, N, A11, AFIO_GPIO) | PAFIO(PORT, N, A12, AFIO_GPIO) | PAFIO(PORT, N, A13, AFIO_GPIO) | PAFIO(PORT, N, A14, AFIO_GPIO) | PAFIO(PORT, N, B2, AFIO_GPIO) | PAFIO(PORT, N, B3, AFIO_GPIO) | 0) /** * @brief PAL setup. diff --git a/keyboards/annepro2/boards/ANNEPRO2_C15/board.h b/keyboards/annepro2/boards/ANNEPRO2_C15/board.h index 48a65a135516..0a044ea18122 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C15/board.h +++ b/keyboards/annepro2/boards/ANNEPRO2_C15/board.h @@ -28,46 +28,12 @@ #define FLASH_SIZE (0x10000 - 0x4000) // 64kB - 16kB -/* - * I/O - */ - -#define LINE_UART_TX PAL_LINE(IOPORTB, 0) // Master TX, LED RX -#define LINE_UART_RX PAL_LINE(IOPORTB, 1) // Master RX, LED TX - -#define LINE_BT_UART_TX PAL_LINE(IOPORTA, 4) // Master TX, BLE RX -#define LINE_BT_UART_RX PAL_LINE(IOPORTA, 5) // Master RX, BLE TX - -// outputs (rows are pulled low) -#define LINE_ROW1 PAL_LINE(IOPORTC, 2) -#define LINE_ROW2 PAL_LINE(IOPORTC, 1) -#define LINE_ROW3 PAL_LINE(IOPORTB, 5) -#define LINE_ROW4 PAL_LINE(IOPORTB, 4) -#define LINE_ROW5 PAL_LINE(IOPORTC, 3) - -// inputs (columns are sampled) -#define LINE_COL1 PAL_LINE(IOPORTC, 4) -#define LINE_COL2 PAL_LINE(IOPORTC, 5) -#define LINE_COL3 PAL_LINE(IOPORTB, 10) -#define LINE_COL4 PAL_LINE(IOPORTB, 11) -#define LINE_COL5 PAL_LINE(IOPORTC, 0) -#define LINE_COL6 PAL_LINE(IOPORTA, 15) -#define LINE_COL7 PAL_LINE(IOPORTA, 8) -#define LINE_COL8 PAL_LINE(IOPORTA, 10) -#define LINE_COL9 PAL_LINE(IOPORTA, 11) -// PORTA 12,13 conflict with SWD -#define LINE_COL10 PAL_LINE(IOPORTA, 12) -#define LINE_COL11 PAL_LINE(IOPORTA, 13) -#define LINE_COL12 PAL_LINE(IOPORTA, 14) -#define LINE_COL13 PAL_LINE(IOPORTB, 2) -#define LINE_COL14 PAL_LINE(IOPORTB, 3) - #if !defined(_FROM_ASM_) -# ifdef __cplusplus +#ifdef __cplusplus extern "C" { -# endif +#endif void boardInit(void); -# ifdef __cplusplus +#ifdef __cplusplus } -# endif +#endif #endif /* _FROM_ASM_ */ \ No newline at end of file diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.c b/keyboards/annepro2/boards/ANNEPRO2_C18/board.c index 9bac4d227107..42c03d3d0036 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C18/board.c +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.c @@ -25,12 +25,12 @@ #define PAFIO_H(PORT, LINE, AF) (((PAL_PORT(LINE) == PORT) && (PAL_PAD(LINE) >= 8)) ? (AF << ((PAL_PAD(LINE) - 8) << 2)) : 0) #define PAFIO(PORT, N, LINE, AF) ((N) ? PAFIO_H(PORT, LINE, AF) : PAFIO_L(PORT, LINE, AF)) -#define OUT_BITS(PORT) (PBIT(PORT, LINE_ROW1) | PBIT(PORT, LINE_ROW2) | PBIT(PORT, LINE_ROW3) | PBIT(PORT, LINE_ROW4) | PBIT(PORT, LINE_ROW5) | 0) +#define OUT_BITS(PORT) (PBIT(PORT, B5) | PBIT(PORT, B4) | PBIT(PORT, B3) | PBIT(PORT, B2) | PBIT(PORT, D1) | 0) -#define IN_BITS(PORT) (PBIT(PORT, LINE_COL1) | PBIT(PORT, LINE_COL2) | PBIT(PORT, LINE_COL3) | PBIT(PORT, LINE_COL4) | PBIT(PORT, LINE_COL5) | PBIT(PORT, LINE_COL6) | PBIT(PORT, LINE_COL7) | PBIT(PORT, LINE_COL8) | PBIT(PORT, LINE_COL9) | PBIT(PORT, LINE_COL10) | PBIT(PORT, LINE_COL11) | PBIT(PORT, LINE_COL12) | PBIT(PORT, LINE_COL13) | PBIT(PORT, LINE_COL14) | 0) +#define IN_BITS(PORT) (PBIT(PORT, C4) | PBIT(PORT, C5) | PBIT(PORT, D0) | PBIT(PORT, B15) | PBIT(PORT, C11) | PBIT(PORT, A15) | PBIT(PORT, C12) | PBIT(PORT, C13) | PBIT(PORT, A8) | PBIT(PORT, A10) | PBIT(PORT, A11) | PBIT(PORT, A14) | PBIT(PORT, D2) | PBIT(PORT, D3) | 0) // Alternate Functions -#define AF_BITS(PORT, N) (PAFIO(PORT, N, LINE_UART_RX, AFIO_USART) | PAFIO(PORT, N, LINE_UART_TX, AFIO_USART) | PAFIO(PORT, N, LINE_BT_UART_TX, AFIO_USART) | PAFIO(PORT, N, LINE_BT_UART_RX, AFIO_USART) | PAFIO(PORT, N, LINE_ROW1, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW2, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW3, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW4, AFIO_GPIO) | PAFIO(PORT, N, LINE_ROW5, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL1, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL2, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL3, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL4, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL5, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL6, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL7, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL8, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL9, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL10, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL11, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL12, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL13, AFIO_GPIO) | PAFIO(PORT, N, LINE_COL14, AFIO_GPIO) | 0) +#define AF_BITS(PORT, N) (PAFIO(PORT, N, LINE_UART_RX, AFIO_USART) | PAFIO(PORT, N, LINE_UART_TX, AFIO_USART) | PAFIO(PORT, N, LINE_BT_UART_TX, AFIO_USART) | PAFIO(PORT, N, LINE_BT_UART_RX, AFIO_USART) | PAFIO(PORT, N, B5, AFIO_GPIO) | PAFIO(PORT, N, B4, AFIO_GPIO) | PAFIO(PORT, N, B3, AFIO_GPIO) | PAFIO(PORT, N, B2, AFIO_GPIO) | PAFIO(PORT, N, D1, AFIO_GPIO) | PAFIO(PORT, N, C4, AFIO_GPIO) | PAFIO(PORT, N, C5, AFIO_GPIO) | PAFIO(PORT, N, D0, AFIO_GPIO) | PAFIO(PORT, N, B15, AFIO_GPIO) | PAFIO(PORT, N, C11, AFIO_GPIO) | PAFIO(PORT, N, A15, AFIO_GPIO) | PAFIO(PORT, N, C12, AFIO_GPIO) | PAFIO(PORT, N, C13, AFIO_GPIO) | PAFIO(PORT, N, A8, AFIO_GPIO) | PAFIO(PORT, N, A10, AFIO_GPIO) | PAFIO(PORT, N, A11, AFIO_GPIO) | PAFIO(PORT, N, A14, AFIO_GPIO) | PAFIO(PORT, N, D2, AFIO_GPIO) | PAFIO(PORT, N, D3, AFIO_GPIO) | 0) /** * @brief PAL setup. diff --git a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h index 8dd5c2e87860..7345b24231b8 100644 --- a/keyboards/annepro2/boards/ANNEPRO2_C18/board.h +++ b/keyboards/annepro2/boards/ANNEPRO2_C18/board.h @@ -22,49 +22,17 @@ /* * Board identifier. */ -#define BOARD_NAME "Anne Pro 2" +#define BOARD_NAME "Anne Pro 2" #define HT32F52342 -#define FLASH_SIZE (0x10000 - 0x4000) // 64kB - 16kB - -/* - * I/O - */ -#define LINE_UART_TX PAL_LINE(IOPORTB, 0) -#define LINE_UART_RX PAL_LINE(IOPORTB, 1) - -#define LINE_BT_UART_TX PAL_LINE(IOPORTA, 4) // Master TX, BLE RX -#define LINE_BT_UART_RX PAL_LINE(IOPORTA, 5) // Master RX, BLE TX - -// outputs (rows are pulled low) -#define LINE_ROW1 PAL_LINE(IOPORTB, 5) -#define LINE_ROW2 PAL_LINE(IOPORTB, 4) -#define LINE_ROW3 PAL_LINE(IOPORTB, 3) -#define LINE_ROW4 PAL_LINE(IOPORTB, 2) -#define LINE_ROW5 PAL_LINE(IOPORTD, 1) - -// inputs (columns are sampled) -#define LINE_COL1 PAL_LINE(IOPORTC, 4) -#define LINE_COL2 PAL_LINE(IOPORTC, 5) -#define LINE_COL3 PAL_LINE(IOPORTD, 0) -#define LINE_COL4 PAL_LINE(IOPORTB, 15) -#define LINE_COL5 PAL_LINE(IOPORTC, 11) -#define LINE_COL6 PAL_LINE(IOPORTA, 15) -#define LINE_COL7 PAL_LINE(IOPORTC, 12) -#define LINE_COL8 PAL_LINE(IOPORTC, 13) -#define LINE_COL9 PAL_LINE(IOPORTA, 8) -#define LINE_COL10 PAL_LINE(IOPORTA, 10) -#define LINE_COL11 PAL_LINE(IOPORTA, 11) -#define LINE_COL12 PAL_LINE(IOPORTA, 14) -#define LINE_COL13 PAL_LINE(IOPORTD, 2) -#define LINE_COL14 PAL_LINE(IOPORTD, 3) +#define FLASH_SIZE (0x10000 - 0x4000) // 64kB - 16kB #if !defined(_FROM_ASM_) #ifdef __cplusplus extern "C" { #endif - void boardInit(void); +void boardInit(void); #ifdef __cplusplus } #endif diff --git a/keyboards/annepro2/c15/config.h b/keyboards/annepro2/c15/config.h index 108a4e0bb51b..f28a6a1b53c3 100644 --- a/keyboards/annepro2/c15/config.h +++ b/keyboards/annepro2/c15/config.h @@ -17,6 +17,8 @@ #pragma once +#include "pin_defs.h" + /* USB Device descriptor parameter */ #define VENDOR_ID 0xfeed #define PRODUCT_ID 0xac15 @@ -27,3 +29,19 @@ #define MATRIX_ROWS 5 #define MATRIX_COLS 14 // layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 140 bytes + +#define LINE_UART_TX B0 // Master TX, LED RX +#define LINE_UART_RX B1 // Master RX, LED TX + +#define LINE_BT_UART_TX A4 // Master TX, BLE RX +#define LINE_BT_UART_RX A5 // Master RX, BLE TX + +// outputs (rows are pulled low) +#define MATRIX_ROW_PINS \ + { C2, C1, B5, B4, C3 } + +// inputs (columns are sampled) +// PORTA 12,13 conflict with SWD + +#define MATRIX_COL_PINS \ + { C4, C5, B10, B11, C0, A15, A8, A10, A11, A12, A13, A14, B2, B3 } diff --git a/keyboards/annepro2/c18/config.h b/keyboards/annepro2/c18/config.h index e99ec2bba7f6..f610ef76e4fd 100644 --- a/keyboards/annepro2/c18/config.h +++ b/keyboards/annepro2/c18/config.h @@ -17,6 +17,8 @@ #pragma once +#include "pin_defs.h" + /* USB Device descriptor parameter */ #define VENDOR_ID 0xfeed #define PRODUCT_ID 0xac18 @@ -27,3 +29,17 @@ #define MATRIX_ROWS 5 #define MATRIX_COLS 14 // layer size: MATRIX_ROWS * MATRIX_COLS * sizeof(uint16_t) = 140 bytes + +#define LINE_UART_TX B0 +#define LINE_UART_RX B1 + +#define LINE_BT_UART_TX A4 // Master TX, BLE RX +#define LINE_BT_UART_RX A5 // Master RX, BLE TX + +// outputs (rows are pulled low) +#define MATRIX_ROW_PINS \ + { B5, B4, B3, B2, D1 } + +// inputs (columns are sampled) +#define MATRIX_COL_PINS \ + { C4, C5, D0, B15, C11, A15, C12, C13, A8, A10, A11, A14, D2, D3 } diff --git a/keyboards/annepro2/matrix.c b/keyboards/annepro2/matrix.c index cbd522a54a9a..5eb69b0c7029 100644 --- a/keyboards/annepro2/matrix.c +++ b/keyboards/annepro2/matrix.c @@ -25,11 +25,11 @@ #include "matrix.h" #include "annepro2.h" -extern ioline_t row_list[MATRIX_ROWS]; -extern ioline_t col_list[MATRIX_COLS]; +pin_t row_list[MATRIX_ROWS] = MATRIX_ROW_PINS; +pin_t col_list[MATRIX_COLS] = MATRIX_COL_PINS; bool matrix_scan_custom(matrix_row_t current_matrix[]) { - bool matrix_has_changed = false; + bool matrix_has_changed = false; // cache of input ports for columns static uint16_t port_cache[4]; // scan each row @@ -56,8 +56,8 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { if (current_matrix[row] != data) { current_matrix[row] = data; - matrix_has_changed = true; + matrix_has_changed = true; } } return matrix_has_changed; -} +} \ No newline at end of file From 36c22424a1cc3c766eeec4b6c83df7307eb43459 Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 14 Nov 2021 08:08:57 +0100 Subject: [PATCH 76/88] annepro2: ioline --- keyboards/annepro2/matrix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/annepro2/matrix.c b/keyboards/annepro2/matrix.c index 5eb69b0c7029..a1585e4ddf1f 100644 --- a/keyboards/annepro2/matrix.c +++ b/keyboards/annepro2/matrix.c @@ -49,7 +49,7 @@ bool matrix_scan_custom(matrix_row_t current_matrix[]) { // get columns from ports matrix_row_t data = 0; for (int col = 0; col < MATRIX_COLS; ++col) { - ioline_t line = col_list[col]; + pin_t line = col_list[col]; uint16_t port = port_cache[HT32_PAL_IDX(PAL_PORT(line))]; data |= (((port & (1 << PAL_PAD(line))) ? 0 : 1) << col); } From be70725f9003e991991f6fb42dc5c1bb78ee9604 Mon Sep 17 00:00:00 2001 From: bwisn Date: Mon, 15 Nov 2021 18:01:41 +0100 Subject: [PATCH 77/88] change waiting time --- keyboards/annepro2/annepro2.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index c681ca19b29c..37489defff34 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -92,7 +92,7 @@ void keyboard_post_init_kb(void) { // Give the send uart thread some time to // send out the queue before we read back - wait_ms(15); + wait_ms(100); // loop to clear out receive buffer from ble wakeup while (!sdGetWouldBlock(&SD1)) sdGet(&SD1); From 3da34f297a7503ce97690452b3765beeed4c54a7 Mon Sep 17 00:00:00 2001 From: zvecr Date: Sat, 26 Feb 2022 00:57:08 +0000 Subject: [PATCH 78/88] Start develop for 2022q2 --- readme.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/readme.md b/readme.md index 5649ddfa097a..63b483c74474 100644 --- a/readme.md +++ b/readme.md @@ -1,3 +1,7 @@ +# This is the `develop` branch! + +See the [Breaking Changes](https://docs.qmk.fm/#/breaking_changes) document for more information. + # Quantum Mechanical Keyboard Firmware [![Current Version](https://img.shields.io/github/tag/qmk/qmk_firmware.svg)](https://github.com/qmk/qmk_firmware/tags) From 156f0561f2e9865eb76a79742d8224cdd7100f27 Mon Sep 17 00:00:00 2001 From: Stefan Kerkmann Date: Sun, 27 Feb 2022 04:05:03 +0100 Subject: [PATCH 79/88] [Core] Squeeze AVR some more with `-mrelax` and `-mcall-prologues` (#16269) --- platforms/avr/platform.mk | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/platforms/avr/platform.mk b/platforms/avr/platform.mk index 4d9cafaeef4a..9f304d2e209d 100644 --- a/platforms/avr/platform.mk +++ b/platforms/avr/platform.mk @@ -18,6 +18,13 @@ COMPILEFLAGS += -ffunction-sections COMPILEFLAGS += -fdata-sections COMPILEFLAGS += -fpack-struct COMPILEFLAGS += -fshort-enums +COMPILEFLAGS += -mcall-prologues + +# Linker relaxation is only possible if +# link time optimizations are not enabled. +ifeq ($(strip $(LTO_ENABLE)), no) + COMPILEFLAGS += -mrelax +endif ASFLAGS += $(AVR_ASFLAGS) @@ -28,7 +35,7 @@ CFLAGS += -fno-strict-aliasing CXXFLAGS += $(COMPILEFLAGS) CXXFLAGS += -fno-exceptions -std=c++11 -LDFLAGS +=-Wl,--gc-sections +LDFLAGS += -Wl,--gc-sections OPT_DEFS += -DF_CPU=$(F_CPU)UL From e4a6afa369ca695be97dc3ba96fe129a1c24456e Mon Sep 17 00:00:00 2001 From: Joel Challis Date: Sun, 27 Feb 2022 11:28:51 +0000 Subject: [PATCH 80/88] Rework generate-api CLI command to use .build directory (#16441) --- .github/workflows/api.yml | 2 +- .github/workflows/develop_api.yml | 2 +- api_data/_config.yml | 1 - {api_data => data/templates/api}/readme.md | 0 lib/python/qmk/cli/generate/api.py | 28 ++++++++++++++++------ lib/python/qmk/tests/test_cli_commands.py | 2 +- 6 files changed, 24 insertions(+), 11 deletions(-) delete mode 100644 api_data/_config.yml rename {api_data => data/templates/api}/readme.md (100%) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index a19667f97e7f..f0c49baf60bb 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -35,4 +35,4 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_SECRET_KEY }} AWS_S3_ENDPOINT: https://nyc3.digitaloceanspaces.com - SOURCE_DIR: 'api_data' + SOURCE_DIR: '.build/api_data' diff --git a/.github/workflows/develop_api.yml b/.github/workflows/develop_api.yml index f0098142c7bc..3eb6e53c20b7 100644 --- a/.github/workflows/develop_api.yml +++ b/.github/workflows/develop_api.yml @@ -35,4 +35,4 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_SECRET_KEY }} AWS_S3_ENDPOINT: https://nyc3.digitaloceanspaces.com - SOURCE_DIR: 'api_data' + SOURCE_DIR: '.build/api_data' diff --git a/api_data/_config.yml b/api_data/_config.yml deleted file mode 100644 index 277f1f2c510d..000000000000 --- a/api_data/_config.yml +++ /dev/null @@ -1 +0,0 @@ -theme: jekyll-theme-cayman diff --git a/api_data/readme.md b/data/templates/api/readme.md similarity index 100% rename from api_data/readme.md rename to data/templates/api/readme.md diff --git a/lib/python/qmk/cli/generate/api.py b/lib/python/qmk/cli/generate/api.py index 285bd90eb560..0596b3f22b50 100755 --- a/lib/python/qmk/cli/generate/api.py +++ b/lib/python/qmk/cli/generate/api.py @@ -1,7 +1,7 @@ """This script automates the generation of the QMK API data. """ from pathlib import Path -from shutil import copyfile +import shutil import json from milc import cli @@ -12,28 +12,42 @@ from qmk.json_schema import json_load from qmk.keyboard import find_readme, list_keyboards +TEMPLATE_PATH = Path('data/templates/api/') +BUILD_API_PATH = Path('.build/api_data/') + @cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't write the data to disk.") +@cli.argument('-f', '--filter', arg_only=True, action='append', default=[], help="Filter the list of keyboards based on partial name matches the supplied value. May be passed multiple times.") @cli.subcommand('Creates a new keymap for the keyboard of your choosing', hidden=False if cli.config.user.developer else True) def generate_api(cli): """Generates the QMK API data. """ - api_data_dir = Path('api_data') - v1_dir = api_data_dir / 'v1' + if BUILD_API_PATH.exists(): + shutil.rmtree(BUILD_API_PATH) + + shutil.copytree(TEMPLATE_PATH, BUILD_API_PATH) + + v1_dir = BUILD_API_PATH / 'v1' keyboard_all_file = v1_dir / 'keyboards.json' # A massive JSON containing everything keyboard_list_file = v1_dir / 'keyboard_list.json' # A simple list of keyboard targets keyboard_aliases_file = v1_dir / 'keyboard_aliases.json' # A list of historical keyboard names and their new name keyboard_metadata_file = v1_dir / 'keyboard_metadata.json' # All the data configurator/via needs for initialization usb_file = v1_dir / 'usb.json' # A mapping of USB VID/PID -> keyboard target - if not api_data_dir.exists(): - api_data_dir.mkdir() + # Filter down when required + keyboard_list = list_keyboards() + if cli.args.filter: + kb_list = [] + for keyboard_name in keyboard_list: + if any(i in keyboard_name for i in cli.args.filter): + kb_list.append(keyboard_name) + keyboard_list = kb_list kb_all = {} usb_list = {} # Generate and write keyboard specific JSON files - for keyboard_name in list_keyboards(): + for keyboard_name in keyboard_list: kb_all[keyboard_name] = info_json(keyboard_name) keyboard_dir = v1_dir / 'keyboards' / keyboard_name keyboard_info = keyboard_dir / 'info.json' @@ -47,7 +61,7 @@ def generate_api(cli): cli.log.debug('Wrote file %s', keyboard_info) if keyboard_readme_src: - copyfile(keyboard_readme_src, keyboard_readme) + shutil.copyfile(keyboard_readme_src, keyboard_readme) cli.log.debug('Copied %s -> %s', keyboard_readme_src, keyboard_readme) if 'usb' in kb_all[keyboard_name]: diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index 54b143c64fe2..c379c9222930 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py @@ -232,7 +232,7 @@ def test_clean(): def test_generate_api(): - result = check_subcommand('generate-api', '--dry-run') + result = check_subcommand('generate-api', '--dry-run', '--filter', 'handwired/pytest') check_returncode(result) From f634fddd344a456c3eff8014d9d58a2d764d7a8c Mon Sep 17 00:00:00 2001 From: Ryan Date: Fri, 4 Mar 2022 22:04:45 +1100 Subject: [PATCH 81/88] Remove `send_unicode_hex_string()` (#16518) --- docs/feature_unicode.md | 11 ------- docs/ja/feature_unicode.md | 11 ------- .../process_keycode/process_unicode_common.c | 33 ------------------- .../process_keycode/process_unicode_common.h | 1 - 4 files changed, 56 deletions(-) diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index 6c3e2a1a2fba..bced419a03fe 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -230,17 +230,6 @@ send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻"); Example uses include sending Unicode strings when a key is pressed, as described in [Macros](feature_macros.md). -### `send_unicode_hex_string()` (Deprecated) - -Similar to `send_unicode_string()`, but the characters are represented by their Unicode code points, written in hexadecimal and separated by spaces. For example, the table flip above would be achieved with: - -```c -send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B"); -``` - -An easy way to convert your Unicode string to this format is to use [this site](https://r12a.github.io/app-conversion/) and take the result in the "Hex/UTF-32" section. - - ## Additional Language Support In `quantum/keymap_extras`, you'll see various language files — these work the same way as the ones for alternative layouts such as Colemak or BÉPO. When you include one of these language headers, you gain access to keycodes specific to that language / national layout. Such keycodes are defined by a 2-letter country/language code, followed by an underscore and a 4-letter abbreviation of the character to which the key corresponds. For example, including `keymap_french.h` and using `FR_UGRV` in your keymap will output `ù` when typed on a system with a native French AZERTY layout. diff --git a/docs/ja/feature_unicode.md b/docs/ja/feature_unicode.md index bfcb866ce1b0..2158678f3c48 100644 --- a/docs/ja/feature_unicode.md +++ b/docs/ja/feature_unicode.md @@ -233,17 +233,6 @@ send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻"); 使用例には、[Macros](ja/feature_macros.md) で説明されているように、キーが押された時に Unicode 文字列を送信することが含まれます。 -### `send_unicode_hex_string()` - -`send_unicode_string()` に似ていますが、文字は Unicode コードポイントで表され、16進数で記述され、空白で区切られています。例えば、上記のちゃぶ台返しは以下で表されます: - -```c -send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B"); -``` - -[このサイト](https://r12a.github.io/app-conversion/)で結果を "Hex/UTF-32" で受け取ることで、Unicode 文字列をこの形式に簡単に変換できます。 - - ## 追加の言語サポート `quantum/keymap_extras` には、様々な言語ファイルがあります — これらは Colemak または BÉPO のような代替レイアウトのファイルと同じように動作します。これらの言語ヘッダのいずれかを `#include` すると、その言語/国のレイアウトに固有のキーコードにアクセスできます。このようなキーコードは、2文字の国/言語コードの後に、アンダースコアとキーが対応する4文字の略語が続くことで定義されます。例えば、キーマップに `keymap_french.h` を含め、`FR_UGRV` を使うと、ネイティブのフランス語 AZERTY レイアウトを使うシステムで入力すると、`ù` が出力されます。 diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 46b77e14bae5..2606ea1f3720 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -16,8 +16,6 @@ #include "process_unicode_common.h" #include "eeprom.h" -#include -#include unicode_config_t unicode_config; uint8_t unicode_saved_mods; @@ -231,37 +229,6 @@ void register_unicode(uint32_t code_point) { unicode_input_finish(); } -// clang-format off - -void send_unicode_hex_string(const char *str) { - if (!str) { - return; - } - - while (*str) { - // Find the next code point (token) in the string - for (; *str == ' '; str++); // Skip leading spaces - size_t n = strcspn(str, " "); // Length of the current token - char code_point[n+1]; - strncpy(code_point, str, n); // Copy token into buffer - code_point[n] = '\0'; // Make sure it's null-terminated - - // Normalize the code point: make all hex digits lowercase - for (char *p = code_point; *p; p++) { - *p = tolower((unsigned char)*p); - } - - // Send the code point as a Unicode input string - unicode_input_start(); - send_string(code_point); - unicode_input_finish(); - - str += n; // Move to the first ' ' (or '\0') after the current token - } -} - -// clang-format on - // Borrowed from https://nullprogram.com/blog/2017/10/06/ static const char *decode_utf8(const char *str, int32_t *code_point) { const char *next; diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 1a6607c757d6..8a4494c9395c 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -90,7 +90,6 @@ void register_hex(uint16_t hex); void register_hex32(uint32_t hex); void register_unicode(uint32_t code_point); -void send_unicode_hex_string(const char *str); void send_unicode_string(const char *str); bool process_unicode_common(uint16_t keycode, keyrecord_t *record); From ace0603f4f060783ea91c224c0caec6c1b799f15 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 5 Mar 2022 00:25:24 +1100 Subject: [PATCH 82/88] Change data driven "str" type to represent a quoted string literal (#16516) * Change data driven "str" type to represent a quoted string literal * Update docs --- data/mappings/info_config.json | 2 +- data/mappings/info_rules.json | 4 ++-- docs/data_driven_config.md | 5 +++-- lib/python/qmk/cli/generate/config_h.py | 9 +++++++-- lib/python/qmk/cli/generate/rules_mk.py | 4 +++- lib/python/qmk/info.py | 10 ++++++++-- 6 files changed, 24 insertions(+), 10 deletions(-) diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json index cfe8807d4363..6c55f1164794 100644 --- a/data/mappings/info_config.json +++ b/data/mappings/info_config.json @@ -3,7 +3,7 @@ { # Format: # : {"info_key": , ["value_type": ], ["to_json": ], ["to_c": ]} - # value_type: one of "array", "array.int", "bool", "int", "hex", "list", "mapping" + # value_type: one of "array", "array.int", "bool", "int", "hex", "list", "mapping", "str", "raw" # to_json: Default `true`. Set to `false` to exclude this mapping from info.json # to_c: Default `true`. Set to `false` to exclude this mapping from config.h # warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places diff --git a/data/mappings/info_rules.json b/data/mappings/info_rules.json index aea67e04c846..f03cadcd44f6 100644 --- a/data/mappings/info_rules.json +++ b/data/mappings/info_rules.json @@ -3,7 +3,7 @@ { # Format: # : {"info_key": , ["value_type": ], ["to_json": ], ["to_c": ]} - # value_type: one of "array", "array.int", "bool", "int", "list", "hex", "mapping" + # value_type: one of "array", "array.int", "bool", "int", "list", "hex", "mapping", "str", "raw" # to_json: Default `true`. Set to `false` to exclude this mapping from info.json # to_c: Default `true`. Set to `false` to exclude this mapping from rules.mk # warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places @@ -20,6 +20,6 @@ "MOUSEKEY_ENABLE": {"info_key": "mouse_key.enabled", "value_type": "bool"}, "NO_USB_STARTUP_CHECK": {"info_key": "usb.no_startup_check", "value_type": "bool"}, "SPLIT_KEYBOARD": {"info_key": "split.enabled", "value_type": "bool"}, - "SPLIT_TRANSPORT": {"info_key": "split.transport.protocol", "value_type": "str", "to_c": false}, + "SPLIT_TRANSPORT": {"info_key": "split.transport.protocol", "to_c": false}, "WAIT_FOR_USB": {"info_key": "usb.wait_for", "value_type": "bool"} } diff --git a/docs/data_driven_config.md b/docs/data_driven_config.md index 38fb5dbf1445..cdcf21a19c5b 100644 --- a/docs/data_driven_config.md +++ b/docs/data_driven_config.md @@ -44,7 +44,7 @@ In other cases you should group like options together in an `object`. This is pa In most cases you can add a simple mapping. These are maintained as JSON files in `data/mappings/info_config.json` and `data/mappings/info_rules.json`, and control mapping for `config.h` and `rules.mk`, respectively. Each mapping is keyed by the `config.h` or `rules.mk` variable, and the value is a hash with the following keys: * `info_key`: (required) The location within `info.json` for this value. See below. -* `value_type`: (optional) Default `str`. The format for this variable's value. See below. +* `value_type`: (optional) Default `raw`. The format for this variable's value. See below. * `to_json`: (optional) Default `true`. Set to `false` to exclude this mapping from info.json * `to_c`: (optional) Default `true`. Set to `false` to exclude this mapping from config.h * `warn_duplicate`: (optional) Default `true`. Set to `false` to turn off warning when a value exists in both places @@ -57,7 +57,7 @@ Under the hood we use [Dotty Dict](https://dotty-dict.readthedocs.io/en/latest/) #### Value Types -By default we treat all values as simple strings. If your value is more complex you can use one of these types to intelligently parse the data: +By default we treat all values as unquoted "raw" data. If your value is more complex you can use one of these types to intelligently parse the data: * `array`: A comma separated array of strings * `array.int`: A comma separated array of integers @@ -65,6 +65,7 @@ By default we treat all values as simple strings. If your value is more complex * `hex`: A number formatted as hex * `list`: A space separate array of strings * `mapping`: A hash of key/value pairs +* `str`: A quoted string literal ### Add code to extract it diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py index 24bbbdf51726..340ed1043678 100755 --- a/lib/python/qmk/cli/generate/config_h.py +++ b/lib/python/qmk/cli/generate/config_h.py @@ -82,7 +82,7 @@ def generate_config_items(kb_info_json, config_h_lines): for config_key, info_dict in info_config_map.items(): info_key = info_dict['info_key'] - key_type = info_dict.get('value_type', 'str') + key_type = info_dict.get('value_type', 'raw') to_config = info_dict.get('to_config', True) if not to_config: @@ -110,6 +110,11 @@ def generate_config_items(kb_info_json, config_h_lines): config_h_lines.append(f'#ifndef {key}') config_h_lines.append(f'# define {key} {value}') config_h_lines.append(f'#endif // {key}') + elif key_type == 'str': + config_h_lines.append('') + config_h_lines.append(f'#ifndef {config_key}') + config_h_lines.append(f'# define {config_key} "{config_value}"') + config_h_lines.append(f'#endif // {config_key}') elif key_type == 'bcd_version': (major, minor, revision) = config_value.split('.') config_h_lines.append('') @@ -200,7 +205,7 @@ def generate_config_h(cli): cli.args.output.parent.mkdir(parents=True, exist_ok=True) if cli.args.output.exists(): cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak')) - cli.args.output.write_text(config_h) + cli.args.output.write_text(config_h, encoding='utf-8') if not cli.args.quiet: cli.log.info('Wrote info_config.h to %s.', cli.args.output) diff --git a/lib/python/qmk/cli/generate/rules_mk.py b/lib/python/qmk/cli/generate/rules_mk.py index ce824f6378e6..a1b10cc945a9 100755 --- a/lib/python/qmk/cli/generate/rules_mk.py +++ b/lib/python/qmk/cli/generate/rules_mk.py @@ -19,7 +19,7 @@ def process_mapping_rule(kb_info_json, rules_key, info_dict): return None info_key = info_dict['info_key'] - key_type = info_dict.get('value_type', 'str') + key_type = info_dict.get('value_type', 'raw') try: rules_value = kb_info_json[info_key] @@ -32,6 +32,8 @@ def process_mapping_rule(kb_info_json, rules_key, info_dict): return f'{rules_key} ?= {"yes" if rules_value else "no"}' elif key_type == 'mapping': return '\n'.join([f'{key} ?= {value}' for key, value in rules_value.items()]) + elif key_type == 'str': + return f'{rules_key} ?= "{rules_value}"' return f'{rules_key} ?= {rules_value}' diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index b86eaa059f11..c399a9f32198 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -411,7 +411,7 @@ def _extract_config_h(info_data): for config_key, info_dict in info_config_map.items(): info_key = info_dict['info_key'] - key_type = info_dict.get('value_type', 'str') + key_type = info_dict.get('value_type', 'raw') try: if config_key in config_c and info_dict.get('to_json', True): @@ -443,6 +443,9 @@ def _extract_config_h(info_data): elif key_type == 'int': dotty_info[info_key] = int(config_c[config_key]) + elif key_type == 'str': + dotty_info[info_key] = config_c[config_key].strip('"') + elif key_type == 'bcd_version': major = int(config_c[config_key][2:4]) minor = int(config_c[config_key][4]) @@ -491,7 +494,7 @@ def _extract_rules_mk(info_data): for rules_key, info_dict in info_rules_map.items(): info_key = info_dict['info_key'] - key_type = info_dict.get('value_type', 'str') + key_type = info_dict.get('value_type', 'raw') try: if rules_key in rules and info_dict.get('to_json', True): @@ -523,6 +526,9 @@ def _extract_rules_mk(info_data): elif key_type == 'int': dotty_info[info_key] = int(rules[rules_key]) + elif key_type == 'str': + dotty_info[info_key] = rules[rules_key].strip('"') + else: dotty_info[info_key] = rules[rules_key] From 7d41639d549c7db0763d6769a089794b6050c99f Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 5 Mar 2022 11:20:34 +1100 Subject: [PATCH 83/88] Map data driven `DESCRIPTION` as string literal (#16523) --- data/mappings/info_config.json | 2 +- keyboards/sowbug/68keys/config.h | 1 - keyboards/sowbug/ansi_tkl/config.h | 1 - keyboards/unicomp/spacesaver_m_pre_2013/overnumpad_1xb/config.h | 1 - keyboards/xelus/ninjin/config.h | 1 - lib/python/qmk/tests/test_cli_commands.py | 2 +- 6 files changed, 2 insertions(+), 6 deletions(-) diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json index 6c55f1164794..2121741d1996 100644 --- a/data/mappings/info_config.json +++ b/data/mappings/info_config.json @@ -17,7 +17,7 @@ "DEVICE_VER": {"info_key": "usb.device_ver", "value_type": "hex"}, # TODO: Replace ^^^ with vvv #"DEVICE_VER": {"info_key": "usb.device_version", "value_type": "bcd_version"}, - "DESCRIPTION": {"info_key": "keyboard_folder", "to_json": false}, + "DESCRIPTION": {"info_key": "keyboard_folder", "value_type": "str", "to_json": false}, "DIODE_DIRECTION": {"info_key": "diode_direction"}, "FORCE_NKRO": {"info_key": "usb.force_nkro", "value_type": "bool"}, "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR": {"info_key": "dynamic_keymap.eeprom_max_addr", "value_type": "int"}, diff --git a/keyboards/sowbug/68keys/config.h b/keyboards/sowbug/68keys/config.h index 0aad9a457470..0721302dbe1e 100644 --- a/keyboards/sowbug/68keys/config.h +++ b/keyboards/sowbug/68keys/config.h @@ -26,7 +26,6 @@ #define DEVICE_VER 0x0001 #define MANUFACTURER github.com/sowbug #define PRODUCT 68-key keyboard -#define DESCRIPTION A 68-key keyboard based on 68keys.io // key matrix size #define MATRIX_ROWS 5 diff --git a/keyboards/sowbug/ansi_tkl/config.h b/keyboards/sowbug/ansi_tkl/config.h index 505453b72b55..44e82bbac734 100644 --- a/keyboards/sowbug/ansi_tkl/config.h +++ b/keyboards/sowbug/ansi_tkl/config.h @@ -26,7 +26,6 @@ #define DEVICE_VER 0x0001 #define MANUFACTURER github.com/sowbug #define PRODUCT ANSI TKL -#define DESCRIPTION A tenkeyless ANSI-layout keyboard // key matrix size #define MATRIX_ROWS 6 diff --git a/keyboards/unicomp/spacesaver_m_pre_2013/overnumpad_1xb/config.h b/keyboards/unicomp/spacesaver_m_pre_2013/overnumpad_1xb/config.h index 7bd5b224dff1..597d287b077c 100644 --- a/keyboards/unicomp/spacesaver_m_pre_2013/overnumpad_1xb/config.h +++ b/keyboards/unicomp/spacesaver_m_pre_2013/overnumpad_1xb/config.h @@ -23,7 +23,6 @@ #define DEVICE_VER 0x0001 #define MANUFACTURER Unicomp/Purdea Andrei #define PRODUCT Unicomp Spacesaver M -#define DESCRIPTION QMK firmware for the Unicomp Spacesaver M keyboard with a replacement Overnumpad controller #define SERIAL_NUMBER "purdea.ro:overnumpad_controller" /* key matrix size */ diff --git a/keyboards/xelus/ninjin/config.h b/keyboards/xelus/ninjin/config.h index cbaca37b5edc..4dd40210a66a 100644 --- a/keyboards/xelus/ninjin/config.h +++ b/keyboards/xelus/ninjin/config.h @@ -22,7 +22,6 @@ #define DEVICE_VER 0x0001 #define MANUFACTURER Xelus #define PRODUCT Ninjin -#define DESCRIPTION Ninjin /* key matrix size */ #define MATRIX_ROWS 6 diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index d5cf1841c9ae..d40d4bf57394 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py @@ -259,7 +259,7 @@ def test_generate_config_h(): result = check_subcommand('generate-config-h', '-kb', 'handwired/pytest/basic') check_returncode(result) assert '# define DEVICE_VER 0x0001' in result.stdout - assert '# define DESCRIPTION handwired/pytest/basic' in result.stdout + assert '# define DESCRIPTION "handwired/pytest/basic"' in result.stdout assert '# define DIODE_DIRECTION COL2ROW' in result.stdout assert '# define MANUFACTURER none' in result.stdout assert '# define PRODUCT pytest' in result.stdout From 240745dc05783c612e92bab153da5c46e037d675 Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 6 Mar 2022 11:16:33 +0100 Subject: [PATCH 84/88] update bootloader --- keyboards/annepro2/annepro2.c | 24 ------------------------ keyboards/annepro2/c15/rules.mk | 2 ++ keyboards/annepro2/c18/rules.mk | 2 ++ 3 files changed, 4 insertions(+), 24 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 37489defff34..a24d0106562e 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -21,9 +21,6 @@ #include "ap2_led.h" #include "protocol.h" -#define RAM_MAGIC_LOCATION 0x20001ffc -#define IAP_MAGIC_VALUE 0x0000fab2 - static const SerialConfig ledUartInitConfig = { .speed = 115200, }; @@ -44,27 +41,6 @@ static uint8_t ledMcuWakeup[11] = {0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7 ble_capslock_t BLECapsLock = {._dummy = {0}, .caps_lock = false}; -void bootloader_jump(void) { - // Send msg to shine to boot into IAP - annepro2SetIAP(); - - // 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 - // It’s from reversing original boot loader - // If value is that it stays in boot loader aka IAP - *((uint32_t *)RAM_MAGIC_LOCATION) = IAP_MAGIC_VALUE; - - // Load the main MCU into IAP - __disable_irq(); - NVIC_SystemReset(); -} - void keyboard_pre_init_kb(void) { // Start LED UART sdStart(&SD0, &ledUartInitConfig); diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index ea4d1b441220..95002f487741 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -16,6 +16,8 @@ MCU_STARTUP = ht32f523xx BOARD = ANNEPRO2_C15 +BOOTLOADER=annepro2 + # Options # Keys diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 3858c7f46a47..4dffd055b596 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -16,6 +16,8 @@ MCU_STARTUP = ht32f523xx BOARD = ANNEPRO2_C18 +BOOTLOADER=annepro2 + # Options # Keys From 1585912a8acd35fa6e52fcba7bdf789b5f92b729 Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 6 Mar 2022 19:29:38 +0100 Subject: [PATCH 85/88] Revert "Merge pull request #2 from qmk/develop" This reverts commit 9c76065188c3adda98bdaa1f28dad85600e73ee9, reversing changes made to 240745dc05783c612e92bab153da5c46e037d675. --- .github/workflows/api.yml | 2 +- .github/workflows/develop_api.yml | 2 +- api_data/_config.yml | 1 + {data/templates/api => api_data}/readme.md | 0 data/mappings/info_config.json | 4 +-- data/mappings/info_rules.json | 4 +-- docs/data_driven_config.md | 5 ++- docs/feature_unicode.md | 11 +++++++ docs/ja/feature_unicode.md | 11 +++++++ keyboards/sowbug/68keys/config.h | 1 + keyboards/sowbug/ansi_tkl/config.h | 1 + .../overnumpad_1xb/config.h | 1 + keyboards/xelus/ninjin/config.h | 1 + lib/python/qmk/cli/generate/api.py | 28 ++++------------ lib/python/qmk/cli/generate/config_h.py | 9 ++--- lib/python/qmk/cli/generate/rules_mk.py | 4 +-- lib/python/qmk/info.py | 10 ++---- lib/python/qmk/tests/test_cli_commands.py | 4 +-- platforms/avr/platform.mk | 9 +---- .../process_keycode/process_unicode_common.c | 33 +++++++++++++++++++ .../process_keycode/process_unicode_common.h | 1 + readme.md | 4 --- 22 files changed, 84 insertions(+), 62 deletions(-) create mode 100644 api_data/_config.yml rename {data/templates/api => api_data}/readme.md (100%) diff --git a/.github/workflows/api.yml b/.github/workflows/api.yml index f0c49baf60bb..a19667f97e7f 100644 --- a/.github/workflows/api.yml +++ b/.github/workflows/api.yml @@ -35,4 +35,4 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_SECRET_KEY }} AWS_S3_ENDPOINT: https://nyc3.digitaloceanspaces.com - SOURCE_DIR: '.build/api_data' + SOURCE_DIR: 'api_data' diff --git a/.github/workflows/develop_api.yml b/.github/workflows/develop_api.yml index 3eb6e53c20b7..f0098142c7bc 100644 --- a/.github/workflows/develop_api.yml +++ b/.github/workflows/develop_api.yml @@ -35,4 +35,4 @@ jobs: AWS_ACCESS_KEY_ID: ${{ secrets.SPACES_ACCESS_KEY }} AWS_SECRET_ACCESS_KEY: ${{ secrets.SPACES_SECRET_KEY }} AWS_S3_ENDPOINT: https://nyc3.digitaloceanspaces.com - SOURCE_DIR: '.build/api_data' + SOURCE_DIR: 'api_data' diff --git a/api_data/_config.yml b/api_data/_config.yml new file mode 100644 index 000000000000..277f1f2c510d --- /dev/null +++ b/api_data/_config.yml @@ -0,0 +1 @@ +theme: jekyll-theme-cayman diff --git a/data/templates/api/readme.md b/api_data/readme.md similarity index 100% rename from data/templates/api/readme.md rename to api_data/readme.md diff --git a/data/mappings/info_config.json b/data/mappings/info_config.json index 2121741d1996..cfe8807d4363 100644 --- a/data/mappings/info_config.json +++ b/data/mappings/info_config.json @@ -3,7 +3,7 @@ { # Format: # : {"info_key": , ["value_type": ], ["to_json": ], ["to_c": ]} - # value_type: one of "array", "array.int", "bool", "int", "hex", "list", "mapping", "str", "raw" + # value_type: one of "array", "array.int", "bool", "int", "hex", "list", "mapping" # to_json: Default `true`. Set to `false` to exclude this mapping from info.json # to_c: Default `true`. Set to `false` to exclude this mapping from config.h # warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places @@ -17,7 +17,7 @@ "DEVICE_VER": {"info_key": "usb.device_ver", "value_type": "hex"}, # TODO: Replace ^^^ with vvv #"DEVICE_VER": {"info_key": "usb.device_version", "value_type": "bcd_version"}, - "DESCRIPTION": {"info_key": "keyboard_folder", "value_type": "str", "to_json": false}, + "DESCRIPTION": {"info_key": "keyboard_folder", "to_json": false}, "DIODE_DIRECTION": {"info_key": "diode_direction"}, "FORCE_NKRO": {"info_key": "usb.force_nkro", "value_type": "bool"}, "DYNAMIC_KEYMAP_EEPROM_MAX_ADDR": {"info_key": "dynamic_keymap.eeprom_max_addr", "value_type": "int"}, diff --git a/data/mappings/info_rules.json b/data/mappings/info_rules.json index f03cadcd44f6..aea67e04c846 100644 --- a/data/mappings/info_rules.json +++ b/data/mappings/info_rules.json @@ -3,7 +3,7 @@ { # Format: # : {"info_key": , ["value_type": ], ["to_json": ], ["to_c": ]} - # value_type: one of "array", "array.int", "bool", "int", "list", "hex", "mapping", "str", "raw" + # value_type: one of "array", "array.int", "bool", "int", "list", "hex", "mapping" # to_json: Default `true`. Set to `false` to exclude this mapping from info.json # to_c: Default `true`. Set to `false` to exclude this mapping from rules.mk # warn_duplicate: Default `true`. Set to `false` to turn off warning when a value exists in both places @@ -20,6 +20,6 @@ "MOUSEKEY_ENABLE": {"info_key": "mouse_key.enabled", "value_type": "bool"}, "NO_USB_STARTUP_CHECK": {"info_key": "usb.no_startup_check", "value_type": "bool"}, "SPLIT_KEYBOARD": {"info_key": "split.enabled", "value_type": "bool"}, - "SPLIT_TRANSPORT": {"info_key": "split.transport.protocol", "to_c": false}, + "SPLIT_TRANSPORT": {"info_key": "split.transport.protocol", "value_type": "str", "to_c": false}, "WAIT_FOR_USB": {"info_key": "usb.wait_for", "value_type": "bool"} } diff --git a/docs/data_driven_config.md b/docs/data_driven_config.md index cdcf21a19c5b..38fb5dbf1445 100644 --- a/docs/data_driven_config.md +++ b/docs/data_driven_config.md @@ -44,7 +44,7 @@ In other cases you should group like options together in an `object`. This is pa In most cases you can add a simple mapping. These are maintained as JSON files in `data/mappings/info_config.json` and `data/mappings/info_rules.json`, and control mapping for `config.h` and `rules.mk`, respectively. Each mapping is keyed by the `config.h` or `rules.mk` variable, and the value is a hash with the following keys: * `info_key`: (required) The location within `info.json` for this value. See below. -* `value_type`: (optional) Default `raw`. The format for this variable's value. See below. +* `value_type`: (optional) Default `str`. The format for this variable's value. See below. * `to_json`: (optional) Default `true`. Set to `false` to exclude this mapping from info.json * `to_c`: (optional) Default `true`. Set to `false` to exclude this mapping from config.h * `warn_duplicate`: (optional) Default `true`. Set to `false` to turn off warning when a value exists in both places @@ -57,7 +57,7 @@ Under the hood we use [Dotty Dict](https://dotty-dict.readthedocs.io/en/latest/) #### Value Types -By default we treat all values as unquoted "raw" data. If your value is more complex you can use one of these types to intelligently parse the data: +By default we treat all values as simple strings. If your value is more complex you can use one of these types to intelligently parse the data: * `array`: A comma separated array of strings * `array.int`: A comma separated array of integers @@ -65,7 +65,6 @@ By default we treat all values as unquoted "raw" data. If your value is more com * `hex`: A number formatted as hex * `list`: A space separate array of strings * `mapping`: A hash of key/value pairs -* `str`: A quoted string literal ### Add code to extract it diff --git a/docs/feature_unicode.md b/docs/feature_unicode.md index bced419a03fe..6c3e2a1a2fba 100644 --- a/docs/feature_unicode.md +++ b/docs/feature_unicode.md @@ -230,6 +230,17 @@ send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻"); Example uses include sending Unicode strings when a key is pressed, as described in [Macros](feature_macros.md). +### `send_unicode_hex_string()` (Deprecated) + +Similar to `send_unicode_string()`, but the characters are represented by their Unicode code points, written in hexadecimal and separated by spaces. For example, the table flip above would be achieved with: + +```c +send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B"); +``` + +An easy way to convert your Unicode string to this format is to use [this site](https://r12a.github.io/app-conversion/) and take the result in the "Hex/UTF-32" section. + + ## Additional Language Support In `quantum/keymap_extras`, you'll see various language files — these work the same way as the ones for alternative layouts such as Colemak or BÉPO. When you include one of these language headers, you gain access to keycodes specific to that language / national layout. Such keycodes are defined by a 2-letter country/language code, followed by an underscore and a 4-letter abbreviation of the character to which the key corresponds. For example, including `keymap_french.h` and using `FR_UGRV` in your keymap will output `ù` when typed on a system with a native French AZERTY layout. diff --git a/docs/ja/feature_unicode.md b/docs/ja/feature_unicode.md index 2158678f3c48..bfcb866ce1b0 100644 --- a/docs/ja/feature_unicode.md +++ b/docs/ja/feature_unicode.md @@ -233,6 +233,17 @@ send_unicode_string("(ノಠ痊ಠ)ノ彡┻━┻"); 使用例には、[Macros](ja/feature_macros.md) で説明されているように、キーが押された時に Unicode 文字列を送信することが含まれます。 +### `send_unicode_hex_string()` + +`send_unicode_string()` に似ていますが、文字は Unicode コードポイントで表され、16進数で記述され、空白で区切られています。例えば、上記のちゃぶ台返しは以下で表されます: + +```c +send_unicode_hex_string("0028 30CE 0CA0 75CA 0CA0 0029 30CE 5F61 253B 2501 253B"); +``` + +[このサイト](https://r12a.github.io/app-conversion/)で結果を "Hex/UTF-32" で受け取ることで、Unicode 文字列をこの形式に簡単に変換できます。 + + ## 追加の言語サポート `quantum/keymap_extras` には、様々な言語ファイルがあります — これらは Colemak または BÉPO のような代替レイアウトのファイルと同じように動作します。これらの言語ヘッダのいずれかを `#include` すると、その言語/国のレイアウトに固有のキーコードにアクセスできます。このようなキーコードは、2文字の国/言語コードの後に、アンダースコアとキーが対応する4文字の略語が続くことで定義されます。例えば、キーマップに `keymap_french.h` を含め、`FR_UGRV` を使うと、ネイティブのフランス語 AZERTY レイアウトを使うシステムで入力すると、`ù` が出力されます。 diff --git a/keyboards/sowbug/68keys/config.h b/keyboards/sowbug/68keys/config.h index 0721302dbe1e..0aad9a457470 100644 --- a/keyboards/sowbug/68keys/config.h +++ b/keyboards/sowbug/68keys/config.h @@ -26,6 +26,7 @@ #define DEVICE_VER 0x0001 #define MANUFACTURER github.com/sowbug #define PRODUCT 68-key keyboard +#define DESCRIPTION A 68-key keyboard based on 68keys.io // key matrix size #define MATRIX_ROWS 5 diff --git a/keyboards/sowbug/ansi_tkl/config.h b/keyboards/sowbug/ansi_tkl/config.h index 44e82bbac734..505453b72b55 100644 --- a/keyboards/sowbug/ansi_tkl/config.h +++ b/keyboards/sowbug/ansi_tkl/config.h @@ -26,6 +26,7 @@ #define DEVICE_VER 0x0001 #define MANUFACTURER github.com/sowbug #define PRODUCT ANSI TKL +#define DESCRIPTION A tenkeyless ANSI-layout keyboard // key matrix size #define MATRIX_ROWS 6 diff --git a/keyboards/unicomp/spacesaver_m_pre_2013/overnumpad_1xb/config.h b/keyboards/unicomp/spacesaver_m_pre_2013/overnumpad_1xb/config.h index 597d287b077c..7bd5b224dff1 100644 --- a/keyboards/unicomp/spacesaver_m_pre_2013/overnumpad_1xb/config.h +++ b/keyboards/unicomp/spacesaver_m_pre_2013/overnumpad_1xb/config.h @@ -23,6 +23,7 @@ #define DEVICE_VER 0x0001 #define MANUFACTURER Unicomp/Purdea Andrei #define PRODUCT Unicomp Spacesaver M +#define DESCRIPTION QMK firmware for the Unicomp Spacesaver M keyboard with a replacement Overnumpad controller #define SERIAL_NUMBER "purdea.ro:overnumpad_controller" /* key matrix size */ diff --git a/keyboards/xelus/ninjin/config.h b/keyboards/xelus/ninjin/config.h index 4dd40210a66a..cbaca37b5edc 100644 --- a/keyboards/xelus/ninjin/config.h +++ b/keyboards/xelus/ninjin/config.h @@ -22,6 +22,7 @@ #define DEVICE_VER 0x0001 #define MANUFACTURER Xelus #define PRODUCT Ninjin +#define DESCRIPTION Ninjin /* key matrix size */ #define MATRIX_ROWS 6 diff --git a/lib/python/qmk/cli/generate/api.py b/lib/python/qmk/cli/generate/api.py index 0596b3f22b50..285bd90eb560 100755 --- a/lib/python/qmk/cli/generate/api.py +++ b/lib/python/qmk/cli/generate/api.py @@ -1,7 +1,7 @@ """This script automates the generation of the QMK API data. """ from pathlib import Path -import shutil +from shutil import copyfile import json from milc import cli @@ -12,42 +12,28 @@ from qmk.json_schema import json_load from qmk.keyboard import find_readme, list_keyboards -TEMPLATE_PATH = Path('data/templates/api/') -BUILD_API_PATH = Path('.build/api_data/') - @cli.argument('-n', '--dry-run', arg_only=True, action='store_true', help="Don't write the data to disk.") -@cli.argument('-f', '--filter', arg_only=True, action='append', default=[], help="Filter the list of keyboards based on partial name matches the supplied value. May be passed multiple times.") @cli.subcommand('Creates a new keymap for the keyboard of your choosing', hidden=False if cli.config.user.developer else True) def generate_api(cli): """Generates the QMK API data. """ - if BUILD_API_PATH.exists(): - shutil.rmtree(BUILD_API_PATH) - - shutil.copytree(TEMPLATE_PATH, BUILD_API_PATH) - - v1_dir = BUILD_API_PATH / 'v1' + api_data_dir = Path('api_data') + v1_dir = api_data_dir / 'v1' keyboard_all_file = v1_dir / 'keyboards.json' # A massive JSON containing everything keyboard_list_file = v1_dir / 'keyboard_list.json' # A simple list of keyboard targets keyboard_aliases_file = v1_dir / 'keyboard_aliases.json' # A list of historical keyboard names and their new name keyboard_metadata_file = v1_dir / 'keyboard_metadata.json' # All the data configurator/via needs for initialization usb_file = v1_dir / 'usb.json' # A mapping of USB VID/PID -> keyboard target - # Filter down when required - keyboard_list = list_keyboards() - if cli.args.filter: - kb_list = [] - for keyboard_name in keyboard_list: - if any(i in keyboard_name for i in cli.args.filter): - kb_list.append(keyboard_name) - keyboard_list = kb_list + if not api_data_dir.exists(): + api_data_dir.mkdir() kb_all = {} usb_list = {} # Generate and write keyboard specific JSON files - for keyboard_name in keyboard_list: + for keyboard_name in list_keyboards(): kb_all[keyboard_name] = info_json(keyboard_name) keyboard_dir = v1_dir / 'keyboards' / keyboard_name keyboard_info = keyboard_dir / 'info.json' @@ -61,7 +47,7 @@ def generate_api(cli): cli.log.debug('Wrote file %s', keyboard_info) if keyboard_readme_src: - shutil.copyfile(keyboard_readme_src, keyboard_readme) + copyfile(keyboard_readme_src, keyboard_readme) cli.log.debug('Copied %s -> %s', keyboard_readme_src, keyboard_readme) if 'usb' in kb_all[keyboard_name]: diff --git a/lib/python/qmk/cli/generate/config_h.py b/lib/python/qmk/cli/generate/config_h.py index 340ed1043678..24bbbdf51726 100755 --- a/lib/python/qmk/cli/generate/config_h.py +++ b/lib/python/qmk/cli/generate/config_h.py @@ -82,7 +82,7 @@ def generate_config_items(kb_info_json, config_h_lines): for config_key, info_dict in info_config_map.items(): info_key = info_dict['info_key'] - key_type = info_dict.get('value_type', 'raw') + key_type = info_dict.get('value_type', 'str') to_config = info_dict.get('to_config', True) if not to_config: @@ -110,11 +110,6 @@ def generate_config_items(kb_info_json, config_h_lines): config_h_lines.append(f'#ifndef {key}') config_h_lines.append(f'# define {key} {value}') config_h_lines.append(f'#endif // {key}') - elif key_type == 'str': - config_h_lines.append('') - config_h_lines.append(f'#ifndef {config_key}') - config_h_lines.append(f'# define {config_key} "{config_value}"') - config_h_lines.append(f'#endif // {config_key}') elif key_type == 'bcd_version': (major, minor, revision) = config_value.split('.') config_h_lines.append('') @@ -205,7 +200,7 @@ def generate_config_h(cli): cli.args.output.parent.mkdir(parents=True, exist_ok=True) if cli.args.output.exists(): cli.args.output.replace(cli.args.output.parent / (cli.args.output.name + '.bak')) - cli.args.output.write_text(config_h, encoding='utf-8') + cli.args.output.write_text(config_h) if not cli.args.quiet: cli.log.info('Wrote info_config.h to %s.', cli.args.output) diff --git a/lib/python/qmk/cli/generate/rules_mk.py b/lib/python/qmk/cli/generate/rules_mk.py index a1b10cc945a9..ce824f6378e6 100755 --- a/lib/python/qmk/cli/generate/rules_mk.py +++ b/lib/python/qmk/cli/generate/rules_mk.py @@ -19,7 +19,7 @@ def process_mapping_rule(kb_info_json, rules_key, info_dict): return None info_key = info_dict['info_key'] - key_type = info_dict.get('value_type', 'raw') + key_type = info_dict.get('value_type', 'str') try: rules_value = kb_info_json[info_key] @@ -32,8 +32,6 @@ def process_mapping_rule(kb_info_json, rules_key, info_dict): return f'{rules_key} ?= {"yes" if rules_value else "no"}' elif key_type == 'mapping': return '\n'.join([f'{key} ?= {value}' for key, value in rules_value.items()]) - elif key_type == 'str': - return f'{rules_key} ?= "{rules_value}"' return f'{rules_key} ?= {rules_value}' diff --git a/lib/python/qmk/info.py b/lib/python/qmk/info.py index c399a9f32198..b86eaa059f11 100644 --- a/lib/python/qmk/info.py +++ b/lib/python/qmk/info.py @@ -411,7 +411,7 @@ def _extract_config_h(info_data): for config_key, info_dict in info_config_map.items(): info_key = info_dict['info_key'] - key_type = info_dict.get('value_type', 'raw') + key_type = info_dict.get('value_type', 'str') try: if config_key in config_c and info_dict.get('to_json', True): @@ -443,9 +443,6 @@ def _extract_config_h(info_data): elif key_type == 'int': dotty_info[info_key] = int(config_c[config_key]) - elif key_type == 'str': - dotty_info[info_key] = config_c[config_key].strip('"') - elif key_type == 'bcd_version': major = int(config_c[config_key][2:4]) minor = int(config_c[config_key][4]) @@ -494,7 +491,7 @@ def _extract_rules_mk(info_data): for rules_key, info_dict in info_rules_map.items(): info_key = info_dict['info_key'] - key_type = info_dict.get('value_type', 'raw') + key_type = info_dict.get('value_type', 'str') try: if rules_key in rules and info_dict.get('to_json', True): @@ -526,9 +523,6 @@ def _extract_rules_mk(info_data): elif key_type == 'int': dotty_info[info_key] = int(rules[rules_key]) - elif key_type == 'str': - dotty_info[info_key] = rules[rules_key].strip('"') - else: dotty_info[info_key] = rules[rules_key] diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index d40d4bf57394..55e69175e64a 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py @@ -244,7 +244,7 @@ def test_clean(): def test_generate_api(): - result = check_subcommand('generate-api', '--dry-run', '--filter', 'handwired/pytest') + result = check_subcommand('generate-api', '--dry-run') check_returncode(result) @@ -259,7 +259,7 @@ def test_generate_config_h(): result = check_subcommand('generate-config-h', '-kb', 'handwired/pytest/basic') check_returncode(result) assert '# define DEVICE_VER 0x0001' in result.stdout - assert '# define DESCRIPTION "handwired/pytest/basic"' in result.stdout + assert '# define DESCRIPTION handwired/pytest/basic' in result.stdout assert '# define DIODE_DIRECTION COL2ROW' in result.stdout assert '# define MANUFACTURER none' in result.stdout assert '# define PRODUCT pytest' in result.stdout diff --git a/platforms/avr/platform.mk b/platforms/avr/platform.mk index 9f304d2e209d..4d9cafaeef4a 100644 --- a/platforms/avr/platform.mk +++ b/platforms/avr/platform.mk @@ -18,13 +18,6 @@ COMPILEFLAGS += -ffunction-sections COMPILEFLAGS += -fdata-sections COMPILEFLAGS += -fpack-struct COMPILEFLAGS += -fshort-enums -COMPILEFLAGS += -mcall-prologues - -# Linker relaxation is only possible if -# link time optimizations are not enabled. -ifeq ($(strip $(LTO_ENABLE)), no) - COMPILEFLAGS += -mrelax -endif ASFLAGS += $(AVR_ASFLAGS) @@ -35,7 +28,7 @@ CFLAGS += -fno-strict-aliasing CXXFLAGS += $(COMPILEFLAGS) CXXFLAGS += -fno-exceptions -std=c++11 -LDFLAGS += -Wl,--gc-sections +LDFLAGS +=-Wl,--gc-sections OPT_DEFS += -DF_CPU=$(F_CPU)UL diff --git a/quantum/process_keycode/process_unicode_common.c b/quantum/process_keycode/process_unicode_common.c index 2606ea1f3720..46b77e14bae5 100644 --- a/quantum/process_keycode/process_unicode_common.c +++ b/quantum/process_keycode/process_unicode_common.c @@ -16,6 +16,8 @@ #include "process_unicode_common.h" #include "eeprom.h" +#include +#include unicode_config_t unicode_config; uint8_t unicode_saved_mods; @@ -229,6 +231,37 @@ void register_unicode(uint32_t code_point) { unicode_input_finish(); } +// clang-format off + +void send_unicode_hex_string(const char *str) { + if (!str) { + return; + } + + while (*str) { + // Find the next code point (token) in the string + for (; *str == ' '; str++); // Skip leading spaces + size_t n = strcspn(str, " "); // Length of the current token + char code_point[n+1]; + strncpy(code_point, str, n); // Copy token into buffer + code_point[n] = '\0'; // Make sure it's null-terminated + + // Normalize the code point: make all hex digits lowercase + for (char *p = code_point; *p; p++) { + *p = tolower((unsigned char)*p); + } + + // Send the code point as a Unicode input string + unicode_input_start(); + send_string(code_point); + unicode_input_finish(); + + str += n; // Move to the first ' ' (or '\0') after the current token + } +} + +// clang-format on + // Borrowed from https://nullprogram.com/blog/2017/10/06/ static const char *decode_utf8(const char *str, int32_t *code_point) { const char *next; diff --git a/quantum/process_keycode/process_unicode_common.h b/quantum/process_keycode/process_unicode_common.h index 8a4494c9395c..1a6607c757d6 100644 --- a/quantum/process_keycode/process_unicode_common.h +++ b/quantum/process_keycode/process_unicode_common.h @@ -90,6 +90,7 @@ void register_hex(uint16_t hex); void register_hex32(uint32_t hex); void register_unicode(uint32_t code_point); +void send_unicode_hex_string(const char *str); void send_unicode_string(const char *str); bool process_unicode_common(uint16_t keycode, keyrecord_t *record); diff --git a/readme.md b/readme.md index 63b483c74474..5649ddfa097a 100644 --- a/readme.md +++ b/readme.md @@ -1,7 +1,3 @@ -# This is the `develop` branch! - -See the [Breaking Changes](https://docs.qmk.fm/#/breaking_changes) document for more information. - # Quantum Mechanical Keyboard Firmware [![Current Version](https://img.shields.io/github/tag/qmk/qmk_firmware.svg)](https://github.com/qmk/qmk_firmware/tags) From 75967b88e929b157fdc46d794231f57abf8fa501 Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 6 Mar 2022 19:30:39 +0100 Subject: [PATCH 86/88] Revert "update bootloader" This reverts commit 240745dc05783c612e92bab153da5c46e037d675. --- keyboards/annepro2/annepro2.c | 24 ++++++++++++++++++++++++ keyboards/annepro2/c15/rules.mk | 2 -- keyboards/annepro2/c18/rules.mk | 2 -- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index a24d0106562e..37489defff34 100644 --- a/keyboards/annepro2/annepro2.c +++ b/keyboards/annepro2/annepro2.c @@ -21,6 +21,9 @@ #include "ap2_led.h" #include "protocol.h" +#define RAM_MAGIC_LOCATION 0x20001ffc +#define IAP_MAGIC_VALUE 0x0000fab2 + static const SerialConfig ledUartInitConfig = { .speed = 115200, }; @@ -41,6 +44,27 @@ static uint8_t ledMcuWakeup[11] = {0x7b, 0x10, 0x43, 0x10, 0x03, 0x00, 0x00, 0x7 ble_capslock_t BLECapsLock = {._dummy = {0}, .caps_lock = false}; +void bootloader_jump(void) { + // Send msg to shine to boot into IAP + annepro2SetIAP(); + + // 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 + // It’s from reversing original boot loader + // If value is that it stays in boot loader aka IAP + *((uint32_t *)RAM_MAGIC_LOCATION) = IAP_MAGIC_VALUE; + + // Load the main MCU into IAP + __disable_irq(); + NVIC_SystemReset(); +} + void keyboard_pre_init_kb(void) { // Start LED UART sdStart(&SD0, &ledUartInitConfig); diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index 95002f487741..ea4d1b441220 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -16,8 +16,6 @@ MCU_STARTUP = ht32f523xx BOARD = ANNEPRO2_C15 -BOOTLOADER=annepro2 - # Options # Keys diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 4dffd055b596..3858c7f46a47 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -16,8 +16,6 @@ MCU_STARTUP = ht32f523xx BOARD = ANNEPRO2_C18 -BOOTLOADER=annepro2 - # Options # Keys From 2057887419675c6239699124acf457bfb7db59ec Mon Sep 17 00:00:00 2001 From: bwisn Date: Sun, 6 Mar 2022 19:32:28 +0100 Subject: [PATCH 87/88] fix rules.mk --- keyboards/annepro2/c15/rules.mk | 2 ++ keyboards/annepro2/c18/rules.mk | 2 ++ 2 files changed, 4 insertions(+) diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index ea4d1b441220..729c01ebec11 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -33,3 +33,5 @@ RAW_ENABLE = no MIDI_ENABLE = no VIRTSER_ENABLE = no COMBO_ENABLE = no +BOOTLOADER = custom +PROGRAM_CMD = annepro2_tools $(BUILD_DIR)/$(TARGET).bin diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index 3858c7f46a47..fd1b260fd6cb 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -33,3 +33,5 @@ RAW_ENABLE = no MIDI_ENABLE = no VIRTSER_ENABLE = no COMBO_ENABLE = no +BOOTLOADER = custom +PROGRAM_CMD = annepro2_tools $(BUILD_DIR)/$(TARGET).bin -i=0 From 259d7997aa5a8002c51e8958342a7605b557c210 Mon Sep 17 00:00:00 2001 From: bwisn Date: Mon, 7 Mar 2022 07:20:45 +0100 Subject: [PATCH 88/88] change PROGRAM_CMD --- keyboards/annepro2/c15/rules.mk | 2 +- keyboards/annepro2/c18/rules.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/keyboards/annepro2/c15/rules.mk b/keyboards/annepro2/c15/rules.mk index 729c01ebec11..554ddc28ceb2 100644 --- a/keyboards/annepro2/c15/rules.mk +++ b/keyboards/annepro2/c15/rules.mk @@ -34,4 +34,4 @@ MIDI_ENABLE = no VIRTSER_ENABLE = no COMBO_ENABLE = no BOOTLOADER = custom -PROGRAM_CMD = annepro2_tools $(BUILD_DIR)/$(TARGET).bin +PROGRAM_CMD = annepro2_tools --boot $(BUILD_DIR)/$(TARGET).bin diff --git a/keyboards/annepro2/c18/rules.mk b/keyboards/annepro2/c18/rules.mk index fd1b260fd6cb..b2e16cc35f16 100644 --- a/keyboards/annepro2/c18/rules.mk +++ b/keyboards/annepro2/c18/rules.mk @@ -34,4 +34,4 @@ MIDI_ENABLE = no VIRTSER_ENABLE = no COMBO_ENABLE = no BOOTLOADER = custom -PROGRAM_CMD = annepro2_tools $(BUILD_DIR)/$(TARGET).bin -i=0 +PROGRAM_CMD = annepro2_tools --boot $(BUILD_DIR)/$(TARGET).bin