1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers/periph_gpio_ll: Add features for compile-time-checks

This adds the features

 - periph_gpio_ll_input_pull_down:
        To indicate support for input mode with internal pull down
 - periph_gpio_ll_input_pull_keep:
        To indicate support for input mode with internal resistor
        pulling towards current level
 - periph_gpio_ll_input_pull_up:
        To indicate support for input mode with internal pull up
 - periph_gpio_ll_disconnect:
        To indicate a GPIO can be disconnected
 - periph_gpio_ll_open_drain:
        To indicate support for open drain mode
 - periph_gpio_ll_open_drain_pull_up:
        To indicate support for open drain mode with internal pull up
 - periph_gpio_ll_open_source:
        To indicate support for open source mode
 - periph_gpio_ll_open_source_pull_down:
        To indicate support for open source mode with internal pull down
This commit is contained in:
Marian Buschsieweke 2024-01-23 09:05:13 +01:00
parent e5cb676dfe
commit bd3f54ac8f
No known key found for this signature in database
GPG Key ID: 77AA882EC78084E6
10 changed files with 89 additions and 12 deletions

View File

@ -8,6 +8,7 @@ FEATURES_PROVIDED += atmega_pcint0
FEATURES_PROVIDED += periph_eeprom
FEATURES_PROVIDED += periph_gpio periph_gpio_irq
FEATURES_PROVIDED += periph_gpio_ll
FEATURES_PROVIDED += periph_gpio_ll_input_pull_up
FEATURES_PROVIDED += periph_gpio_ll_irq
FEATURES_PROVIDED += periph_gpio_ll_irq_level_triggered_low
FEATURES_PROVIDED += periph_gpio_ll_irq_unmask

View File

@ -18,6 +18,13 @@ FEATURES_PROVIDED += periph_flashpage_in_address_space
FEATURES_PROVIDED += periph_flashpage_pagewise
FEATURES_PROVIDED += periph_gpio periph_gpio_irq
FEATURES_PROVIDED += periph_gpio_ll
FEATURES_PROVIDED += periph_gpio_ll_disconnect
FEATURES_PROVIDED += periph_gpio_ll_input_pull_down
FEATURES_PROVIDED += periph_gpio_ll_input_pull_up
FEATURES_PROVIDED += periph_gpio_ll_open_drain
FEATURES_PROVIDED += periph_gpio_ll_open_drain_pull_up
FEATURES_PROVIDED += periph_gpio_ll_open_source
FEATURES_PROVIDED += periph_gpio_ll_open_source_pull_down
FEATURES_PROVIDED += periph_rtt_set_counter
FEATURES_PROVIDED += periph_rtt_overflow
FEATURES_PROVIDED += periph_uart_modecfg

View File

@ -22,9 +22,14 @@ FEATURES_PROVIDED += periph_flashpage
FEATURES_PROVIDED += periph_flashpage_in_address_space
FEATURES_PROVIDED += periph_flashpage_pagewise
FEATURES_PROVIDED += periph_gpio_ll
FEATURES_PROVIDED += periph_gpio_ll_disconnect
FEATURES_PROVIDED += periph_gpio_ll_input_pull_down
FEATURES_PROVIDED += periph_gpio_ll_input_pull_up
FEATURES_PROVIDED += periph_gpio_ll_irq
FEATURES_PROVIDED += periph_gpio_ll_irq_level_triggered_high
FEATURES_PROVIDED += periph_gpio_ll_irq_level_triggered_low
FEATURES_PROVIDED += periph_gpio_ll_open_drain
FEATURES_PROVIDED += periph_gpio_ll_open_drain_pull_up
FEATURES_PROVIDED += periph_spi_reconfigure
FEATURES_PROVIDED += puf_sram

View File

