Apply suggestions from @tzarc code review

Co-authored-by: Nick Brassel <nick@tzarc.org>
This commit is contained in:
bwisn 2021-11-02 16:34:37 +01:00 committed by GitHub
parent 0e1449c458
commit 72884e63f9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 24 additions and 52 deletions

View File

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

View File

@ -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);
}

View File

@ -14,11 +14,7 @@
limitations under the License.
*/
#include <string.h>
#include "hal.h"
#include "wait.h"
#include "led.h"
#include "annepro2.h"
/* ============ Private Defines ===================== */

View File

@ -22,7 +22,6 @@
/*
* Board identifier.
*/
#define ANNEPRO2
#define BOARD_NAME "Anne Pro 2"
#define HT32F52342

View File

@ -22,7 +22,6 @@
/*
* Board identifier.
*/
#define ANNEPRO2
#define BOARD_NAME "Anne Pro 2"
#define HT32F52342

View File

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

View File

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

View File

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

View File

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

View File

@ -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 <halconf.h>

View File

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