Skip to content

Commit

Permalink
Add remaining GPIO pins for ESP32-S2/S3 ULP
Browse files Browse the repository at this point in the history
  • Loading branch information
Dominic Fischer committed Jun 19, 2024
1 parent 2d90fa3 commit 5444b29
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions esp-lp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add the `ulp-riscv-hal` package (#840)
- Add LP_UART basic driver (#1113)
- Added basic `LP-I2C` driver for C6 (#1185)
- Add remaining GPIO pins for ESP32-S2/S3 (#1695)

### Changed

Expand Down
9 changes: 7 additions & 2 deletions esp-lp-hal/src/gpio.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ type LpIo = crate::pac::LP_IO;
#[cfg(any(feature = "esp32s2", feature = "esp32s3"))]
type LpIo = crate::pac::RTC_IO;

#[cfg(feature = "esp32c6")]
const MAX_GPIO_PIN: u8 = 7;
#[cfg(any(feature = "esp32s2", feature = "esp32s3"))]
const MAX_GPIO_PIN: u8 = 21;

#[non_exhaustive]
pub struct Input<const PIN: u8> {}

Expand Down Expand Up @@ -40,7 +45,7 @@ impl<const PIN: u8> Output<PIN> {
// Used by the `entry` procmacro:
#[doc(hidden)]
pub unsafe fn conjure_output<const PIN: u8>() -> Option<Output<PIN>> {
if PIN > 7 {
if PIN > MAX_GPIO_PIN {
None
} else {
Some(Output {})
Expand All @@ -50,7 +55,7 @@ pub unsafe fn conjure_output<const PIN: u8>() -> Option<Output<PIN>> {
// Used by the `entry` procmacro:
#[doc(hidden)]
pub unsafe fn conjure_input<const PIN: u8>() -> Option<Input<PIN>> {
if PIN > 7 {
if PIN > MAX_GPIO_PIN {
None
} else {
Some(Input {})
Expand Down

0 comments on commit 5444b29

Please sign in to comment.