From 9ff47d75b5c07661ca2547efb770d02089c2a5d7 Mon Sep 17 00:00:00 2001 From: Evangelos Rigas Date: Wed, 22 May 2019 08:20:36 +0900 Subject: [PATCH] Add support for Gnukey-DS. --- board/board-gnukey-ds.h | 39 ++++++++++++++++++++++++++++++++++++++ contrib/ackbtn-stm32f103.c | 1 + mcu/sys-stm32f103.h | 1 + 3 files changed, 41 insertions(+) create mode 100644 board/board-gnukey-ds.h diff --git a/board/board-gnukey-ds.h b/board/board-gnukey-ds.h new file mode 100644 index 0000000..2b650a0 --- /dev/null +++ b/board/board-gnukey-ds.h @@ -0,0 +1,39 @@ +#define BOARD_NAME "Gnukey DS" +#define BOARD_ID 0x67ee65a3 +/* echo -n "Gnukey DS" | sha256sum | sed -e 's/^.*\(........\) -$/\1/' */ + +#define MCU_STM32F1 1 +#define STM32F10X_MD /* Medium-density device */ + +#define STM32_PLLXTPRE STM32_PLLXTPRE_DIV1 +#define STM32_PLLMUL_VALUE 9 // 8MHz * 9 = 72 MHz +#define STM32_HSECLK 8000000 + +#define GPIO_LED_BASE GPIOA_BASE +#define GPIO_LED_SET_TO_EMIT 3 +#define GPIO_USB_BASE GPIOA_BASE +#undef GPIO_OTHER_BASE + +/* + * Port A setup. + * PA0 - input with pull-up: AN0 for NeuG + * PA1 - input with pull-up: AN1 for NeuG + * PA2 - input with pull-up: Hall effect sensor output + * PA3 - Push pull output 10MHz 0 default (LED 1:ON 0:OFF) + * PA11 - Push Pull output 10MHz 0 default (until USB enabled) (USBDM) + * PA12 - Push Pull output 10MHz 0 default (until USB enabled) (USBDP) + * ------------------------ Default + * PAx - input with pull-up. + */ +#define VAL_GPIO_LED_ODR 0xFFFFE7F7 /* 0/1 Pull Down/Up */ +#define VAL_GPIO_LED_CRL 0x88881888 /* PA7...PA0 */ +#define VAL_GPIO_LED_CRH 0x88811888 /* PA15...PA8 */ + +#define RCC_ENR_IOP_EN RCC_APB2ENR_IOPAEN +#define RCC_RSTR_IOP_RST RCC_APB2RSTR_IOPARST + +/* + * Board specific information other than clock and GPIO initial + * setting should not be in board-*.h, but each driver should include + * such specific information by itself. + */ diff --git a/contrib/ackbtn-stm32f103.c b/contrib/ackbtn-stm32f103.c index dce7c62..460940f 100644 --- a/contrib/ackbtn-stm32f103.c +++ b/contrib/ackbtn-stm32f103.c @@ -57,6 +57,7 @@ ackbtn_init (chopstx_intr_t *intr) { case BOARD_ID_FST_01: case BOARD_ID_FST_01G: + case BOARD_ID_GNUKEY_DS: /* PA2 can be connected to a hall sensor or a switch */ afio_exticr_index = 0; afio_exticr_extiX_pY = AFIO_EXTICR1_EXTI2_PA; diff --git a/mcu/sys-stm32f103.h b/mcu/sys-stm32f103.h index 2492acc..702fea2 100644 --- a/mcu/sys-stm32f103.h +++ b/mcu/sys-stm32f103.h @@ -12,6 +12,7 @@ #define BOARD_ID_ST_DONGLE 0x2cd4e471 #define BOARD_ID_ST_NUCLEO_F103 0x9b87c16d #define BOARD_ID_NITROKEY_START 0xad1e7ebd +#define BOARD_ID_GNUKEY_DS 0x67ee65a3 extern const uint8_t sys_version[8]; #if defined(USE_SYS3) || defined(USE_SYS_BOARD_ID)