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

cpu/gd32v/periph_gpio_ll: fix and clean up

Use analog mode for GPIO_DISCONNECT, as this is said to have the lowest
current leakage due to disabling the Schmitt trigger and correctly
detect this in `gpio_ll_query_conf()`.

Also drop the `schmitt_trigger_disabled` member in `gpio_conf_t`, as
the Schmitt trigger is only ever disabled in Analog mode anyway and
cannot be freely configured.
This commit is contained in:
Marian Buschsieweke 2024-01-23 14:18:46 +01:00
parent 1351c61c6a
commit f10a994a9e
No known key found for this signature in database
GPG Key ID: 77AA882EC78084E6
2 changed files with 3 additions and 21 deletions

View File

@ -239,7 +239,7 @@ typedef union gpio_conf_gd32v gpio_conf_t;
* @ingroup drivers_periph_gpio_ll
*/
union gpio_conf_gd32v {
uint16_t bits; /**< the raw bits */
uint8_t bits; /**< the raw bits */
struct {
/**
* @brief State of the pin
@ -259,18 +259,6 @@ union gpio_conf_gd32v {
* configured to @ref GPIO_OUTPUT_PUSH_PULL or @ref GPIO_OUTPUT_OPEN_DRAIN.
*/
gpio_slew_t slew_rate : 2;
/**
* @brief Whether to disable the input Schmitt trigger
*
* @details This could be called `schmitt_trigger` with inverse
* meaning, but the API contract says that additional
* members in the structure should have a sane
* default when zero.
*
* This value is ignored *unless* @ref gpio_conf_stm32::state is
* configured to @ref GPIO_INPUT.
*/
bool schmitt_trigger_disabled : 1;
/**
* @brief Initial value of the output
*
@ -285,7 +273,6 @@ union gpio_conf_gd32v {
* consulted.
*/
bool initial_value : 1;
uint8_t : 7; /*< padding */
};
};

View File

@ -60,7 +60,6 @@ int gpio_ll_init(gpio_port_t port, uint8_t pin, gpio_conf_t conf)
switch (conf.state) {
case GPIO_DISCONNECT:
*ctrl |= 0x1 << (pos + 2);
pin_used[GPIO_PORT_NUM(port)] &= ~(1 << pin);
if (pin_used[GPIO_PORT_NUM(port)] == 0) {
periph_clk_dis(APB2, (RCU_APB2EN_PAEN_Msk << GPIO_PORT_NUM(port)));
@ -121,14 +120,14 @@ gpio_conf_t gpio_ll_query_conf(gpio_port_t port, uint8_t pin)
result.state = GPIO_INPUT;
switch (ctrl) {
case 0:
result.state = GPIO_USED_BY_PERIPHERAL;
result.state = GPIO_DISCONNECT;
break;
case 1:
result.pull = GPIO_FLOATING;
break;
case 2:
result.pull = (((GPIO_Type *)port)->OCTL & (1UL << pin)) ? GPIO_PULL_UP
: GPIO_PULL_DOWN;
: GPIO_PULL_DOWN;
break;
default:
break;
@ -173,8 +172,4 @@ void gpio_ll_print_conf(gpio_conf_t conf)
gpio_ll_print_conf_common(conf);
print_str(", slew: ");
print_str(slew_strs[conf.slew_rate]);
if (conf.schmitt_trigger_disabled) {
print_str(", Schmitt trigger disabled");
}
}