more fixes

This commit is contained in:
bwisn 2021-11-01 07:54:07 +01:00
parent 6f89eeea6b
commit 0e1449c458
8 changed files with 100 additions and 178 deletions

View File

@ -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

View File

@ -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,7 +43,8 @@
*/
const PALConfig pal_default_config = {
// GPIO A
.setup[0] = {
.setup[0] =
{
.DIR = OUT_BITS(IOPORTA),
.INE = IN_BITS(IOPORTA),
.PU = IN_BITS(IOPORTA),
@ -104,7 +57,8 @@ const PALConfig pal_default_config = {
.CFG[1] = AF_BITS(IOPORTA, 1),
},
// GPIO B
.setup[1] = {
.setup[1] =
{
.DIR = OUT_BITS(IOPORTB),
.INE = IN_BITS(IOPORTB),
.PU = IN_BITS(IOPORTB),
@ -117,7 +71,8 @@ const PALConfig pal_default_config = {
.CFG[1] = AF_BITS(IOPORTB, 1),
},
// GPIO C
.setup[2] = {
.setup[2] =
{
.DIR = OUT_BITS(IOPORTC),
.INE = IN_BITS(IOPORTC),
.PU = IN_BITS(IOPORTC),
@ -130,7 +85,8 @@ const PALConfig pal_default_config = {
.CFG[1] = AF_BITS(IOPORTC, 1),
},
// GPIO D
.setup[3] = {
.setup[3] =
{
.DIR = OUT_BITS(IOPORTD),
.INE = IN_BITS(IOPORTD),
.PU = IN_BITS(IOPORTD),
@ -147,33 +103,17 @@ const PALConfig pal_default_config = {
};
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) {}

View File

@ -14,8 +14,7 @@
limitations under the License.
*/
#ifndef BOARD_H
#define BOARD_H
#pragma once
/*
* Setup for Anne Pro 2 board.
*/
@ -65,13 +64,11 @@
#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
#endif /* _FROM_ASM_ */
#endif /* BOARD_H */

View File

@ -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 */

View File

@ -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

View File

@ -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

View File

@ -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_ */

View File

@ -6,8 +6,7 @@
* shine's clang formatting).
*/
#ifndef PROTOCOL_INCLUDED
#define PROTOCOL_INCLUDED
#pragma once
#include <inttypes.h>
#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