Skip to content

Commit

Permalink
changelog/migration
Browse files Browse the repository at this point in the history
  • Loading branch information
MabezDev committed Dec 19, 2024
1 parent a789165 commit 5b38487
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
1 change: 1 addition & 0 deletions documentation/API-GUIDELINES.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ In general, the [Rust API Guidelines](https://rust-lang.github.io/api-guidelines
- This helps us reducing the need of introducing breaking changes if we implement additional functionalities.
- Avoid abbreviations and contractions in the API, where possible.
- Saving a few characters may introduce ambiguity, e.g `SpiTransDone`, is it `Transmit` or `Transfer`?
- Common abbreviations, that are well understood such as `Dma` are perfectly fine.

## Maintainability

Expand Down
2 changes: 2 additions & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated `esp-pacs` with support for Wi-Fi on the ESP32 and made the peripheral non virtual
- `SpiBitOrder`, `SpiDataMode`, `SpiMode` were renamed to `BitOder`, `DataMode` and `Mode` (#2828)
- `crate::Mode` was renamed to `crate::DriverMode` (#2828)
- Renamed some I2C error variants (#2844)

### Fixed

- Xtensa devices now correctly enable the `esp-hal-procmacros/rtc-slow` feature (#2594)
Expand Down
13 changes: 13 additions & 0 deletions esp-hal/MIGRATING-0.22.md
Original file line number Diff line number Diff line change
Expand Up @@ -300,3 +300,16 @@ is not compatible with the hardware.
- spi_dma.transfer(dma_rx_buf, dma_tx_buf);
+ spi_dma.transfer(5, dma_rx_buf, 5, dma_tx_buf);
```

## I2C Error changes

To avoid abbreviations and contractions (as per the esp-hal guidelines), some error variants have changed

```diff
- Error::ExecIncomplete
+ Error::ExecutionIncomplete
- Error::CommandNrExceeded
+ Error::CommandNumberExceeded
- Error::ExceedingFifo
+ Error::FifoExceeded
```
12 changes: 6 additions & 6 deletions esp-hal/src/i2c/master/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ const MAX_ITERATIONS: u32 = 1_000_000;
#[non_exhaustive]
pub enum Error {
/// The transmission exceeded the FIFO size.
ExceedingFifo,
FifoExceeded,
/// The acknowledgment check failed.
AckCheckFailed,
/// A timeout occurred during transmission.
Expand All @@ -101,7 +101,7 @@ pub enum Error {
/// The execution of the I2C command was incomplete.
ExecutionIncomplete,
/// The number of commands issued exceeded the limit.
CommandNrExceeded,
CommandNumberExceeded,
/// Zero length read or write operation.
InvalidZeroLength,
}
Expand All @@ -111,7 +111,7 @@ impl core::error::Error for Error {}
impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
match self {
Error::ExceedingFifo => write!(f, "The transmission exceeded the FIFO size"),
Error::FifoExceeded => write!(f, "The transmission exceeded the FIFO size"),
Error::AckCheckFailed => write!(f, "The acknowledgment check failed"),
Error::TimeOut => write!(f, "A timeout occurred during transmission"),
Error::ArbitrationLost => write!(f, "The arbitration for the bus was lost"),
Expand Down Expand Up @@ -204,7 +204,7 @@ impl embedded_hal::i2c::Error for Error {
use embedded_hal::i2c::{ErrorKind, NoAcknowledgeSource};

match self {
Self::ExceedingFifo => ErrorKind::Overrun,
Self::FifoExceeded => ErrorKind::Overrun,
Self::ArbitrationLost => ErrorKind::ArbitrationLoss,
Self::AckCheckFailed => ErrorKind::NoAcknowledge(NoAcknowledgeSource::Unknown),
_ => ErrorKind::Other,
Expand Down Expand Up @@ -1337,7 +1337,7 @@ impl Driver<'_> {
let max_len = if start { 254usize } else { 255usize };
if bytes.len() > max_len {
// we could support more by adding multiple write operations
return Err(Error::ExceedingFifo);
return Err(Error::FifoExceeded);
}

let write_len = if start { bytes.len() + 1 } else { bytes.len() };
Expand Down Expand Up @@ -1395,7 +1395,7 @@ impl Driver<'_> {
};
if buffer.len() > max_len {
// we could support more by adding multiple read operations
return Err(Error::ExceedingFifo);
return Err(Error::FifoExceeded);
}

if start {
Expand Down

0 comments on commit 5b38487

Please sign in to comment.