Skip to content

Commit

Permalink
Fix I8080.set_byte_order() (#2487)
Browse files Browse the repository at this point in the history
Co-authored-by: Dominic Fischer <[email protected]>
Co-authored-by: Jesse Braham <[email protected]>
  • Loading branch information
3 people authored Nov 8, 2024
1 parent d5e6ba5 commit d6f63d6
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 7 deletions.
2 changes: 2 additions & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- `spi::master::Config` and `{Spi, SpiDma, SpiDmaBus}::apply_config` (#2448)
- `embassy_embedded_hal::SetConfig` is now implemented for `{Spi, SpiDma, SpiDmaBus}` (#2448)
- `slave::Spi::{with_mosi(), with_miso(), with_sclk(), with_cs()}` functions (#2485)
- I8080: Added `set_8bits_order()` to set the byte order in 8-bit mode (#2487)

### Changed

Expand Down Expand Up @@ -66,6 +67,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- ESP32: added UART-specific workaround for https://docs.espressif.com/projects/esp-chip-errata/en/latest/esp32/03-errata-description/esp32/cpu-subsequent-access-halted-when-get-interrupted.html (#2441)
- Fixed some SysTimer race conditions and panics (#2451)
- TWAI: accept all messages by default (#2467)
- I8080: `set_byte_order()` now works correctly in 16-bit mode (#2487)

### Removed

Expand Down
15 changes: 14 additions & 1 deletion esp-hal/MIGRATING-0.21.md
Original file line number Diff line number Diff line change
Expand Up @@ -305,4 +305,17 @@ refer to the `Config` struct as `uart::Config`.
+ ..Config::default()
+ },
+)
```
```

## I8080 driver split `set_byte_order()` into `set_8bits_order()` and `set_byte_order()`.

If you were using an 8-bit bus.
```diff
- i8080.set_byte_order(ByteOrder::default());
+ i8080.set_8bits_order(ByteOrder::default());
```

If you were using an 16-bit bus, you don't need to change anything, `set_byte_order()` now works correctly.

If you were sharing the bus between an 8-bit and 16-bit device, you will have to call the corresponding method when
you switch between devices. Be sure to read the documentation of the new methods.
22 changes: 17 additions & 5 deletions esp-hal/src/lcd_cam/lcd/i8080.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,25 @@ impl<'d, DM: Mode> I8080<'d, DM> {
}

impl<'d, DM: Mode> I8080<'d, DM> {
/// Configures the byte order for data transmission.
/// Configures the byte order for data transmission in 16-bit mode.
/// This must be set to [ByteOrder::default()] when transmitting in 8-bit
/// mode.
pub fn set_byte_order(&mut self, byte_order: ByteOrder) -> &mut Self {
let is_inverted = byte_order != ByteOrder::default();
self.lcd_cam.lcd_user().modify(|_, w| {
w.lcd_byte_order().bit(is_inverted);
w.lcd_8bits_order().bit(is_inverted)
});
self.lcd_cam
.lcd_user()
.modify(|_, w| w.lcd_byte_order().bit(is_inverted));
self
}

/// Configures the byte order for data transmission in 8-bit mode.
/// This must be set to [ByteOrder::default()] when transmitting in 16-bit
/// mode.
pub fn set_8bits_order(&mut self, byte_order: ByteOrder) -> &mut Self {
let is_inverted = byte_order != ByteOrder::default();
self.lcd_cam
.lcd_user()
.modify(|_, w| w.lcd_8bits_order().bit(is_inverted));
self
}

Expand Down
2 changes: 1 addition & 1 deletion esp-hal/src/lcd_cam/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ pub enum BitOrder {
#[derive(Debug, Clone, Copy, PartialEq, Default)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
pub enum ByteOrder {
/// Do not change bit order.
/// Do not change byte order.
#[default]
Native = 0,
/// Invert byte order.
Expand Down

0 comments on commit d6f63d6

Please sign in to comment.