mirror of
https://github.com/qmk/qmk_firmware.git
synced 2025-07-21 15:12:02 +00:00
apply CR suggestions
This commit is contained in:
parent
d36ed0c251
commit
f0d102c214
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
/* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#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
|
||||
|
@ -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(); }
|
||||
|
107
keyboards/annepro2/boards/ANNEPRO2_C18/board.c
Normal file
107
keyboards/annepro2/boards/ANNEPRO2_C18/board.c
Normal file
@ -0,0 +1,107 @@
|
||||
/*
|
||||
Copyright (C) 2020 Yaotian Feng, Codetector<codetector@codetector.cn>
|
||||
|
||||
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) {}
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -1,4 +0,0 @@
|
||||
ifeq ($(strip $(ANNEPRO2_EEPROM)), yes)
|
||||
OPT_DEFS += -DANNEPRO2_EEPROM
|
||||
SRC += spi_master.c eeprom_w25x20cl.c
|
||||
endif
|
@ -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
|
||||
|
@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
#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
|
||||
}
|
Loading…
Reference in New Issue
Block a user