From 0e1449c4589483a558af840f46096d7e4b580b3c Mon Sep 17 00:00:00 2001 From: bwisn Date: Mon, 1 Nov 2021 07:54:07 +0100 Subject: [PATCH] more fixes --- keyboards/annepro2/annepro2.c | 2 +- .../annepro2/boards/ANNEPRO2_C15/board.c | 186 ++++++------------ .../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, 100 insertions(+), 178 deletions(-) diff --git a/keyboards/annepro2/annepro2.c b/keyboards/annepro2/annepro2.c index 0216f13cde1..353bc20d447 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 2be9e0f31c2..d5d6ba535bf 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 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) +#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 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 boardInit(void) { -} +void early_hardware_init_pre(void) { ht32_clock_init(); } + +void board_init(void) {} + +void boardInit(void) {} diff --git a/keyboards/annepro2/boards/ANNEPRO2_C15/board.h b/keyboards/annepro2/boards/ANNEPRO2_C15/board.h index 695f1b7e96a..e29a73956ae 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 ee75f310d66..01ca26c917d 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 4b6363507e4..3b7b56f5824 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 ad77ed9d26e..957c0284c05 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 a663cae5af3..8c6e00c978e 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 4e07908b404..ccc85df09df 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