Skip to content

Commit

Permalink
Address the rest of reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
playfulFence committed Aug 22, 2024
1 parent fa64933 commit fccabc3
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 2 deletions.
6 changes: 6 additions & 0 deletions esp-hal/src/gpio/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,12 @@ pub enum DriveStrength {
}

/// Alternate functions
///
/// GPIO pins can be configured for various functions, such as GPIO
/// or being directly connected to a peripheral's signal like UART, SPI, etc.
/// The `AlternateFunction` enum allows to select one of several functions that
/// a pin can perform, rather than using it as a general-purpose input or
/// output.
#[derive(PartialEq)]
pub enum AlternateFunction {
/// Alternate function 0.
Expand Down
14 changes: 14 additions & 0 deletions esp-hal/src/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1642,6 +1642,12 @@ pub trait Instance: crate::private::Sealed {
}

/// Checks for I2C transmission errors and handles them.
///
/// This function inspects specific I2C-related interrupts to detect errors
/// during communication, such as timeouts, failed acknowledgments, or
/// arbitration loss. If an error is detected, the function handles it
/// by resetting the I2C peripheral to clear the error condition and then
/// returns an appropriate error.
fn check_errors(&self) -> Result<(), Error> {
let interrupts = self.register_block().int_raw().read();

Expand Down Expand Up @@ -1683,6 +1689,14 @@ pub trait Instance: crate::private::Sealed {
}

/// Updates the configuration of the I2C peripheral.
///
/// This function ensures that the configuration values, such as clock
/// settings, SDA/SCL filtering, timeouts, and other operational
/// parameters, which are configured in other functions, are properly
/// propagated to the I2C hardware. This step is necessary to synchronize
/// the software-configured settings with the peripheral's internal
/// registers, ensuring that the hardware behaves according to the
/// current configuration.
fn update_config(&self) {
// Ensure that the configuration of the peripheral is correctly propagated
// (only necessary for C2, C3, C6, H2 and S3 variant)
Expand Down
11 changes: 9 additions & 2 deletions esp-hal/src/peripheral.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,16 @@ mod peripheral_macros {

#[doc(hidden)]
#[macro_export]
/// Macro to create a peripheral structure.
macro_rules! create_peripheral {
($(#[$cfg:meta])? $name:ident <= virtual) => {
$(#[$cfg])?
#[derive(Debug)]
#[allow(non_camel_case_types)]
/// Macro to create a peripheral structure.
/// Represents a virtual peripheral with no associated hardware.
///
/// This struct is generated by the `create_peripheral!` macro when the peripheral
/// is defined as virtual.
pub struct $name { _inner: () }

$(#[$cfg])?
Expand Down Expand Up @@ -389,7 +393,10 @@ mod peripheral_macros {
$(#[$cfg])?
#[derive(Debug)]
#[allow(non_camel_case_types)]
/// Macro to create a peripheral structure.
/// Represents a concrete hardware peripheral.
///
/// This struct is generated by the `create_peripheral!` macro when the peripheral
/// is tied to an actual hardware device.
pub struct $name { _inner: () }

$(#[$cfg])?
Expand Down

0 comments on commit fccabc3

Please sign in to comment.