Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix I8080.set_byte_order() #2487

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions esp-hal/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- GPIO ETM tasks and events now accept `InputSignal` and `OutputSignal` (#2427)
- `spi::master::Config` and `{Spi, SpiDma, SpiDmaBus}::apply_config` (#2448)
- `embassy_embedded_hal::SetConfig` is now implemented for `{Spi, SpiDma, SpiDmaBus}` (#2448)
- I8080: Added `set_8bits_order()` to set the byte order in 8-bit mode (#2487)

### Changed

Expand Down Expand Up @@ -64,6 +65,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 @@ -284,4 +284,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