@ -5,9 +5,13 @@ FEATURES_PROVIDED += periph_clic
FEATURES_PROVIDED += periph_gpio
FEATURES_PROVIDED += periph_gpio_irq
FEATURES_PROVIDED += periph_gpio_ll
FEATURES_PROVIDED += periph_gpio_ll_disconnect
FEATURES_PROVIDED += periph_gpio_ll_input_pull_down
FEATURES_PROVIDED += periph_gpio_ll_input_pull_up
FEATURES_PROVIDED += periph_gpio_ll_irq
FEATURES_PROVIDED += periph_gpio_ll_irq_level_triggered_high
FEATURES_PROVIDED += periph_gpio_ll_irq_level_triggered_low
FEATURES_PROVIDED += periph_gpio_ll_open_drain
FEATURES_PROVIDED += periph_rtc
FEATURES_PROVIDED += periph_rtc_mem
FEATURES_PROVIDED += periph_rtt

View File

@ -11,7 +11,16 @@ FEATURES_PROVIDED += periph_uart_modecfg
FEATURES_PROVIDED += periph_wdt periph_wdt_cb
ifeq (,$(filter nrf5340_app,$(CPU_MODEL)))
FEATURES_PROVIDED += periph_gpio_ll periph_gpio_ll_irq periph_gpio_ll_irq_unmask
FEATURES_PROVIDED += periph_gpio_ll
FEATURES_PROVIDED += periph_gpio_ll_disconnect
FEATURES_PROVIDED += periph_gpio_ll_input_pull_down
FEATURES_PROVIDED += periph_gpio_ll_input_pull_up
FEATURES_PROVIDED += periph_gpio_ll_irq
FEATURES_PROVIDED += periph_gpio_ll_irq_unmask
FEATURES_PROVIDED += periph_gpio_ll_open_drain
FEATURES_PROVIDED += periph_gpio_ll_open_drain_pull_up
FEATURES_PROVIDED += periph_gpio_ll_open_source
FEATURES_PROVIDED += periph_gpio_ll_open_source_pull_down
endif
# nRF9160/nRF5340 don't support these drivers right now

View File

@ -14,6 +14,9 @@ FEATURES_PROVIDED += periph_flashpage_pagewise
FEATURES_PROVIDED += periph_flashpage_rwee
FEATURES_PROVIDED += periph_gpio periph_gpio_irq
FEATURES_PROVIDED += periph_gpio_ll
FEATURES_PROVIDED += periph_gpio_ll_disconnect
FEATURES_PROVIDED += periph_gpio_ll_input_pull_down
FEATURES_PROVIDED += periph_gpio_ll_input_pull_up
FEATURES_PROVIDED += periph_gpio_ll_irq
FEATURES_PROVIDED += periph_gpio_ll_irq_level_triggered_high
FEATURES_PROVIDED += periph_gpio_ll_irq_level_triggered_low

View File

@ -13,9 +13,17 @@ FEATURES_PROVIDED += periph_rtt_overflow
FEATURES_PROVIDED += periph_uart_modecfg
FEATURES_PROVIDED += periph_uart_nonblocking
FEATURES_PROVIDED += periph_gpio_ll
FEATURES_PROVIDED += periph_gpio_ll_disconnect
FEATURES_PROVIDED += periph_gpio_ll_input_pull_down
FEATURES_PROVIDED += periph_gpio_ll_input_pull_up
FEATURES_PROVIDED += periph_gpio_ll_irq
FEATURES_PROVIDED += periph_gpio_ll_irq_level_triggered_high
FEATURES_PROVIDED += periph_gpio_ll_irq_level_triggered_low
FEATURES_PROVIDED += periph_gpio_ll_open_drain
ifneq (f1,$(CPU_FAM))
FEATURES_PROVIDED += periph_gpio_ll_open_drain_pull_up
endif
ifneq (,$(filter $(CPU_FAM),f0 f1 f3 g0 g4 l0 l1 l4 l5 u5 wb wl))
FEATURES_PROVIDED += periph_flashpage

View File

