From 87b1e2c69a01443adc19fd4b30d6ffea60be9942 Mon Sep 17 00:00:00 2001 From: codetector Date: Sat, 4 Jul 2020 01:45:23 -0400 Subject: [PATCH] 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 c770163bedb..a128140de9e 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 d95f3fb3859..92d597a9e1d 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 d9dcd3e3bb3..405dc63d967 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 05fe1c4e531..ea9c8da299a 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 e98da37f45a..a503bb7c884 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_ */