-
Notifications
You must be signed in to change notification settings - Fork 7.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feat/gpio_reserve_rmt' into 'master'
Check GPIO reservation in the RMT driver Closes IDF-9199 and IDF-9104 See merge request espressif/esp-idf!29130
- Loading branch information
Showing
14 changed files
with
122 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,30 @@ | ||
/* | ||
* SPDX-FileCopyrightText: 2023 Espressif Systems (Shanghai) CO LTD | ||
* SPDX-FileCopyrightText: 2023-2024 Espressif Systems (Shanghai) CO LTD | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <stdatomic.h> | ||
#include "soc/soc_caps.h" | ||
#include "esp_types.h" | ||
#include "esp_bit_defs.h" | ||
#include "soc/soc_caps.h" | ||
#include "esp_private/esp_gpio_reserve.h" | ||
|
||
static _Atomic uint64_t s_reserved_pin_mask = ATOMIC_VAR_INIT(~(SOC_GPIO_VALID_OUTPUT_GPIO_MASK)); | ||
|
||
static uint64_t s_reserve_status = 0; | ||
uint64_t esp_gpio_reserve(uint64_t gpio_mask) | ||
{ | ||
return atomic_fetch_or(&s_reserved_pin_mask, gpio_mask); | ||
} | ||
|
||
void esp_gpio_reserve_pins(uint64_t mask) | ||
uint64_t esp_gpio_revoke(uint64_t gpio_mask) | ||
{ | ||
#if SOC_GPIO_PIN_COUNT < 64 | ||
mask &= BIT64(SOC_GPIO_PIN_COUNT) - 1; | ||
#endif | ||
s_reserve_status |= mask; | ||
return atomic_fetch_and(&s_reserved_pin_mask, ~gpio_mask); | ||
} | ||
|
||
bool esp_gpio_is_pin_reserved(uint32_t gpio_num) | ||
bool esp_gpio_is_reserved(uint64_t gpio_mask) | ||
{ | ||
if (gpio_num >= SOC_GPIO_PIN_COUNT) { | ||
return false; | ||
} | ||
return !!(s_reserve_status & BIT64(gpio_num)); | ||
return atomic_load(&s_reserved_pin_mask) & gpio_mask; | ||
} | ||
|
||
// TODO: IDF-6968 reserve the pins that not fanned out regarding the SiP version |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.