@ -134,6 +134,8 @@ typedef enum {
/**
* @brief Use pin as output in push-pull configuration
*
* @note This is supported and implemented on all MCUs.
*
* | Logical Value | Electrical Behavior |
* |:-------------- |:--------------------------------- |
* | `0` | Low |
@ -143,6 +145,10 @@ typedef enum {
/**
* @brief Use pin as output in open collector configuration
*
* @note The feature `periph_gpio_ll_open_drain` is used to indicate
* support for this GPIO mode. However, it may not be available on
* all pins.
*
* | Logical Value | Electrical Behavior |
* |:-------------- |:--------------------------------- |
* | `0` | Low |
@ -152,13 +158,22 @@ typedef enum {
/**
* @brief Use pin as output in open emitter configuration
*
* @note The feature `periph_gpio_ll_open_source` is used to indicate
* support for this GPIO mode. However, it may not be available on
* all pins.
*
* | Logical Value | Electrical Behavior |
* |:-------------- |:--------------------------------- |
* | `0` | High Impedance (Disconnected) |
* | `1` | High |
*/
GPIO_OUTPUT_OPEN_SOURCE,
GPIO_INPUT, /**< Use pin as input */
/**
* @brief Use pin as input
*
* @note This is supported and implemented on all MCUs.
*/
GPIO_INPUT,
/**
* @brief The GPIO pin is used by a peripheral
*
@ -175,6 +190,12 @@ typedef enum {
/**
* @brief Disconnect pin from all peripherals
*
* @note This may be an alias for GPIO_INPUT when the MCU does not
* support support disconnecting GPIO pins from the GPIO
* peripheral. The feature `periph_gpio_ll_disconnect` indicates
* that disconnecting pins from all peripherals (including the
* GPIO peripheral) is supported.
*
* The implementation should aim to reduce power consumption of the pin
* when this state is entered, if this is feasible. For pins where it is
* possible and sensible, this should electrically disconnect them

View File

@ -1,4 +1,14 @@
# Always use periph_gpio_irq_unmask, if available
# Always use hardware features, if available
ifneq (,$(filter periph_gpio_ll%,$(USEMODULE)))
FEATURES_OPTIONAL += periph_gpio_ll_disconnect
FEATURES_OPTIONAL += periph_gpio_ll_irq_level_triggered_high
FEATURES_OPTIONAL += periph_gpio_ll_input_pull_down
FEATURES_OPTIONAL += periph_gpio_ll_input_pull_keep
FEATURES_OPTIONAL += periph_gpio_ll_input_pull_up
FEATURES_OPTIONAL += periph_gpio_ll_irq_level_triggered_low
FEATURES_OPTIONAL += periph_gpio_ll_irq_unmask
FEATURES_OPTIONAL += periph_gpio_ll_open_drain
FEATURES_OPTIONAL += periph_gpio_ll_open_drain_pull_up
FEATURES_OPTIONAL += periph_gpio_ll_open_source
FEATURES_OPTIONAL += periph_gpio_ll_open_source_pull_down
endif

View File

@ -33,24 +33,33 @@ void gpio_ll_print_conf_common(const gpio_conf_t conf)
print_str("state: ");
switch (conf.state) {
case GPIO_OUTPUT_PUSH_PULL:
print_str("out-pp");
break;
case GPIO_OUTPUT_OPEN_DRAIN:
print_str("out-od");
break;
case GPIO_OUTPUT_OPEN_SOURCE:
print_str("out-os");
break;
case GPIO_INPUT:
print_str("in");
break;
case GPIO_OUTPUT_PUSH_PULL:
print_str("out-pp");
break;
#if MODULE_PERIPH_GPIO_LL_OPEN_DRAIN
case GPIO_OUTPUT_OPEN_DRAIN:
print_str("out-od");
break;
#endif
#if MODULE_PERIPH_GPIO_LL_OPEN_SOURCE
case GPIO_OUTPUT_OPEN_SOURCE:
print_str("out-os");
break;
#endif
case GPIO_USED_BY_PERIPHERAL:
print_str("periph");
break;
#if MODULE_PERIPH_GPIO_LL_DISCONNECT
case GPIO_DISCONNECT:
print_str("off");
break;
#endif
default:
print_str("?");
break;
}
if (conf.state != GPIO_OUTPUT_PUSH_PULL) {