Skip to content

Conversation

@GBJin
Copy link

@GBJin GBJin commented Dec 18, 2025

Add a new function to set input buffer (enable/disable) for power saving. For Surface products, gpio configured as output pin should has input buffer disabled in deep doze.
image

@GBJin GBJin requested a review from a team as a code owner December 18, 2025 10:41
Copy link
Contributor

@felipebalbi felipebalbi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, but shouldn't every Output have input buffer disabled?

}

/// Set the input buffer state
///
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This blank line is not necessary

@jerrysxie
Copy link
Contributor

LGTM, but shouldn't every Output have input buffer disabled?

Output with input buffer disabled cannot read back the state of the pin as an input.


/// Set the input buffer state
///
pub fn set_input_buffer(&mut self, enable: bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can already do this with Sense enabled and disabled state. If we add this API, this would break the typestate.

    /// Return a new Flex pin instance with level sensing disabled.
    ///
    /// Consumes less power than a flex pin with sensing enabled.
    #[must_use]
    pub fn disable_sensing(self) -> Flex<'d, SenseDisabled> {
        // Cloning the pin is ok since we consume self immediately
        let new_pin = unsafe { self.pin.clone_unchecked() };
        drop(self);
        Flex::<SenseDisabled>::new(new_pin)
    }

@felipebalbi
Copy link
Contributor

LGTM, but shouldn't every Output have input buffer disabled?

Output with input buffer disabled cannot read back the state of the pin as an input.

when you try to read, grab a critical_section then enable input buffer, read, disable input buffer?

@jerrysxie
Copy link
Contributor

LGTM, but shouldn't every Output have input buffer disabled?

Output with input buffer disabled cannot read back the state of the pin as an input.

when you try to read, grab a critical_section then enable input buffer, read, disable input buffer?

We could do that. Right now sensing is enforced with typestate. is_high() and is_low() only existed for Flex<'d, SenseEnabled>. If we want to make this more dynamic then we have to remove the typestate and returns an error when is_high() and is_low() are invoked with input buffer disabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

4 participants