From 8bfe5930e42e9af4158d315a585d13610e638762 Mon Sep 17 00:00:00 2001 From: Richard Li Date: Tue, 16 Jul 2024 14:20:03 +0800 Subject: [PATCH] Fixed EM in keys diagnostic screen --- radio/src/targets/pl18/hal.h | 5 +++++ radio/util/hw_defs/stm32_keys.jinja | 9 ++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/radio/src/targets/pl18/hal.h b/radio/src/targets/pl18/hal.h index 810391aa3dd..b95ebb56f49 100644 --- a/radio/src/targets/pl18/hal.h +++ b/radio/src/targets/pl18/hal.h @@ -306,6 +306,11 @@ #endif #else + #define KEYS_GPIO_PIN_ENTER + #define KEYS_GPIO_REG_ENTER + #define KEYS_GPIO_PIN_EXIT + #define KEYS_GPIO_REG_EXIT + #define ADC_GPIO_PIN_STICK_TH LL_GPIO_PIN_3 // PA.03 #define ADC_GPIO_PIN_STICK_ST LL_GPIO_PIN_2 // PA.02 #define ADC_CHANNEL_STICK_TH LL_ADC_CHANNEL_3 // ADC123_IN3 -> ADC1_IN3 diff --git a/radio/util/hw_defs/stm32_keys.jinja b/radio/util/hw_defs/stm32_keys.jinja index e3271f56778..b8fce28cb05 100644 --- a/radio/util/hw_defs/stm32_keys.jinja +++ b/radio/util/hw_defs/stm32_keys.jinja @@ -3,15 +3,18 @@ // This file has been generated from the target's JSON hardware description // +{% set hw_keys = keys | selectattr('pin', 'true') | selectattr('gpio', 'true') | list %} static inline void _init_keys() { {% for key_gpio, pins in key_gpios | dictsort %} - stm32_gpio_enable_clock({{ key_gpio }}); + {% if key_gpio %} + stm32_gpio_enable_clock({{ key_gpio }}); + {% endif %} {% endfor %} LL_GPIO_InitTypeDef pinInit; LL_GPIO_StructInit(&pinInit); pinInit.Mode = LL_GPIO_MODE_INPUT; -{% for key in keys %} +{% for key in hw_keys %} pinInit.Pin = {{ key.pin }}; pinInit.Pull = {{ 'LL_GPIO_PULL_UP' if key.active_low else 'LL_GPIO_PULL_DOWN' }}; LL_GPIO_Init({{ key.gpio }}, &pinInit); @@ -21,7 +24,7 @@ static inline void _init_keys() static inline uint32_t _read_keys() { uint32_t keys = 0; -{% for key in keys %} +{% for key in hw_keys %} if ({{'!' if key.active_low }}LL_GPIO_IsInputPinSet({{ key.gpio }}, {{ key.pin }})) keys |= (1 << {{ key.key }}); {% endfor %}