Skip to content

Commit

Permalink
Fixed EM in keys diagnostic screen
Browse files Browse the repository at this point in the history
  • Loading branch information
richardclli committed Jul 29, 2024
1 parent ad40efb commit 6f96397
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 5 additions & 0 deletions radio/src/targets/pl18/hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions radio/util/hw_defs/stm32_keys.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,18 @@
// This file has been generated from the target's JSON hardware description
//

{% set hw_keys = keys | rejectattr('pin', 'none') | rejectattr('gpio', 'none') | 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);
Expand All @@ -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 %}
Expand Down

0 comments on commit 6f96397

Please sign in to comment.